@@ -59,24 +59,33 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
5959 buzzer.begin ();
6060#endif
6161
62- // Initialize button with appropriate configuration
63- #if defined(PIN_USER_BTN) || defined(PIN_USER_BTN_ANA)
64- #ifdef PIN_USER_BTN
65- _userButton = new Button (PIN_USER_BTN, USER_BTN_PRESSED);
66- #else
67- _userButton = new Button (PIN_USER_BTN_ANA, USER_BTN_PRESSED, true , 20 );
68- #endif
69-
62+ // Initialize digital button if available
63+ #ifdef PIN_USER_BTN
64+ _userButton = new Button (PIN_USER_BTN, USER_BTN_PRESSED);
7065 _userButton->begin ();
7166
72- // Set up button callbacks
67+ // Set up digital button callbacks
7368 _userButton->onShortPress ([this ]() { handleButtonShortPress (); });
7469 _userButton->onDoublePress ([this ]() { handleButtonDoublePress (); });
7570 _userButton->onTriplePress ([this ]() { handleButtonTriplePress (); });
7671 _userButton->onQuadruplePress ([this ]() { handleButtonQuadruplePress (); });
7772 _userButton->onLongPress ([this ]() { handleButtonLongPress (); });
7873 _userButton->onAnyPress ([this ]() { handleButtonAnyPress (); });
7974#endif
75+
76+ // Initialize analog button if available
77+ #ifdef PIN_USER_BTN_ANA
78+ _userButtonAnalog = new Button (PIN_USER_BTN_ANA, USER_BTN_PRESSED, true , 20 );
79+ _userButtonAnalog->begin ();
80+
81+ // Set up analog button callbacks
82+ _userButtonAnalog->onShortPress ([this ]() { handleButtonShortPress (); });
83+ _userButtonAnalog->onDoublePress ([this ]() { handleButtonDoublePress (); });
84+ _userButtonAnalog->onTriplePress ([this ]() { handleButtonTriplePress (); });
85+ _userButtonAnalog->onQuadruplePress ([this ]() { handleButtonQuadruplePress (); });
86+ _userButtonAnalog->onLongPress ([this ]() { handleButtonLongPress (); });
87+ _userButtonAnalog->onAnyPress ([this ]() { handleButtonAnyPress (); });
88+ #endif
8089 ui_started_at = millis ();
8190}
8291
@@ -291,11 +300,16 @@ void UITask::shutdown(bool restart){
291300}
292301
293302void UITask::loop () {
294- #if defined( PIN_USER_BTN) || defined(PIN_USER_BTN_ANA)
303+ #ifdef PIN_USER_BTN
295304 if (_userButton) {
296305 _userButton->update ();
297306 }
298307 #endif
308+ #ifdef PIN_USER_BTN_ANA
309+ if (_userButtonAnalog) {
310+ _userButtonAnalog->update ();
311+ }
312+ #endif
299313 userLedHandler ();
300314
301315#ifdef PIN_BUZZER
0 commit comments