fix(GFX_Button): initialize currstate/laststate

Adafruit_GFX_Button's constructor only initializes _gfx, leaving
currstate/laststate as indeterminate memory. justPressed()/
justReleased() read these before the first press() call, so they can
report a spurious press/release transition on a button that was never
actually touched.

Fixes #401

Signed-off-by: 94xhn <87560781+94xhn@users.noreply.github.com>
This commit is contained in:
94xhn committed 2026-07-11 16:35:19 +08:00
1 parent ac6d7c3869
commit b522b1edba
1 file changed
+4 -1
+4 -1
View File
@@ -1806,7 +1806,10 @@ void Adafruit_GFX::invertDisplay(bool i) {
@brief Create a simple drawn button UI element
*/
/**************************************************************************/
Adafruit_GFX_Button::Adafruit_GFX_Button(void) { _gfx = 0; }
Adafruit_GFX_Button::Adafruit_GFX_Button(void) {
_gfx = 0;
currstate = laststate = false;
}
/**************************************************************************/
/*!