Skip to content

Commit 3f65e58

Browse files
authored
Merge pull request #216 from LeeLeahy2/profile-name
Set active profile bit when profile name is changed
2 parents 0e08bc9 + e11c38a commit 3f65e58

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
@@ -974,6 +974,16 @@ uint8_t loadProfileNames()
974974
return (profiles);
975975
}
976976

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