mirror of
https://github.com/esphome/esphome.git
synced 2024-12-03 13:34:01 +01:00
touchscreen driver fixes (#6356)
This commit is contained in:
parent
f5b02056b9
commit
f264151537
@ -71,7 +71,7 @@ class FT5x06Touchscreen : public touchscreen::Touchscreen, public i2c::I2CDevice
|
||||
this->x_raw_max_ = this->display_->get_native_width();
|
||||
}
|
||||
if (this->y_raw_max_ == this->y_raw_min_) {
|
||||
this->x_raw_max_ = this->display_->get_native_height();
|
||||
this->y_raw_max_ = this->display_->get_native_height();
|
||||
}
|
||||
}
|
||||
esph_log_config(TAG, "FT5x06 Touchscreen setup complete");
|
||||
|
@ -39,7 +39,6 @@ void Touchscreen::loop() {
|
||||
ESP_LOGVV(TAG, "<< Do Touch loop >>");
|
||||
this->first_touch_ = this->touches_.empty();
|
||||
this->need_update_ = false;
|
||||
this->was_touched_ = this->is_touched_;
|
||||
this->is_touched_ = false;
|
||||
this->skip_update_ = false;
|
||||
for (auto &tp : this->touches_) {
|
||||
@ -62,7 +61,11 @@ void Touchscreen::loop() {
|
||||
if (this->touch_timeout_ > 0) {
|
||||
// Simulate a touch after <this->touch_timeout_> ms. This will reset any existing timeout operation.
|
||||
// This is to detect touch release.
|
||||
this->set_timeout(TAG, this->touch_timeout_, [this]() { this->store_.touched = true; });
|
||||
if (this->is_touched_) {
|
||||
this->set_timeout(TAG, this->touch_timeout_, [this]() { this->store_.touched = true; });
|
||||
} else {
|
||||
this->cancel_timeout(TAG);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -111,6 +114,7 @@ void Touchscreen::add_raw_touch_position_(uint8_t id, int16_t x_raw, int16_t y_r
|
||||
|
||||
void Touchscreen::send_touches_() {
|
||||
TouchPoints_t touches;
|
||||
ESP_LOGV(TAG, "Touch status: is_touched=%d, was_touched=%d", this->is_touched_, this->was_touched_);
|
||||
for (auto tp : this->touches_) {
|
||||
ESP_LOGV(TAG, "Touch status: %d/%d: raw:(%4d,%4d,%4d) calc:(%3d,%4d)", tp.second.id, tp.second.state,
|
||||
tp.second.x_raw, tp.second.y_raw, tp.second.z_raw, tp.second.x, tp.second.y);
|
||||
@ -124,14 +128,10 @@ void Touchscreen::send_touches_() {
|
||||
}
|
||||
if (!this->is_touched_) {
|
||||
if (this->was_touched_) {
|
||||
if (this->touch_timeout_ > 0) {
|
||||
this->cancel_timeout(TAG);
|
||||
}
|
||||
this->release_trigger_.trigger();
|
||||
for (auto *listener : this->touch_listeners_)
|
||||
listener->release();
|
||||
this->touches_.clear();
|
||||
this->was_touched_ = false;
|
||||
}
|
||||
} else {
|
||||
if (this->first_touch_) {
|
||||
@ -142,6 +142,7 @@ void Touchscreen::send_touches_() {
|
||||
}
|
||||
}
|
||||
}
|
||||
this->was_touched_ = this->is_touched_;
|
||||
}
|
||||
|
||||
int16_t Touchscreen::normalize_(int16_t val, int16_t min_val, int16_t max_val, bool inverted) {
|
||||
|
Loading…
Reference in New Issue
Block a user