Split files
To improve readability and increase my chances to have more people collaborating with this project. Solves #27
This commit is contained in:
212
ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml
Normal file
212
ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml
Normal file
@@ -0,0 +1,212 @@
|
||||
####################################################################################################
|
||||
##### TX Ultimate Easy for ESPHome #####
|
||||
##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy #####
|
||||
####################################################################################################
|
||||
##### Purpose: ESPHome Core - Hardware - Touch panel #####
|
||||
####################################################################################################
|
||||
##### Author: edwardtfn - https://github.com/edwardtfn - https://buymeacoffee.com/edwardfirmo #####
|
||||
####################################################################################################
|
||||
##### NOTE: #####
|
||||
##### - Make changes ONLY if absolutely necessary and you have the required knowledge. #####
|
||||
##### - For normal system use, modifications to this file are NOT required. #####
|
||||
####################################################################################################
|
||||
---
|
||||
binary_sensor:
|
||||
- id: bs_multi_touch
|
||||
name: Multi-touch
|
||||
icon: mdi:gesture-two-tap
|
||||
internal: false
|
||||
platform: template
|
||||
on_click:
|
||||
then:
|
||||
- lambda: send_event_to_ha->execute("multi_touch", "multi_touch");
|
||||
|
||||
- id: bs_swipe_left
|
||||
name: Swipe left
|
||||
icon: mdi:gesture-swipe-left
|
||||
internal: true
|
||||
platform: template
|
||||
on_click:
|
||||
then:
|
||||
- lambda: send_event_to_ha->execute("swipe", "left");
|
||||
|
||||
- id: bs_swipe_right
|
||||
name: Swipe right
|
||||
icon: mdi:gesture-swipe-right
|
||||
internal: true
|
||||
platform: template
|
||||
on_click:
|
||||
then:
|
||||
- lambda: send_event_to_ha->execute("swipe", "right");
|
||||
|
||||
- id: bs_swipe_up
|
||||
name: Swipe up
|
||||
icon: mdi:gesture-swipe-up
|
||||
internal: true
|
||||
platform: template
|
||||
on_click:
|
||||
then:
|
||||
- lambda: send_event_to_ha->execute("swipe", "up");
|
||||
|
||||
- id: bs_swipe_down
|
||||
name: Swipe down
|
||||
icon: mdi:gesture-swipe-down
|
||||
internal: true
|
||||
platform: template
|
||||
on_click:
|
||||
then:
|
||||
- lambda: send_event_to_ha->execute("swipe", "down");
|
||||
|
||||
external_components:
|
||||
- source: github://edwardtfn/TX-Ultimate-Easy@dev # Change this before releasing
|
||||
components:
|
||||
- tx_ultimate_easy
|
||||
|
||||
number:
|
||||
- id: nr_touch_duration
|
||||
name: Touch duration
|
||||
icon: mdi:timer-cog-outline
|
||||
unit_of_measurement: ms
|
||||
# mode: box
|
||||
internal: false
|
||||
entity_category: config
|
||||
platform: template
|
||||
min_value: 10
|
||||
max_value: 1500
|
||||
step: 1
|
||||
initial_value: 250
|
||||
optimistic: true
|
||||
restore_value: true
|
||||
|
||||
script:
|
||||
- id: touch_on_multi_touch_release
|
||||
mode: restart
|
||||
then:
|
||||
# Extended by:
|
||||
# - HW Buttons
|
||||
# - HW Vibration
|
||||
- script.execute: touch_on_multi_touch_release_touch
|
||||
|
||||
- id: touch_on_multi_touch_release_touch
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: bs_multi_touch->publish_state(true);
|
||||
- delay: !lambda return nr_touch_duration->state;
|
||||
- lambda: bs_multi_touch->publish_state(false);
|
||||
|
||||
- id: touch_on_press
|
||||
mode: restart
|
||||
parameters:
|
||||
touch_x: uint8_t
|
||||
then:
|
||||
# Extended by:
|
||||
# - HW Buttons
|
||||
# - HW Vibration
|
||||
|
||||
- id: touch_on_release
|
||||
mode: restart
|
||||
then:
|
||||
# Extended by:
|
||||
# - HW Buttons
|
||||
# - HW Vibration
|
||||
- script.execute: touch_swipe_turn_off_binary_sensor
|
||||
|
||||
- id: touch_swipe_left
|
||||
mode: restart
|
||||
then:
|
||||
# Extended by:
|
||||
# - HW Buttons
|
||||
- script.execute: touch_swipe_left_touch
|
||||
|
||||
- id: touch_swipe_left_touch
|
||||
mode: restart
|
||||
then:
|
||||
- binary_sensor.template.publish:
|
||||
id: bs_swipe_left
|
||||
state: ON
|
||||
- delay: !lambda return nr_touch_duration->state;
|
||||
- script.execute: touch_swipe_turn_off_binary_sensor
|
||||
|
||||
- id: touch_swipe_right
|
||||
mode: restart
|
||||
then:
|
||||
# Extended by:
|
||||
# - HW Buttons
|
||||
- script.execute: touch_swipe_right_touch
|
||||
|
||||
- id: touch_swipe_right_touch
|
||||
mode: restart
|
||||
then:
|
||||
- binary_sensor.template.publish:
|
||||
id: bs_swipe_right
|
||||
state: ON
|
||||
- delay: !lambda return nr_touch_duration->state;
|
||||
- script.execute: touch_swipe_turn_off_binary_sensor
|
||||
|
||||
- id: touch_swipe_turn_off_binary_sensor
|
||||
mode: restart
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
binary_sensor.is_on: bs_swipe_left
|
||||
then:
|
||||
- binary_sensor.template.publish:
|
||||
id: bs_swipe_left
|
||||
state: OFF
|
||||
- if:
|
||||
condition:
|
||||
binary_sensor.is_on: bs_swipe_right
|
||||
then:
|
||||
- binary_sensor.template.publish:
|
||||
id: bs_swipe_right
|
||||
state: OFF
|
||||
|
||||
switch:
|
||||
- id: sw_touch_panel_power
|
||||
name: Touch panel - Power
|
||||
platform: gpio
|
||||
pin:
|
||||
number: GPIO5
|
||||
inverted: true
|
||||
restore_mode: ALWAYS_ON
|
||||
internal: false
|
||||
entity_category: config
|
||||
|
||||
tx_ultimate_easy:
|
||||
id: tx_ultimate
|
||||
uart: uart_touch
|
||||
|
||||
on_multi_touch_release:
|
||||
- lambda: ESP_LOGI("tx_ultimate_easy", "Multi-touch released");
|
||||
- script.execute: touch_on_multi_touch_release
|
||||
|
||||
on_press:
|
||||
- lambda: ESP_LOGI("tx_ultimate_easy", "Pressed");
|
||||
- script.execute:
|
||||
id: touch_on_multi_touch_press
|
||||
touch_x: !lambda return static_cast<uint8_t>(touch.x);
|
||||
|
||||
on_release:
|
||||
- lambda: ESP_LOGI("tx_ultimate_easy", "Released");
|
||||
- script.execute: touch_on_release
|
||||
|
||||
on_swipe_left:
|
||||
- lambda: ESP_LOGI("tx_ultimate_easy", "Swipe left");
|
||||
- script.execute: touch_swipe_left
|
||||
|
||||
on_swipe_right:
|
||||
- lambda: ESP_LOGI("tx_ultimate_easy", "Swipe right");
|
||||
- script.execute: touch_swipe_right
|
||||
|
||||
on_touch_event:
|
||||
- lambda: |-
|
||||
ESP_LOGD("tx_ultimate_easy", "Touch event:");
|
||||
ESP_LOGD("tx_ultimate_easy", " State: %i (%s)", touch.state, touch.state_str.c_str());
|
||||
ESP_LOGD("tx_ultimate_easy", " Position: %i", touch.x);
|
||||
|
||||
uart:
|
||||
id: uart_touch
|
||||
tx_pin: GPIO19
|
||||
rx_pin: GPIO22
|
||||
baud_rate: 115200
|
||||
...
|
||||
Reference in New Issue
Block a user