9 namespace esp32_touch {
11 static const char *
const TAG =
"esp32_touch";
14 ESP_LOGCONFIG(TAG,
"Setting up ESP32 Touch Hub...");
26 touch_pad_config(child->get_touch_pad(), 0);
31 ESP_LOGCONFIG(TAG,
"Config for ESP32 Touch Hub:");
32 ESP_LOGCONFIG(TAG,
" Meas cycle: %.2fms", this->
meas_cycle_ / (8000000.0f / 1000.0f));
33 ESP_LOGCONFIG(TAG,
" Sleep cycle: %.2fms", this->
sleep_cycle_ / (150000.0f / 1000.0f));
53 ESP_LOGCONFIG(TAG,
" Low Voltage Reference: %s", lv_s);
73 ESP_LOGCONFIG(TAG,
" High Voltage Reference: %s", hv_s);
77 case TOUCH_HVOLT_ATTEN_1V5:
80 case TOUCH_HVOLT_ATTEN_1V:
83 case TOUCH_HVOLT_ATTEN_0V5:
86 case TOUCH_HVOLT_ATTEN_0V:
93 ESP_LOGCONFIG(TAG,
" Voltage Attenuation: %s", atten_s);
96 ESP_LOGCONFIG(TAG,
" IIR Filter: %ums", this->
iir_filter_);
98 ESP_LOGCONFIG(TAG,
" IIR Filter DISABLED");
101 ESP_LOGCONFIG(TAG,
" Setup Mode ENABLED!");
105 LOG_BINARY_SENSOR(
" ",
"Touch Pad", child);
106 ESP_LOGCONFIG(TAG,
" Pad: T%d", child->get_touch_pad());
107 ESP_LOGCONFIG(TAG,
" Threshold: %u", child->get_threshold());
112 const uint32_t now =
millis();
117 touch_pad_read_filtered(child->get_touch_pad(), &value);
119 touch_pad_read(child->get_touch_pad(), &value);
122 child->value_ = value;
123 child->publish_state(value < child->get_threshold());
126 ESP_LOGD(TAG,
"Touch Pad '%s' (T%u): %u", child->get_name().c_str(), child->get_touch_pad(), value);
134 this->setup_mode_last_log_print_ = now;
139 bool is_wakeup_source =
false;
142 touch_pad_filter_stop();
143 touch_pad_filter_delete();
147 if (child->get_wakeup_threshold() != 0) {
148 if (!is_wakeup_source) {
149 is_wakeup_source =
true;
151 touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER);
155 touch_pad_config(child->get_touch_pad(), child->get_wakeup_threshold());
159 if (!is_wakeup_source) {
165 : touch_pad_(touch_pad), threshold_(threshold), wakeup_threshold_(wakeup_threshold) {}
uint32_t setup_mode_last_log_print_
void on_shutdown() override
bool iir_filter_enabled_() const
Is the IIR filter enabled?
std::vector< ESP32TouchBinarySensor * > children_
void dump_config() override
uint32_t IRAM_ATTR HOT millis()
ESP32TouchBinarySensor(touch_pad_t touch_pad, uint16_t threshold, uint16_t wakeup_threshold)
touch_volt_atten_t voltage_attenuation_
Application App
Global storage of Application pointer - only one Application can exist.
touch_high_volt_t high_voltage_reference_
touch_low_volt_t low_voltage_reference_