diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2021-11-29 20:59:05 +0000 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2021-12-05 13:37:25 -0500 |
commit | e3ee1908ddf99711b65b46fdab0c7b4ddca7867d (patch) | |
tree | ae466471001efac7e1d8072fd124094c387bbd3d /firmware | |
parent | 204be7f637b36e1c5c7615fe1381f45ad58e293d (diff) | |
download | rockbox-e3ee1908ddf99711b65b46fdab0c7b4ddca7867d.tar.gz rockbox-e3ee1908ddf99711b65b46fdab0c7b4ddca7867d.zip |
powermgmt: Small cleanups to battery capacity code
- Don't include the 'battery capacity' setting unless the
target allows changing it.
- Clean up the preprocessor conditionals used to check for
variable battery capacity support.
- Don't use a variable for battery capacity unless it is
actually needed.
Change-Id: I3d8a338f107014f2c5098bc0a44ef0cfb4df9356
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/export/config.h | 8 | ||||
-rw-r--r-- | firmware/export/powermgmt.h | 4 | ||||
-rw-r--r-- | firmware/powermgmt.c | 6 |
3 files changed, 16 insertions, 2 deletions
diff --git a/firmware/export/config.h b/firmware/export/config.h index bb3f405d6a..277a1d8632 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -709,6 +709,14 @@ Lyre prototype 1 */ #define BATTERY_CAPACITY_DEFAULT 0 #endif +#ifndef BATTERY_CAPACITY_MIN +#define BATTERY_CAPACITY_MIN BATTERY_CAPACITY_DEFAULT +#endif + +#ifndef BATTERY_CAPACITY_MAX +#define BATTERY_CAPACITY_MAX BATTERY_CAPACITY_DEFAULT +#endif + #ifndef BATTERY_CAPACITY_INC #define BATTERY_CAPACITY_INC 0 #endif diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h index f45690573a..329e64d653 100644 --- a/firmware/export/powermgmt.h +++ b/firmware/export/powermgmt.h @@ -157,8 +157,10 @@ void battery_read_info(int *voltage, int *level); bool battery_level_safe(void); void set_poweroff_timeout(int timeout); +#if BATTERY_CAPACITY_INC > 0 void set_battery_capacity(int capacity); /* set local battery capacity value */ -int get_battery_capacity(void); /* get local battery capacity value */ +#endif +int get_battery_capacity(void); /* get local battery capacity value */ void set_battery_type(int type); /* set local battery type */ void set_sleeptimer_duration(int minutes); diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 8c807e5382..8e47b19721 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c @@ -114,7 +114,11 @@ int _battery_time(void) { return powermgmt_est_runningtime_min; } #endif /* default value, mAh */ +#if BATTERY_CAPACITY_INC > 0 static int battery_capacity = BATTERY_CAPACITY_DEFAULT; +#else +# define battery_capacity BATTERY_CAPACITY_DEFAULT +#endif #if BATTERY_TYPES_COUNT > 1 static int battery_type = 0; @@ -170,7 +174,7 @@ void set_battery_type(int type) } #endif -#ifdef BATTERY_CAPACITY_MIN +#if BATTERY_CAPACITY_INC > 0 void set_battery_capacity(int capacity) { if (capacity > BATTERY_CAPACITY_MAX) |