|
TB2026-YDS Firmware
|
Battery autonomy self-test: run a workload on battery until shutdown, log a curve. More...
#include "esp_err.h"#include <stdbool.h>#include <stdint.h>Go to the source code of this file.
Data Structures | |
| struct | autonomy_status_t |
| Snapshot of the running test, for the in-progress screen. More... | |
Enumerations | |
| enum | autonomy_test_t { AUTONOMY_TEST_IDLE = 0 , AUTONOMY_TEST_JACK , AUTONOMY_TEST_BT } |
| Which workload the run exercises. More... | |
| enum | autonomy_result_t { AUTONOMY_RESULT_NONE = 0 , AUTONOMY_RESULT_CANCELLED , AUTONOMY_RESULT_COMPLETED , AUTONOMY_RESULT_ABORTED , AUTONOMY_RESULT_INTERRUPTED } |
| Outcome of the most recent run, for the UI's "Last run" block. More... | |
Functions | |
| esp_err_t | autonomy_start (autonomy_test_t type) |
| Start an autonomy run with the given workload. | |
| void | autonomy_cancel (void) |
| Cancel the running test, keeping it as the last (cancelled) result. No-op if idle. | |
| bool | autonomy_is_running (void) |
| Whether a run is currently in progress. | |
| void | autonomy_get_status (autonomy_status_t *out) |
| Copy the running test's snapshot. | |
| void | autonomy_tick (void) |
| Periodic hook, called from the maintenance task (after power_tick()). | |
| esp_err_t | autonomy_boot_export (void) |
| Export a stored (not-yet-exported) run to a CSV on the SD card. Call once at boot. | |
| esp_err_t | autonomy_redump (void) |
| Re-export the last stored run to a fresh CSV on the SD card (without rebooting). | |
| autonomy_result_t | autonomy_get_last_result (void) |
| Outcome of the most recent run (AUTONOMY_RESULT_NONE until one happens). | |
| autonomy_test_t | autonomy_get_last_type (void) |
| Workload of the most recent run (valid when the last result is not NONE). | |
| uint32_t | autonomy_get_last_duration_s (void) |
| Duration of the most recent run in seconds (0 if none). | |
| bool | autonomy_get_last_dump_ok (void) |
| Whether the most recent run has been successfully written to the SD card. | |
Battery autonomy self-test: run a workload on battery until shutdown, log a curve.
Drives a characterisation run: the user charges to 100%, picks a workload, and the board runs on battery until it shuts itself off, logging a discharge curve so the autonomy can be read back from an SD CSV on the next boot. The service owns the run state and the logging; the in-progress UI is a screensaver-like mode in the UI task, and the maintenance task drives autonomy_tick().
Storage: the discharge curve accumulates in RAM and is rewritten to a single NVS blob on every sample (bounded to a fixed sample count by halving the rate when full), so the run survives any shutdown — graceful or a crash. On the next boot autonomy_boot_export() writes it out as a CSV on the SD card. The NVS partition here is only 24 KB, hence the bound rather than a full-detail curve.