|
TB2026-YDS Firmware
|
Self-measured battery autonomy: workload run + discharge-curve logging. More...

Files | |
| file | components/services/autonomy/autonomy.c |
| Autonomy test service: run lifecycle, discharge-curve logging, SD export. | |
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. | |
Self-measured battery autonomy: workload run + discharge-curve logging.
| enum autonomy_result_t |
Outcome of the most recent run, for the UI's "Last run" block.
| enum autonomy_test_t |
| 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.
Reads the NVS run blob; if one is present and not yet exported, writes it as a CSV to the SD card, marks it exported, and populates the "last run" fields for the UI. Requires the SD card to be mounted. A no-op if there is no stored run. Also loads the last-run summary for the UI even when the run was already exported on an earlier boot.
| void autonomy_cancel | ( | void | ) |
Cancel the running test, keeping it as the last (cancelled) result. No-op if idle.
| bool autonomy_get_last_dump_ok | ( | void | ) |
Whether the most recent run has been successfully written to the SD card.
| uint32_t autonomy_get_last_duration_s | ( | void | ) |
Duration of the most recent run in seconds (0 if none).
| 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).
| void autonomy_get_status | ( | autonomy_status_t * | out | ) |
Copy the running test's snapshot.
| [out] | out | Receives the snapshot; ignored if NULL. |
| bool autonomy_is_running | ( | void | ) |
Whether a run is currently in progress.
| esp_err_t autonomy_redump | ( | void | ) |
Re-export the last stored run to a fresh CSV on the SD card (without rebooting).
Writes the run currently held in RAM (loaded at boot by autonomy_boot_export(), or the one that just ended this session) out to a new uniquely-named CSV, to confirm the SD write path. A no-op while a run is in progress.
| esp_err_t autonomy_start | ( | autonomy_test_t | type | ) |
Start an autonomy run with the given workload.
IDLE stops playback (silence). JACK and BT measure whatever is already playing on the respective output: the caller must have a track playing on the DAC (JACK) or on a connected Bluetooth sink (BT) first. The run pins that stream down for the duration — it forces loop-one (so it never ends early) and a fixed pot-independent volume (JACK 50%, BT a near-silent 1% — BT amplifies in the externally powered speaker, so its level does not affect this board's draw) — and restores both when the run ends.
| type | Workload to exercise. |
| void autonomy_tick | ( | void | ) |
Periodic hook, called from the maintenance task (after power_tick()).
Samples the discharge curve at the current interval and persists it. While a run is in progress it also owns the end: once the cell is near-empty (power_soc_at_shutdown(), on battery, not charging) it writes the final log and calls power_shutdown(). No-op when no run is in progress.