Skip to content

Commit e11c38a

Browse files
committed
Set active profile bit when profile name is changed
Add setProfileName routine to copy the profile name from settings into the profile name array. This routine also sets the activeProfile bit. Use setProfileName in Form.ino and menuMain.ino. Use setSettingsFileName in menuMain.ino, already in use by Form.ino.
1 parent d4c0f37 commit e11c38a

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

Firmware/RTK_Surveyor/Form.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
488488
else if (strcmp(settingName, "profileName") == 0)
489489
{
490490
strcpy(settings.profileName, settingValueStr);
491-
strcpy(profileNames[profileNumber], settingValueStr);
491+
setProfileName(profileNumber);
492492
}
493493
else if (strcmp(settingName, "profileNumber") == 0)
494494
{

Firmware/RTK_Surveyor/NVM.ino

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,16 @@ Serial.printf("profiles: 0x%02x\r\n", profiles);
975975
return (profiles);
976976
}
977977

978+
//Copy the profile name into the array of profile names
979+
void setProfileName(uint8_t ProfileNumber)
980+
{
981+
//Update the name in the array of profile names
982+
strcpy(profileNames[profileNumber], settings.profileName);
983+
984+
//Mark this profile as active
985+
activeProfiles |= 1 << ProfileNumber;
986+
}
987+
978988
//Open the clear text file, scan for 'profileName' and return the string
979989
//Returns true if successfully found tag in file, length may be zero
980990
//Looks at LittleFS first, then SD

Firmware/RTK_Surveyor/menuMain.ino

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ void menuUserProfiles()
156156

157157
recordProfileNumber(incoming - 1); //Align to array
158158
profileNumber = incoming - 1;
159-
160-
sprintf(settingsFileName, "/%s_Settings_%d.txt", platformFilePrefix, profileNumber); //Enables Delete Profile
159+
setSettingsFileName(); //Enables Delete Profile
161160

162161
//We need to load these settings from file so that we can record a profile name change correctly
163162
bool responseLFS = loadSystemSettingsFromFileLFS(settingsFileName, &settings);
@@ -175,8 +174,7 @@ void menuUserProfiles()
175174
Serial.print("Enter new profile name: ");
176175
readLine(settings.profileName, sizeof(settings.profileName), menuTimeoutExtended);
177176
recordSystemSettings(); //We need to update this immediately in case user lists the available profiles again
178-
179-
strcpy(profileNames[profileNumber], settings.profileName); //Update array
177+
setProfileName(profileNumber);
180178
}
181179
else if (incoming == MAX_PROFILE_COUNT + 2)
182180
{

0 commit comments

Comments
 (0)