mirror of
https://github.com/randybb/esphome-configs.git
synced 2026-10-14 16:35:12 +02:00
Same boot screen as on the other displays: "Made for ESPHome" logo, name, WiFi with signal, IPv6 addresses first (link-local skipped), Home Assistant state, ESPHome version and uptime.
169 lines
4.3 KiB
YAML
169 lines
4.3 KiB
YAML
---
|
|
substitutions:
|
|
device: tft
|
|
name: TFT
|
|
area: DEV
|
|
comment: "${area} | Desk TFT Display"
|
|
|
|
esphome:
|
|
name: mcu-${device}
|
|
friendly_name: ${name}
|
|
area: ${area}
|
|
comment: ${comment}
|
|
platformio_options:
|
|
board_build.flash_mode: dio
|
|
|
|
|
|
esp32:
|
|
variant: esp32c3
|
|
framework:
|
|
type: esp-idf
|
|
|
|
packages:
|
|
common: !include common/common.yaml
|
|
ipv6_only: !include common/ipv6_only.yaml
|
|
|
|
logger:
|
|
logs:
|
|
component: ERROR
|
|
|
|
# GPIO1 UART TX
|
|
# GPIO3 UART RX
|
|
# GPIO4 I2C SDA
|
|
# GPIO5 I2C SCL
|
|
# GPIO12 DISPLAY DIO
|
|
# GPIO12 DISPLAY CLOCK
|
|
# GPIO14 BUZZER
|
|
# GPIO16 RGB
|
|
|
|
spi:
|
|
clk_pin: 4
|
|
mosi_pin: 5
|
|
miso_pin: 6
|
|
|
|
color:
|
|
- id: my_green
|
|
hex: 00ff00
|
|
- id: my_magenta
|
|
hex: ff00ff
|
|
- id: my_red
|
|
hex: ff0000
|
|
- id: my_white
|
|
hex: ffffff
|
|
- id: status_ok
|
|
hex: 4dd966
|
|
- id: status_wait
|
|
hex: ffb300
|
|
- id: status_dim
|
|
hex: 8c8c8c
|
|
|
|
image:
|
|
- platform: file
|
|
file: assets/images/made-for-esphome-white-on-black.svg
|
|
id: esphome_logo
|
|
resize: 220x65
|
|
type: RGB565
|
|
transparency: alpha_channel
|
|
|
|
font:
|
|
- file: "gfonts://Roboto"
|
|
id: font_default
|
|
size: 20
|
|
- file: "gfonts://B612"
|
|
id: b612_24
|
|
size: 24
|
|
- file: "gfonts://B612"
|
|
id: b612_16
|
|
size: 16
|
|
- file: "gfonts://B612"
|
|
id: b612_12
|
|
size: 12
|
|
- file: "gfonts://B612 Mono"
|
|
id: b612_24_mono
|
|
size: 24
|
|
- file: "gfonts://B612 Mono"
|
|
id: b612_16_mono
|
|
size: 16
|
|
- file: "gfonts://B612 Mono"
|
|
id: b612_12_mono
|
|
size: 12
|
|
- file: "gfonts://Roboto"
|
|
id: roboto_32
|
|
size: 32
|
|
- file: "gfonts://Roboto"
|
|
id: roboto_24
|
|
size: 24
|
|
- file: "gfonts://Roboto"
|
|
id: roboto_16
|
|
size: 16
|
|
- file: "gfonts://Roboto"
|
|
id: roboto_12
|
|
size: 12
|
|
- file: "gfonts://Roboto Mono"
|
|
id: roboto_32_mono
|
|
size: 32
|
|
- file: "gfonts://Roboto Mono"
|
|
id: roboto_24_mono
|
|
size: 24
|
|
- file: "gfonts://Roboto Mono"
|
|
id: roboto_16_mono
|
|
size: 16
|
|
- file: "gfonts://Roboto Mono"
|
|
id: roboto_12_mono
|
|
size: 12
|
|
|
|
|
|
display:
|
|
- platform: mipi_spi
|
|
model: ILI9341
|
|
cs_pin: 7
|
|
dc_pin: 8
|
|
reset_pin: 10
|
|
invert_colors: false
|
|
lambda: |-
|
|
it.fill(Color::BLACK);
|
|
|
|
// status screen until Home Assistant connects (240x320)
|
|
if (!api::global_api_server->is_connected_with_state_subscription()) {
|
|
const int cx = it.get_width() / 2;
|
|
it.image(cx, 48, id(esphome_logo), ImageAlign::CENTER);
|
|
it.print(cx, 100, id(roboto_24), id(my_white), TextAlign::CENTER, "${name}");
|
|
|
|
int y = 130;
|
|
if (wifi::global_wifi_component->is_connected()) {
|
|
it.printf(8, y, id(roboto_16), id(status_ok), "WiFi: connected (%d dBm)",
|
|
wifi::global_wifi_component->wifi_rssi());
|
|
y += 22;
|
|
// IPv6 first (skip link-local), then IPv4
|
|
char buf[network::IP_ADDRESS_BUFFER_SIZE];
|
|
for (bool v6 : {true, false}) {
|
|
for (auto &ip : wifi::global_wifi_component->get_ip_addresses()) {
|
|
if (!ip.is_set() || ip.is_ip6() != v6 || y > 200)
|
|
continue;
|
|
ip.str_to(buf);
|
|
if (v6 && strncmp(buf, "fe80", 4) == 0)
|
|
continue;
|
|
it.print(8, y, id(roboto_12), id(status_dim), buf);
|
|
y += 16;
|
|
}
|
|
}
|
|
} else {
|
|
it.print(8, y, id(roboto_16), id(status_wait), "WiFi: connecting...");
|
|
y += 22;
|
|
}
|
|
y += 8;
|
|
it.print(8, y, id(roboto_16), api::global_api_server->is_connected() ? id(status_ok) : id(status_wait),
|
|
api::global_api_server->is_connected() ? "Home Assistant: connected" : "Home Assistant: waiting...");
|
|
|
|
it.printf(8, it.get_height() - 8, id(roboto_12), id(status_dim), TextAlign::BOTTOM_LEFT, "ESPHome %s",
|
|
ESPHOME_VERSION);
|
|
it.printf(it.get_width() - 8, it.get_height() - 8, id(roboto_12), id(status_dim), TextAlign::BOTTOM_RIGHT,
|
|
"up %us", (unsigned) (millis() / 1000));
|
|
return;
|
|
}
|
|
|
|
it.print(0, 0, id(b612_12), id(my_white), TextAlign::TOP_LEFT, "HELLO WORLD!");
|
|
it.print(0, 14, id(b612_12), id(my_green), TextAlign::TOP_LEFT, "HELLO WORLD!");
|
|
it.print(0, 28, id(b612_12), id(my_magenta), TextAlign::TOP_LEFT, "HELLO WORLD!");
|
|
it.print(0, 42, id(b612_12), id(my_red), TextAlign::TOP_LEFT, "HELLO WORLD!");
|