Rework powermgmt to enable code re-use on appliation and sims.

* Introduce CONFIG_BATTERY_MEASURE define, to allow targets (application)
to break powermgmt.c's assumption about the ability to read battery voltage.
There's now additionally percentage (android) and remaining time measure
(maemo). No measure at all also works (sdl app). If voltage can't be measured,
then battery_level() is king and it'll be used for power_history and runtime
estimation.

* Implement target's API in the simulator, i.e. _battery_voltage(), so it
doesn't need to implement it's own powermgmt.c and other stubs. Now
the sim behaves much more like a native target, although it still
changes the simulated battery voltage quickly,

* Other changes include include renaming battery_adc_voltage() to
_battery_voltage(), for consistency with the new target functions and
making some of the apps code aware that voltage and runtime estimation
is not always available.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31548 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2012-01-03 23:44:38 +00:00
parent 949e6398c8
commit c1bd9b0361
156 changed files with 525 additions and 384 deletions

View File

@ -900,8 +900,7 @@ static bool tsc2100_debug(void)
return simplelist_show_list(&info);
}
#endif
#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0)
#ifdef HAVE_LCD_BITMAP
#if (CONFIG_BATTERY_MEASURE != 0) && defined(HAVE_LCD_BITMAP) && !defined(SIMULATOR)
/*
* view_battery() shows a automatically scaled graph of the battery voltage
* over time. Usable for estimating battery life / charging rate.
@ -909,13 +908,14 @@ static bool tsc2100_debug(void)
*/
#define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
#define BAT_YSPACE (LCD_HEIGHT - 20)
#define BAT_TSPACE 20
#define BAT_YSPACE (LCD_HEIGHT - BAT_TSPACE)
static bool view_battery(void)
{
int view = 0;
int i, x, y, y1, y2, grid, graph;
int i, x, y, z, y1, y2, grid, graph;
unsigned short maxv, minv;
lcd_setfont(FONT_SYSFIXED);
@ -934,19 +934,28 @@ static bool view_battery(void)
if (power_history[i] < minv)
minv = power_history[i];
}
/* print header */
#if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE)
/* adjust grid scale */
if ((maxv - minv) > 50)
grid = 50;
else
grid = 5;
/* print header */
lcd_putsf(0, 0, "battery %d.%03dV", power_history[0] / 1000,
power_history[0] % 1000);
lcd_putsf(0, 1, "%d.%03d-%d.%03dV (%2dmV)",
minv / 1000, minv % 1000, maxv / 1000, maxv % 1000,
grid);
#elif (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE)
/* adjust grid scale */
if ((maxv - minv) > 10)
grid = 10;
else
grid = 1;
lcd_putsf(0, 0, "battery %d%%", power_history[0]);
lcd_putsf(0, 1, "%d%%-%d%% (%d %%)", minv, maxv, grid);
#endif
i = 1;
while ((y = (minv - (minv % grid)+i*grid)) < maxv)
@ -971,11 +980,11 @@ static bool view_battery(void)
{
y1 = (power_history[i] - minv) * BAT_YSPACE /
(maxv - minv);
y1 = MIN(MAX(LCD_HEIGHT-1 - y1, 20),
y1 = MIN(MAX(LCD_HEIGHT-1 - y1, BAT_TSPACE),
LCD_HEIGHT-1);
y2 = (power_history[i-1] - minv) * BAT_YSPACE /
(maxv - minv);
y2 = MIN(MAX(LCD_HEIGHT-1 - y2, 20),
y2 = MIN(MAX(LCD_HEIGHT-1 - y2, BAT_TSPACE),
LCD_HEIGHT-1);
lcd_set_drawmode(DRMODE_SOLID);
@ -999,10 +1008,13 @@ static bool view_battery(void)
lcd_putsf(0, 0, "Pwr status: %s",
charging_state() ? "charging" : "discharging");
#else
lcd_puts(0, 0, "Power status:");
lcd_puts(0, 0, "Power status: unknown");
#endif
battery_read_info(&y, NULL);
lcd_putsf(0, 1, "Battery: %d.%03d V", y / 1000, y % 1000);
battery_read_info(&y, &z);
if (y > 0)
lcd_putsf(0, 1, "Battery: %d.%03d V (%d %%)", y / 1000, y % 1000, z);
else if (z > 0)
lcd_putsf(0, 1, "Battery: %d %%", z);
#ifdef ADC_EXT_POWER
y = (adc_read(ADC_EXT_POWER) * EXT_SCALE_FACTOR) / 1000;
lcd_putsf(0, 2, "External: %d.%03d V", y / 1000, y % 1000);
@ -1169,16 +1181,23 @@ static bool view_battery(void)
#endif /* target type */
#endif /* CONFIG_CHARGING */
break;
case 2: /* voltage deltas: */
#if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE)
lcd_puts(0, 0, "Voltage deltas:");
for (i = 0; i <= 6; i++) {
for (i = 0; i < POWER_HISTORY_LEN-1; i++) {
y = power_history[i] - power_history[i+1];
lcd_putsf(0, i+1, "-%d min: %s%d.%03d V", i,
(y < 0) ? "-" : "", ((y < 0) ? y * -1 : y) / 1000,
lcd_putsf(0, i+1, "-%d min: %c%d.%03d V", i,
(y < 0) ? '-' : ' ', ((y < 0) ? y * -1 : y) / 1000,
((y < 0) ? y * -1 : y ) % 1000);
}
#elif (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE)
lcd_puts(0, 0, "Percentage deltas:");
for (i = 0; i < POWER_HISTORY_LEN-1; i++) {
y = power_history[i] - power_history[i+1];
lcd_putsf(0, i+1, "-%d min: %c%d%%", i,
(y < 0) ? '-' : ' ', ((y < 0) ? y * -1 : y));
}
#endif
break;
case 3: /* remaining time estimation: */
@ -1195,13 +1214,19 @@ static bool view_battery(void)
lcd_putsf(0, 4, "Trickle sec: %d/60", trickle_sec);
#endif /* ARCHOS_RECORDER */
#if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE)
lcd_putsf(0, 5, "Last PwrHist: %d.%03dV",
power_history[0] / 1000,
power_history[0] % 1000);
#endif
lcd_putsf(0, 6, "battery level: %d%%", battery_level());
lcd_putsf(0, 7, "Est. remain: %d m", battery_time());
int time_left = battery_time();
if (time_left >= 0)
lcd_putsf(0, 7, "Est. remain: %d m", time_left);
else
lcd_puts(0, 7, "Estimation n/a");
break;
}
@ -1228,8 +1253,7 @@ static bool view_battery(void)
return false;
}
#endif /* HAVE_LCD_BITMAP */
#endif
#endif /* (CONFIG_BATTERY_MEASURE != 0) && HAVE_LCD_BITMAP */
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
#if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
@ -2168,7 +2192,7 @@ static const struct the_menu_item menuitems[] = {
{ "View CPU stats", dbg_cpuinfo },
#endif
#ifdef HAVE_LCD_BITMAP
#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0)
#if (CONFIG_BATTERY_MEASURE != 0) && !defined(SIMULATOR)
{ "View battery", view_battery },
#endif
#ifndef APPLICATION

View File

@ -1068,9 +1068,13 @@ const char *get_token_value(struct gui_wps *gwps,
case SKIN_TOKEN_BATTERY_VOLTS:
{
unsigned int v = battery_voltage();
snprintf(buf, buf_size, "%d.%02d", v / 1000, (v % 1000) / 10);
return buf;
int v = battery_voltage();
if (v >= 0) {
snprintf(buf, buf_size, "%d.%02d", v / 1000, (v % 1000) / 10);
return buf;
} else {
return "?";
}
}
case SKIN_TOKEN_BATTERY_TIME:

View File

@ -210,7 +210,7 @@ static const char* info_getname(int selected_item, void *data,
snprintf(buffer, buffer_len, str(LANG_BATTERY_TIME),
battery_level(), battery_time() / 60, battery_time() % 60);
else
return "(n/a)";
return "Battery n/a"; /* translating worth it? */
break;
case INFO_DISK1: /* disk usage 1 */
#ifdef HAVE_MULTIVOLUME
@ -289,9 +289,11 @@ static int info_speak_item(int selected_item, void * data)
#endif /* CONFIG_CHARGING = */
if (battery_level() >= 0)
{
int time_left = battery_time();
talk_id(LANG_BATTERY_TIME, false);
talk_value(battery_level(), UNIT_PERCENT, true);
talk_value(battery_time() *60, UNIT_TIME, true);
if (time_left >= 0)
talk_value(time_left * 60, UNIT_TIME, true);
}
else talk_id(VOICE_BLANK, false);
break;

View File

@ -219,7 +219,11 @@ MAKE_MENU(bars_menu, ID2P(LANG_BARS_MENU), 0, Icon_NOICON,
#if CONFIG_KEYPAD == RECORDER_PAD
&buttonbar,
#endif
&volume_type, &battery_display);
&volume_type
#if (CONFIG_BATTERY_MEASURE != 0)
, &battery_display
#endif
);
#endif /* HAVE_LCD_BITMAP */
/* */

View File

@ -277,6 +277,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
if (batt_safe)
{
int level;
#ifdef HAVE_TAGCACHE
if (!tagcache_prepare_shutdown())
{
@ -285,7 +286,8 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
return false;
}
#endif
if (battery_level() > 10)
level = battery_level();
if (level > 10 || level < 0)
splash(0, str(LANG_SHUTTINGDOWN));
else
{

View File

@ -664,9 +664,7 @@ static const struct plugin_api rockbox_api = {
battery_level,
battery_level_safe,
battery_time,
#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0)
battery_voltage,
#endif
#if CONFIG_CHARGING
charger_inserted,
# if CONFIG_CHARGING >= CHARGING_MONITOR

View File

@ -794,9 +794,7 @@ struct plugin_api {
int (*battery_level)(void);
bool (*battery_level_safe)(void);
int (*battery_time)(void);
#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0)
unsigned int (*battery_voltage)(void);
#endif
int (*battery_voltage)(void);
#if CONFIG_CHARGING
bool (*charger_inserted)(void);
# if CONFIG_CHARGING >= CHARGING_MONITOR

View File

@ -1,5 +1,5 @@
/* plugins common to all models */
#ifndef SIMULATOR
#if !defined(SIMULATOR) && (CONFIG_BATTERY_MEASURE != 0)
battery_bench.c
#endif
chessclock.c

View File

@ -638,7 +638,7 @@ struct user_settings
/* power settings */
int poweroff; /* idle power off timer */
#ifdef BATTERY_CAPACITY_DEFAULT
#if BATTERY_CAPACITY_DEFAULT > 0
int battery_capacity; /* in mAh */
#endif

View File

@ -838,7 +838,7 @@ const struct settings_list settings[] = {
NULL, NULL, NULL),
/* use this setting for user code even if there's no exchangable battery
* support enabled */
#ifdef BATTERY_CAPACITY_DEFAULT
#if BATTERY_CAPACITY_DEFAULT > 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

View File

@ -358,7 +358,7 @@ void main(void)
printf("Version " RBVERSION);
adc_init();
batt = battery_adc_voltage();
batt = _battery_voltage();
printf("Battery: %d.%03d V", batt / 1000, batt % 1000);
check_battery_safe();

View File

@ -110,7 +110,7 @@ void check_battery(void)
{
int battery_voltage, batt_int, batt_frac;
battery_voltage = battery_adc_voltage();
battery_voltage = _battery_voltage();
batt_int = battery_voltage / 1000;
batt_frac = (battery_voltage % 1000) / 10;

View File

@ -170,7 +170,7 @@ void check_battery(void)
{
int battery_voltage, batt_int, batt_frac;
battery_voltage = battery_adc_voltage();
battery_voltage = _battery_voltage();
batt_int = battery_voltage / 1000;
batt_frac = (battery_voltage % 1000) / 10;

View File

@ -112,7 +112,7 @@ void check_battery(void)
{
int battery_voltage, batt_int, batt_frac;
battery_voltage = battery_adc_voltage();
battery_voltage = _battery_voltage();
batt_int = battery_voltage / 1000;
batt_frac = (battery_voltage % 1000) / 10;

View File

@ -160,7 +160,7 @@ static void check_battery(void)
int battery_voltage, batt_int, batt_frac;
battery_voltage = battery_adc_voltage();
battery_voltage = _battery_voltage();
batt_int = battery_voltage / 1000;
batt_frac = (battery_voltage % 1000) / 10;

View File

@ -14,7 +14,6 @@ target/hosted/cpuinfo-linux.c
#endif
#ifndef SAMSUNG_YPR0 /* uses as3514 rtc */
target/hosted/powermgmt.c
target/hosted/rtc.c
#endif
#endif

View File

@ -59,3 +59,5 @@ void audiohw_set_balance(int balance)
{
(void)balance;
}
void audiohw_close(void) {}

View File

@ -167,6 +167,9 @@ void audiohw_set_eq_band_width(unsigned int band, int value)
void audiohw_set_depth_3d(int value)
{ (void)value; }
#endif
void audiohw_close(void) {}
#ifdef CONFIG_SAMPR_TYPES
unsigned int pcm_sampr_to_hw_sampr(unsigned int samplerate,
unsigned int type)

View File

@ -184,6 +184,15 @@
* charging or specific programming is required to
* use the charging hardware. */
/* CONFIG_BATTERY_MEASURE bits */
#define VOLTAGE_MEASURE 1 /* Target can report battery voltage
* Usually native ports */
#define PERCENTAGE_MEASURE 2 /* Target can report remaining capacity in %
* Usually application/hosted ports */
#define TIME_MEASURE 4 /* Target can report remaining time estimation
Usually application ports, and only
if the estimation is better that ours
(which it probably is) */
/* CONFIG_LCD */
#define LCD_SSD1815 1 /* as used by Archos Recorders and Ondios */
#define LCD_SSD1801 2 /* as used by Archos Player/Studio */
@ -603,6 +612,11 @@ Lyre prototype 1 */
#define CONFIG_CHARGING 0
#endif
#ifndef CONFIG_BATTERY_MEASURE
#define CONFIG_BATTERY_MEASURE 0
#define NO_LOW_BATTERY_SHUTDOWN
#endif
#ifndef CONFIG_RTC
#define CONFIG_RTC 0
#endif
@ -611,6 +625,10 @@ Lyre prototype 1 */
#define BATTERY_TYPES_COUNT 0
#endif
#ifndef BATTERY_CAPACITY_DEFAULT
#define BATTERY_CAPACITY_DEFAULT 0
#endif
#ifndef BATTERY_CAPACITY_INC
#define BATTERY_CAPACITY_INC 0
#endif

View File

@ -86,11 +86,9 @@
#define HAVE_HEADPHONE_DETECTION
/* Define current usage levels. */
#define CURRENT_NORMAL 88 /* 18 hours from a 1600 mAh battery */
#define CURRENT_BACKLIGHT 30 /* TBD */
#define CURRENT_RECORD 0 /* no recording yet */
#define CONFIG_BATTERY_MEASURE PERCENTAGE_MEASURE
#define NO_LOW_BATTERY_SHUTDOWN
/* Define this to the CPU frequency */
/*
#define CPU_FREQ 48000000

View File

@ -91,6 +91,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
#define CURRENT_NORMAL 145 /* usual current in mA */
#define CURRENT_RECORD 35 /* additional recording current */
#define CURRENT_USB 500 /* usual current in mA in USB mode */

View File

@ -73,6 +73,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* define this if the unit should not shut down on low battery. */
#define NO_LOW_BATTERY_SHUTDOWN

View File

@ -60,6 +60,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* define this if the unit should not shut down on low battery. */
#define NO_LOW_BATTERY_SHUTDOWN

View File

@ -49,6 +49,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
#define CURRENT_NORMAL 145 /* usual current in mA */
#define CURRENT_USB 500 /* usual current in mA in USB mode */

View File

@ -80,6 +80,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
#if MEMORYSIZE < 8
#define CURRENT_NORMAL 145 /* usual current in mA */
#else

View File

@ -86,6 +86,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
#define CURRENT_NORMAL 145 /* usual current in mA */
#define CURRENT_RECORD 35 /* additional recording current */
#define CURRENT_USB 500 /* usual current in mA in USB mode */

View File

@ -136,6 +136,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -130,6 +130,8 @@
#define BATTERY_CAPACITY_INC 100 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging with monitoring */
//#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -129,6 +129,8 @@
#define BATTERY_CAPACITY_INC 25 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging with monitoring */
#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -173,6 +173,8 @@
#define BATTERY_CAPACITY_INC 25 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* TODO: have a proper status displayed in the bootloader and have it
* work! */
/* Charging implemented in a target-specific algorithm */

View File

@ -141,6 +141,8 @@
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -144,6 +144,8 @@
#define BATTERY_CAPACITY_INC 20 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -125,6 +125,8 @@
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Charging implemented in a target-specific algorithm */
#define CONFIG_CHARGING CHARGING_TARGET
#define HAVE_POWEROFF_WHILE_CHARGING

View File

@ -130,6 +130,8 @@
#define BATTERY_CAPACITY_INC 10 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging with monitoring */
#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -118,6 +118,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging with monitoring */
#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -131,6 +131,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
#define CONFIG_CHARGING CHARGING_SIMPLE
/* Define this if you have a TCC770 */

View File

@ -114,6 +114,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging? FIXME */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -138,6 +138,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging? FIXME */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -141,6 +141,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging? FIXME */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -130,6 +130,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging? FIXME */
//#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -137,6 +137,8 @@
#define BATTERY_CAPACITY_INC 10 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging? FIXME */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -143,6 +143,8 @@
#define BATTERY_CAPACITY_INC 10 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging? */
#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -145,6 +145,8 @@
#define BATTERY_CAPACITY_INC 10 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging with monitoring */
#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -130,6 +130,8 @@
#define BATTERY_CAPACITY_INC 10 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging? */
#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -141,6 +141,8 @@
#define BATTERY_CAPACITY_INC 10 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* define current usage levels */
#define CURRENT_NORMAL 50 /* PP5024 uses ~40mA, so add some for disk */
#define CURRENT_BACKLIGHT 20 /* FIXME: This needs to be measured */

View File

@ -142,6 +142,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* define current usage levels */
#define CURRENT_NORMAL 50 /* PP5024 uses ~40mA, so add some for disk */
#define CURRENT_BACKLIGHT 20 /* FIXME: This needs to be measured */

View File

@ -134,6 +134,8 @@
#define BATTERY_CAPACITY_INC 20 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging with monitoring */
#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -148,6 +148,8 @@
#define BATTERY_CAPACITY_INC 10 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging with monitoring */
#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -149,6 +149,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging with monitoring */
#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -127,6 +127,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -131,6 +131,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -110,6 +110,8 @@
#define BATTERY_CAPACITY_INC 10 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -135,6 +135,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -130,6 +130,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging with monitoring */
#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -70,6 +70,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* define this if the unit should not shut down on low battery. */
#define NO_LOW_BATTERY_SHUTDOWN

View File

@ -102,6 +102,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* define this if the unit should not shut down on low battery. */
#define NO_LOW_BATTERY_SHUTDOWN

View File

@ -84,6 +84,8 @@
#define BATTERY_CAPACITY_INC 100 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
#define CONFIG_CPU AT91SAM9260
/* Define this to the CPU frequency */

View File

@ -119,6 +119,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging, software can monitor plug and charge state */
#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -119,6 +119,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging? FIXME */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -125,6 +125,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging? FIXME */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -95,6 +95,8 @@
#define BATTERY_CAPACITY_INC 100 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/***************************************************************************/

View File

@ -116,6 +116,8 @@
#define CODEC_SRCTRL_88200HZ (0x1E << 1)
#define BATTERY_TYPES_COUNT 1
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
#define BATTERY_CAPACITY_DEFAULT 850 /* this is wild guess */
#define BATTERY_CAPACITY_MIN 800 /* min. capacity selectable */
#define BATTERY_CAPACITY_MAX 2500 /* max. capacity selectable */

View File

@ -119,6 +119,8 @@
#define CODEC_SRCTRL_88200HZ (0x1E << 1)
#define BATTERY_TYPES_COUNT 1
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
#define BATTERY_CAPACITY_DEFAULT 1200 /* this is wild guess */
#define BATTERY_CAPACITY_MIN 800 /* min. capacity selectable */
#define BATTERY_CAPACITY_MAX 2500 /* max. capacity selectable */

View File

@ -142,6 +142,8 @@
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -197,6 +197,8 @@
#define BATTERY_CAPACITY_INC 100 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* define current usage levels */
#define CURRENT_NORMAL 85 /* Measured */
#define CURRENT_BACKLIGHT 200 /* Over 200 mA total measured when on */

View File

@ -74,12 +74,11 @@
#define HAVE_SDL
#define HAVE_SDL_AUDIO
#define HAVE_SW_TONE_CONTROLS
#define HAVE_SW_TONE_CONTROLS
/* Define current usage levels. */
#define CURRENT_NORMAL 88 /* 18 hours from a 1600 mAh battery */
#define CURRENT_BACKLIGHT 30 /* TBD */
#define CURRENT_RECORD 0 /* no recording yet */
/* can provide both remaining percentage and time information */
#define CONFIG_BATTERY_MEASURE (PERCENTAGE_MEASURE|TIME_MEASURE)
#define NO_LOW_BATTERY_SHUTDOWN
/* Define this to the CPU frequency */
/*

View File

@ -74,14 +74,11 @@
#define HAVE_SDL
#define HAVE_SDL_AUDIO
#define HAVE_SW_TONE_CONTROLS
#define HAVE_SW_TONE_CONTROLS
/* Define current usage levels. */
#define CURRENT_NORMAL 88 /* 18 hours from a 1600 mAh battery */
#define CURRENT_BACKLIGHT 30 /* TBD */
#define CURRENT_RECORD 0 /* no recording yet */
/* Define this to the CPU frequency */
/* can provide both remaining percentage and time information */
#define CONFIG_BATTERY_MEASURE (PERCENTAGE_MEASURE|TIME_MEASURE)
#define NO_LOW_BATTERY_SHUTDOWN
/*
#define CPU_FREQ 48000000
*/

View File

@ -157,6 +157,8 @@
#define BATTERY_CAPACITY_INC 100 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging with monitoring */
#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -132,6 +132,8 @@
#define BATTERY_CAPACITY_INC 100 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging with monitoring */
//#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -151,6 +151,8 @@
#define BATTERY_CAPACITY_INC 100 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging with monitoring */
#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -136,6 +136,8 @@
#define BATTERY_CAPACITY_INC 10 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging with monitoring */
#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -134,6 +134,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -141,6 +141,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -138,6 +138,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -132,6 +132,8 @@
#define CURRENT_NORMAL 24 /* ~25h, on 600mAh that's about 24mA */
#define CURRENT_BACKLIGHT 62 /* ~6,5h -> 92mA. Minus 24mA normal that gives us 68mA */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Linux controlls charging, we can monitor */
#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -118,6 +118,8 @@
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging, software can monitor plug and charge state */
#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -92,6 +92,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* define this if the unit should not shut down on low battery. */
#define NO_LOW_BATTERY_SHUTDOWN

View File

@ -142,6 +142,8 @@
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Charging implemented in a target-specific algorithm */
#define CONFIG_CHARGING CHARGING_TARGET
#define HAVE_POWEROFF_WHILE_CHARGING

View File

@ -138,6 +138,8 @@
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Charging implemented in a target-specific algorithm */
#define CONFIG_CHARGING CHARGING_TARGET

View File

@ -141,6 +141,8 @@
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Charging implemented in a target-specific algorithm */
#define CONFIG_CHARGING CHARGING_TARGET

View File

@ -148,6 +148,8 @@
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Charging implemented in a target-specific algorithm */
#define CONFIG_CHARGING CHARGING_TARGET

View File

@ -144,6 +144,8 @@
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Charging implemented in a target-specific algorithm */
#define CONFIG_CHARGING CHARGING_TARGET

View File

@ -149,6 +149,8 @@
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Charging implemented in a target-specific algorithm */
#define CONFIG_CHARGING CHARGING_TARGET

View File

@ -149,6 +149,8 @@
#define BATTERY_CAPACITY_INC 100 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* define current usage levels */
#if 0
/* TODO */

View File

@ -142,6 +142,8 @@
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Charging implemented in a target-specific algorithm */
#define CONFIG_CHARGING CHARGING_TARGET
#define HAVE_POWEROFF_WHILE_CHARGING

View File

@ -152,6 +152,8 @@
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Charging implemented in a target-specific algorithm */
#define CONFIG_CHARGING CHARGING_TARGET

View File

@ -156,6 +156,8 @@
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Charging implemented in a target-specific algorithm */
#define CONFIG_CHARGING CHARGING_TARGET

View File

@ -140,6 +140,8 @@
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Charging implemented in a target-specific algorithm */
#define CONFIG_CHARGING CHARGING_TARGET

View File

@ -161,6 +161,8 @@
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Charging implemented in a target-specific algorithm */
#define CONFIG_CHARGING CHARGING_TARGET

View File

@ -98,6 +98,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* define this if the unit should not shut down on low battery. */
#define NO_LOW_BATTERY_SHUTDOWN

View File

@ -118,6 +118,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* define this if the unit should not shut down on low battery. */
#define NO_LOW_BATTERY_SHUTDOWN

View File

@ -129,6 +129,8 @@
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Charging implemented in a target-specific algorithm */
#define CONFIG_CHARGING CHARGING_SIMPLE
#define HAVE_POWEROFF_WHILE_CHARGING

View File

@ -80,11 +80,6 @@
#define HAVE_SW_TONE_CONTROLS
/* Define current usage levels. */
#define CURRENT_NORMAL 88 /* 18 hours from a 1600 mAh battery */
#define CURRENT_BACKLIGHT 30 /* TBD */
#define CURRENT_RECORD 0 /* no recording yet */
/* Define this to the CPU frequency */
/*
#define CPU_FREQ 48000000

View File

@ -36,6 +36,11 @@
#undef CONFIG_STORAGE
#if defined(CONFIG_CHARGING) && CONFIG_CHARGING > CHARGING_MONITOR
#undef CONFIG_CHARGING
#define CONFIG_CHARGING CHARGING_MONITOR
#endif
#undef CONFIG_USBOTG
#undef USB_HANDLED_BY_OF

View File

@ -85,6 +85,8 @@
#define BATTERY_CAPACITY_INC 10 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging? FIXME */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -126,6 +126,8 @@
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging, software can monitor plug and charge state */
#define CONFIG_CHARGING CHARGING_SIMPLE

View File

@ -131,6 +131,8 @@
#define BATTERY_CAPACITY_INC 100 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging with monitoring */
//#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -130,6 +130,8 @@
#define BATTERY_CAPACITY_INC 100 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Hardware controlled charging with monitoring */
//#define CONFIG_CHARGING CHARGING_MONITOR

View File

@ -23,7 +23,6 @@
#include "config.h"
#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0) || defined(SIMULATOR)
#if CONFIG_CHARGING
enum power_input_flags {
/* No external power source? Default. */
@ -101,6 +100,4 @@ bool tuner_power(bool status);
bool tuner_powered(void);
#endif
#endif
#endif /* _POWER_H_ */

View File

@ -78,8 +78,6 @@ extern unsigned int power_thread_inputs;
/* Start up power management thread */
void powermgmt_init(void) INIT_ATTR;
#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0)
/* Generic current values that are intentionally meaningless - config header
* should define proper numbers.*/
@ -130,13 +128,18 @@ extern const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11];
extern const unsigned short percent_to_volt_charge[11];
#endif
#endif /* PLATFORM_NATIVE */
/* Returns battery statust */
/* Returns battery status, filtered for runtime estimation */
int battery_level(void); /* percent */
int battery_time(void); /* minutes */
unsigned int battery_adc_voltage(void); /* voltage from ADC in millivolts */
unsigned int battery_voltage(void); /* filtered batt. voltage in millivolts */
int battery_voltage(void); /* filtered batt. voltage in millivolts */
/* Implemented by the target, unfiltered */
int _battery_level(void); /* percent */
int _battery_time(void); /* minutes */
int _battery_voltage(void); /* voltage in millivolts */
#if CONFIG_CHARGING >= CHARGING_TARGET
void powermgmt_init_target(void);
#endif
#ifdef HAVE_BATTERY_SWITCH
unsigned int input_millivolts(void); /* voltage that device is running from */

Some files were not shown because too many files have changed in this diff Show More