Skip to content

Commit 81e7599

Browse files
committed
Add previous state retention. Allows Express to startup in last used rover/base state.
1 parent b1bb9e4 commit 81e7599

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,25 @@ void beginAccelerometer()
362362

363363
online.accelerometer = true;
364364
}
365+
366+
//Depending on platform and previous power down state, set system state
367+
void beginSystemState()
368+
{
369+
if (productVariant == RTK_SURVEYOR)
370+
{
371+
//Assume Rover. checkButtons() will correct as needed.
372+
systemState = STATE_ROVER_NOT_STARTED;
373+
buttonPreviousState = BUTTON_BASE;
374+
}
375+
if (productVariant == RTK_EXPRESS || productVariant == RTK_EXPRESS)
376+
{
377+
systemState = settings.lastState; //Return to system state previous to power down.
378+
379+
if (systemState == STATE_ROVER_NOT_STARTED)
380+
buttonPreviousState = BUTTON_ROVER;
381+
else if (systemState == STATE_BASE_NOT_STARTED)
382+
buttonPreviousState = BUTTON_BASE;
383+
else
384+
buttonPreviousState = BUTTON_ROVER;
385+
}
386+
}

Firmware/RTK_Surveyor/NVM.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ void recordSystemSettingsToFile()
137137
settingsFile.println("sppRxQueueSize=" + (String)settings.sppRxQueueSize);
138138
settingsFile.println("sppTxQueueSize=" + (String)settings.sppTxQueueSize);
139139
settingsFile.println("dynamicModel=" + (String)settings.dynamicModel);
140+
settingsFile.println("lastState=" + (String)settings.lastState);
140141

141142
//Record message settings
142143
for (int x = 0 ; x < MAX_UBX_MSG ; x++)
@@ -385,6 +386,8 @@ bool parseLine(char* str) {
385386
settings.sppTxQueueSize = d;
386387
else if (strcmp(settingName, "dynamicModel") == 0)
387388
settings.dynamicModel = d;
389+
else if (strcmp(settingName, "lastState") == 0)
390+
settings.lastState = (SystemState)d;
388391

389392
//Check for message rates
390393
//Must be last on else list

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ void setup()
332332

333333
beginAccelerometer();
334334

335+
beginSystemState(); //Determine initial system state
336+
335337
Serial.flush(); //Complete any previous prints
336338

337339
danceLEDs(); //Turn on LEDs like a car dashboard

Firmware/RTK_Surveyor/States.ino

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ void updateSystemState()
3232

3333
if (productVariant == RTK_SURVEYOR)
3434
digitalWrite(pin_baseStatusLED, LOW);
35+
36+
settings.lastState = STATE_ROVER_NOT_STARTED;
37+
recordSystemSettings();
38+
3539
displayRoverSuccess(500);
3640

3741
changeState(STATE_ROVER_NO_FIX);
@@ -101,6 +105,9 @@ void updateSystemState()
101105

102106
if (configureUbloxModuleBase() == true)
103107
{
108+
settings.lastState = STATE_BASE_NOT_STARTED; //Record this state for next POR
109+
recordSystemSettings();
110+
104111
displayBaseSuccess(500); //Show 'Base Started'
105112

106113
if (settings.fixedBase == false)

Firmware/RTK_Surveyor/settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ struct struct_settings {
282282
uint16_t sppRxQueueSize = 2048;
283283
uint16_t sppTxQueueSize = 512;
284284
uint8_t dynamicModel = DYN_MODEL_PORTABLE;
285+
SystemState lastState = STATE_ROVER_NO_FIX; //For Express, start unit in state prior to powerdown
285286
} settings;
286287

287288
//These are the devices on board RTK Surveyor that may be on or offline.

0 commit comments

Comments
 (0)