1857 views|6 replies

2

Posts

0

Resources
The OP
 

Help code modification, so that LCD12864 can display Chinese [Copy link]

 

I am a newbie. I have an LCD12864 screen with fonts, connected to ESP32 and DHT11, which can display temp, humi and their values normally.
Now I want to change the first line of characters on the screen to the Chinese characters "四川成都", and change "temp" and "humi" to the Chinese characters "温度" and "幽默" respectively, but I don't know how to modify them.
I attach the code for help. I hope experts can give me some advice. Thank you!

from machine import Pin
import time
from dht import DHT11
dht11=DHT11(Pin(27))
cs = Pin(12,Pin.OUT) # LCD12864 uses the serial data transmission method
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) Lcd1286
4_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()

Latest reply

If it comes with a font library, you can look for examples of displaying Chinese characters and you will know how to use it.   Details Published on 2024-3-19 13:15
 
 

1022

Posts

0

Resources
2
 

It is recommended to send back a single Chinese character. Don't think you can send a string of Chinese characters or phrases. It will be very troublesome!

Personal signatureچوآن شـين
 
 
 

1w

Posts

25

Resources
3
 

If you need to use it universally, you need a character library, and use it to get the Chinese character dot matrix for display. If you only need a few Chinese characters, you can first take the modulus and store it in a file or array.

 
 
 

4764

Posts

12

Resources
4
 
Use Chinese characters to take the modulus and then send it.
 
 
 

5998

Posts

6

Resources
5
 

Doing it yourself is just taking the model, after all, there are not many words

Personal signature

在爱好的道路上不断前进,在生活的迷雾中播撒光引

 
 
 

6742

Posts

2

Resources
6
 

If it comes with a font library, you can look for examples of displaying Chinese characters and you will know how to use it.

 
 
 

2

Posts

0

Resources
7
 

Take replacing "temp" with the Chinese character "温度" as an example, how do we modify the original code? Please give me detailed advice from the moderator and other experts, thank you!

 
 
 

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list