Skip to content

Commit acb9109

Browse files
author
Michael Haas
committed
Fix EEPROM defaults
1 parent 60f410b commit acb9109

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/SettingsStorage.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ void SettingsStorage::begin() {
2121
if (strncmp(this->storage.configVersion, CONFIG_VERSION, CONFIG_VERSION_LENGTH) != 0) {
2222
// If you don't see this message, add a delay() to make sure the serial port
2323
// is initialized
24+
delay(100);
25+
2426
DEBUG.println("SettingsStorage::begin: no settings found in EEPROM. Storing defaults!");
2527
// no config found - write default config from header file into EEPROM
26-
memcpy(this->storage.configVersion, CONFIG_VERSION, CONFIG_VERSION_LENGTH);
27-
EEPROM.put(CONFIG_DATA_OFFSET, this->storage);
28+
EEPROM.put(CONFIG_DATA_OFFSET, this->defaultSettings);
2829
EEPROM.commit();
2930
}
3031
// Load config from EEPROM

src/SettingsStorage.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,16 @@ class SettingsStorage {
5252
double currentTemperature = 0;
5353
double pidOutput = 0;
5454

55-
SettingsStorage::PidSettings storage = {
55+
SettingsStorage::PidSettings storage;
56+
57+
SettingsStorage::PidSettings defaultSettings = {
5658
.desiredTemperature = DEFAULT_HEATER_TEMP,
5759
.tempOffset = 0,
5860
.kp = DEFAULT_HEATER_KP,
5961
.ki = DEFAULT_HEATER_KI,
60-
.kd = DEFAULT_HEATER_KD
62+
.kd = DEFAULT_HEATER_KD,
63+
// TODO: duplicated from above
64+
.configVersion = "124",
6165
};
6266

6367
void store(double value, double* target);

0 commit comments

Comments
 (0)