7#include <esp_idf_version.h>
11#include <driver/touch_sensor.h>
12#include <freertos/FreeRTOS.h>
13#include <freertos/queue.h>
16namespace esp32_touch {
30static const uint32_t SETUP_MODE_LOG_INTERVAL_MS = 250;
51 void setup()
override;
58#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3)
109#ifdef USE_ESP32_VARIANT_ESP32
118 struct TouchPadEventV1 {
129#elif defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3)
137 struct TouchPadEventV2 {
151 touch_pad_denoise_grade_t
grade_{TOUCH_PAD_DENOISE_MAX};
152 touch_pad_denoise_cap_t
cap_level_{TOUCH_PAD_DENOISE_CAP_MAX};
162 return (this->
grade_ != TOUCH_PAD_DENOISE_MAX) && (this->
cap_level_ != TOUCH_PAD_DENOISE_CAP_MAX);
184 case TOUCH_LVOLT_0V5:
186 case TOUCH_LVOLT_0V6:
188 case TOUCH_LVOLT_0V7:
190 case TOUCH_LVOLT_0V8:
199 case TOUCH_HVOLT_2V4:
201 case TOUCH_HVOLT_2V5:
203 case TOUCH_HVOLT_2V6:
205 case TOUCH_HVOLT_2V7:
214 case TOUCH_HVOLT_ATTEN_1V5:
216 case TOUCH_HVOLT_ATTEN_1V:
218 case TOUCH_HVOLT_ATTEN_0V5:
220 case TOUCH_HVOLT_ATTEN_0V:
Base class for all binary_sensor-type classes.
Simple helper class to expose a touch pad value as a binary sensor.
uint32_t last_touch_time_
bool initial_state_published_
uint32_t get_wakeup_threshold() const
void set_threshold(uint32_t threshold)
uint32_t get_value() const
Get the raw touch measurement value.
touch_pad_t get_touch_pad() const
uint32_t get_threshold() const
uint32_t value_
Stores the last raw touch measurement value.
const uint32_t wakeup_threshold_
friend ESP32TouchComponent
ESP32TouchBinarySensor(touch_pad_t touch_pad, uint32_t threshold, uint32_t wakeup_threshold)
touch_volt_atten_t voltage_attenuation_
void set_jitter_step(uint32_t jitter_step)
touch_filter_mode_t filter_mode_
bool create_touch_queue_()
bool filter_configured_() const
static void touch_isr_handler(void *arg)
bool iir_filter_enabled_() const
touch_pad_t waterproof_guard_ring_pad_
void set_setup_mode(bool setup_mode)
uint32_t release_check_interval_ms_
void set_measurement_duration(uint16_t meas_cycle)
uint32_t setup_mode_last_log_print_
void register_touch_pad(ESP32TouchBinarySensor *pad)
void check_and_disable_loop_if_all_released_(size_t pads_off)
bool check_and_update_touch_state_(ESP32TouchBinarySensor *child)
static void touch_isr_handler(void *arg)
void set_debounce_count(uint32_t debounce_count)
void publish_initial_state_if_needed_(ESP32TouchBinarySensor *child, uint32_t now)
static const char * get_high_voltage_reference_str(touch_high_volt_t ref)
void set_low_voltage_reference(touch_low_volt_t low_voltage_reference)
QueueHandle_t touch_queue_
void set_voltage_attenuation(touch_volt_atten_t voltage_attenuation)
bool waterproof_configured_() const
touch_pad_denoise_grade_t grade_
void calculate_release_timeout_()
void update_touch_state_(ESP32TouchBinarySensor *child, bool is_touched, uint32_t value)
bool denoise_configured_() const
static constexpr uint32_t MINIMUM_RELEASE_TIME_MS
static const char * get_low_voltage_reference_str(touch_low_volt_t ref)
void on_shutdown() override
void set_high_voltage_reference(touch_high_volt_t high_voltage_reference)
touch_high_volt_t high_voltage_reference_
touch_pad_shield_driver_t waterproof_shield_driver_
uint32_t noise_threshold_
void set_filter_mode(touch_filter_mode_t filter_mode)
void set_denoise_grade(touch_pad_denoise_grade_t denoise_grade)
void set_sleep_duration(uint16_t sleep_duration)
void set_waterproof_shield_driver(touch_pad_shield_driver_t drive_capability)
touch_smooth_mode_t smooth_level_
void process_setup_mode_logging_(uint32_t now)
uint32_t release_timeout_ms_
void dump_config_sensors_()
void set_noise_threshold(uint32_t noise_threshold)
float get_setup_priority() const override
void set_iir_filter(uint32_t iir_filter)
std::vector< ESP32TouchBinarySensor * > children_
uint32_t read_touch_value(touch_pad_t pad) const
void set_denoise_cap(touch_pad_denoise_cap_t cap_level)
touch_pad_denoise_cap_t cap_level_
touch_low_volt_t low_voltage_reference_
void set_smooth_level(touch_smooth_mode_t smooth_level)
void cleanup_touch_queue_()
void configure_wakeup_pads_()
bool should_check_for_releases_(uint32_t now)
static const char * get_voltage_attenuation_str(touch_volt_atten_t atten)
uint32_t last_release_check_
void set_waterproof_guard_ring_pad(touch_pad_t pad)
void dump_config() override
const float DATA
For components that import data from directly connected sensors like DHT.
Providing packet encoding functions for exchanging data with a remote host.