From 841e704fc3b5bde96ca8de4794c85198e2f12a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mo=C5=84?= Date: Wed, 7 Jul 2021 08:22:50 +0200 Subject: 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 --- firmware/export/config/sansaconnect.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'firmware/export') diff --git a/firmware/export/config/sansaconnect.h b/firmware/export/config/sansaconnect.h index 5668d579fc..fa929f3c10 100644 --- a/firmware/export/config/sansaconnect.h +++ b/firmware/export/config/sansaconnect.h @@ -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 -- cgit v1.2.3