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:
simon
2026-09-26 13:07:13 +02:00
co-authored by Cursor
parent f006f8b912
commit d7441cb85f
32 changed files with 1859 additions and 150 deletions
+54
View File
@@ -82,6 +82,10 @@ static client_slot_t *alloc_slot(const uint8_t mac[CLIENT_MAC_LEN],
slot->active = true;
memcpy(slot->info.mac, mac, CLIENT_MAC_LEN);
slot->info.accel_deadzone = CLIENT_REGISTRY_DEFAULT_ACCEL_DEADZONE;
{
static const bma456_tap_config_t k_tap_default = BMA456_TAP_CONFIG_DEFAULT;
slot->info.tap_config = k_tap_default;
}
if (out_is_new != NULL) {
*out_is_new = true;
}
@@ -246,6 +250,56 @@ size_t client_registry_set_accel_deadzone_all(uint32_t deadzone) {
return n;
}
esp_err_t client_registry_set_tap_config(uint32_t client_id,
const bma456_tap_config_t *cfg) {
if (cfg == NULL || !bma456_tap_config_valid(cfg)) {
return ESP_ERR_INVALID_ARG;
}
const client_info_t *info = client_registry_find_by_id(client_id);
if (info == NULL) {
return ESP_ERR_NOT_FOUND;
}
for (size_t i = 0; i < CLIENT_REGISTRY_MAX; i++) {
if (s_clients[i].active && s_clients[i].info.id == client_id) {
s_clients[i].info.tap_config = *cfg;
return ESP_OK;
}
}
return ESP_ERR_NOT_FOUND;
}
esp_err_t client_registry_get_tap_config(uint32_t client_id,
bma456_tap_config_t *cfg_out) {
if (cfg_out == NULL) {
return ESP_ERR_INVALID_ARG;
}
const client_info_t *info = client_registry_find_by_id(client_id);
if (info == NULL) {
return ESP_ERR_NOT_FOUND;
}
*cfg_out = info->tap_config;
return ESP_OK;
}
size_t client_registry_set_tap_config_all(const bma456_tap_config_t *cfg) {
if (cfg == NULL || !bma456_tap_config_valid(cfg)) {
return 0;
}
size_t n = 0;
for (size_t i = 0; i < CLIENT_REGISTRY_MAX; i++) {
if (!s_clients[i].active) {
continue;
}
s_clients[i].info.tap_config = *cfg;
n++;
}
return n;
}
static void clear_client_accel(client_slot_t *slot) {
if (slot == NULL) {
return;