Freeze display time during partial-buffer updates
This commit is contained in:
@@ -142,6 +142,10 @@ font:
|
|||||||
- "\U000F092D" # mdi:wifi-strength-off
|
- "\U000F092D" # mdi:wifi-strength-off
|
||||||
|
|
||||||
globals:
|
globals:
|
||||||
|
- id: display_time
|
||||||
|
type: esphome::ESPTime
|
||||||
|
restore_value: false
|
||||||
|
initial_value: 'esphome::ESPTime{}'
|
||||||
- id: page_index
|
- id: page_index
|
||||||
type: int
|
type: int
|
||||||
restore_value: true
|
restore_value: true
|
||||||
@@ -313,6 +317,9 @@ sensor:
|
|||||||
name: 'WireGuard Latest Handshake'
|
name: 'WireGuard Latest Handshake'
|
||||||
|
|
||||||
interval:
|
interval:
|
||||||
|
- interval: 1s
|
||||||
|
then:
|
||||||
|
- script.execute: refresh_display
|
||||||
- interval: 10s
|
- interval: 10s
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
@@ -330,10 +337,15 @@ interval:
|
|||||||
if (id(internet_history_count) < 361) id(internet_history_count)++;
|
if (id(internet_history_count) < 361) id(internet_history_count)++;
|
||||||
|
|
||||||
script:
|
script:
|
||||||
|
- id: refresh_display
|
||||||
|
then:
|
||||||
|
# The partial-buffer driver draws multiple strips; freeze time for the entire frame.
|
||||||
|
- lambda: id(display_time) = id(sntp_time).now();
|
||||||
|
- component.update: tft
|
||||||
- id: show_previous_page
|
- id: show_previous_page
|
||||||
then:
|
then:
|
||||||
- lambda: id(page_index) = (id(page_index) + 4 - 1) % 4;
|
- lambda: id(page_index) = (id(page_index) + 4 - 1) % 4;
|
||||||
- component.update: tft
|
- script.execute: refresh_display
|
||||||
- id: toggle_page_mode
|
- id: toggle_page_mode
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
@@ -346,11 +358,11 @@ script:
|
|||||||
} else if (id(page_index) == 3) {
|
} else if (id(page_index) == 3) {
|
||||||
id(internet_view) = (id(internet_view) + 1) % 3;
|
id(internet_view) = (id(internet_view) + 1) % 3;
|
||||||
}
|
}
|
||||||
- component.update: tft
|
- script.execute: refresh_display
|
||||||
- id: show_next_page
|
- id: show_next_page
|
||||||
then:
|
then:
|
||||||
- lambda: id(page_index) = (id(page_index) + 1) % 4;
|
- lambda: id(page_index) = (id(page_index) + 1) % 4;
|
||||||
- component.update: tft
|
- script.execute: refresh_display
|
||||||
|
|
||||||
button:
|
button:
|
||||||
- platform: template
|
- platform: template
|
||||||
@@ -419,13 +431,14 @@ display:
|
|||||||
dc_pin: GPIO27
|
dc_pin: GPIO27
|
||||||
reset_pin: GPIO33
|
reset_pin: GPIO33
|
||||||
invert_colors: true
|
invert_colors: true
|
||||||
update_interval: 1s
|
update_interval: never
|
||||||
lambda: |-
|
lambda: |-
|
||||||
|
const auto now = id(display_time);
|
||||||
it.fill(Color::BLACK);
|
it.fill(Color::BLACK);
|
||||||
|
|
||||||
if (id(sntp_time).now().is_valid()) {
|
if (now.is_valid()) {
|
||||||
it.strftime(234, 10, id(font_small), Color::WHITE, TextAlign::TOP_RIGHT,
|
it.strftime(234, 10, id(font_small), Color::WHITE, TextAlign::TOP_RIGHT,
|
||||||
"%H:%M", id(sntp_time).now());
|
"%H:%M", now);
|
||||||
} else {
|
} else {
|
||||||
it.printf(234, 10, id(font_small), Color::WHITE, TextAlign::TOP_RIGHT, "--:--");
|
it.printf(234, 10, id(font_small), Color::WHITE, TextAlign::TOP_RIGHT, "--:--");
|
||||||
}
|
}
|
||||||
@@ -643,7 +656,6 @@ display:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (id(page_index) == 2) {
|
if (id(page_index) == 2) {
|
||||||
const auto now = id(sntp_time).now();
|
|
||||||
const Color accent(143, 190, 223);
|
const Color accent(143, 190, 223);
|
||||||
const Color gold(255, 170, 40);
|
const Color gold(255, 170, 40);
|
||||||
const Color muted(55, 65, 80);
|
const Color muted(55, 65, 80);
|
||||||
|
|||||||
Reference in New Issue
Block a user