Skip to content

Commit

Permalink
Reduce preferences key length to max 15 characters. Add notes about t…
Browse files Browse the repository at this point in the history
…his limitation.
  • Loading branch information
mvgalen authored Dec 15, 2024
1 parent 5289796 commit ebddb59
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Software/Software.ino
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ void init_serial() {

void init_stored_settings() {
static uint32_t temp = 0;
// ATTENTION ! The maximum length for settings keys is 15 characters
settings.begin("batterySettings", false);

// Always get the equipment stop status
Expand Down Expand Up @@ -431,15 +432,15 @@ void init_stored_settings() {
settings.end();

settings.begin("batteryExtra", false);
temp = settings.getUInt("TARGETCHARGEVOLTAGE", false);
temp = settings.getUInt("TARGETCHVOLT", false);
if (temp != 0) {
datalayer.battery.settings.max_user_set_charge_voltage_dV = temp;
}
temp = settings.getUInt("TARGETDISCHARGEVOLTAGE", false);
temp = settings.getUInt("TARGETDISCHVOLT", false);
if (temp != 0) {
datalayer.battery.settings.max_user_set_discharge_voltage_dV = temp;
}
datalayer.battery.settings.user_set_voltage_limits_active = settings.getBool("USE_VOLTAGE_LIMITS", false);
datalayer.battery.settings.user_set_voltage_limits_active = settings.getBool("USEVOLTLIMITS", false);
settings.end();
}

Expand Down Expand Up @@ -1059,6 +1060,7 @@ void store_settings_equipment_stop() {
}

void storeSettings() {
// ATTENTION ! The maximum length for settings keys is 15 characters
if (!settings.begin("batterySettings", false)) {
set_event(EVENT_PERSISTENT_SAVE_INFO, 0);
return;
Expand Down Expand Up @@ -1091,13 +1093,13 @@ void storeSettings() {
if (!settings.putUInt("MAXDISCHARGEAMP", datalayer.battery.settings.max_user_set_discharge_dA)) {
set_event(EVENT_PERSISTENT_SAVE_INFO, 8);
}
if (!settings.putBool("USE_VOLTAGE_LIMITS", datalayer.battery.settings.user_set_voltage_limits_active)) {
if (!settings.putBool("USEVOLTLIMITS", datalayer.battery.settings.user_set_voltage_limits_active)) {
set_event(EVENT_PERSISTENT_SAVE_INFO, 9);
}
if (!settings.putUInt("TARGETCHARGEVOLTAGE", datalayer.battery.settings.max_user_set_charge_voltage_dV)) {
if (!settings.putUInt("TARGETCHVOLT", datalayer.battery.settings.max_user_set_charge_voltage_dV)) {
set_event(EVENT_PERSISTENT_SAVE_INFO, 10);
}
if (!settings.putUInt("TARGETDISCHARGEVOLTAGE", datalayer.battery.settings.max_user_set_discharge_voltage_dV)) {
if (!settings.putUInt("TARGETDISCHVOLT", datalayer.battery.settings.max_user_set_discharge_voltage_dV)) {
set_event(EVENT_PERSISTENT_SAVE_INFO, 11);
}
settings.end(); // Close preferences handle
Expand Down

0 comments on commit ebddb59

Please sign in to comment.