Merge branch 'testbranch' into dev

This commit is contained in:
SGE 2024-04-02 10:10:05 +02:00
commit 00e5df923e
4 changed files with 17 additions and 9 deletions

View file

@ -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;
@ -49,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);
}
}
}
}

View file

@ -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};

View file

@ -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),

View file

@ -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;
@ -106,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;
}