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

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

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

打赏 支付宝打赏 微信打赏

相关文章

esp32外部中断学习笔记

esp32外部中断学习笔记

思路:我使用的esp32开发板为简易的开发板,因为板上没有用户自己定义的键盘所以在使用中想要输入或者控制无法完成。研究发现在开发板上有的下载按钮是不是可以在进入系统后复用为一个按键呢。实现:参考官方的例程对代码如下首先宏定义参数:#define KYE_0   0    //GPIO0检测 #define KEYS_SET   (1ULL<<0) &nb...

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

Python使用struct处理二进制(pack和unpack用法)

Python使用struct处理二进制(pack和unpack用法)

有的时候需要用python处理二进制数据,比如,存取文件,socket操作时.这时候,可以使用python的struct模块来完成.可以用 struct来处理c语言中的结构体. struct模块中最重要的三个函数是pack(), unpack(), calcsize()pack(fmt, v1, v2, ...)     按照给定的格式(fmt),把数据封装成字符串(实际上是类似于c结构体的字节流) un...

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  中添加入...

word转换服务python版本

word转换服务python版本

网页无法打开word文档。但是可以转换为pdf来在网页上找开。用python实现在线转换服务。from flask import Flask, request, jsonify,redirect,send_from_directory from win32com.client import constants,gencache import requests import os impor...

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

发表评论

访客

看不清,换一张

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