font:
- file: "gfonts://Roboto"
id: roboto
size: 20
- file: "fonts/simsunb.ttf"
id: font2
size: 28
glyphs: 水位.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
time:
- platform: homeassistant
id: my_time
sensor:
# 获取HA上面水位传感器
- platform: homeassistant
id: watertowerlevel
entity_id: sensor.test1 # HA上面的实体ID
internal: true
# Example configuration entry
spi:
clk_pin: GPIO14
mosi_pin: GPIO15
display:
- platform: st7920
cs_pin:
number: GPIO13
inverted: true
width: 128
height: 64
update_interval: 100ms
# ##起点 列X 行Y ,终点 列X 行Y
lambda: |-
it.line(0, 0, 127, 0);
it.line(0, 63, 127, 63);
it.line(0, 0, 0, 63);
it.line(127, 0, 127, 63);
it.strftime(10,1,id(roboto),"%m.%d %H:%M", id(my_time).now());
it.printf(64, 25, id(font2), TextAlign::TOP_CENTER, "水位 : %.0f", id(watertowerlevel).state);
想要显示中文字体很重要,英文字体会乱码,反复测试发现simsunb字体显示效果不错
|