from machine import Pin,PWM,I2C
import time,ssd1306,dht
data = dht.DHT22(Pin(15)) #DHT22温湿度检测模块初始化管脚为15
i2c = I2C(0,scl = Pin(22),sda = Pin(21)) #调用函数 设置I2C通信的管脚
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width,oled_height,i2c) #调用类
dzk1 = {
0xE4BA94: #字典里的key
[0x00,0x7F,0x02,0x02,0x02,0x02,0x3F,0x04,0x04,0x04,0x04,0x08,0x08,0x08,0xFF,0x00,
0x00,0xFC,0x00,0x00,0x00,0x00,0xF0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xFE,0x00],#五
0xE7BB84: #字典里的key
[0x10,0x11,0x21,0x21,0x49,0xF9,0x11,0x21,0x41,0xF9,0x41,0x01,0x19,0xE1,0x47,0x00,
0x00,0xF8,0x08,0x08,0x08,0xF8,0x08,0x08,0x08,0xF8,0x08,0x08,0x08,0x08,0xFE,0x00],#组
0xEFBC9A:
[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],#:
0xE983AD:
[0x10,0x08,0xFF,0x00,0x7E,0x42,0x7E,0x00,0x7E,0x04,0x08,0x0F,0xF8,0x08,0x28,0x10,
0x00,0x7C,0x44,0x48,0x48,0x50,0x48,0x48,0x44,0x44,0x44,0x68,0x50,0x40,0x40,0x40],#郭
0xE5A495:
[0x02,0x02,0x02,0x02,0x07,0x04,0x08,0x10,0x24,0x42,0x01,0x00,0x01,0x02,0x0C,0x70,
0x00,0x00,0x00,0x00,0xF8,0x08,0x08,0x10,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x00],#夕
0xE5BCBA:
[0x00,0xF9,0x09,0x09,0x09,0x78,0x40,0x43,0x42,0x7A,0x0B,0x08,0x08,0x08,0x57,0x20,
0x00,0xFC,0x04,0x04,0xFC,0x20,0x20,0xFE,0x22,0x22,0xFE,0x20,0x24,0x22,0xFE,0x02],#强
0xEFBC8C:
[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x10,0x20,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],#,
}
dzk2 = {
0xE58881:
[0x00,0x3F,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x60,0x00,0x00,0x00,
0x00,0xF8,0x08,0x08,0x08,0x48,0x88,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x50,0x20],#刁
0xE4B89C:
[0x02,0x02,0x02,0x7F,0x04,0x09,0x11,0x21,0x3F,0x01,0x09,0x11,0x21,0x41,0x05,0x02,
0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0xF8,0x00,0x20,0x10,0x08,0x04,0x00,0x00],#东
0xE6B3A2:
[0x00,0x20,0x10,0x13,0x82,0x42,0x4A,0x0B,0x12,0x12,0xE2,0x22,0x22,0x24,0x24,0x09,
0x20,0x20,0x20,0xFE,0x22,0x24,0x20,0xFC,0x84,0x88,0x48,0x50,0x20,0x50,0x88,0x06],#波
0xEFBC8C:
[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x10,0x20,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],#,
0xE9AB98:
[0x02,0x01,0xFF,0x00,0x0F,0x08,0x08,0x0F,0x00,0x7F,0x40,0x4F,0x48,0x48,0x4F,0x40,
0x00,0x00,0xFE,0x00,0xE0,0x20,0x20,0xE0,0x00,0xFC,0x04,0xE4,0x24,0x24,0xE4,0x0C],#高
0xE68890:
[0x00,0x00,0x00,0x3F,0x20,0x20,0x20,0x3E,0x22,0x22,0x22,0x22,0x2A,0x44,0x40,0x81,
0x50,0x48,0x40,0xFE,0x40,0x40,0x44,0x44,0x44,0x28,0x28,0x12,0x32,0x4A,0x86,0x02],#成
0xE58F8B:
[0x02,0x02,0x02,0xFF,0x04,0x04,0x0F,0x0A,0x12,0x11,0x21,0x40,0x81,0x06,0x18,0x60,
0x00,0x00,0x00,0xFE,0x00,0x00,0xF0,0x10,0x10,0x20,0x40,0x80,0x40,0x20,0x18,0x06],#友
0xEFBC8C:
[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x10,0x20,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]#,
}
dzk3 = {
0xE69D9C:
[0x10,0x10,0x10,0x10,0xFC,0x10,0x33,0x38,0x54,0x54,0x90,0x10,0x10,0x10,0x17,0x10,
0x20,0x20,0x20,0x20,0x20,0x20,0xFE,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xFE,0x00],#杜
0xE6B393:
[0x00,0x27,0x10,0x10,0x80,0x47,0x44,0x14,0x14,0x27,0xE0,0x20,0x20,0x20,0x25,0x02,
0x08,0x88,0x88,0x88,0x88,0x88,0x08,0x10,0x10,0x90,0x94,0xA4,0xA2,0xBE,0x02,0x00],#泓
0xE6B481:
[0x00,0x40,0x20,0x2F,0x00,0x80,0x47,0x50,0x10,0x23,0xE2,0x22,0x22,0x22,0x23,0x02,
0x40,0x40,0x40,0xFE,0x40,0x40,0xFC,0x00,0x00,0xF8,0x08,0x08,0x08,0x08,0xF8,0x08],#洁
0xEFBC8C:
[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x10,0x20,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],#,
0xE4BEAF:
[0x08,0x0B,0x08,0x10,0x17,0x31,0x31,0x53,0x94,0x10,0x1F,0x10,0x10,0x11,0x12,0x1C,
0x00,0xF8,0x08,0x08,0xFE,0x00,0x00,0xF8,0x40,0x40,0xFE,0x40,0xA0,0x10,0x08,0x06],#侯
0xE889B3:
[0x10,0x10,0x10,0xFD,0x12,0x15,0x11,0x7D,0x11,0x11,0x11,0xFD,0x11,0x11,0x10,0x10,
0x80,0x80,0xF8,0x08,0x10,0xFC,0x24,0x24,0x24,0xFC,0x00,0x00,0x02,0x02,0xFE,0x00],#艳
0xE4B8BD:
[0x00,0xFF,0x00,0x00,0x3E,0x22,0x22,0x22,0x32,0x2A,0x2A,0x22,0x22,0x22,0x2A,0x24,
0x00,0xFE,0x00,0x00,0xF8,0x88,0x88,0x88,0xC8,0xA8,0xA8,0x88,0x88,0x88,0xA8,0x90]#丽
}
#定义汉字显示函数
def oled_dzk(ch_str,x_pos,y_pos,dzk):
offset = 0
for k in ch_str: #将中文变成十六进制的编码值
code = 0x00
data_code = k.encode("utf_8")
code |= data_code[0] << 16
code |= data_code[1] << 8
code |= data_code[2]
byte_data = dzk[code] #通过key寻找里面的值
for y in range(0,16):
a_ = bin(byte_data[y]).replace('0b','')
while len(a_) < 8:
a_ = '0'+a_
b_ = bin(byte_data[y+16]).replace('0b','')
while len(b_) < 8:
b_ = '0' + b_
for x in range(0,8):
oled.pixel(x_pos + offset + x,y + y_pos,int(a_[x]))
oled.pixel(x_pos + offset + x + 8,y + y_pos,int(b_[x]))
offset = offset + 16
oled_dzk("五组:郭夕强,",10,5,dzk1)
oled_dzk("刁东波,高成友",10,25,dzk2)
oled_dzk("杜泓洁,侯艳丽",10,45,dzk3)
oled.show()
time.sleep(2)