Send ESP-NOW accel only on deadzone change and harden BLE+WiFi OTA coex.

Quiet pods no longer spam 100 Hz samples; mute wifi logs and throttle BLE
notifies during slave distribution so the wifi task stack does not panic.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-02 00:55:50 +01:00
co-authored by Cursor
parent 141176a824
commit 8f90dfe82f
9 changed files with 112 additions and 14 deletions
+23 -1
View File
@@ -2,7 +2,7 @@
* BMA456H integration for Powerpod (ESP-IDF I2C master + Bosch SensorAPI).
*
* Polls accelerometer at 10 Hz; tap events arrive on BMA456_INT_GPIO.
* Accel logging is filtered in software (deadzone); slaves stream samples via ESP-NOW.
* Accel log + ESP-NOW stream share a software deadzone filter (emit on change).
*/
#include "bosch456.h"
@@ -33,6 +33,10 @@ static int16_t s_last_x;
static int16_t s_last_y;
static int16_t s_last_z;
static bool s_have_last_sample;
static int16_t s_stream_last_x;
static int16_t s_stream_last_y;
static int16_t s_stream_last_z;
static bool s_stream_have_last;
static volatile bool s_int_pending;
static SemaphoreHandle_t s_accel_mutex;
@@ -119,6 +123,7 @@ bool bma456_is_ready(void) { return s_bma456_ready; }
void bma456_set_accel_deadzone(uint32_t deadzone_lsb) {
s_accel_deadzone = deadzone_lsb;
s_have_last_sample = false;
s_stream_have_last = false;
if (s_bma456_ready) {
ESP_LOGI(TAG, "accel deadzone %lu LSB", (unsigned long)deadzone_lsb);
}
@@ -126,6 +131,23 @@ void bma456_set_accel_deadzone(uint32_t deadzone_lsb) {
uint32_t bma456_get_accel_deadzone(void) { return s_accel_deadzone; }
void bma456_accel_stream_reset_baseline(void) { s_stream_have_last = false; }
bool bma456_accel_stream_take_if_changed(int16_t x, int16_t y, int16_t z) {
if (s_stream_have_last) {
if (axis_delta(x, s_stream_last_x) <= (int16_t)s_accel_deadzone &&
axis_delta(y, s_stream_last_y) <= (int16_t)s_accel_deadzone &&
axis_delta(z, s_stream_last_z) <= (int16_t)s_accel_deadzone) {
return false;
}
}
s_stream_last_x = x;
s_stream_last_y = y;
s_stream_last_z = z;
s_stream_have_last = true;
return true;
}
bool bma456_tap_config_valid(const bma456_tap_config_t *cfg) {
if (cfg == NULL) {
return false;