feat: persist pressure history to LittleFS across reboots

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-17 20:31:53 +07:00
co-authored by Claude Opus 4.8
parent 0a8dbe198d
commit 77d0a35d69
3 changed files with 45 additions and 1 deletions
+10 -1
View File
@@ -13,6 +13,7 @@ AppState g_state;
static unsigned long tSample = 0;
static unsigned long tHistory = 0;
static unsigned long tFlush = 0;
static void sampleNow() {
g_state.now = rtcNow();
@@ -47,12 +48,14 @@ void setup() {
}
settingsBegin();
historyBegin();
historyLoad(); // restore prior samples (empty on first ever boot)
Serial.printf("history restored: %d samples\n", historyCount());
// Seed first sample immediately.
sampleNow();
historyAdd(rtcEpoch(), g_state.mslHpa, g_state.tempC);
displayRender(g_state);
tSample = tHistory = millis();
tSample = tHistory = tFlush = millis();
}
void loop() {
@@ -68,4 +71,10 @@ void loop() {
tHistory = now;
historyAdd(rtcEpoch(), g_state.mslHpa, g_state.tempC);
}
if (now - tFlush >= FLUSH_INTERVAL_MS) {
tFlush = now;
historySave();
Serial.printf("history flushed: %d samples\n", historyCount());
}
}