当前位置:首页 > 技术 > Python > 正文内容

micropython 使用oled显示前面设置的时间。

Watrt6年前 (2019-12-31)Python32930
from machine import I2C, Pin
import ssd1306,time    #这里引用的是官方的ssd1306库。可以在github上下载下来放入库中。
i2c = I2C(-1, Pin(14), Pin(2))
display = ssd1306.SSD1306_I2C(128, 64, i2c)
#while True:
strdate='%d-%d-%d' % (rtc.datetime()[0],rtc.datetime()[1],rtc.datetime()[2])
strtime='%d:%d:%d' % (rtc.datetime()[4],rtc.datetime()[5],rtc.datetime()[6])
display.fill(0)
display.text(nic.ifconfig()[0], 0,8*4,1)
display.text(IPadd, 0,8*5,1)
display.text(strdate, 0,8*6,1)
display.text(strtime, 0,8*7,1)
display.show()
print(nic.ifconfig()[0])
time.sleep(1)
exec(open('./http_server.py').read(),globals())  #这里让脚本运行到http服务上面。

micropython 使用oled显示前面设置的时间。这里使用的时间是前面文章中设置的rtc。

打赏 支付宝打赏 微信打赏
分享给朋友:

相关文章

micropython中使用rtc设置时间

micropython中使用rtc设置时间

micropython中使用rtc设置时间from machine import RTC rtc = RTC() rtc.datetime((2017, 8, 23, 1, 12, 48, 0, 0)) # set a specific date and time print(rtc.datetime(...

micropython解码bmp

micropython解码bmp

from ST7735 import TFT,TFTColor from machine import SPI,Pin spi = SPI(2, baudrate=20000000, polarity=0, phase=0, sck=Pin(14), mosi=Pin(13), miso=Pin(12)) tft=TFT(spi,16,17,18)...

asyncio --- 异步 I/O http服务代码

asyncio --- 异步 I/O http服务代码

import asyncioasync def service(reader,writer):    data = await reader.read(1024) #同步读取数据    data =data.decode().replace('\r','<br/>')    print(writer.get_extra_info('peername'))   &nbs...

micropython 1.17编译出现FAILED: esp-idf/mbedtls/x509_crt_bundle

micropython 1.17编译出现FAILED: esp-idf/mbedtls/x509_crt_bundle

micropython 1.17编译出现FAILED: esp-idf/mbedtls/x509_crt_bundle 错误解决方法。出现错误的原因是ssl中的证书过期了。解决办法:1:(Top) > Component config > mbedTLS > Certificate Bundle->Enable trusted root certificate bundle   禁用2:修改配置文件 :sdkconfig.base  中添加入...

python使用requests库下载文件

python使用requests库下载文件

import os import requests def downfile(url): try: url=url.split("@")[0].split("?")[0] urlfile=url.split("/")[-1] print(urlfile) except Exception as e: print("地址不正确...

Python内置函数

Python内置函数

以下是 Python 中的全部内置函数,并列出了它们的作用和参数说明。请注意,以下列出的内置函数是基于 Python 3.9 版本。abs(): 返回一个数的绝对值。参数:abs(x)all(): 如果可迭代对象中的所有元素都为 True,则返回 True。参数:all(iterable)any(): 如果可迭代对象中的任何元素为 True,则返回 True。参数:any(iterable)ascii(): 返回一个包含 ASCII 转义字符的字符串表示。参数:ascii(object)bin(...

使用 tqdm 库在控制台中实现进度条

使用 tqdm 库在控制台中实现进度条

简单用法:from tqdm import tqdm  for i in tqdm(range(2)):   pass100%|███████████████████| 2/2 [00:00<00:00, 1998.72it/s]  从上面可以看到生成一个长度为2的列表传入tqdm中,在for中迭代,此时输出了进度条,这里tqdm全部使用了默认参数,默认进度条样式就是如上所示;通常默认进度条所输出...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。