Skip to content

Commit 42ec4c7

Browse files
committed
Fix profile assignment if empty profile exists. Add delete profile.
1 parent 4b02e78 commit 42ec4c7

File tree

4 files changed

+17
-26
lines changed

4 files changed

+17
-26
lines changed

Firmware/RTK_Surveyor/Display.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,8 @@ void paintProfile(uint8_t profileUnit)
14841484
uint8_t profileNumber = getProfileNumberFromUnit(profileUnit);
14851485
recordProfileNumber(profileNumber); //Update internal settings with user's choice, mark unit for config update
14861486

1487+
log_d("Going to profile number %d from unit %d, name '%s'", profileNumber, profileUnit, profileName);
1488+
14871489
snprintf(profileMessage, sizeof(profileMessage), "Loading %s", profileName);
14881490
displayMessage(profileMessage, 2000);
14891491
ESP.restart(); //Profiles require full restart to take effect

Firmware/RTK_Surveyor/NVM.ino

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void loadSettings()
2323
loadSystemSettingsFromFileSD(settingsFileName, &settings);
2424

2525
//Change empty profile name to 'Profile1' etc
26-
if (strcmp(settings.profileName, "(Empty)") == 0)
26+
if (strlen(settings.profileName) == 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
@@ -873,9 +873,7 @@ uint8_t loadProfileNames()
873873
for (int x = 0 ; x < MAX_PROFILE_COUNT ; x++)
874874
profileNames[x][0] = '\0'; //Ensure every profile name is terminated
875875

876-
//Serial.printf("sizeof(Settings): %d\n\r", sizeof(Settings));
877-
878-
//Check LittleFS for profile names
876+
//Check LittleFS and SD for profile names
879877
for (int x = 0 ; x < MAX_PROFILE_COUNT ; x++)
880878
{
881879
char fileName[40];
@@ -885,11 +883,11 @@ uint8_t loadProfileNames()
885883
profileCount++;
886884
}
887885

888-
// Serial.printf("profileCount: %d\n\r", profileCount);
889-
// Serial.println("Profiles:");
890-
// for (int x = 0 ; x < MAX_PROFILE_COUNT ; x++)
891-
// Serial.printf("%d) %s\n\r", x, profileNames[x]);
892-
// Serial.println();
886+
// Serial.printf("profileCount: %d\n\r", profileCount);
887+
// Serial.println("Profiles:");
888+
// for (int x = 0 ; x < MAX_PROFILE_COUNT ; x++)
889+
// Serial.printf("%d) %s\n\r", x, profileNames[x]);
890+
// Serial.println();
893891

894892
return (profileCount);
895893
}
@@ -953,16 +951,14 @@ uint8_t getProfileNumberFromUnit(uint8_t profileUnit)
953951
if (strlen(profileNames[x]) > 0)
954952
{
955953
if (located == profileUnit)
956-
{
957-
return (located);
958-
}
954+
return (x);
959955

960956
located++; //Valid settingFileName but not the unit we are looking for
961957
}
962958
}
963959
log_d("Profile unit %d not found", profileUnit);
964960

965-
return (false);
961+
return (0);
966962
}
967963

968964
//Record large character blob to file

Firmware/RTK_Surveyor/menuMain.ino

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,7 @@ void menuUserProfiles()
149149
recordProfileNumber(incoming - 1); //Align to array
150150
profileNumber = incoming - 1;
151151

152-
sprintf(settingsFileName, "/%s_Settings_%d.txt", platformFilePrefix, profileNumber); //Update file name with new profileNumber
153-
154-
//Start this profile with default settings
155-
Settings tempSettings;
156-
settings = tempSettings;
157-
158-
recordSystemSettings();
152+
sprintf(settingsFileName, "/%s_Settings_%d.txt", platformFilePrefix, profileNumber); //Enables Delete Profile
159153
}
160154
else if (incoming == MAX_PROFILE_COUNT + 1)
161155
{
@@ -182,13 +176,12 @@ void menuUserProfiles()
182176
sd.remove(settingsFileName);
183177
}
184178

185-
//Clear this profile profile with default settings
186-
Settings tempSettings;
187-
settings = tempSettings;
179+
recordProfileNumber(0); //Move to Profile1
180+
profileNumber = 0;
188181

189-
recordSystemSettings();
182+
sprintf(settingsFileName, "/%s_Settings_%d.txt", platformFilePrefix, profileNumber); //Update file name with new profileNumber
190183

191-
strcpy(profileNames[profileNumber], settings.profileName); //Update array
184+
activeProfiles = loadProfileNames(); //Count is used during menu display
192185
}
193186
else
194187
Serial.println(F("Delete aborted"));

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] = "(Empty)";
339+
char profileName[50] = "";
340340

341341
//NTRIP Server
342342
bool enableNtripServer = false;

0 commit comments

Comments
 (0)