Refactor master bedroom remote configuration: Update display button labels and implement backlight control based on user interaction
This commit is contained in:
@@ -17,6 +17,9 @@ esphome:
|
||||
- output.set_level:
|
||||
id: backlight_output
|
||||
level: 100%
|
||||
- lambda: |-
|
||||
id(last_interaction_ms) = millis();
|
||||
id(backlight_is_on) = true;
|
||||
- component.update: my_display
|
||||
|
||||
esp32:
|
||||
@@ -82,7 +85,7 @@ display:
|
||||
} else {
|
||||
it.filled_rectangle(20, 50, 130, 80, Color(0x424242));
|
||||
}
|
||||
it.print(85, 90, id(button_font), Color(0xFFFFFF), TextAlign::CENTER, "ALL");
|
||||
it.print(85, 90, id(button_font), Color(0xFFFFFF), TextAlign::CENTER, "Toggle All");
|
||||
|
||||
// Button 2: Light 1 (top-right)
|
||||
if (id(light1_state)) {
|
||||
@@ -90,7 +93,7 @@ display:
|
||||
} else {
|
||||
it.filled_rectangle(170, 50, 130, 80, Color(0x424242));
|
||||
}
|
||||
it.print(235, 90, id(button_font), Color(0xFFFFFF), TextAlign::CENTER, "Light 1");
|
||||
it.print(235, 90, id(button_font), Color(0xFFFFFF), TextAlign::CENTER, "Polly's Light");
|
||||
|
||||
// Button 3: Light 2 (bottom-left)
|
||||
if (id(light2_state)) {
|
||||
@@ -98,7 +101,7 @@ display:
|
||||
} else {
|
||||
it.filled_rectangle(20, 150, 130, 80, Color(0x424242));
|
||||
}
|
||||
it.print(85, 190, id(button_font), Color(0xFFFFFF), TextAlign::CENTER, "Light 2");
|
||||
it.print(85, 190, id(button_font), Color(0xFFFFFF), TextAlign::CENTER, "Joshua's Light");
|
||||
|
||||
// Button 4: Fan (bottom-right)
|
||||
if (id(fan_state)) {
|
||||
@@ -106,7 +109,7 @@ display:
|
||||
} else {
|
||||
it.filled_rectangle(170, 150, 130, 80, Color(0x424242));
|
||||
}
|
||||
it.print(235, 190, id(button_font), Color(0xFFFFFF), TextAlign::CENTER, "Fan");
|
||||
it.print(235, 190, id(button_font), Color(0xFFFFFF), TextAlign::CENTER, "Ceiling Fan");
|
||||
|
||||
# XPT2046 Touchscreen
|
||||
touchscreen:
|
||||
@@ -121,6 +124,12 @@ touchscreen:
|
||||
y_max: 3860
|
||||
on_touch:
|
||||
- lambda: |-
|
||||
id(last_interaction_ms) = millis();
|
||||
if (!id(backlight_is_on)) {
|
||||
id(backlight).turn_on();
|
||||
id(backlight_is_on) = true;
|
||||
}
|
||||
|
||||
int tx = touch.x;
|
||||
int ty = touch.y;
|
||||
ESP_LOGD("touch", "Touch at x=%d, y=%d", tx, ty);
|
||||
@@ -153,10 +162,10 @@ light:
|
||||
|
||||
# Fonts
|
||||
font:
|
||||
- file: "gfonts://Roboto"
|
||||
- file: "gfonts://Nunito"
|
||||
id: title_font
|
||||
size: 24
|
||||
- file: "gfonts://Roboto"
|
||||
- file: "gfonts://Nunito"
|
||||
id: button_font
|
||||
size: 20
|
||||
|
||||
@@ -186,11 +195,23 @@ globals:
|
||||
- id: touch_fan
|
||||
type: bool
|
||||
initial_value: "false"
|
||||
- id: last_interaction_ms
|
||||
type: uint32_t
|
||||
initial_value: "0"
|
||||
- id: backlight_is_on
|
||||
type: bool
|
||||
initial_value: "true"
|
||||
|
||||
# Process touch events
|
||||
interval:
|
||||
- interval: 100ms
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return id(backlight_is_on) && ((uint32_t)(millis() - id(last_interaction_ms)) > 30000);'
|
||||
then:
|
||||
- light.turn_off: backlight
|
||||
- lambda: 'id(backlight_is_on) = false;'
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return id(touch_all);'
|
||||
|
||||
Reference in New Issue
Block a user