Add runtime BMA456 tap config with NVS persistence and goTool UI.
Expose multitap parameters over UART/ESP-NOW (like deadzone), store per node in NVS, and allow get/set from CLI, REST, and the dashboard without poll-overwrite while editing. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+29
-1
@@ -88,12 +88,16 @@ Powerpod uses the Bosch **BMA456H** (hearable) variant, not the generic `bma456w
|
||||
|
||||
**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).
|
||||
|
||||
Tap detection parameters (`bma456_tap_config_t`) use the same pattern with NVS key `tap_cfg` (blob), UART `TAP_CONFIG`, and ESP-NOW `ESPNOW_SET_TAP_CONFIG`.
|
||||
|
||||
**Configuration paths:**
|
||||
|
||||
| Path | Effect |
|
||||
|------|--------|
|
||||
| UART `ACCEL_DEADZONE` with `client_id = 0` | Set + save local deadzone |
|
||||
| ESP-NOW `SET_ACCEL_DEADZONE` | Set + save on the receiving slave |
|
||||
| UART `TAP_CONFIG` with `client_id = 0` | Set + save local tap config |
|
||||
| ESP-NOW `SET_TAP_CONFIG` | Set + save tap config 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.
|
||||
@@ -116,6 +120,7 @@ Schema: `proto/esp_now_messages.proto`. Encode/decode: `esp_now_proto.c`. The ES
|
||||
| `ESPNOW_SLAVE_INFO` | Slave → master | `EspNowSlavePresence` |
|
||||
| `ESPNOW_HEARTBEAT` | Slave → master | `EspNowSlavePresence` (same fields) |
|
||||
| `ESPNOW_SET_ACCEL_DEADZONE` | Master → slave | `EspNowAccelDeadzone` (`deadzone` LSB) |
|
||||
| `ESPNOW_SET_TAP_CONFIG` | Master → slave | `EspNowTapConfig` (multitap sens/timing/axis + enable S/D/T) |
|
||||
| `ESPNOW_UNICAST_TEST` | Master → slave | `EspNowUnicastTest` (`seq`) |
|
||||
| `ESPNOW_FIND_ME` | Master → slave | `EspNowFindMe` (`client_id` filter) — LED locate sequence |
|
||||
| `ESPNOW_RESTART` | Master → slave | `EspNowRestart` (`client_id` filter) — reboot slave |
|
||||
@@ -232,6 +237,7 @@ Host and master speak nanopb-encoded `UartMessage` inside UART frames (byte 0 =
|
||||
| 29 | `CACHE_STATUS` | Implemented (`cmd/cmd_cache_status.c`) — subscribed accel + tap cache (one UART round-trip) |
|
||||
| 30 | `ESPNOW_ECHO_PING` | Implemented (`cmd/cmd_espnow_echo_ping.c`) — ESP-NOW timestamp echo (latency test) |
|
||||
| 31 | `SET_LOG_LEVEL` | Implemented (`cmd/cmd_set_log_level.c`) — get/set global `esp_log_level_set("*", …)` on master |
|
||||
| 32 | `TAP_CONFIG` | Implemented (`cmd/cmd_tap_config.c`) — get/set BMA456H multitap params (+ NVS) |
|
||||
|
||||
Regenerate C code:
|
||||
|
||||
@@ -325,6 +331,27 @@ Sets the **software** deadzone used by `bosch456.c` when logging accel (see [BMA
|
||||
|
||||
**Response:** `accel_deadzone_response` with applied `deadzone`, `success`, and `slaves_updated` (ESP-NOW count).
|
||||
|
||||
### TAP_CONFIG command
|
||||
|
||||
Get/set **hardware** BMA456H multitap parameters (`tap_sens_thres`, timing fields, `axis_sel`, enable single/double/triple). Applied via `bma456_set_tap_config()` and persisted in NVS (`tap_cfg`) on each target node.
|
||||
|
||||
**Request:** framed `20` (`0x20`) + `tap_config_request`:
|
||||
|
||||
| Field | Meaning |
|
||||
|-------|---------|
|
||||
| `write` | `false` = read, `true` = write |
|
||||
| `tap_sens_thres` … `enable_triple` | Same fields as `bma456_tap_config_t` |
|
||||
| `client_id` | `0` = local sensor; `>0` = slave id (master) |
|
||||
| `all_clients` | Master: ESP-NOW unicast to every registered slave |
|
||||
|
||||
**Response:** `tap_config_response` with fields echo, `success`, `slaves_updated`.
|
||||
|
||||
```bash
|
||||
go run . -port /dev/ttyUSB0 tap-config
|
||||
go run . -port /dev/ttyUSB0 tap-config -set -sens 5 -axis 2
|
||||
go run . -port /dev/ttyUSB0 tap-config -client 16 -set -sens 7
|
||||
```
|
||||
|
||||
### TAP_NOTIFY command
|
||||
|
||||
Configure which BMA456 tap kinds a **slave** forwards to the master over ESP-NOW. The slave only sends `ESPNOW_TAP_EVENT` when the matching notify flag is enabled (set locally on the slave via ESP-NOW).
|
||||
@@ -578,10 +605,11 @@ 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, on-demand read, tap INT, deadzone filter |
|
||||
| `cmd/cmd_tap_notify.c` | UART `TAP_NOTIFY` — ESP-NOW tap notify config |
|
||||
| `cmd/cmd_tap_config.c` | UART `TAP_CONFIG` — BMA456 multitap params + NVS |
|
||||
| `cmd/cmd_cache_status.c` | UART `CACHE_STATUS` — subscribed accel + tap cache poll |
|
||||
| `board_input.c/h` | Taster GPIO12, LiPo ADC on GPIO1 / GPIO11 |
|
||||
| `battery_uv.c/h` | Software LiPo UV latch, energy-save boot (`POWERPOD_BATTERY_UV_ENABLE`) |
|
||||
| `pod_settings.c/h` | NVS persistence (accel deadzone, UV latch, …) |
|
||||
| `pod_settings.c/h` | NVS persistence (accel deadzone, tap config, UV latch) |
|
||||
| `led_ring.c/h` | LED ring (digit display, progress bar) |
|
||||
| `cmd/cmd_led_ring.c` | UART `LED_RING` progress command |
|
||||
| `cmd/cmd_set_log_level.c` | UART `SET_LOG_LEVEL` — runtime ESP-IDF log level |
|
||||
|
||||
Reference in New Issue
Block a user