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

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

Watrt7年前 (2019-12-31)Python35170
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。

打赏 支付宝打赏 微信打赏

相关文章

python编写的简单http请求和应答

python编写的简单http请求和应答

响应(服务端)import machine import socket pins = [machine.Pin(i, machine.Pin.IN) for i in (0, 2, 4, 5, 12, 13, 14, 15)] adc = machine.ADC(0) html = &quo...

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连接到wifi上面

micropython连接到wifi上面

import network,time,ujson,urequests,ntptime from machine import RTC nic=network.WLAN(network.STA_IF) nic.active(True) #nic.connect('ZCWH','00004157') nic.connect('028sd.com','88884444') nic.co...

python利用pyinstaller打包简明教程

python利用pyinstaller打包简明教程

在创建了独立应用(自包含该应用的依赖包)之后,还可以使用 PyInstaller 将 Python 程序生成可直接运行的程序,这个程序就可以被分发到对应的 Windows 或 Mac OS X 平台上运行。安装 PyInstallePython 默认并不包含 PyInstaller 模块,因此需要自行安装 PyInstaller 模块。安装 PyInstaller 模块与安装其他 Python 模块一样,使用 pip 命令安装即可。在命令行输入如下命令:pip install ...

pyqt5 开发入门

pyqt5 开发入门

使用:pyqt5-tools designer 进行窗口设计使用命令:pyuic5 -o textedit.py textedit.ui  把设计的UI文件转换成py文件注意:使用对话框的话要继承于class Ui_MainWindow(QtWidgets.QMainWindow):使用信号的方法:self.actionnew.triggered.connect(self.new_btn)    self.new_btn 为当前类下的方法下面示例:#&nb...

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...

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("地址不正确...

发表评论

访客

看不清,换一张

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