mirror of
https://github.com/esphome/esphome.git
synced 2025-09-17 10:42:21 +01:00
adjust
This commit is contained in:
@@ -69,6 +69,10 @@ class ESP32TouchComponent : public Component {
|
|||||||
protected:
|
protected:
|
||||||
static void touch_isr_handler(void *arg);
|
static void touch_isr_handler(void *arg);
|
||||||
|
|
||||||
|
// Common helper methods used by both v1 and v2
|
||||||
|
void dump_config_base_();
|
||||||
|
void dump_config_sensors_();
|
||||||
|
|
||||||
QueueHandle_t touch_queue_{nullptr};
|
QueueHandle_t touch_queue_{nullptr};
|
||||||
uint32_t last_touch_time_[TOUCH_PAD_MAX] = {0}; // Track last time each pad was seen as touched
|
uint32_t last_touch_time_[TOUCH_PAD_MAX] = {0}; // Track last time each pad was seen as touched
|
||||||
uint32_t release_timeout_ms_{1500}; // Calculated timeout for release detection
|
uint32_t release_timeout_ms_{1500}; // Calculated timeout for release detection
|
||||||
|
42
esphome/components/esp32_touch/esp32_touch_common.cpp
Normal file
42
esphome/components/esp32_touch/esp32_touch_common.cpp
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#ifdef USE_ESP32
|
||||||
|
|
||||||
|
#include "esp32_touch.h"
|
||||||
|
#include "esphome/core/log.h"
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace esp32_touch {
|
||||||
|
|
||||||
|
static const char *const TAG = "esp32_touch";
|
||||||
|
|
||||||
|
void ESP32TouchComponent::dump_config_base_() {
|
||||||
|
const char *lv_s = get_low_voltage_reference_str(this->low_voltage_reference_);
|
||||||
|
const char *hv_s = get_high_voltage_reference_str(this->high_voltage_reference_);
|
||||||
|
const char *atten_s = get_voltage_attenuation_str(this->voltage_attenuation_);
|
||||||
|
|
||||||
|
ESP_LOGCONFIG(TAG,
|
||||||
|
"Config for ESP32 Touch Hub:\n"
|
||||||
|
" Meas cycle: %.2fms\n"
|
||||||
|
" Sleep cycle: %.2fms\n"
|
||||||
|
" Low Voltage Reference: %s\n"
|
||||||
|
" High Voltage Reference: %s\n"
|
||||||
|
" Voltage Attenuation: %s\n"
|
||||||
|
" ISR Configuration:\n"
|
||||||
|
" Release timeout: %" PRIu32 "ms\n"
|
||||||
|
" Release check interval: %" PRIu32 "ms",
|
||||||
|
this->meas_cycle_ / (8000000.0f / 1000.0f), this->sleep_cycle_ / (150000.0f / 1000.0f), lv_s, hv_s,
|
||||||
|
atten_s, this->release_timeout_ms_, this->release_check_interval_ms_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ESP32TouchComponent::dump_config_sensors_() {
|
||||||
|
for (auto *child : this->children_) {
|
||||||
|
LOG_BINARY_SENSOR(" ", "Touch Pad", child);
|
||||||
|
ESP_LOGCONFIG(TAG, " Pad: T%" PRIu32, (uint32_t) child->get_touch_pad());
|
||||||
|
ESP_LOGCONFIG(TAG, " Threshold: %" PRIu32, child->get_threshold());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace esp32_touch
|
||||||
|
} // namespace esphome
|
||||||
|
|
||||||
|
#endif // USE_ESP32
|
@@ -78,22 +78,7 @@ void ESP32TouchComponent::setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ESP32TouchComponent::dump_config() {
|
void ESP32TouchComponent::dump_config() {
|
||||||
const char *lv_s = get_low_voltage_reference_str(this->low_voltage_reference_);
|
this->dump_config_base_();
|
||||||
const char *hv_s = get_high_voltage_reference_str(this->high_voltage_reference_);
|
|
||||||
const char *atten_s = get_voltage_attenuation_str(this->voltage_attenuation_);
|
|
||||||
|
|
||||||
ESP_LOGCONFIG(TAG,
|
|
||||||
"Config for ESP32 Touch Hub:\n"
|
|
||||||
" Meas cycle: %.2fms\n"
|
|
||||||
" Sleep cycle: %.2fms\n"
|
|
||||||
" Low Voltage Reference: %s\n"
|
|
||||||
" High Voltage Reference: %s\n"
|
|
||||||
" Voltage Attenuation: %s\n"
|
|
||||||
" ISR Configuration:\n"
|
|
||||||
" Release timeout: %" PRIu32 "ms\n"
|
|
||||||
" Release check interval: %" PRIu32 "ms",
|
|
||||||
this->meas_cycle_ / (8000000.0f / 1000.0f), this->sleep_cycle_ / (150000.0f / 1000.0f), lv_s, hv_s,
|
|
||||||
atten_s, this->release_timeout_ms_, this->release_check_interval_ms_);
|
|
||||||
|
|
||||||
if (this->iir_filter_enabled_()) {
|
if (this->iir_filter_enabled_()) {
|
||||||
ESP_LOGCONFIG(TAG, " IIR Filter: %" PRIu32 "ms", this->iir_filter_);
|
ESP_LOGCONFIG(TAG, " IIR Filter: %" PRIu32 "ms", this->iir_filter_);
|
||||||
@@ -105,11 +90,7 @@ void ESP32TouchComponent::dump_config() {
|
|||||||
ESP_LOGCONFIG(TAG, " Setup Mode ENABLED");
|
ESP_LOGCONFIG(TAG, " Setup Mode ENABLED");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto *child : this->children_) {
|
this->dump_config_sensors_();
|
||||||
LOG_BINARY_SENSOR(" ", "Touch Pad", child);
|
|
||||||
ESP_LOGCONFIG(TAG, " Pad: T%" PRIu32, (uint32_t) child->get_touch_pad());
|
|
||||||
ESP_LOGCONFIG(TAG, " Threshold: %" PRIu32, child->get_threshold());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ESP32TouchComponent::loop() {
|
void ESP32TouchComponent::loop() {
|
||||||
|
@@ -123,22 +123,7 @@ void ESP32TouchComponent::setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ESP32TouchComponent::dump_config() {
|
void ESP32TouchComponent::dump_config() {
|
||||||
const char *lv_s = get_low_voltage_reference_str(this->low_voltage_reference_);
|
this->dump_config_base_();
|
||||||
const char *hv_s = get_high_voltage_reference_str(this->high_voltage_reference_);
|
|
||||||
const char *atten_s = get_voltage_attenuation_str(this->voltage_attenuation_);
|
|
||||||
|
|
||||||
ESP_LOGCONFIG(TAG,
|
|
||||||
"Config for ESP32 Touch Hub:\n"
|
|
||||||
" Meas cycle: %.2fms\n"
|
|
||||||
" Sleep cycle: %.2fms\n"
|
|
||||||
" Low Voltage Reference: %s\n"
|
|
||||||
" High Voltage Reference: %s\n"
|
|
||||||
" Voltage Attenuation: %s\n"
|
|
||||||
" ISR Configuration:\n"
|
|
||||||
" Release timeout: %" PRIu32 "ms\n"
|
|
||||||
" Release check interval: %" PRIu32 "ms",
|
|
||||||
this->meas_cycle_ / (8000000.0f / 1000.0f), this->sleep_cycle_ / (150000.0f / 1000.0f), lv_s, hv_s,
|
|
||||||
atten_s, this->release_timeout_ms_, this->release_check_interval_ms_);
|
|
||||||
|
|
||||||
if (this->filter_configured_()) {
|
if (this->filter_configured_()) {
|
||||||
const char *filter_mode_s;
|
const char *filter_mode_s;
|
||||||
@@ -256,11 +241,7 @@ void ESP32TouchComponent::dump_config() {
|
|||||||
ESP_LOGCONFIG(TAG, " Setup Mode ENABLED");
|
ESP_LOGCONFIG(TAG, " Setup Mode ENABLED");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto *child : this->children_) {
|
this->dump_config_sensors_();
|
||||||
LOG_BINARY_SENSOR(" ", "Touch Pad", child);
|
|
||||||
ESP_LOGCONFIG(TAG, " Pad: T%" PRIu32, (uint32_t) child->get_touch_pad());
|
|
||||||
ESP_LOGCONFIG(TAG, " Threshold: %" PRIu32, child->get_threshold());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ESP32TouchComponent::loop() {
|
void ESP32TouchComponent::loop() {
|
||||||
|
Reference in New Issue
Block a user