Keep a slider's value when you let go, and stop needless full resends (0.2.55)
A light's colour slider on Studio 1 sometimes sent red on release. Measured live: an automation with a state trigger on a six-lamp group (no `to:`) set "Standby after" to its current value after every colour change. The screen reported the setting, ESP Screen Manager saved the layout and resent layout, header and every tile state, and the screen drew its whole page again, reading no touch input meanwhile. The GT911's stray (0, 0) contact then became the finger's last position, and LVGL 9.5 set the slider from it on release. Both red commits left 75-85 ms after such a resync. The app no longer saves or resends a setting event whose value the layout already has. The four setting numbers return before the preference write and the event when nothing changed. A layout message that changes nothing on the screen no longer runs layout_changed() and refresh_all(); the tile states after it redraw their own tiles. The Guition wraps the LVGL touch read callback with cyd::GhostTouch, which repeats the previous read for a pressed (0, 0), and the edge swipe skips that sample too. Both slider handlers log a jump to an end on release. Checked with 214 Python and 14 C++ tests, generate_packages --check, and ESP32 builds of both Easy profiles. Firmware 0.2.47. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -183,4 +183,37 @@ class EdgeSwipe {
|
||||
bool done_{true};
|
||||
};
|
||||
inline EdgeSwipe edge_swipe;
|
||||
|
||||
// The GT911 (Guition) now and then reports a contact at exactly (0, 0), mostly as the last
|
||||
// sample before the finger lifts. LVGL takes the last pressed sample as the finger's position
|
||||
// on release, so a slider jumped to its end and sent that value (a colour turning red). The
|
||||
// corner pixel is never a real touch: such a sample repeats the read before it instead.
|
||||
struct PointerRead {
|
||||
bool pressed;
|
||||
int x, y;
|
||||
};
|
||||
class GhostTouch {
|
||||
public:
|
||||
// `ghost_x`, `ghost_y`: where the native (0, 0) lands after the display rotation.
|
||||
PointerRead filter(PointerRead read, int ghost_x, int ghost_y) {
|
||||
if (read.pressed && read.x == ghost_x && read.y == ghost_y) {
|
||||
++dropped_;
|
||||
return last_;
|
||||
}
|
||||
last_ = read;
|
||||
return read;
|
||||
}
|
||||
unsigned dropped() const { return dropped_; }
|
||||
private:
|
||||
PointerRead last_{false, 0, 0};
|
||||
unsigned dropped_{0};
|
||||
};
|
||||
inline GhostTouch ghost_touch;
|
||||
|
||||
// A dragged slider that LVGL moved to one of its ends on release, far from where the finger held
|
||||
// it: the touch panel reported a stray point. Worth a log line, the finger was never there.
|
||||
inline bool release_jump(int held, int released, int minimum, int maximum) {
|
||||
const bool at_end = released <= minimum || released >= maximum;
|
||||
return at_end && std::abs(released - held) * 4 > maximum - minimum;
|
||||
}
|
||||
} // namespace cyd
|
||||
|
||||
Reference in New Issue
Block a user