mirror of
https://github.com/pelgraine/Meck.git
synced 2026-07-29 04:42:41 +02:00
fcd8b70384
Fixes a pre-existing bug on both watches. SensorBMA423::begin() calls bma423_write_config_file(), which re-flashes the BMA423 feature engine and zeroes the step register on every boot. _stepBaseline and _lastStepDay were RAM-only, so a reboot mid-day silently reset the day's steps to zero. Persisting the baseline would not have helped, since the raw count it is measured against restarts at 0. Replaces the baseline model with accumulate-plus-reset-detection: delta = (raw >= lastRaw) ? raw - lastRaw : raw todaySteps += delta lastRaw is seeded from the chip on the first read rather than from the file, which is correct whether or not the counter survived the reset. Persists lastStepDay, todaySteps and history[6] to /steps.dat on the LittleFS 'maps' partition, already mounted before UITask::begin(). Written on day rollover and at most every 5 minutes otherwise: a >=6s PWR hold is a hardware power cut by the AXP2101, so there is no clean-shutdown hook to flush from. A rollover across several days shifts in the completed day then pads with zeros for the days the watch was off; a clock corrected backwards re-anchors without disturbing history. Adds StepsHistoryScreen: today plus the previous six days as labelled bars, today in the tile blue. Reached by long-pressing the steps screen, which on the S3 the PWR key's short press also delivers (both arrive as KEY_ENTER). Any input returns to the steps screen. Gated on MECK_TWATCH, so the Plus gets both the fix and the screen.