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:
@@ -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
|
||||
|
Reference in New Issue
Block a user