forked from len0rd/rockbox
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
This commit is contained in:
parent
204be7f637
commit
e3ee1908dd
8 changed files with 26 additions and 14 deletions
|
@ -259,7 +259,7 @@ static int usbcharging_callback(int action,
|
||||||
MENUITEM_SETTING(usb_charging, &global_settings.usb_charging, usbcharging_callback);
|
MENUITEM_SETTING(usb_charging, &global_settings.usb_charging, usbcharging_callback);
|
||||||
#endif /* HAVE_USB_CHARGING_ENABLE */
|
#endif /* HAVE_USB_CHARGING_ENABLE */
|
||||||
MAKE_MENU(battery_menu, ID2P(LANG_BATTERY_MENU), 0, Icon_NOICON,
|
MAKE_MENU(battery_menu, ID2P(LANG_BATTERY_MENU), 0, Icon_NOICON,
|
||||||
#if defined(BATTERY_CAPACITY_INC) && BATTERY_CAPACITY_INC > 0
|
#if BATTERY_CAPACITY_INC > 0
|
||||||
&battery_capacity,
|
&battery_capacity,
|
||||||
#endif
|
#endif
|
||||||
#if BATTERY_TYPES_COUNT > 1
|
#if BATTERY_TYPES_COUNT > 1
|
||||||
|
|
|
@ -567,7 +567,12 @@ enum plugin_status plugin_start(const void* parameter)
|
||||||
,MODEL_NAME,rb->rbversion);
|
,MODEL_NAME,rb->rbversion);
|
||||||
|
|
||||||
rb->fdprintf(fd, "# Battery type: %d mAh Buffer Entries: %d\n",
|
rb->fdprintf(fd, "# Battery type: %d mAh Buffer Entries: %d\n",
|
||||||
rb->global_settings->battery_capacity, (int)BUF_ELEMENTS);
|
#if BATTERY_CAPACITY_INC > 0
|
||||||
|
rb->global_settings->battery_capacity,
|
||||||
|
#else
|
||||||
|
BATTERY_CAPACITY_DEFAULT,
|
||||||
|
#endif
|
||||||
|
(int)BUF_ELEMENTS);
|
||||||
|
|
||||||
rb->fdprintf(fd, "# Rockbox has been running for %02d:%02d:%02d\n",
|
rb->fdprintf(fd, "# Rockbox has been running for %02d:%02d:%02d\n",
|
||||||
HMS((unsigned)start_tick/HZ));
|
HMS((unsigned)start_tick/HZ));
|
||||||
|
|
|
@ -835,7 +835,7 @@ void settings_apply(bool read_disk)
|
||||||
set_keypress_restarts_sleep_timer(
|
set_keypress_restarts_sleep_timer(
|
||||||
global_settings.keypress_restarts_sleeptimer);
|
global_settings.keypress_restarts_sleeptimer);
|
||||||
|
|
||||||
#if defined(BATTERY_CAPACITY_INC) && BATTERY_CAPACITY_INC > 0
|
#if BATTERY_CAPACITY_INC > 0
|
||||||
/* only call if it's really exchangable */
|
/* only call if it's really exchangable */
|
||||||
set_battery_capacity(global_settings.battery_capacity);
|
set_battery_capacity(global_settings.battery_capacity);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -608,10 +608,9 @@ struct user_settings
|
||||||
|
|
||||||
/* power settings */
|
/* power settings */
|
||||||
int poweroff; /* idle power off timer */
|
int poweroff; /* idle power off timer */
|
||||||
#if BATTERY_CAPACITY_DEFAULT > 0
|
#if BATTERY_CAPACITY_INC > 0
|
||||||
int battery_capacity; /* in mAh */
|
int battery_capacity; /* in mAh */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BATTERY_TYPES_COUNT > 1
|
#if BATTERY_TYPES_COUNT > 1
|
||||||
int battery_type; /* for units which can take multiple types (Ondio). */
|
int battery_type; /* for units which can take multiple types (Ondio). */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1036,13 +1036,7 @@ const struct settings_list settings[] = {
|
||||||
NULL, NULL, NULL),
|
NULL, NULL, NULL),
|
||||||
/* use this setting for user code even if there's no exchangable battery
|
/* use this setting for user code even if there's no exchangable battery
|
||||||
* support enabled */
|
* support enabled */
|
||||||
#if BATTERY_CAPACITY_DEFAULT > 0
|
#if BATTERY_CAPACITY_INC > 0
|
||||||
/* define min/max/inc for this file if there's only one battery */
|
|
||||||
#ifndef BATTERY_CAPACITY_MIN
|
|
||||||
#define BATTERY_CAPACITY_MIN BATTERY_CAPACITY_DEFAULT
|
|
||||||
#define BATTERY_CAPACITY_MAX BATTERY_CAPACITY_DEFAULT
|
|
||||||
#define BATTERY_CAPACITY_INC 0
|
|
||||||
#endif
|
|
||||||
#if defined(IPOD_VIDEO) && !defined(SIMULATOR)
|
#if defined(IPOD_VIDEO) && !defined(SIMULATOR)
|
||||||
/* its easier to leave this one un-macro()ed for the time being */
|
/* its easier to leave this one un-macro()ed for the time being */
|
||||||
{ F_T_INT|F_DEF_ISFUNC|F_INT_SETTING, &global_settings.battery_capacity,
|
{ F_T_INT|F_DEF_ISFUNC|F_INT_SETTING, &global_settings.battery_capacity,
|
||||||
|
|
|
@ -709,6 +709,14 @@ Lyre prototype 1 */
|
||||||
#define BATTERY_CAPACITY_DEFAULT 0
|
#define BATTERY_CAPACITY_DEFAULT 0
|
||||||
#endif
|
#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
|
#ifndef BATTERY_CAPACITY_INC
|
||||||
#define BATTERY_CAPACITY_INC 0
|
#define BATTERY_CAPACITY_INC 0
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -157,8 +157,10 @@ void battery_read_info(int *voltage, int *level);
|
||||||
bool battery_level_safe(void);
|
bool battery_level_safe(void);
|
||||||
|
|
||||||
void set_poweroff_timeout(int timeout);
|
void set_poweroff_timeout(int timeout);
|
||||||
|
#if BATTERY_CAPACITY_INC > 0
|
||||||
void set_battery_capacity(int capacity); /* set local battery capacity value */
|
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_battery_type(int type); /* set local battery type */
|
||||||
|
|
||||||
void set_sleeptimer_duration(int minutes);
|
void set_sleeptimer_duration(int minutes);
|
||||||
|
|
|
@ -114,7 +114,11 @@ int _battery_time(void) { return powermgmt_est_runningtime_min; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* default value, mAh */
|
/* default value, mAh */
|
||||||
|
#if BATTERY_CAPACITY_INC > 0
|
||||||
static int battery_capacity = BATTERY_CAPACITY_DEFAULT;
|
static int battery_capacity = BATTERY_CAPACITY_DEFAULT;
|
||||||
|
#else
|
||||||
|
# define battery_capacity BATTERY_CAPACITY_DEFAULT
|
||||||
|
#endif
|
||||||
|
|
||||||
#if BATTERY_TYPES_COUNT > 1
|
#if BATTERY_TYPES_COUNT > 1
|
||||||
static int battery_type = 0;
|
static int battery_type = 0;
|
||||||
|
@ -170,7 +174,7 @@ void set_battery_type(int type)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BATTERY_CAPACITY_MIN
|
#if BATTERY_CAPACITY_INC > 0
|
||||||
void set_battery_capacity(int capacity)
|
void set_battery_capacity(int capacity)
|
||||||
{
|
{
|
||||||
if (capacity > BATTERY_CAPACITY_MAX)
|
if (capacity > BATTERY_CAPACITY_MAX)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue