Skip to content

Commit a55d1ca

Browse files
committed
Mark ZED config when profile changes
1 parent 293a4ff commit a55d1ca

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

Firmware/RTK_Surveyor/Display.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ void paintProfile(uint8_t profileUnit)
14221422
{
14231423
//Lookup profileNumber based on unit
14241424
uint8_t profileNumber = getProfileNumberFromUnit(profileUnit);
1425-
recordProfileNumber(profileNumber); //Update internal settings with user's choice
1425+
recordProfileNumber(profileNumber, true); //Update internal settings with user's choice, mark unit for config update
14261426

14271427
snprintf(profileMessage, sizeof(profileMessage), "Loading %s", profileName);
14281428
displayMessage(profileMessage, 2000);

Firmware/RTK_Surveyor/NVM.ino

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void loadSettings()
3737

3838
activeProfiles = getActiveProfiles(); //Count is used during menu display
3939

40-
log_d("Settings profile #%d loaded", profileNumber);
40+
log_d("Settings profile #%d loaded of %d profiles", profileNumber, activeProfiles);
4141
}
4242

4343
//Load a given settings file into a given settings array
@@ -96,11 +96,12 @@ uint8_t getProfileNumber()
9696
log_d("profileNumber.txt not found");
9797
profileNumber = 0;
9898
updateZEDSettings = true; //Force module update
99-
recordProfileNumber(profileNumber);
99+
recordProfileNumber(profileNumber, false); //Record profile but we don't need a module config at next POR
100100
}
101101
else
102102
{
103103
profileNumber = fileProfileNumber.read();
104+
updateZEDSettings = fileProfileNumber.read();
104105
fileProfileNumber.close();
105106
}
106107

@@ -109,7 +110,8 @@ uint8_t getProfileNumber()
109110
{
110111
log_d("ProfileNumber invalid. Going to zero.");
111112
profileNumber = 0;
112-
recordProfileNumber(profileNumber);
113+
updateZEDSettings = true; //Force module update
114+
recordProfileNumber(profileNumber, false); //Record profile but we don't need a module config at next POR
113115
}
114116

115117
log_d("Using profile #%d", profileNumber);
@@ -205,8 +207,8 @@ uint8_t getProfileNumberFromUnit(uint8_t profileUnit)
205207
return (false);
206208
}
207209

208-
//Record the given profile number
209-
void recordProfileNumber(uint8_t profileNumber)
210+
//Record the given profile number as well as a config bool
211+
void recordProfileNumber(uint8_t profileNumber, bool markForUpdate)
210212
{
211213
File fileProfileNumber = LittleFS.open("/profileNumber.txt", FILE_WRITE);
212214
if (!fileProfileNumber)
@@ -215,6 +217,7 @@ void recordProfileNumber(uint8_t profileNumber)
215217
return;
216218
}
217219
fileProfileNumber.write(profileNumber);
220+
fileProfileNumber.write(markForUpdate); //If true, ZED will be config'd next POR
218221
fileProfileNumber.close();
219222
}
220223

@@ -375,7 +378,7 @@ void recordSystemSettingsToFile()
375378

376379
settingsFile.close();
377380

378-
log_d("System settings recorded to file");
381+
log_d("Settings recorded to SD: %s", settingsFileName);
379382

380383
xSemaphoreGive(xFATSemaphore);
381384
}

Firmware/RTK_Surveyor/menuMain.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ void menuUserProfiles()
168168
{
169169
recordSystemSettings(); //Before switching, we need to record the current settings to LittleFS and SD
170170

171-
recordProfileNumber(incoming - 1); //Align to array
171+
recordProfileNumber(incoming - 1, true); //Align to array, reconfig ZED at next POR
172172
}
173173
//Reset settings to default
174174
Settings defaultSettings;

0 commit comments

Comments
 (0)