forcing save from ui

This commit is contained in:
Patrick Haßel 2024-12-31 12:16:59 +01:00
parent 399723d77a
commit 71b99cca5e
3 changed files with 20 additions and 0 deletions

View File

@ -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{};

View File

@ -16,6 +16,8 @@ void config_setup();
void config_loop();
void configSaveNowIfDirty();
bool config_load();
void config_set_dirty();

View File

@ -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"(<button onclick="get('/config/date?year=' + document.getElementById('year').value + '&month=' + document.getElementById('month').value + '&day=' + document.getElementById('day').value);">Datum setzen</button>)");
server.sendContent(R"(</p>)");
server.sendContent(R"(<p>)");
server.sendContent(R"(<button onclick="get('/config/save');">Speichern erzwingen</button>)");
server.sendContent(R"(</p>)");
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);