Added tap to wake and cycle feed
This commit is contained in:
+83
-3
@@ -2,13 +2,16 @@
|
||||
# Copy this file AND the components/ folder into your ESPHome config directory.
|
||||
# Pair with the resizer proxy in this repo.
|
||||
#
|
||||
# Touch cycles: stream A (default) -> stream B -> off -> stream A ...
|
||||
#
|
||||
# Uses a custom fast_jpeg component (RGB565 block decode + DMA blit).
|
||||
# Stock online_image JPEG is too slow for ~5 fps.
|
||||
|
||||
substitutions:
|
||||
name: doorbell-display
|
||||
friendly_name: Doorbell Display
|
||||
image_url: "http://10.0.1.195:8080/"
|
||||
stream_a_url: "http://10.0.1.195:8080/doorbell/?size=480"
|
||||
stream_b_url: "http://10.0.1.195:8080/oprit/?size=480"
|
||||
|
||||
external_components:
|
||||
- source:
|
||||
@@ -35,6 +38,15 @@ esphome:
|
||||
- delay: 120ms
|
||||
- lambda: |-
|
||||
id(ext_io)->digital_write(7, true);
|
||||
- priority: 600
|
||||
then:
|
||||
- lambda: |-
|
||||
id(touch_state) = 0;
|
||||
id(doorbell_jpg).set_url("${stream_a_url}");
|
||||
id(doorbell_jpg).set_enabled(true);
|
||||
- light.turn_on:
|
||||
id: backlight
|
||||
brightness: 100%
|
||||
|
||||
esp32:
|
||||
board: esp32-s3-devkitc-1
|
||||
@@ -79,6 +91,45 @@ pca9554:
|
||||
address: 0x20
|
||||
pin_count: 8
|
||||
|
||||
globals:
|
||||
- id: touch_state
|
||||
type: int
|
||||
restore_value: false
|
||||
initial_value: "0"
|
||||
|
||||
script:
|
||||
- id: cycle_stream
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: |-
|
||||
id(touch_state) = (id(touch_state) + 1) % 3;
|
||||
- if:
|
||||
condition:
|
||||
lambda: "return id(touch_state) == 0;"
|
||||
then:
|
||||
- lambda: |-
|
||||
id(doorbell_jpg).set_url("${stream_a_url}");
|
||||
id(doorbell_jpg).set_enabled(true);
|
||||
- light.turn_on:
|
||||
id: backlight
|
||||
brightness: 100%
|
||||
- if:
|
||||
condition:
|
||||
lambda: "return id(touch_state) == 1;"
|
||||
then:
|
||||
- lambda: |-
|
||||
id(doorbell_jpg).set_url("${stream_b_url}");
|
||||
id(doorbell_jpg).set_enabled(true);
|
||||
- light.turn_on:
|
||||
id: backlight
|
||||
brightness: 100%
|
||||
- if:
|
||||
condition:
|
||||
lambda: "return id(touch_state) == 2;"
|
||||
then:
|
||||
- lambda: "id(doorbell_jpg).set_enabled(false);"
|
||||
- light.turn_off: backlight
|
||||
|
||||
spi:
|
||||
- id: disp_spi
|
||||
interface: software
|
||||
@@ -107,7 +158,10 @@ light:
|
||||
restore_mode: ALWAYS_ON
|
||||
default_transition_length: 0s
|
||||
on_turn_on:
|
||||
- lambda: id(doorbell_jpg).set_enabled(true);
|
||||
- lambda: |-
|
||||
if (id(touch_state) != 2) {
|
||||
id(doorbell_jpg).set_enabled(true);
|
||||
}
|
||||
on_turn_off:
|
||||
- lambda: id(doorbell_jpg).set_enabled(false);
|
||||
|
||||
@@ -120,12 +174,38 @@ switch:
|
||||
lambda: |-
|
||||
return id(backlight).current_values.is_on();
|
||||
turn_on_action:
|
||||
- lambda: |-
|
||||
id(touch_state) = 0;
|
||||
id(doorbell_jpg).set_url("${stream_a_url}");
|
||||
id(doorbell_jpg).set_enabled(true);
|
||||
- light.turn_on:
|
||||
id: backlight
|
||||
brightness: 100%
|
||||
turn_off_action:
|
||||
- lambda: |-
|
||||
id(touch_state) = 2;
|
||||
id(doorbell_jpg).set_enabled(false);
|
||||
- light.turn_off: backlight
|
||||
|
||||
touchscreen:
|
||||
- platform: gt911
|
||||
id: touch
|
||||
display: lcd
|
||||
update_interval: 50ms
|
||||
reset_pin:
|
||||
pca9554: ext_io
|
||||
number: 5
|
||||
mode:
|
||||
output: true
|
||||
# INT is on the IO expander; used for address selection, polled for touches.
|
||||
interrupt_pin:
|
||||
pca9554: ext_io
|
||||
number: 6
|
||||
mode:
|
||||
input: true
|
||||
on_touch:
|
||||
- script.execute: cycle_stream
|
||||
|
||||
display:
|
||||
- platform: mipi_rgb
|
||||
id: lcd
|
||||
@@ -199,7 +279,7 @@ display:
|
||||
|
||||
fast_jpeg:
|
||||
id: doorbell_jpg
|
||||
url: ${image_url}
|
||||
url: ${stream_a_url}
|
||||
display_id: lcd
|
||||
update_interval: 200ms
|
||||
# If colours look swapped, set big_endian: false
|
||||
|
||||
Reference in New Issue
Block a user