1#ifdef USE_ESP32_VARIANT_ESP32 
   12#include "hal/touch_sensor_ll.h" 
   15namespace esp32_touch {
 
   17static const char *
const TAG = 
"esp32_touch";
 
   19static const uint32_t SETUP_MODE_THRESHOLD = 0xFFFF;
 
   31  touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER);
 
   39#if ESP_IDF_VERSION_MAJOR >= 5 
   40  touch_pad_set_measurement_clock_cycles(this->
meas_cycle_);
 
   50      touch_pad_config(child->get_touch_pad(), SETUP_MODE_THRESHOLD);
 
   52      touch_pad_config(child->get_touch_pad(), child->get_threshold());
 
   59    ESP_LOGE(TAG, 
"Failed to register touch ISR: %s", esp_err_to_name(err));
 
   69  touch_pad_intr_enable();
 
 
   76    ESP_LOGCONFIG(TAG, 
"    IIR Filter: %" PRIu32 
"ms", this->
iir_filter_);
 
   78    ESP_LOGCONFIG(TAG, 
"  IIR Filter DISABLED");
 
   82    ESP_LOGCONFIG(TAG, 
"  Setup Mode ENABLED");
 
 
   97  TouchPadEventV1 event;
 
   98  while (xQueueReceive(this->
touch_queue_, &event, 0) == pdTRUE) {
 
  101      if (child->get_touch_pad() != event.pad) {
 
  106      child->value_ = 
event.value;
 
  109      bool new_state = 
event.is_touched;
 
  113        child->last_touch_time_ = now;
 
  117      if (new_state != child->last_state_) {
 
  118        child->initial_state_published_ = 
true;
 
  119        child->last_state_ = new_state;
 
  120        child->publish_state(new_state);
 
  123        ESP_LOGV(TAG, 
"Touch Pad '%s' state: %s (value: %" PRIu32 
" < threshold: %" PRIu32 
")",
 
  124                 child->get_name().c_str(), ONOFF(new_state), event.value, child->get_threshold());
 
  140    if (child->last_state_) {
 
  143      uint32_t time_diff = now - child->last_touch_time_;
 
  148        child->last_state_ = 
false;
 
  149        child->publish_state(
false);
 
  150        ESP_LOGV(TAG, 
"Touch Pad '%s' state: OFF (timeout)", child->get_name().c_str());
 
 
  169  touch_pad_intr_disable();
 
  174    touch_pad_filter_stop();
 
  175    touch_pad_filter_delete();
 
 
  186  touch_ll_read_trigger_status_mask(&mask);
 
  187  touch_ll_clear_trigger_status_mask();
 
  188  touch_pad_clear_status();
 
  200  for (
auto *child : 
component->children_) {
 
  201    touch_pad_t 
pad = child->get_touch_pad();
 
  210    uint32_t value = touch_ll_read_raw_data(
pad);
 
  213    if (((mask >> 
pad) & 1) == 0) {
 
  221    bool is_touched = value < child->get_threshold();
 
  226    TouchPadEventV1 event;
 
  229    event.is_touched = is_touched;
 
  232    BaseType_t x_higher_priority_task_woken = pdFALSE;
 
  233    xQueueSendFromISR(
component->touch_queue_, &event, &x_higher_priority_task_woken);
 
  234    component->enable_loop_soon_any_context();
 
  235    if (x_higher_priority_task_woken) {
 
  236      portYIELD_FROM_ISR();
 
 
uint32_t IRAM_ATTR HOT get_loop_component_start_time() const
Get the cached time in milliseconds from when the current component started its loop execution.
 
virtual void mark_failed()
Mark this component as failed.
 
touch_volt_atten_t voltage_attenuation_
 
bool create_touch_queue_()
 
static void touch_isr_handler(void *arg)
 
bool iir_filter_enabled_() const
 
void check_and_disable_loop_if_all_released_(size_t pads_off)
 
void publish_initial_state_if_needed_(ESP32TouchBinarySensor *child, uint32_t now)
 
QueueHandle_t touch_queue_
 
void calculate_release_timeout_()
 
void on_shutdown() override
 
touch_high_volt_t high_voltage_reference_
 
void process_setup_mode_logging_(uint32_t now)
 
uint32_t release_timeout_ms_
 
void dump_config_sensors_()
 
std::vector< ESP32TouchBinarySensor * > children_
 
touch_low_volt_t low_voltage_reference_
 
void cleanup_touch_queue_()
 
void configure_wakeup_pads_()
 
bool should_check_for_releases_(uint32_t now)
 
void dump_config() override
 
const Component * component
 
Providing packet encoding functions for exchanging data with a remote host.
 
Application App
Global storage of Application pointer - only one Application can exist.