尝试使用 micropython 在树莓派 pico 的 SERLCD 液晶显示器上显示“degree f”

时间:2021-03-26 23:41:35

标签: unicode raspberry-pi lcd micropython

尝试使用 micropython 在树莓派 pico 的 SERLCD 液晶显示器上显示“degree f”

示例代码:

import machine
import utime
sda = machine.Pin(0)
scl = machine.Pin(1)
i2c = machine.I2C(0, sda = sda, scl = scl, freq = 400000)
print(i2c.scan())  #Prints 114
utime.sleep_ms(100)
i2c.writeto(114, '\x7C')   #Sending hexadecimal string
i2c.writeto(114, '\x2D')   #2D blanks the display and sets the cursor to the beginning
y = str(1234)    #Test character  
#i2c.writeto(114,  str(10.5) + str(u'\xb0'))   #Works OK
i2c.writeto(114, "Count:" + y + (str('u\2109')))

显示为 Count 1234132。u\2109 是“degree F”的 unicode 显示“F 度”符号的正确技术是什么?

1 个答案:

答案 0 :(得分:0)

据我所知,要显示特殊字符,您必须发送一个十六进制字符串,该字符串由显示驱动程序根据其字符集进行转换。

您的显示驱动程序的整个文档都可用 here。但是,如果您只想查看字符集,您也可以在 wikipedia 上找到它。

在字符集中,您要查找的字符位于右下角。它是二进制标识符——您可以通过查看表头和其对应行的开头来识别——在这种情况下是 11011111。但是,SERLCD 希望您向它发送十六进制。

十六进制的 11011111 是“DF”。 根据您的示例代码,发送此十六进制指令的代码如下:

i2c.writeto(114, '\xDF')