mirror of
https://github.com/esphome/esphome.git
synced 2025-09-21 12:42:21 +01:00
help with setup
This commit is contained in:
@@ -92,6 +92,16 @@ class ESP32TouchComponent : public Component {
|
|||||||
static void touch_isr_handler(void *arg);
|
static void touch_isr_handler(void *arg);
|
||||||
QueueHandle_t touch_queue_{nullptr};
|
QueueHandle_t touch_queue_{nullptr};
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Touch event structure for ESP32 v1
|
||||||
|
// Contains touch pad info, value, and touch state for queue communication
|
||||||
|
struct TouchPadEventV1 {
|
||||||
|
touch_pad_t pad;
|
||||||
|
uint32_t value;
|
||||||
|
bool is_touched;
|
||||||
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
// Design note: last_touch_time_ does not require synchronization primitives because:
|
// Design note: last_touch_time_ does not require synchronization primitives because:
|
||||||
// 1. ESP32 guarantees atomic 32-bit aligned reads/writes
|
// 1. ESP32 guarantees atomic 32-bit aligned reads/writes
|
||||||
// 2. ISR only writes timestamps, main loop only reads (except sentinel value 1)
|
// 2. ISR only writes timestamps, main loop only reads (except sentinel value 1)
|
||||||
@@ -110,6 +120,15 @@ class ESP32TouchComponent : public Component {
|
|||||||
static void touch_isr_handler(void *arg);
|
static void touch_isr_handler(void *arg);
|
||||||
QueueHandle_t touch_queue_{nullptr};
|
QueueHandle_t touch_queue_{nullptr};
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Touch event structure for ESP32 v2 (S2/S3)
|
||||||
|
// Contains touch pad and interrupt mask for queue communication
|
||||||
|
struct TouchPadEventV2 {
|
||||||
|
touch_pad_t pad;
|
||||||
|
uint32_t intr_mask;
|
||||||
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
// Filter configuration
|
// Filter configuration
|
||||||
touch_filter_mode_t filter_mode_{TOUCH_PAD_FILTER_MAX};
|
touch_filter_mode_t filter_mode_{TOUCH_PAD_FILTER_MAX};
|
||||||
uint32_t debounce_count_{0};
|
uint32_t debounce_count_{0};
|
||||||
|
@@ -9,20 +9,6 @@ namespace esp32_touch {
|
|||||||
|
|
||||||
static const char *const TAG = "esp32_touch";
|
static const char *const TAG = "esp32_touch";
|
||||||
|
|
||||||
// Forward declare the event structures that are defined in the variant-specific files
|
|
||||||
#ifdef USE_ESP32_VARIANT_ESP32
|
|
||||||
struct TouchPadEventV1 {
|
|
||||||
touch_pad_t pad;
|
|
||||||
uint32_t value;
|
|
||||||
bool is_touched;
|
|
||||||
};
|
|
||||||
#else
|
|
||||||
struct TouchPadEventV2 {
|
|
||||||
touch_pad_t pad;
|
|
||||||
uint32_t intr_mask;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void ESP32TouchComponent::dump_config_base_() {
|
void ESP32TouchComponent::dump_config_base_() {
|
||||||
const char *lv_s = get_low_voltage_reference_str(this->low_voltage_reference_);
|
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 *hv_s = get_high_voltage_reference_str(this->high_voltage_reference_);
|
||||||
|
@@ -18,18 +18,7 @@ namespace esp32_touch {
|
|||||||
|
|
||||||
static const char *const TAG = "esp32_touch";
|
static const char *const TAG = "esp32_touch";
|
||||||
|
|
||||||
struct TouchPadEventV1 {
|
|
||||||
touch_pad_t pad;
|
|
||||||
uint32_t value;
|
|
||||||
bool is_touched;
|
|
||||||
};
|
|
||||||
|
|
||||||
void ESP32TouchComponent::setup() {
|
void ESP32TouchComponent::setup() {
|
||||||
ESP_LOGCONFIG(TAG, "Running setup for ESP32");
|
|
||||||
|
|
||||||
touch_pad_init();
|
|
||||||
touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER);
|
|
||||||
|
|
||||||
// Create queue for touch events
|
// Create queue for touch events
|
||||||
// Queue size calculation: children * 4 allows for burst scenarios where ISR
|
// Queue size calculation: children * 4 allows for burst scenarios where ISR
|
||||||
// fires multiple times before main loop processes. This is important because
|
// fires multiple times before main loop processes. This is important because
|
||||||
@@ -38,6 +27,9 @@ void ESP32TouchComponent::setup() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
touch_pad_init();
|
||||||
|
touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER);
|
||||||
|
|
||||||
// Set up IIR filter if enabled
|
// Set up IIR filter if enabled
|
||||||
if (this->iir_filter_enabled_()) {
|
if (this->iir_filter_enabled_()) {
|
||||||
touch_pad_filter_start(this->iir_filter_);
|
touch_pad_filter_start(this->iir_filter_);
|
||||||
|
@@ -10,11 +10,6 @@ namespace esp32_touch {
|
|||||||
|
|
||||||
static const char *const TAG = "esp32_touch";
|
static const char *const TAG = "esp32_touch";
|
||||||
|
|
||||||
struct TouchPadEventV2 {
|
|
||||||
touch_pad_t pad;
|
|
||||||
uint32_t intr_mask;
|
|
||||||
};
|
|
||||||
|
|
||||||
void ESP32TouchComponent::setup() {
|
void ESP32TouchComponent::setup() {
|
||||||
// Create queue for touch events first
|
// Create queue for touch events first
|
||||||
if (!this->create_touch_queue()) {
|
if (!this->create_touch_queue()) {
|
||||||
|
Reference in New Issue
Block a user