FS#13538 export and import battery level tables

when battery_bench is run
exports a file in the rockbox directory called 'battery_levels.default'

if the user wants their own levels they can rename the file battery_levels.cfg
and it will be loaded at boot

some minimal error checking is performed prior to using the values

added manual entry

Change-Id: Ia0126faced0c7229fcf8385a1bcb584b5a9dc378
This commit is contained in:
William Wilgus 2025-01-11 18:54:53 -05:00 committed by William Wilgus
parent 3539dd5a70
commit 10f8312db4
79 changed files with 611 additions and 298 deletions

View file

@ -25,25 +25,25 @@
#include "power.h"
#include "audiohw.h"
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
unsigned short battery_level_disksafe[BATTERY_TYPES_COUNT] =
{
3600
};
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
{
3350
};
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
{
{ 3550, 3783, 3830, 3882, 3911, 3949, 3996, 4067, 4148, 4228, 4310 }
};
#if CONFIG_CHARGING
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
const unsigned short percent_to_volt_charge[11] =
unsigned short percent_to_volt_charge[11] =
{
3550, 3783, 3830, 3882, 3911, 3949, 3996, 4067, 4148, 4228, 4310
};

View file

@ -32,27 +32,27 @@
Discharge and charge curves have not been calibrated yet.
*/
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
unsigned short battery_level_disksafe[BATTERY_TYPES_COUNT] =
{
/* TODO: this is just an initial guess */
3400
};
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
{
/* TODO: this is just an initial guess */
3300
};
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
{
/* TODO: simple uncalibrated curve, linear except for first 10% */
{ 3300, 3600, 3665, 3730, 3795, 3860, 3925, 3990, 4055, 4120, 4185 }
};
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
const unsigned short percent_to_volt_charge[11] =
unsigned short percent_to_volt_charge[11] =
/* TODO: simple uncalibrated curve, linear except for first 10% */
{ 3300, 3600, 3665, 3730, 3795, 3860, 3925, 3990, 4055, 4120, 4185 };

View file

@ -24,20 +24,20 @@
#include "adc.h"
#include "adc-target.h"
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
unsigned short battery_level_disksafe[BATTERY_TYPES_COUNT] =
{
/* TODO: this is just an initial guess */
3400
};
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
{
/* TODO: this is just an initial guess */
3300
};
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
{
/* TODO: simple uncalibrated curve, linear except for first 10% */
{ 3300, 3390, 3480, 3570, 3660, 3750, 3840, 3930, 4020, 4110, 4200 }
@ -45,7 +45,7 @@ const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
#if CONFIG_CHARGING
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
const unsigned short percent_to_volt_charge[11] =
unsigned short percent_to_volt_charge[11] =
{
/* TODO: simple uncalibrated curve, linear except for first 10% */
3300, 3390, 3480, 3570, 3660, 3750, 3840, 3930, 4020, 4110, 4200