I'm trying to make my LCD driver(st7735s) to support Chinese letters.
My solution is to encode a Chinese letter and get its utf-8 format code, then use this code and a key to search in a dict that contains all the letters used in my project.
Code: Select all
letter_dict = {
0xe586af: [0x00, ..], # the pixel bits of char '冯'
}
data_code = '冯'.encode('utf-8')
# the code length is in a range of 1bytes to 4 bytes.
d = data_code[0]
for i in range(1, len(data_code)):
d = d<<8 | data_code[i]
letter_bits = letter_dict[d]
...
Code: Select all
===
b'\xb7\xeb'
��
>>>
Code: Select all
Python 3.8.0 (default, Nov 6 2019, 16:00:02) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> '冯'.encode('utf-8')
b'\xe5\x86\xaf'
>>>
The utf-8 code should be the same in both of the environment, only with that can I extract letters in json stream (utf-8 code) then show them on my LCD.
Another thing is that when I use REPL through COM9 (my COM to my board), I cannot type Chinese letters in cmd...
My implement details are as follows:
board : ESP32 DEVKIT V1 GPIO with 30 pins
firmware : esp32-20220117-v1.18.bin lateset firmware, downloaded from https://micropython.org/download/esp32/
IDE : VS Code with RT-Thread, python 3.8.0 with esptool 4.0
Can anyone help my get out of it? Or is there another way to match json char from web API to my local letters?
Best regards!
Lab~