Skip to content

Commit b693eaf

Browse files
committed
Add STATE_NOT_SET. Add default states for platforms.
1 parent 4bc5a6b commit b693eaf

File tree

3 files changed

+38
-25
lines changed

3 files changed

+38
-25
lines changed

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -905,49 +905,58 @@ void beginAccelerometer()
905905
//Depending on platform and previous power down state, set system state
906906
void beginSystemState()
907907
{
908+
if (systemState > STATE_NOT_SET)
909+
{
910+
systemPrintln("Unknown state - factory reset");
911+
factoryReset();
912+
}
913+
908914
if (productVariant == RTK_SURVEYOR)
909915
{
916+
if (settings.lastState == STATE_NOT_SET) //Default
917+
{
918+
systemState = STATE_ROVER_NOT_STARTED;
919+
settings.lastState = systemState;
920+
}
921+
910922
//If the rocker switch was moved while off, force module settings
911923
//When switch is set to '1' = BASE, pin will be shorted to ground
912924
if (settings.lastState == STATE_ROVER_NOT_STARTED && digitalRead(pin_setupButton) == LOW) settings.updateZEDSettings = true;
913925
else if (settings.lastState == STATE_BASE_NOT_STARTED && digitalRead(pin_setupButton) == HIGH) settings.updateZEDSettings = true;
914926

915-
if (online.lband == false)
916-
systemState = STATE_ROVER_NOT_STARTED; //Assume Rover. ButtonCheckTask() will correct as needed.
917-
else
918-
systemState = STATE_KEYS_STARTED; //Begin process for getting new keys
927+
systemState = STATE_ROVER_NOT_STARTED; //Assume Rover. ButtonCheckTask() will correct as needed.
919928

920929
setupBtn = new Button(pin_setupButton); //Create the button in memory
921930
}
922931
else if (productVariant == RTK_EXPRESS || productVariant == RTK_EXPRESS_PLUS)
923932
{
933+
if (settings.lastState == STATE_NOT_SET) //Default
934+
{
935+
systemState = STATE_ROVER_NOT_STARTED;
936+
settings.lastState = systemState;
937+
}
938+
924939
if (online.lband == false)
925940
systemState = settings.lastState; //Return to either Rover or Base Not Started. The last state previous to power down.
926941
else
927942
systemState = STATE_KEYS_STARTED; //Begin process for getting new keys
928943

929-
if (systemState > STATE_SHUTDOWN)
930-
{
931-
systemPrintln("Unknown state - factory reset");
932-
factoryReset();
933-
}
934-
935944
setupBtn = new Button(pin_setupButton); //Create the button in memory
936945
powerBtn = new Button(pin_powerSenseAndControl); //Create the button in memory
937946
}
938947
else if (productVariant == RTK_FACET || productVariant == RTK_FACET_LBAND)
939948
{
949+
if (settings.lastState == STATE_NOT_SET) //Default
950+
{
951+
systemState = STATE_ROVER_NOT_STARTED;
952+
settings.lastState = systemState;
953+
}
954+
940955
if (online.lband == false)
941956
systemState = settings.lastState; //Return to either Rover or Base Not Started. The last state previous to power down.
942957
else
943958
systemState = STATE_KEYS_STARTED; //Begin process for getting new keys
944959

945-
if (systemState > STATE_SHUTDOWN)
946-
{
947-
systemPrintln("Unknown state - factory reset");
948-
factoryReset();
949-
}
950-
951960
firstRoverStart = true; //Allow user to enter test screen during first rover start
952961
if (systemState == STATE_BASE_NOT_STARTED)
953962
firstRoverStart = false;
@@ -956,14 +965,14 @@ void beginSystemState()
956965
}
957966
else if (productVariant == REFERENCE_STATION)
958967
{
959-
systemState = settings.lastState; //Return to either NTP, Base or Rover Not Started. The last state previous to power down.
960-
961-
if (systemState > STATE_SHUTDOWN)
968+
if (settings.lastState == STATE_NOT_SET) //Default
962969
{
963-
systemPrintln("Unknown state - factory reset");
964-
factoryReset();
970+
systemState = STATE_BASE_NOT_STARTED;
971+
settings.lastState = systemState;
965972
}
966973

974+
systemState = settings.lastState; //Return to either NTP, Base or Rover Not Started. The last state previous to power down.
975+
967976
setupBtn = new Button(pin_setupButton); //Create the button in memory
968977
}
969978

Firmware/RTK_Surveyor/States.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,9 @@ void changeState(SystemState newState)
13011301
case (STATE_SHUTDOWN):
13021302
systemPrint("State: Shut Down");
13031303
break;
1304+
case (STATE_NOT_SET):
1305+
systemPrint("State: Not Set");
1306+
break;
13041307
default:
13051308
systemPrintf("Change State Unknown: %d", systemState);
13061309
break;

Firmware/RTK_Surveyor/settings.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ typedef enum
4343
STATE_CONFIG_VIA_ETH,
4444
STATE_CONFIG_VIA_ETH_RESTART_BASE,
4545
STATE_SHUTDOWN,
46+
STATE_NOT_SET, //Must be last on list
4647
} SystemState;
47-
volatile SystemState systemState = STATE_ROVER_NOT_STARTED;
48-
SystemState lastSystemState = STATE_ROVER_NOT_STARTED;
49-
SystemState requestedSystemState = STATE_ROVER_NOT_STARTED;
48+
volatile SystemState systemState = STATE_NOT_SET;
49+
SystemState lastSystemState = STATE_NOT_SET;
50+
SystemState requestedSystemState = STATE_NOT_SET;
5051
bool newSystemStateRequested = false;
5152

5253
//The setup display can show a limited set of states
@@ -671,7 +672,7 @@ typedef struct {
671672
uint16_t sppRxQueueSize = 2048;
672673
uint16_t sppTxQueueSize = 512;
673674
uint8_t dynamicModel = DYN_MODEL_PORTABLE;
674-
SystemState lastState = STATE_ROVER_NOT_STARTED; //For Express, start unit in last known state
675+
SystemState lastState = STATE_NOT_SET; //Start unit in last known state
675676
bool enableSensorFusion = false; //If IMU is available, avoid using it unless user specifically selects automotive
676677
bool autoIMUmountAlignment = true; //Allows unit to automatically establish device orientation in vehicle
677678
bool enableResetDisplay = false;

0 commit comments

Comments
 (0)