feat: in-RAM pressure history ring buffer with 3h trend

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-17 20:02:40 +07:00
co-authored by Claude Opus 4.8
parent 5819739fcb
commit 5c96cfc1f3
3 changed files with 66 additions and 0 deletions
+13
View File
@@ -5,6 +5,7 @@
#include "sensors.h"
#include "rtc_time.h"
#include "forecast.h"
#include "history.h"
static void i2cScan() {
Serial.println(F("I2C scan:"));
@@ -46,6 +47,18 @@ void setup() {
Serial.printf("p=%.0f trend=%d -> %c [%s] (%s)\n",
c.p, c.tr, f.letter, f.text, categoryShort(f.category));
}
// --- history self-test (remove after Task 8) ---
historyBegin();
uint32_t base = 1000000000UL;
for (int i = 0; i < 40; i++) // 40 samples @ 5 min = 3h20m, pressure falling
historyAdd(base + (uint32_t)i * 300, 1015.0f - i * 0.2f, 20.0f);
float d;
if (historyTrendDelta(d))
Serial.printf("history count=%d 3h delta=%.2f hPa trend=%d\n",
historyCount(), d, classifyTrend(d));
else
Serial.println(F("history: not enough data for trend"));
}
void loop() {