Skip to content

Commit fe66c9b

Browse files
committed
Rework menu system to avoid false button presses
Fixes the accelerated painting of the screen.
1 parent 8ddde69 commit fe66c9b

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

Firmware/RTK_Everywhere/RTK_Everywhere.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ const uint8_t buttonCheckTaskPriority = 1; // 3 being the highest, and 0 being t
541541
const int buttonTaskStackSize = 2000;
542542

543543
const int shutDownButtonTime = 2000; // ms press and hold before shutdown
544+
bool firstButtonThrownOut = false;
544545
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
545546

546547
// Webserver for serving config page from ESP32 as Acess Point

Firmware/RTK_Everywhere/States.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ void stateUpdate()
389389
case (STATE_DISPLAY_SETUP): {
390390
if (millis() - lastSetupMenuChange > 10000) // Exit Setup after 10s
391391
{
392-
// forceSystemStateUpdate = true; // Immediately go to this new state
392+
firstButtonThrownOut = false;
393393
changeState(lastSystemState); // Return to the last system state
394394
}
395395
}

Firmware/RTK_Everywhere/Tasks.ino

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,25 +1575,29 @@ void buttonCheckTask(void *e)
15751575
if ((previousButtonRelease > 0) && (thisButtonRelease > 0) &&
15761576
((thisButtonRelease - previousButtonRelease) <= doubleTapInterval)) // Do we have a double tap?
15771577
{
1578-
doubleTap = true;
1579-
singleTap = false;
1580-
previousButtonRelease = 0;
1581-
thisButtonRelease = 0;
1578+
// Do not register button taps until the system is displaying the menu
1579+
if (systemState == STATE_DISPLAY_SETUP)
1580+
{
1581+
doubleTap = true;
1582+
singleTap = false;
1583+
previousButtonRelease = 0;
1584+
thisButtonRelease = 0;
1585+
}
15821586
}
15831587
else if ((thisButtonRelease > 0) &&
15841588
((millis() - thisButtonRelease) > doubleTapInterval)) // Do we have a single tap?
15851589
{
1586-
// Discard the first button press as it was used to display the menu
1587-
if (showMenu == true)
1588-
{
1589-
showMenu = false;
1590-
}
1591-
else
1590+
// Do not register button taps until the system is displaying the menu
1591+
if (systemState == STATE_DISPLAY_SETUP)
15921592
{
1593-
doubleTap = false;
1594-
singleTap = true;
15951593
previousButtonRelease = 0;
15961594
thisButtonRelease = 0;
1595+
doubleTap = false;
1596+
1597+
if (firstButtonThrownOut == false)
1598+
firstButtonThrownOut = true; // Throw away the first button press
1599+
else
1600+
singleTap = true;
15971601
}
15981602
}
15991603

@@ -1750,8 +1754,8 @@ void buttonCheckTask(void *e)
17501754
lastSystemState = systemState; // Remember this state to return if needed
17511755
requestChangeState(STATE_DISPLAY_SETUP);
17521756
lastSetupMenuChange = millis();
1753-
setupSelectedButton = 0; // Highlight the first button
1754-
forceDisplayUpdate = true; // User is interacting so repaint display quickly
1757+
setupSelectedButton = 0; // Highlight the first button
1758+
showMenu = false;
17551759
break;
17561760

17571761
case STATE_DISPLAY_SETUP:
@@ -1838,7 +1842,10 @@ void buttonCheckTask(void *e)
18381842
requestChangeState(STATE_PROFILE);
18391843
}
18401844
else if (it->newState == STATE_NOT_SET) // Exit
1845+
{
1846+
firstButtonThrownOut = false;
18411847
requestChangeState(lastSystemState);
1848+
}
18421849
else
18431850
requestChangeState(it->newState);
18441851

0 commit comments

Comments
 (0)