mirror of
https://github.com/okalachev/flix.git
synced 2026-08-15 16:29:00 +00:00
Store only changed parameters in flash instead of all
Rationale: 1. Parameters NVS storage is limited and storing unchanged parameters is wasteful. 2. This allows changing parameters in the code without having to erase the flash storage. 3. Updating the firmware version may change the parameter defaults.
This commit is contained in:
+3
-4
@@ -135,11 +135,10 @@ void setupParameters() {
|
||||
storage.begin("flix");
|
||||
// Read parameters from storage
|
||||
for (auto ¶meter : parameters) {
|
||||
if (!storage.isKey(parameter.name)) {
|
||||
storage.putFloat(parameter.name, parameter.getValue()); // store default value
|
||||
}
|
||||
parameter.inital = parameter.getValue();
|
||||
parameter.setValue(storage.getFloat(parameter.name, 0));
|
||||
if (storage.isKey(parameter.name)) {
|
||||
parameter.setValue(storage.getFloat(parameter.name));
|
||||
}
|
||||
parameter.cache = parameter.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user