Mercurial > code > home > repos > homeauto
comparison espNode/theater_lcd.yaml @ 802:d88085f35745
theater_lcd displays lines from mqtt on an ili9486 display in 8-bit mode
author | drewp@bigasterisk.com |
---|---|
date | Sat, 27 Mar 2021 22:15:56 -0700 |
parents | |
children | 2bed2f68243c |
comparison
equal
deleted
inserted
replaced
801:706539aa1990 | 802:d88085f35745 |
---|---|
1 | |
2 esphome: | |
3 name: theater_lcd | |
4 platform: ESP32 | |
5 board: esp32cam | |
6 build_path: build | |
7 | |
8 wifi: | |
9 ssid: !secret wifi_ssid | |
10 password: !secret wifi_password | |
11 domain: '' | |
12 | |
13 mqtt: | |
14 broker: '10.2.0.1' | |
15 port: 1883 | |
16 username: '' | |
17 password: '' | |
18 | |
19 logger: | |
20 baud_rate: 115200 | |
21 level: DEBUG | |
22 | |
23 ota: | |
24 | |
25 # image: | |
26 # - file: "colorscape.png" | |
27 # id: colorscape | |
28 # type: RGB24 | |
29 | |
30 font: | |
31 - file: "bluefish-scratched/BLUEFISH BLACK SCRATCHED_Demo.ttf" | |
32 id: font_bluefish_big | |
33 size: 120 | |
34 glyphs: "0123456789ms " | |
35 - file: "Teko/Teko-Regular.ttf" | |
36 id: font_teko_small | |
37 size: 60 | |
38 glyphs: "+-_.:0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ " | |
39 | |
40 display: | |
41 - platform: ili9486_8bit | |
42 model: 'TFT_3.5' | |
43 id: lcd | |
44 cs_pin: GPIO16 # wh | |
45 dc_pin: GPIO17 # gy | |
46 wr_pin: GPIO5 # pu | |
47 rd_pin: GPIO18 # bk | |
48 data_pins: | |
49 - GPIO33 # gy | |
50 - GPIO32 # bk | |
51 - GPIO13 # pu | |
52 - GPIO12 # bl | |
53 - GPIO14 # gn | |
54 - GPIO27 # ye | |
55 - GPIO26 # or | |
56 - GPIO25 # re | |
57 rotation: 90 | |
58 lambda: |- | |
59 it.clear(); // may be cheaper to get text extent and fill that box only | |
60 { | |
61 const std::string line = id(line1).state; | |
62 const char color_letter = line[0]; | |
63 const char* text = line.c_str() + (line.size() > 1 ? 1 : 0); | |
64 Color color; | |
65 switch(color_letter) { | |
66 // from https://coolors.co/e75d18-48a8a8-ededca-ac162a-550589-ed787f | |
67 case 'o': color = Color(0xe75d18);break; | |
68 case 'b': color = Color(0x48a8a8);break; | |
69 case 'y': color = Color(0xededca);break; | |
70 case 'r': color = Color(0xac162a);break; | |
71 case 'i': color = Color(0x550589);break; | |
72 case 'p': color = Color(0xed787f);break; | |
73 default: color = COLOR_WHITE; | |
74 } | |
75 it.print(0, 0, id(font_bluefish_big), color, text); | |
76 } | |
77 { | |
78 const std::string line = id(line2).state; | |
79 const char color_letter = line[0]; | |
80 const char* text = line.c_str() + (line.size() > 1 ? 1 : 0); | |
81 Color color; | |
82 switch(color_letter) { | |
83 case 'o': color = Color(0xe75d18);break; | |
84 case 'b': color = Color(0x48a8a8);break; | |
85 case 'y': color = Color(0xededca);break; | |
86 case 'r': color = Color(0xac162a);break; | |
87 case 'i': color = Color(0x550589);break; | |
88 case 'p': color = Color(0xed787f);break; | |
89 default: color = COLOR_WHITE; | |
90 } | |
91 it.print(0, 150, id(font_teko_small), color, text); | |
92 | |
93 } | |
94 | |
95 | |
96 text_sensor: | |
97 - platform: mqtt_subscribe | |
98 name: "line1" | |
99 id: line1 | |
100 topic: theater_lcd/line1 | |
101 on_value: | |
102 then: | |
103 - component.update: lcd | |
104 - platform: mqtt_subscribe | |
105 name: "line2" | |
106 id: line2 | |
107 topic: theater_lcd/line2 | |
108 on_value: | |
109 then: | |
110 - component.update: lcd | |
111 | |
112 # ili9486 setup | |
113 # http://www.lcdwiki.com/3.5inch_Arduino_Display-UNO | |
114 # (https://www.aliexpress.com/item/4000055026873.html $12) | |
115 # and https://circuits4you.com/wp-content/uploads/2018/12/ESP32-Pinout.jpg | |
116 # | |
117 # GND - GND Power ground | |
118 # 5V - 5V 5V power input | |
119 # NC - 3V3 3.3V power input, this pin can be disconnected | |
120 # GND - LCD_RST LCD bus reset signal, low level reset | |
121 # | |
122 # GPIO16 - LCD_CS LCD bus chip select signal, low level enable | |
123 # | |
124 # GPIO17 - LCD_RS LCD bus command / data selection signal, low level: command, high level: data | |
125 # GPIO5 - LCD_WR LCD bus write signal | |
126 # GPIO18 - LCD_RD LCD bus read signal | |
127 | |
128 # GPIO33 - LCD_D0 LCD 8-bit data Bit0 | |
129 # GPIO32 - LCD_D1 LCD 8-bit data Bit1 | |
130 # GPIO13 - LCD_D2 LCD 8-bit data Bit2 | |
131 # GPIO12 - LCD_D3 LCD 8-bit data Bit3 | |
132 # GPIO14 - LCD_D4 LCD 8-bit data Bit4 | |
133 # GPIO27 - LCD_D5 LCD 8-bit data Bit5 | |
134 # GPIO26 - LCD_D6 LCD 8-bit data Bit6 | |
135 # GPIO25 - LCD_D7 LCD 8-bit data Bit7 |