From 71b99cca5ecd204791d86022bf33ccce9b595992 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Patrick=20Ha=C3=9Fel?=
Date: Tue, 31 Dec 2024 12:16:59 +0100
Subject: [PATCH] forcing save from ui
---
src/config.cpp | 6 ++++++
src/config.h | 2 ++
src/server.cpp | 12 ++++++++++++
3 files changed, 20 insertions(+)
diff --git a/src/config.cpp b/src/config.cpp
index 2876edc..9df3ae3 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -58,6 +58,12 @@ void config_loop() {
Serial.printf("Config saved to EEPROM.\n");
}
+void configSaveNowIfDirty() {
+ if (dirty) {
+ lastDirtyMillis = millis() - 30000;
+ }
+}
+
bool config_load() {
Config tmp{};
diff --git a/src/config.h b/src/config.h
index a0cf06b..34d4bbc 100644
--- a/src/config.h
+++ b/src/config.h
@@ -16,6 +16,8 @@ void config_setup();
void config_loop();
+void configSaveNowIfDirty();
+
bool config_load();
void config_set_dirty();
diff --git a/src/server.cpp b/src/server.cpp
index 37f5591..506a536 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -63,6 +63,8 @@ void web_fps_off();
void web_config_date();
+void web_config_save();
+
void server_setup() {
server.on("/", web_index);
server.on("/player", web_player);
@@ -76,6 +78,7 @@ void server_setup() {
server.on("/fps/on", web_fps_on);
server.on("/fps/off", web_fps_off);
server.on("/config/date", web_config_date);
+ server.on("/config/save", web_config_save);
server.begin();
}
@@ -126,6 +129,10 @@ void web_index() {
server.sendContent(R"()");
server.sendContent(R"(
)");
+ server.sendContent(R"()");
+ server.sendContent(R"()");
+ server.sendContent(R"(
)");
+
server.client().flush();
}
@@ -285,6 +292,11 @@ void web_fps_off() {
server.send(200);
}
+void web_config_save() {
+ configSaveNowIfDirty();
+ server.send(200);
+}
+
void web_config_date() {
double year = strtod(server.arg("year").c_str(), nullptr);
double month = strtod(server.arg("month").c_str(), nullptr);