在boot.py主程序中,我们编写代码如下:
from machine import Pin, SoftI2C
import ssd1306py as lcd
import math
# ESP8266 Pin assignment
i2c = SoftI2C(scl=Pin(7), sda=Pin(6)) # Adjust the Pin numbers based on your connections
lcd.init_i2c(7,6,128,64)
lcd.text('font8x8', 0, 0, 8)
font16 = {
0xe4bda0:
[0x08, 0x08, 0x08, 0x11, 0x11, 0x32, 0x34, 0x50, 0x91, 0x11, 0x12, 0x12, 0x14, 0x10, 0x10, 0x10, 0x80, 0x80,
0x80, 0xFE, 0x02, 0x04, 0x20, 0x20, 0x28, 0x24, 0x24, 0x22, 0x22, 0x20, 0xA0, 0x40], # 你
0xe5a5bd:
[0x10, 0x10, 0x10, 0x10, 0xFC, 0x24, 0x24, 0x25, 0x24, 0x48, 0x28, 0x10, 0x28, 0x44, 0x84, 0x00, 0x00, 0xFC,
0x04, 0x08, 0x10, 0x20, 0x20, 0xFE, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xA0, 0x40] # 好
}
lcd.set_font(font16, 16)
lcd.text('font16x16', 0, 20, 16)
lcd.text_cn("你好", 0, 40, 16)
lcd.show()