Align BMA456H driver with Powerpod and document sensor integration.
Clarify hearable variant usage, clean up I2C/GPIO/tap init, and add README coverage for hardware, boot behavior, deadzone paths, and logging. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+35
-4
@@ -50,13 +50,43 @@ Pins (`powerpod.h`):
|
||||
| UART TX | 3 |
|
||||
| UART RX | 2 |
|
||||
| LED ring | 7 |
|
||||
| BMA456 INT | 10 |
|
||||
|
||||
Startup order:
|
||||
|
||||
1. Read DIP + IO expander → `app_config`
|
||||
2. `esp_now_comm_init(&app_config)` — WiFi + ESP-NOW
|
||||
3. `led_ring_init()`
|
||||
4. **Master only:** command queue, UART, registered commands (e.g. VERSION)
|
||||
2. **I2C bus** — IO expander `0x20`; optional **BMA456H** (`init_bma456`, same bus)
|
||||
3. `esp_now_comm_init(&app_config)` — WiFi + ESP-NOW
|
||||
4. `led_ring_init()`
|
||||
5. **Master only:** command queue, UART, registered commands (e.g. VERSION)
|
||||
|
||||
## BMA456 accelerometer (`bosch456.c`)
|
||||
|
||||
Powerpod uses the Bosch **BMA456H** (hearable) variant, not the generic `bma456w` examples in the vendor tree.
|
||||
|
||||
| Item | Value |
|
||||
|------|--------|
|
||||
| Project wrapper | `main/bosch456.c`, `main/bosch456.h` |
|
||||
| Vendor component | `components/bma456` — only `bma4.c` + `bma456h.c` are linked |
|
||||
| I2C | Shared bus with IO expander (SCL/SDA GPIO 5/6), address **0x18**, **100 kHz** |
|
||||
| Interrupt | **GPIO 10**, active high, tap events (single / double / triple) |
|
||||
| Polling | FreeRTOS task `bma456_poll`, **10 Hz** accel read |
|
||||
|
||||
**Boot:** `init_bma456(bus_handle)` runs on **master and slave** after the IO expander. If the sensor is missing or init fails, firmware logs `BMA456 init skipped` and continues (`bma456_is_ready() == false`).
|
||||
|
||||
**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.
|
||||
|
||||
**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) |
|
||||
| `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.
|
||||
|
||||
Regenerate nanopb only when changing protos; sensor code has no code generation step.
|
||||
|
||||
## ESP-NOW discovery
|
||||
|
||||
@@ -177,7 +207,7 @@ Encoding: `uart_send_uart_message()` in `uart_proto.c`.
|
||||
|
||||
### ACCEL_DEADZONE command
|
||||
|
||||
Filters BMA456 logs: a new accel line is emitted only when any axis changes by more than `deadzone` raw LSB since the last reported sample (default **100**).
|
||||
Sets the **software** deadzone used by `bosch456.c` when logging accel (see [BMA456 accelerometer](#bma456-accelerometer-bosch456c)). Default **100** LSB.
|
||||
|
||||
**Request:** framed `06` + nanopb `UartMessage` with `accel_deadzone_request`:
|
||||
|
||||
@@ -279,6 +309,7 @@ Target: ESP32-S3. Close serial monitor on the UART adapter port before running `
|
||||
| `cmd_version.c/h` | VERSION handler |
|
||||
| `cmd_client_info.c/h` | CLIENT_INFO handler |
|
||||
| `client_registry.c/h` | Registered slave table |
|
||||
| `bosch456.c/h` | BMA456H I2C driver, accel poll, tap INT, deadzone filter |
|
||||
| `led_ring.c/h` | LED digit display |
|
||||
| `proto/uart_messages.proto` | UART protocol schema |
|
||||
| `proto/esp_now_messages.proto` | ESP-NOW protocol schema |
|
||||
|
||||
Reference in New Issue
Block a user