forked from len0rd/rockbox
More fixes for when both battery PERCENTAGE and VOLTAGE are enabled
Hopefully this fixes the last of the red Change-Id: I732a595cfda088fb5517a15d83c29427dfc18137
This commit is contained in:
parent
07b0015d17
commit
46eb089f97
1 changed files with 6 additions and 8 deletions
|
@ -302,9 +302,7 @@ static void send_battery_level_event(int percent)
|
|||
}
|
||||
}
|
||||
|
||||
#if (!(CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE) && \
|
||||
(CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE)) || \
|
||||
(CONFIG_BATTERY_MEASURE & (PERCENTAGE_MEASURE | VOLTAGE_MEASURE))
|
||||
#if CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE
|
||||
/* Look into the percent_to_volt_* table and estimate the battery level. */
|
||||
static int voltage_to_percent(int voltage, const short* table)
|
||||
{
|
||||
|
@ -352,7 +350,7 @@ static int voltage_to_battery_level(int millivolts)
|
|||
|
||||
return level;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE */
|
||||
|
||||
/* Update battery percentage and time remaining information.
|
||||
*
|
||||
|
@ -435,7 +433,7 @@ void battery_read_info(int *voltage, int *level)
|
|||
*voltage = millivolts;
|
||||
|
||||
if (level) {
|
||||
#if (CONFIG_BATTERY_MEASURE & (PERCENTAGE_MEASURE | VOLTAGE_MEASURE))
|
||||
#if ((CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE) && (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE))
|
||||
*level = _battery_level();
|
||||
if (*level == -1) {
|
||||
*level = voltage_to_battery_level(millivolts);
|
||||
|
@ -488,8 +486,7 @@ bool battery_level_safe(void)
|
|||
{
|
||||
#if defined(NO_LOW_BATTERY_SHUTDOWN)
|
||||
return true;
|
||||
#elif CONFIG_BATTERY_MEASURE & (PERCENTAGE_MEASURE | VOLTAGE_MEASURE)
|
||||
/* if we have both, prefer voltage? */
|
||||
#elif ((CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE) && (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE))
|
||||
return voltage_now > battery_level_dangerous[battery_type];
|
||||
#elif CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE
|
||||
return percent_now > 0;
|
||||
|
@ -522,7 +519,8 @@ bool query_force_shutdown(void)
|
|||
|
||||
#if defined(NO_LOW_BATTERY_SHUTDOWN)
|
||||
return false;
|
||||
#elif CONFIG_BATTERY_MEASURE & (PERCENTAGE_MEASURE | VOLTAGE_MEASURE)
|
||||
#elif ((CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE) && (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE))
|
||||
/* If we have both, prefer voltage */
|
||||
return voltage_now < battery_level_shutoff[battery_type];
|
||||
#elif CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE
|
||||
return percent_now == 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue