Skip to content

Commit 5d989ff

Browse files
committed
Updates:
Change setup timeout to 10s Reorder switch(systemState) so it matches SystemState
1 parent 6ae1f0e commit 5d989ff

File tree

4 files changed

+95
-66
lines changed

4 files changed

+95
-66
lines changed

Firmware/RTK_Everywhere/Begin.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,7 @@ void beginSystemState()
974974
}
975975
else if (productVariant == RTK_EVK)
976976
{
977+
firstRoverStart = false; // Screen should have been tested when it was made ;-)
977978
// Return to either NTP, Base or Rover Not Started. The last state previous to power down.
978979
systemState = settings.lastState;
979980
}

Firmware/RTK_Everywhere/Display.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2473,7 +2473,11 @@ void paintDisplaySetup()
24732473
thisIsButton++;
24742474
}
24752475

2476-
if (printedButtons < maxButtons) // If we printed less than maxButtons, print more
2476+
// If we printed less than maxButtons, print more.
2477+
// This causes Base to be printed below Exit, indicating you can "go round again".
2478+
// I think that's what we want?
2479+
// If not, we could comment this and leave the display blank below Exit.
2480+
while (printedButtons < maxButtons)
24772481
{
24782482
for (auto it = setupButtons.begin(); it != setupButtons.end(); it = std::next(it))
24792483
{

Firmware/RTK_Everywhere/States.ino

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,8 @@ void stateUpdate()
401401
}
402402
break;
403403

404-
case (STATE_PROFILE): {
405-
// Do nothing - display only
406-
}
407-
break;
408-
409404
case (STATE_DISPLAY_SETUP): {
410-
if (millis() - lastSetupMenuChange > 30000) // Exit Setup after 30s
405+
if (millis() - lastSetupMenuChange > 10000) // Exit Setup after 10s
411406
{
412407
//forceSystemStateUpdate = true; // Immediately go to this new state
413408
changeState(lastSystemState); // Return to the last system state
@@ -510,6 +505,11 @@ void stateUpdate()
510505
}
511506
break;
512507

508+
case (STATE_PROFILE): {
509+
// Do nothing - display only
510+
}
511+
break;
512+
513513
case (STATE_KEYS_STARTED): {
514514
if (rtcWaitTime == 0)
515515
rtcWaitTime = millis();
@@ -673,6 +673,36 @@ void stateUpdate()
673673
}
674674
break;
675675

676+
case (STATE_KEYS_WIFI_TIMEOUT): {
677+
paintKeyWiFiFail(2000);
678+
679+
forceSystemStateUpdate = true; // Imediately go to this new state
680+
681+
if (online.rtc == true)
682+
{
683+
int daysRemaining =
684+
daysFromEpoch(settings.pointPerfectNextKeyStart + settings.pointPerfectNextKeyDuration + 1);
685+
686+
if (daysRemaining >= 0)
687+
{
688+
changeState(STATE_KEYS_DAYS_REMAINING);
689+
}
690+
else
691+
{
692+
paintKeysExpired();
693+
changeState(STATE_KEYS_LBAND_ENCRYPTED);
694+
}
695+
}
696+
else
697+
{
698+
// No WiFi. No RTC. We don't know if the keys we have are expired. Attempt to use them.
699+
changeState(STATE_KEYS_LBAND_CONFIGURE);
700+
}
701+
}
702+
break;
703+
704+
// Note: STATE_KEYS_EXPIRED should be here, but isn't. TODO: check this
705+
676706
case (STATE_KEYS_DAYS_REMAINING): {
677707
if (online.rtc == true)
678708
{
@@ -709,34 +739,6 @@ void stateUpdate()
709739
}
710740
break;
711741

712-
case (STATE_KEYS_WIFI_TIMEOUT): {
713-
paintKeyWiFiFail(2000);
714-
715-
forceSystemStateUpdate = true; // Imediately go to this new state
716-
717-
if (online.rtc == true)
718-
{
719-
int daysRemaining =
720-
daysFromEpoch(settings.pointPerfectNextKeyStart + settings.pointPerfectNextKeyDuration + 1);
721-
722-
if (daysRemaining >= 0)
723-
{
724-
changeState(STATE_KEYS_DAYS_REMAINING);
725-
}
726-
else
727-
{
728-
paintKeysExpired();
729-
changeState(STATE_KEYS_LBAND_ENCRYPTED);
730-
}
731-
}
732-
else
733-
{
734-
// No WiFi. No RTC. We don't know if the keys we have are expired. Attempt to use them.
735-
changeState(STATE_KEYS_LBAND_CONFIGURE);
736-
}
737-
}
738-
break;
739-
740742
case (STATE_KEYS_LBAND_ENCRYPTED): {
741743
// Since L-Band is not available, be sure RTCM can be provided to GNSS receiver
742744
gnssEnableRtcmOnGnss();

Firmware/RTK_Everywhere/Tasks.ino

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,50 +1381,48 @@ void buttonCheckTask(void *e)
13811381
}
13821382
else if ((systemState == STATE_BASE_NOT_STARTED) && (firstRoverStart == true) && (userBtn->pressedFor(500)))
13831383
{
1384+
lastSetupMenuChange = millis(); // Prevent a timeout during state change
13841385
forceSystemStateUpdate = true;
13851386
requestChangeState(STATE_TEST);
1386-
lastTestMenuChange = millis(); // Avoid exiting test menu for 1s
13871387
}
13881388
else if (singleTap && (firstRoverStart == false) && (settings.disableSetupButton == false))
13891389
{
13901390
switch (systemState)
13911391
{
1392-
// If we are in any running state, change to STATE_DISPLAY_SETUP and require a double tap to exit
1392+
// If we are in any running state, change to STATE_DISPLAY_SETUP
1393+
case STATE_ROVER_NOT_STARTED:
1394+
case STATE_ROVER_NO_FIX:
1395+
case STATE_ROVER_FIX:
1396+
case STATE_ROVER_RTK_FLOAT:
1397+
case STATE_ROVER_RTK_FIX:
13931398
case STATE_BASE_NOT_STARTED:
13941399
case STATE_BASE_TEMP_SETTLE:
13951400
case STATE_BASE_TEMP_SURVEY_STARTED:
13961401
case STATE_BASE_TEMP_TRANSMITTING:
13971402
case STATE_BASE_FIXED_NOT_STARTED:
13981403
case STATE_BASE_FIXED_TRANSMITTING:
1399-
case STATE_ROVER_NOT_STARTED:
1400-
case STATE_ROVER_NO_FIX:
1401-
case STATE_ROVER_FIX:
1402-
case STATE_ROVER_RTK_FLOAT:
1403-
case STATE_ROVER_RTK_FIX:
1404-
case STATE_NTPSERVER_NOT_STARTED:
1405-
case STATE_NTPSERVER_NO_SYNC:
1406-
case STATE_NTPSERVER_SYNC:
14071404
case STATE_WIFI_CONFIG_NOT_STARTED:
14081405
case STATE_WIFI_CONFIG:
1409-
case STATE_CONFIG_VIA_ETH_NOT_STARTED:
14101406
case STATE_ESPNOW_PAIRING_NOT_STARTED:
14111407
case STATE_ESPNOW_PAIRING:
1408+
case STATE_NTPSERVER_NOT_STARTED:
1409+
case STATE_NTPSERVER_NO_SYNC:
1410+
case STATE_NTPSERVER_SYNC:
1411+
case STATE_CONFIG_VIA_ETH_NOT_STARTED:
14121412
lastSystemState = systemState; // Remember this state to return if needed
14131413
requestChangeState(STATE_DISPLAY_SETUP);
14141414
lastSetupMenuChange = millis();
14151415
setupSelectedButton = 0; // Highlight the first button
14161416
break;
14171417

1418-
case STATE_CONFIG_VIA_ETH_STARTED:
1419-
case STATE_CONFIG_VIA_ETH:
1420-
// If the user presses the button during configure-via-ethernet, then do a complete restart into
1421-
// Base mode
1422-
requestChangeState(STATE_CONFIG_VIA_ETH_RESTART_BASE);
1423-
break;
1424-
1425-
case STATE_PROFILE:
1426-
// If the user presses the setup button during a profile change, do nothing
1427-
// Allow system to return to lastSystemState
1418+
case STATE_DISPLAY_SETUP:
1419+
// If we are displaying the setup menu, a single tap will cycle through possible system states
1420+
// Exit into new system state on double tap - see below
1421+
// Exit display setup into previous state after ~10s - see updateSystemState()
1422+
lastSetupMenuChange = millis();
1423+
setupSelectedButton++;
1424+
if (setupSelectedButton == setupButtons.size()) // Limit reached?
1425+
setupSelectedButton = 0;
14281426
break;
14291427

14301428
case STATE_TEST:
@@ -1433,21 +1431,43 @@ void buttonCheckTask(void *e)
14331431

14341432
case STATE_TESTING:
14351433
// If we are in testing, return to Base Not Started
1434+
lastSetupMenuChange = millis(); // Prevent a timeout during state change
14361435
requestChangeState(STATE_BASE_NOT_STARTED);
14371436
break;
14381437

1439-
case STATE_DISPLAY_SETUP:
1440-
// If we are displaying the setup menu, a single tap will cycle through possible system states
1441-
// Exit into new system state on double tap
1442-
// Exit display setup into previous state after ~30s in updateSystemState()
1443-
setupSelectedButton++;
1444-
if (setupSelectedButton == setupButtons.size()) // Limit reached?
1445-
setupSelectedButton = 0;
1438+
case STATE_PROFILE:
1439+
// If the user presses the setup button during a profile change, do nothing
1440+
// Allow system to return to lastSystemState
1441+
break;
1442+
1443+
case STATE_CONFIG_VIA_ETH_STARTED:
1444+
case STATE_CONFIG_VIA_ETH:
1445+
// If the user presses the button during configure-via-ethernet,
1446+
// do a complete restart into Base mode
1447+
lastSetupMenuChange = millis(); // Prevent a timeout during state change
1448+
requestChangeState(STATE_CONFIG_VIA_ETH_RESTART_BASE);
1449+
break;
1450+
1451+
/* These lines are commented to allow default to print the diagnostic.
1452+
case STATE_KEYS_STARTED:
1453+
case STATE_KEYS_NEEDED:
1454+
case STATE_KEYS_WIFI_STARTED:
1455+
case STATE_KEYS_WIFI_CONNECTED:
1456+
case STATE_KEYS_WIFI_TIMEOUT:
1457+
case STATE_KEYS_EXPIRED:
1458+
case STATE_KEYS_DAYS_REMAINING:
1459+
case STATE_KEYS_LBAND_CONFIGURE:
1460+
case STATE_KEYS_LBAND_ENCRYPTED:
1461+
case STATE_KEYS_PROVISION_WIFI_STARTED:
1462+
case STATE_KEYS_PROVISION_WIFI_CONNECTED:
1463+
// Abort key download?
1464+
// TODO: check this! I think we want to be able to terminate STATE_KEYS via the button?
14461465
break;
1466+
*/
14471467

14481468
default:
1449-
systemPrintf("ButtonCheckTask single tap - unknown system state: %d\r\n", systemState);
1450-
requestChangeState(STATE_BASE_NOT_STARTED);
1469+
systemPrintf("buttonCheckTask single tap - untrapped system state: %d\r\n", systemState);
1470+
//requestChangeState(STATE_BASE_NOT_STARTED);
14511471
break;
14521472
} // End singleTap switch (systemState)
14531473
} // End singleTap
@@ -1457,7 +1477,10 @@ void buttonCheckTask(void *e)
14571477
{
14581478
case STATE_DISPLAY_SETUP:
14591479
{
1480+
// If we are displaying the setup menu, a single tap will cycle through possible system states - see above
14601481
// Exit into new system state on double tap
1482+
// Exit display setup into previous state after ~10s - see updateSystemState()
1483+
lastSetupMenuChange = millis(); // Prevent a timeout during state change
14611484
uint8_t thisIsButton = 0;
14621485
for (auto it = setupButtons.begin(); it != setupButtons.end(); it = std::next(it))
14631486
{
@@ -1477,7 +1500,6 @@ void buttonCheckTask(void *e)
14771500

14781501
break;
14791502
}
1480-
14811503
thisIsButton++;
14821504
}
14831505
}

0 commit comments

Comments
 (0)