From b33d398fd15234646fda1d78349a99ade78a73bc Mon Sep 17 00:00:00 2001 From: SGE Date: Mon, 1 Apr 2024 21:14:39 +0200 Subject: [PATCH 1/5] no conversion to resolution --- esphome/components/touchscreen/touchscreen.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/esphome/components/touchscreen/touchscreen.cpp b/esphome/components/touchscreen/touchscreen.cpp index 21b9122be5..30b2c13643 100644 --- a/esphome/components/touchscreen/touchscreen.cpp +++ b/esphome/components/touchscreen/touchscreen.cpp @@ -97,6 +97,9 @@ void Touchscreen::add_raw_touch_position_(uint8_t id, int16_t x_raw, int16_t y_r if (this->conversion_to_resolution_) { tp.x = (uint16_t) ((int) x * this->display_width_ / 0x1000); tp.y = (uint16_t) ((int) y * this->display_height_ / 0x1000); + } else { + tp.x = (uint16_t) (int) x; + tp.y = (uint16_t) (int) y; } } else { tp.state |= STATE_CALIBRATE; From e16831df583ca974ed54f77271d0fb52ed71848b Mon Sep 17 00:00:00 2001 From: SGE Date: Mon, 1 Apr 2024 21:24:40 +0200 Subject: [PATCH 2/5] set max for x/y coordinates --- esphome/components/icnt86/icnt86.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esphome/components/icnt86/icnt86.cpp b/esphome/components/icnt86/icnt86.cpp index 9653b338df..bceaf3c020 100644 --- a/esphome/components/icnt86/icnt86.cpp +++ b/esphome/components/icnt86/icnt86.cpp @@ -23,6 +23,10 @@ void ICNT86Touchscreen::setup() { this->reset_pin_->setup(); this->reset_(); } + + this->x_raw_max_ = this->display_->get_native_width(); + this->y_raw_max_ = this->display_->get_native_height(); + this->conversion_to_resolution_ = false; // Trigger initial read to activate the interrupt this->store_.touched = true; From 9f5761fc35fa39f430dc1da15d9f924d76fe23f8 Mon Sep 17 00:00:00 2001 From: SGE Date: Mon, 1 Apr 2024 21:40:54 +0200 Subject: [PATCH 3/5] dub triggering --- esphome/components/touchscreen/touchscreen.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esphome/components/touchscreen/touchscreen.cpp b/esphome/components/touchscreen/touchscreen.cpp index 30b2c13643..64e9d2e941 100644 --- a/esphome/components/touchscreen/touchscreen.cpp +++ b/esphome/components/touchscreen/touchscreen.cpp @@ -109,11 +109,12 @@ void Touchscreen::add_raw_touch_position_(uint8_t id, int16_t x_raw, int16_t y_r tp.y_org = tp.y; } - ESP_LOGD(TAG, "Touch info, x_raw: %d, y_raw: %d, p: %d, x: %d, y: %d", x_raw, y_raw, z_raw, tp.x, tp.y); + ESP_LOGD(TAG, "Touch info, x_raw: %d, y_raw: %d, p: %d, x: %d, y: %d, x_prev: %d, y_prev: %d", x_raw, y_raw, z_raw, tp.x, tp.y,tp.x_prev, tp.y_prev ); this->touches_[id] = tp; this->is_touched_ = true; + if ((tp.x != tp.x_prev) || (tp.y != tp.y_prev)) { this->need_update_ = true; } From 194f0168b2607f3a7bffc77a24fe32719c49e93f Mon Sep 17 00:00:00 2001 From: SGE Date: Mon, 1 Apr 2024 21:49:05 +0200 Subject: [PATCH 4/5] formatting --- esphome/components/icnt86/icnt86.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/esphome/components/icnt86/icnt86.h b/esphome/components/icnt86/icnt86.h index bcb134c437..65bb0b54f5 100644 --- a/esphome/components/icnt86/icnt86.h +++ b/esphome/components/icnt86/icnt86.h @@ -23,10 +23,10 @@ class ICNT86Touchscreen : public touchscreen::Touchscreen, public i2c::I2CDevice protected: void update_touches() override; void reset_(); - void i2c_read_byte_(UWORD reg, char const *Data, UBYTE len); - void icnt_read_(UWORD reg, char const *Data, UBYTE len); - void icnt_write_(UWORD reg, char const *Data, UBYTE len); - void i2c_write_byte_(UWORD reg, char const *Data, UBYTE len); + void i2c_read_byte_(UWORD reg, char const *Data, UBYTE len); + void icnt_read_(UWORD reg, char const *Data, UBYTE len); + void icnt_write_(UWORD reg, char const *Data, UBYTE len); + void i2c_write_byte_(UWORD reg, char const *Data, UBYTE len); void reset_touch_sensor_(); InternalGPIOPin *interrupt_pin_{}; GPIOPin *reset_pin_{nullptr}; From 9e3a4333f419b1ff0452878c17ca53d79ec7196b Mon Sep 17 00:00:00 2001 From: SGE Date: Tue, 2 Apr 2024 09:55:34 +0200 Subject: [PATCH 5/5] set time out for release --- esphome/components/icnt86/icnt86.cpp | 6 +++--- esphome/components/icnt86/touchscreen.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/esphome/components/icnt86/icnt86.cpp b/esphome/components/icnt86/icnt86.cpp index bceaf3c020..7b083a1e47 100644 --- a/esphome/components/icnt86/icnt86.cpp +++ b/esphome/components/icnt86/icnt86.cpp @@ -53,9 +53,9 @@ void ICNT86Touchscreen::update_touches() { UWORD y = ((UWORD) buf[4 + 7 * i] << 8) + buf[3 + 7 * i]; UWORD p = buf[5 + 7 * i]; UWORD touch_evenid = buf[6 + 7 * i]; - ESP_LOGD(TAG, "Touch x: %d, y: %d, p: %d", x, y, p); - - this->add_raw_touch_position_(touch_evenid, x, y, p); + if (this->touches_.count(touch_evenid) == 0 || (x != this->touches_[touch_evenid].x_prev && y != this->touches_[touch_evenid].y_prev)) { + this->add_raw_touch_position_(touch_evenid, x, y, p); + } } } } diff --git a/esphome/components/icnt86/touchscreen.py b/esphome/components/icnt86/touchscreen.py index 0bce74707e..bb686c3ec7 100644 --- a/esphome/components/icnt86/touchscreen.py +++ b/esphome/components/icnt86/touchscreen.py @@ -20,7 +20,7 @@ ICNT86Touchscreen = icnt86_ns.class_( CONF_ICNT86_ID = "icnt86_id" CONF_RTS_PIN = "rts_pin" -CONFIG_SCHEMA = touchscreen.TOUCHSCREEN_SCHEMA.extend( +CONFIG_SCHEMA = touchscreen.touchscreen_schema('250ms').extend( cv.Schema( { cv.GenerateID(): cv.declare_id(ICNT86Touchscreen),