1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-02 03:12:20 +01:00

Add set_threshold and get_value methods to ESP32TouchBinarySensor. (#631)

* Add set_threshold and get_value methods to ESP32TouchBinarySensor and add a test.

* esp32_touch_binary_adaptive: fix formatting

* Remove superfluous static from testcase

* Revert "Remove superfluous static from testcase"

This reverts commit 5a6a111aa8.

* Move into header file

* Update esp32_touch.h


Co-authored-by: olg <x>
Co-authored-by: Otto Winter <otto@otto-winter.com>
This commit is contained in:
rnauber
2019-06-16 19:14:13 +02:00
committed by Otto Winter
parent db968bc6b0
commit c13f132399
3 changed files with 31 additions and 30 deletions

View File

@@ -647,6 +647,7 @@ binary_sensor:
name: "ESP32 Touch Pad GPIO27"
pin: GPIO27
threshold: 1000
id: btn_left
- platform: nextion
page_id: 0
component_id: 2
@@ -1154,6 +1155,16 @@ interval:
if (true) return id(page1); else return id(page2);
- display.page.show_next: display1
- display.page.show_previous: display1
- interval: 2s
then:
- lambda: |-
static uint16_t btn_left_state = id(btn_left)->get_value();
ESP_LOGD("adaptive touch", "___ Touch Pad '%s' (T%u): val: %u state: %u tres:%u", id(btn_left)->get_name().c_str(), id(btn_left)->get_touch_pad(), id(btn_left)->get_value(), btn_left_state, id(btn_left)->get_threshold());
btn_left_state = ((uint32_t) id(btn_left)->get_value() + 63 * (uint32_t)btn_left_state) >> 6;
id(btn_left)->set_threshold(btn_left_state * 0.9);
display:
- platform: lcd_gpio