Skip to content

Commit

Permalink
Add upgradePreferences function and call it in initPreferences
Browse files Browse the repository at this point in the history
Upgrade in preferences batteryDischargedMillivolts from 3500 to 3200mV
  • Loading branch information
melkati committed Feb 25, 2024
1 parent d72a512 commit cb56377
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CO2_Gadget.ino
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
void reverseButtons(bool reversed);
void outputsLoop();
void publishMQTTLogData(String logData);
void putPreferences();

// Define enum for toneBuzzerBeep
enum ToneBuzzerBeep {
Expand Down
10 changes: 10 additions & 0 deletions CO2_Gadget_Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ Preferences preferences;
uint8_t prefVersion = 0;
uint8_t prefRevision = 0;

void upgradePreferences() {
if ((batteryDischargedMillivolts == 3500) && (prefVersion == 0) && (prefRevision == 0)) {
batteryDischargedMillivolts = 3200;
Serial.printf("-->[PREF] Upgrading preferences batteryDischargedMillivolts to %d\n", batteryDischargedMillivolts);
prefRevision = 1;
putPreferences();
}
}

void printPreferences() {
Serial.printf("-->[PREF] \n");
Serial.printf("-->[PREF] LOADED PREFERENCES FROM NVR:\n");
Expand Down Expand Up @@ -177,6 +186,7 @@ void initPreferences() {
#ifdef DEBUG_PREFERENCES
printPreferences();
#endif
upgradePreferences();
}

void putPreferences() {
Expand Down

0 comments on commit cb56377

Please sign in to comment.