Persist accelerometer deadzone in NVS across reboots.

Each node saves its local deadzone on UART or ESP-NOW set; pod_settings loads and applies it after BMA456 init.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-19 22:29:00 +02:00
co-authored by Cursor
parent 2e88358c53
commit 5c3cf65bca
7 changed files with 158 additions and 16 deletions
+5 -2
View File
@@ -82,12 +82,14 @@ Powerpod uses the Bosch **BMA456H** (hearable) variant, not the generic `bma456w
**Accel logging:** Samples are printed only when any axis changes by more than the **deadzone** (raw LSB) since the last logged sample (default **100**). This is a **software** filter on top of the sensor; it does not change BMA456 hardware thresholds.
**Persistence:** The local deadzone is stored in the **`nvs`** partition (namespace `powerpod`, key `accel_dz`) via `pod_settings.c`. Each node (master or slave) keeps its own value across reboot. Loaded at boot after `init_bma456()`; saved when set locally (UART `client_id = 0`, `all_clients` on master, or ESP-NOW deadzone on a slave).
**Configuration paths:**
| Path | Effect |
|------|--------|
| UART `ACCEL_DEADZONE` with `client_id = 0` | `bma456_set_accel_deadzone()` on the local node |
| ESP-NOW `SET_ACCEL_DEADZONE` | Same on a slave (no-op log path if sensor not installed) |
| UART `ACCEL_DEADZONE` with `client_id = 0` | Set + save local deadzone |
| ESP-NOW `SET_ACCEL_DEADZONE` | Set + save on the receiving slave |
| `make gotool-deadzone-set DEADZONE=… CLIENT=0` | Host shortcut for local deadzone |
**Logs:** `[BMA456] ACC X=… Y=… Z=…` when deadzone exceeded; `[BMA456] tap: single|double|triple` on interrupt.
@@ -440,6 +442,7 @@ Target: ESP32-S3. Close serial monitor on the UART adapter port before running `
| `client_registry.c/h` | Registered slave table |
| `bosch456.c/h` | BMA456H I2C driver, accel poll, tap INT, deadzone filter |
| `board_input.c/h` | Taster GPIO12, LiPo ADC on GPIO1 / GPIO12 |
| `pod_settings.c/h` | NVS persistence (accel deadzone, …) |
| `led_ring.c/h` | LED ring (digit display, progress bar) |
| `cmd_led_ring.c` | UART `LED_RING` progress command |
| `proto/uart_messages.proto` | UART protocol schema |