Merge branch 'dev' into dev

This commit is contained in:
geduxas 2024-03-12 22:41:27 +02:00 committed by GitHub
commit 8bd79ce5d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 7 deletions

View File

@ -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");

View File

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

View File

@ -12,9 +12,11 @@
#include <cstring>
#ifdef USE_HOST
#ifndef _WIN32
#include <net/if.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#endif
#include <unistd.h>
#endif
#if defined(USE_ESP8266)