Skip to content

armgit / flix

Public Imported from GitHub
0

Making an ESP32-based quadcopter from scratch

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.

Oleg Kalachev9d439afd8089
diff --git a/flix/parameters.ino b/flix/parameters.ino
index 973fde0..0d3e19a 100644
--- a/flix/parameters.ino
+++ b/flix/parameters.ino
@@ -135,11 +135,10 @@ void setupParameters() {
storage.begin("flix");
// Read parameters from storage
for (auto &parameter : 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();
}
}