我是小白,现有一块带字库的LCD12864屏,外接ESP32、DHT11,能正常显示temp、humi及其值。
现在想把屏上第一行字符改成汉字“四川成都”,并将“temp”、“humi”分别换成汉字“温度”、“湿度”,但不知如何修改,
现附上代码求助,望高手不吝赐教,谢谢!
from machine import Pin
import time
from dht import DHT11
dht11=DHT11(Pin(27))
cs = Pin(12,Pin.OUT) # LCD12864采用的是串行数据传输方式
sid = Pin(18,Pin.OUT)
clk = Pin(19,Pin.OUT)
psb = Pin(13,Pin.OUT)
def Lcd12864_Write_Byte(byte):
cs.value(1)
for i in range(0,8,1):
sid.value(1 if(byte<<i)&0x80 else 0)
clk.value(0)
clk.value(1)
cs.value(0)
def Lcd12864_Write(cmd,data):
Lcd12864_Write_Byte(cmd)
Lcd12864_Write_Byte(data&0xf0)
Lcd12864_Write_Byte((data<<4)&0xf0)
def Lcd12864_Init():
psb.value(0)
Lcd12864_Write(0xf8,0x30)
Lcd12864_Write(0xf8,0x06)
Lcd12864_Write(0xf8,0x0c)
Lcd12864_Write(0xf8,0x01)
Lcd12864_Write(0xf8,0x80)
def Lcd12864_Write_Text(addr,data):
Lcd12864_Write(0xf8,addr)
for i in range(len(data)):
Lcd12864_Write(0xfa,ord(data[i]))
def DHT11_Read_Data():
time.sleep(1)
dht11.measure()
temp = dht11.temperature()
humi = dht11.humidity()
Lcd12864_Write_Text(0x88,str("humi = %d%%"%humi))
Lcd12864_Write_Text(0x98,str("temp = %.1f"%temp))
time.sleep(2)
def main():
Lcd12864_Init()
Lcd12864_Write_Text(0x81,str("SC_CD_ZZ_XXX"))
Lcd12864_Write_Text(0x90,str("----------------"))
while True:
DHT11_Read_Data()
if __name__ == "__main__":
main()
带字库的,你找找显示汉字的例程,就知道怎么用了。