mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	help with setup
This commit is contained in:
		| @@ -70,6 +70,7 @@ class ESP32TouchComponent : public Component { | |||||||
|   void dump_config_sensors_(); |   void dump_config_sensors_(); | ||||||
|   bool create_touch_queue(); |   bool create_touch_queue(); | ||||||
|   void cleanup_touch_queue(); |   void cleanup_touch_queue(); | ||||||
|  |   void configure_wakeup_pads(); | ||||||
|  |  | ||||||
|   // Common members |   // Common members | ||||||
|   std::vector<ESP32TouchBinarySensor *> children_; |   std::vector<ESP32TouchBinarySensor *> children_; | ||||||
|   | |||||||
| @@ -61,6 +61,30 @@ void ESP32TouchComponent::cleanup_touch_queue() { | |||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void ESP32TouchComponent::configure_wakeup_pads() { | ||||||
|  |   bool is_wakeup_source = false; | ||||||
|  |  | ||||||
|  |   // Check if any pad is configured for wakeup | ||||||
|  |   for (auto *child : this->children_) { | ||||||
|  |     if (child->get_wakeup_threshold() != 0) { | ||||||
|  |       is_wakeup_source = true; | ||||||
|  |  | ||||||
|  | #ifdef USE_ESP32_VARIANT_ESP32 | ||||||
|  |       // ESP32 v1: No filter available when using as wake-up source. | ||||||
|  |       touch_pad_config(child->get_touch_pad(), child->get_wakeup_threshold()); | ||||||
|  | #else | ||||||
|  |       // ESP32-S2/S3 v2: Set threshold for wakeup | ||||||
|  |       touch_pad_set_thresh(child->get_touch_pad(), child->get_wakeup_threshold()); | ||||||
|  | #endif | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   if (!is_wakeup_source) { | ||||||
|  |     // If no pad is configured for wakeup, deinitialize touch pad | ||||||
|  |     touch_pad_deinit(); | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
| }  // namespace esp32_touch | }  // namespace esp32_touch | ||||||
| }  // namespace esphome | }  // namespace esphome | ||||||
|  |  | ||||||
|   | |||||||
| @@ -181,29 +181,13 @@ void ESP32TouchComponent::on_shutdown() { | |||||||
|   touch_pad_isr_deregister(touch_isr_handler, this); |   touch_pad_isr_deregister(touch_isr_handler, this); | ||||||
|   this->cleanup_touch_queue(); |   this->cleanup_touch_queue(); | ||||||
|  |  | ||||||
|   bool is_wakeup_source = false; |  | ||||||
|  |  | ||||||
|   if (this->iir_filter_enabled_()) { |   if (this->iir_filter_enabled_()) { | ||||||
|     touch_pad_filter_stop(); |     touch_pad_filter_stop(); | ||||||
|     touch_pad_filter_delete(); |     touch_pad_filter_delete(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   for (auto *child : this->children_) { |   // Configure wakeup pads if any are set | ||||||
|     if (child->get_wakeup_threshold() != 0) { |   this->configure_wakeup_pads(); | ||||||
|       if (!is_wakeup_source) { |  | ||||||
|         is_wakeup_source = true; |  | ||||||
|         // Touch sensor FSM mode must be 'TOUCH_FSM_MODE_TIMER' to use it to wake-up. |  | ||||||
|         touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER); |  | ||||||
|       } |  | ||||||
|  |  | ||||||
|       // No filter available when using as wake-up source. |  | ||||||
|       touch_pad_config(child->get_touch_pad(), child->get_wakeup_threshold()); |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   if (!is_wakeup_source) { |  | ||||||
|     touch_pad_deinit(); |  | ||||||
|   } |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void IRAM_ATTR ESP32TouchComponent::touch_isr_handler(void *arg) { | void IRAM_ATTR ESP32TouchComponent::touch_isr_handler(void *arg) { | ||||||
|   | |||||||
| @@ -301,21 +301,8 @@ void ESP32TouchComponent::on_shutdown() { | |||||||
|   touch_pad_isr_deregister(touch_isr_handler, this); |   touch_pad_isr_deregister(touch_isr_handler, this); | ||||||
|   this->cleanup_touch_queue(); |   this->cleanup_touch_queue(); | ||||||
|  |  | ||||||
|   // Check if any pad is configured for wakeup |   // Configure wakeup pads if any are set | ||||||
|   bool is_wakeup_source = false; |   this->configure_wakeup_pads(); | ||||||
|   for (auto *child : this->children_) { |  | ||||||
|     if (child->get_wakeup_threshold() != 0) { |  | ||||||
|       if (!is_wakeup_source) { |  | ||||||
|         is_wakeup_source = true; |  | ||||||
|         // Touch sensor FSM mode must be 'TOUCH_FSM_MODE_TIMER' to use it to wake-up. |  | ||||||
|         touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER); |  | ||||||
|       } |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   if (!is_wakeup_source) { |  | ||||||
|     touch_pad_deinit(); |  | ||||||
|   } |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void IRAM_ATTR ESP32TouchComponent::touch_isr_handler(void *arg) { | void IRAM_ATTR ESP32TouchComponent::touch_isr_handler(void *arg) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user