Добавляем функцию сохранения состояния элементов на flash

This commit is contained in:
2022-10-20 00:18:41 +03:00
parent c89127c067
commit b8e76e19b8
15 changed files with 540 additions and 79 deletions

View File

@@ -149,6 +149,14 @@ void loop() {
loopPeriod = millis() - st;
if (loopPeriod > 2) Serial.println(loopPeriod);
#endif
// сохраняем значения IoTItems в файл каждую секунду, если были изменения (установлены маркеры на сохранение)
if (needSaveValues && millis()%1000 == 0) {
syncValuesFlashJson();
needSaveValues = false;
delay(1);
Serial.println("syncValuesFlashJson()");
}
}
//отправка json
@@ -162,24 +170,6 @@ void loop() {
// delay(1);
// }
// сохраняем значения IoTItems в файл каждую секунду, если были изменения (установлены маркеры на сохранение)
// currentMillis = millis();
// if (currentMillis - prevMillis >= 1000) {
// prevMillis = millis();
// volStrForSave = "";
// for (std::list<IoTItem *>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
// if ((*it)->needSave) {
// (*it)->needSave = false;
// volStrForSave = volStrForSave + (*it)->getID() + "=" + (*it)->getValue() + ";";
// }
// }
//
// if (volStrForSave != "") {
// Serial.print("volStrForSave: ");
// Serial.println(volStrForSave.c_str());
// }
//}
// File dir = FileFS.open("/", "r");
// String out;
// printDirectory(dir, out);