Sansa Connect: Read HDQ battery data

Make it possible for target to provide voltage, percentage and time to
empty values. The voltage measurement is nice to have in debug menu even
if the actions are taken only based on percentage. Perform battery level
estimation based on voltage only if percentage is not available.

Use time to empty based on actual power consumption. This makes the
estimated runtime displayed in Rockbox Info to react to backlight
setting. The bq27000 updates time to empty estimate every 5.12 seconds
so it is possible to see the estimate with backlight off on the screen
if user enters Rockbox Info, activates hold switch, waits 11 seconds and
releases the hold switch.

Change-Id: Iafe3fa0fb334e3428e3a0ad05b2c020d208dc934
This commit is contained in:
Tomasz Moń 2021-07-07 08:22:50 +02:00
parent b87e75f768
commit 841e704fc3
No known key found for this signature in database
GPG key ID: 92BA8820D4D517C8
5 changed files with 153 additions and 15 deletions

View file

@ -152,7 +152,15 @@
#define BATTERY_CAPACITY_INC 100 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE PERCENTAGE_MEASURE
/* bq27000 provides voltage, percentage and time measure.
* Voltage reading is available every 2.56 seconds and does not need filtering.
* Read the measured voltage every 3 seconds so we are guaranteed to not read
* the same value twice (do not try to read every 2.56 seconds as clocks are
* not synchronized).
*/
#define CONFIG_BATTERY_MEASURE (VOLTAGE_MEASURE|PERCENTAGE_MEASURE|TIME_MEASURE)
#define BATT_AVE_SAMPLES 1
#define POWER_THREAD_STEP_TICKS (3*HZ)
/* define current usage levels */
#if 0