Add accelerometer deadzone via UART and ESP-NOW.
Filter BMA456 logs by configurable LSB threshold; master can set deadzone for local sensor or slaves using ACCEL_DEADZONE (UART) and ESP-NOW broadcast until unicast delivery is restored. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -60,6 +60,7 @@ static client_slot_t *alloc_slot(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
slot = &s_clients[i];
|
||||
slot->active = true;
|
||||
memcpy(slot->info.mac, mac, CLIENT_MAC_LEN);
|
||||
slot->info.accel_deadzone = CLIENT_REGISTRY_DEFAULT_ACCEL_DEADZONE;
|
||||
if (out_is_new != NULL) {
|
||||
*out_is_new = true;
|
||||
}
|
||||
@@ -169,6 +170,59 @@ size_t client_registry_count(void) {
|
||||
return n;
|
||||
}
|
||||
|
||||
const client_info_t *client_registry_find_by_id(uint32_t id) {
|
||||
for (size_t i = 0; i < CLIENT_REGISTRY_MAX; i++) {
|
||||
if (s_clients[i].active && s_clients[i].info.id == id) {
|
||||
return &s_clients[i].info;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
esp_err_t client_registry_set_accel_deadzone(uint32_t client_id,
|
||||
uint32_t deadzone) {
|
||||
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.accel_deadzone = deadzone;
|
||||
return ESP_OK;
|
||||
}
|
||||
}
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
esp_err_t client_registry_get_accel_deadzone(uint32_t client_id,
|
||||
uint32_t *deadzone_out) {
|
||||
if (deadzone_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;
|
||||
}
|
||||
|
||||
*deadzone_out = info->accel_deadzone;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
size_t client_registry_set_accel_deadzone_all(uint32_t deadzone) {
|
||||
size_t n = 0;
|
||||
|
||||
for (size_t i = 0; i < CLIENT_REGISTRY_MAX; i++) {
|
||||
if (!s_clients[i].active) {
|
||||
continue;
|
||||
}
|
||||
s_clients[i].info.accel_deadzone = deadzone;
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
const client_info_t *client_registry_at(size_t index) {
|
||||
size_t n = 0;
|
||||
for (size_t i = 0; i < CLIENT_REGISTRY_MAX; i++) {
|
||||
|
||||
Reference in New Issue
Block a user