Skip to content

Commit 7e9bc43

Browse files
committed
Add delete profile feature
1 parent 4dfc4e5 commit 7e9bc43

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

Firmware/RTK_Surveyor/NVM.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ void loadSettings()
2222
//loadSystemSettingsFromFileLFS(settingsFileName, &settings); - Previously loaded during loadSettingsPartial()
2323
loadSystemSettingsFromFileSD(settingsFileName, &settings);
2424

25-
//Change default profile names to 'Profile1' etc
26-
if (strcmp(settings.profileName, "Default") == 0)
25+
//Change empty profile name to 'Profile1' etc
26+
if (strcmp(settings.profileName, "(Empty)") == 0)
2727
sprintf(settings.profileName, "Profile%d", profileNumber + 1);
2828

2929
//Record these settings to LittleFS and SD file to be sure they are the same

Firmware/RTK_Surveyor/menuMain.ino

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,19 @@ void menuUserProfiles()
124124
for (int x = 0 ; x < MAX_PROFILE_COUNT ; x++)
125125
{
126126
if (strlen(profileNames[x]) > 0)
127-
{
128127
Serial.printf("%d) Select %s", x + 1, profileNames[x]);
129-
if (x == profileNumber) Serial.print(" <- Current");
130-
}
131128
else
132129
Serial.printf("%d) Select (Empty)", x + 1);
133130

131+
if (x == profileNumber) Serial.print(" <- Current");
132+
134133
Serial.println();
135134
}
136135

137136
Serial.printf("%d) Edit profile name: %s\n\r", MAX_PROFILE_COUNT + 1, profileNames[profileNumber]);
138137

138+
Serial.printf("%d) Delete profile '%s'\n\r", MAX_PROFILE_COUNT + 2, profileNames[profileNumber]);
139+
139140
Serial.println(F("x) Exit"));
140141

141142
int incoming = getNumber(menuTimeout); //Timeout after x seconds
@@ -164,6 +165,34 @@ void menuUserProfiles()
164165

165166
strcpy(profileNames[profileNumber], settings.profileName); //Update array
166167
}
168+
else if (incoming == MAX_PROFILE_COUNT + 2)
169+
{
170+
Serial.printf("\r\nDelete profile '%s'. Press 'y' to confirm:", profileNames[profileNumber]);
171+
byte bContinue = getByteChoice(menuTimeout);
172+
if (bContinue == 'y')
173+
{
174+
//Remove profile from LittleFS
175+
if (LittleFS.exists(settingsFileName))
176+
LittleFS.remove(settingsFileName);
177+
178+
//Remove profile from SD if available
179+
if (online.microSD == true)
180+
{
181+
if (sd.exists(settingsFileName))
182+
sd.remove(settingsFileName);
183+
}
184+
185+
//Clear this profile profile with default settings
186+
Settings tempSettings;
187+
settings = tempSettings;
188+
189+
recordSystemSettings();
190+
191+
strcpy(profileNames[profileNumber], settings.profileName); //Update array
192+
}
193+
else
194+
Serial.println(F("Delete aborted"));
195+
}
167196

168197
else if (incoming == STATUS_PRESSED_X)
169198
break;

Firmware/RTK_Surveyor/settings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ typedef struct {
336336
};
337337

338338
int maxLogLength_minutes = 60 * 24; //Default to 24 hours
339-
char profileName[50] = "Default";
339+
char profileName[50] = "(Empty)";
340340

341341
//NTRIP Server
342342
bool enableNtripServer = false;

0 commit comments

Comments
 (0)