Add runtime UV protection toggle and treat near-zero sense as external power.
Per-pod NVS enable (default off) via UART/ESP-NOW/dashboard, and skip UV latch when LiPo ADC reads ~0 mV so USB/external supply still boots. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -143,6 +143,7 @@ static client_slot_t *alloc_slot(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
static const bma456_tap_config_t k_tap_default = BMA456_TAP_CONFIG_DEFAULT;
|
||||
slot->info.tap_config = k_tap_default;
|
||||
}
|
||||
slot->info.uv_protection_enabled = false;
|
||||
if (out_is_new != NULL) {
|
||||
*out_is_new = true;
|
||||
}
|
||||
@@ -435,6 +436,41 @@ size_t client_registry_set_tap_config_all(const bma456_tap_config_t *cfg) {
|
||||
return n;
|
||||
}
|
||||
|
||||
esp_err_t client_registry_set_uv_protection(uint32_t client_id, bool enabled) {
|
||||
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.uv_protection_enabled = enabled;
|
||||
return ESP_OK;
|
||||
}
|
||||
}
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
esp_err_t client_registry_get_uv_protection(uint32_t client_id,
|
||||
bool *enabled_out) {
|
||||
if (enabled_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;
|
||||
}
|
||||
*enabled_out = info->uv_protection_enabled;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
size_t client_registry_set_uv_protection_all(bool enabled) {
|
||||
size_t n = 0;
|
||||
for (size_t i = 0; i < CLIENT_REGISTRY_MAX; i++) {
|
||||
if (!s_clients[i].active) {
|
||||
continue;
|
||||
}
|
||||
s_clients[i].info.uv_protection_enabled = enabled;
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
static void clear_client_accel(client_slot_t *slot) {
|
||||
if (slot == NULL) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user