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 -12
View File
@@ -3,6 +3,7 @@
#include "esp_now_comm.h"
#include "led_ring.h"
#include "ota_espnow.h"
#include "pod_settings.h"
#include "esp_now_proto.h"
#include "esp_err.h"
#include "esp_event.h"
@@ -13,7 +14,6 @@
#include "esp_wifi.h"
#include "freertos/FreeRTOS.h"
#include "freertos/idf_additions.h"
#include "nvs_flash.h"
#include "ota_uart.h"
#include <stdio.h>
#include <string.h>
@@ -399,6 +399,10 @@ static void handle_slave_accel_deadzone(const uint8_t *master_mac,
bma456_is_ready() ? "ok" : "not installed");
bma456_set_accel_deadzone(cfg->deadzone);
if (pod_settings_save_accel_deadzone(cfg->deadzone) != ESP_OK) {
ESP_LOGW(TAG, "slave deadzone %lu applied but not saved to NVS",
(unsigned long)cfg->deadzone);
}
}
static void handle_client_presence(const alox_EspNowSlavePresence *presence,
@@ -607,17 +611,6 @@ static void master_discover_task(void *param) {
}
static esp_err_t init_wifi_stack(uint8_t channel) {
esp_err_t err;
err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
err = nvs_flash_init();
}
if (err != ESP_OK) {
return err;
}
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());