@@ -58,23 +58,31 @@ void UITask::begin(DisplayDriver* display, NodePrefs* node_prefs) {
5858 buzzer.begin ();
5959#endif
6060
61- // Initialize button with appropriate configuration
62- #if defined(PIN_USER_BTN) || defined(PIN_USER_BTN_ANA)
63- #ifdef PIN_USER_BTN
64- _userButton = new Button (PIN_USER_BTN, USER_BTN_PRESSED);
65- #else
66- _userButton = new Button (PIN_USER_BTN_ANA, USER_BTN_PRESSED, true , 20 );
67- #endif
68-
61+ // Initialize digital button if available
62+ #ifdef PIN_USER_BTN
63+ _userButton = new Button (PIN_USER_BTN, USER_BTN_PRESSED);
6964 _userButton->begin ();
7065
71- // Set up button callbacks
66+ // Set up digital button callbacks
7267 _userButton->onShortPress ([this ]() { handleButtonShortPress (); });
7368 _userButton->onDoublePress ([this ]() { handleButtonDoublePress (); });
7469 _userButton->onTriplePress ([this ]() { handleButtonTriplePress (); });
7570 _userButton->onLongPress ([this ]() { handleButtonLongPress (); });
7671 _userButton->onAnyPress ([this ]() { handleButtonAnyPress (); });
7772#endif
73+
74+ // Initialize analog button if available
75+ #ifdef PIN_USER_BTN_ANA
76+ _userButtonAnalog = new Button (PIN_USER_BTN_ANA, USER_BTN_PRESSED, true , 20 );
77+ _userButtonAnalog->begin ();
78+
79+ // Set up analog button callbacks
80+ _userButtonAnalog->onShortPress ([this ]() { handleButtonShortPress (); });
81+ _userButtonAnalog->onDoublePress ([this ]() { handleButtonDoublePress (); });
82+ _userButtonAnalog->onTriplePress ([this ]() { handleButtonTriplePress (); });
83+ _userButtonAnalog->onLongPress ([this ]() { handleButtonLongPress (); });
84+ _userButtonAnalog->onAnyPress ([this ]() { handleButtonAnyPress (); });
85+ #endif
7886 ui_started_at = millis ();
7987}
8088
@@ -289,11 +297,16 @@ void UITask::shutdown(bool restart){
289297}
290298
291299void UITask::loop () {
292- #if defined( PIN_USER_BTN) || defined(PIN_USER_BTN_ANA)
300+ #ifdef PIN_USER_BTN
293301 if (_userButton) {
294302 _userButton->update ();
295303 }
296304 #endif
305+ #ifdef PIN_USER_BTN_ANA
306+ if (_userButtonAnalog) {
307+ _userButtonAnalog->update ();
308+ }
309+ #endif
297310 userLedHandler ();
298311
299312#ifdef PIN_BUZZER
0 commit comments