summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/debug_menu.c66
-rw-r--r--apps/gui/skin_engine/skin_tokens.c10
-rw-r--r--apps/menus/main_menu.c6
-rw-r--r--apps/menus/theme_menu.c6
-rw-r--r--apps/misc.c4
-rw-r--r--apps/plugin.c2
-rw-r--r--apps/plugin.h4
-rw-r--r--apps/plugins/SOURCES2
-rw-r--r--apps/settings.h2
-rw-r--r--apps/settings_list.c2
-rw-r--r--bootloader/gigabeat-s.c2
-rw-r--r--bootloader/iaudio_coldfire.c2
-rw-r--r--bootloader/iriver_h1x0.c2
-rw-r--r--bootloader/iriver_h300.c2
-rw-r--r--bootloader/mpio_hd200_hd300.c2
-rw-r--r--firmware/SOURCES1
-rw-r--r--firmware/drivers/audio/android.c2
-rw-r--r--firmware/drivers/audio/sdl.c3
-rw-r--r--firmware/export/config.h18
-rw-r--r--firmware/export/config/android.h6
-rw-r--r--firmware/export/config/archosfmrecorder.h2
-rw-r--r--firmware/export/config/archosondiofm.h2
-rw-r--r--firmware/export/config/archosondiosp.h2
-rw-r--r--firmware/export/config/archosplayer.h2
-rw-r--r--firmware/export/config/archosrecorder.h2
-rw-r--r--firmware/export/config/archosrecorderv2.h2
-rw-r--r--firmware/export/config/cowond2.h2
-rw-r--r--firmware/export/config/creativezv.h2
-rw-r--r--firmware/export/config/gigabeatfx.h2
-rw-r--r--firmware/export/config/gigabeats.h2
-rw-r--r--firmware/export/config/gogearhdd1630.h2
-rw-r--r--firmware/export/config/gogearhdd6330.h2
-rw-r--r--firmware/export/config/gogearsa9200.h2
-rw-r--r--firmware/export/config/hifimanhm60x.h2
-rw-r--r--firmware/export/config/hifimanhm801.h2
-rw-r--r--firmware/export/config/iaudio7.h2
-rw-r--r--firmware/export/config/iaudiom3.h2
-rw-r--r--firmware/export/config/iaudiom5.h2
-rw-r--r--firmware/export/config/iaudiox5.h2
-rw-r--r--firmware/export/config/ipod1g2g.h2
-rw-r--r--firmware/export/config/ipod3g.h2
-rw-r--r--firmware/export/config/ipod4g.h2
-rw-r--r--firmware/export/config/ipod6g.h2
-rw-r--r--firmware/export/config/ipodcolor.h2
-rw-r--r--firmware/export/config/ipodmini1g.h2
-rw-r--r--firmware/export/config/ipodmini2g.h2
-rw-r--r--firmware/export/config/ipodnano1g.h2
-rw-r--r--firmware/export/config/ipodnano2g.h2
-rw-r--r--firmware/export/config/ipodvideo.h2
-rw-r--r--firmware/export/config/iriverh10.h2
-rw-r--r--firmware/export/config/iriverh100.h2
-rw-r--r--firmware/export/config/iriverh10_5gb.h2
-rw-r--r--firmware/export/config/iriverh120.h2
-rw-r--r--firmware/export/config/iriverh300.h2
-rw-r--r--firmware/export/config/iriverifp7xx.h2
-rw-r--r--firmware/export/config/logikdax.h2
-rw-r--r--firmware/export/config/lyreproto1.h2
-rw-r--r--firmware/export/config/meizum3.h2
-rw-r--r--firmware/export/config/meizum6sl.h2
-rw-r--r--firmware/export/config/meizum6sp.h2
-rw-r--r--firmware/export/config/mini2440.h2
-rw-r--r--firmware/export/config/mpiohd200.h2
-rw-r--r--firmware/export/config/mpiohd300.h2
-rw-r--r--firmware/export/config/mrobe100.h2
-rw-r--r--firmware/export/config/mrobe500.h2
-rw-r--r--firmware/export/config/nokian8xx.h9
-rw-r--r--firmware/export/config/nokian900.h11
-rw-r--r--firmware/export/config/ondavx747.h2
-rw-r--r--firmware/export/config/ondavx767.h2
-rw-r--r--firmware/export/config/ondavx777.h2
-rw-r--r--firmware/export/config/rk27generic.h2
-rw-r--r--firmware/export/config/samsungyh820.h2
-rw-r--r--firmware/export/config/samsungyh920.h2
-rw-r--r--firmware/export/config/samsungyh925.h2
-rw-r--r--firmware/export/config/samsungypr0.h2
-rw-r--r--firmware/export/config/samsungyps3.h2
-rw-r--r--firmware/export/config/sansac100.h2
-rw-r--r--firmware/export/config/sansac200.h2
-rw-r--r--firmware/export/config/sansac200v2.h2
-rw-r--r--firmware/export/config/sansaclip.h2
-rw-r--r--firmware/export/config/sansaclipplus.h2
-rw-r--r--firmware/export/config/sansaclipv2.h2
-rw-r--r--firmware/export/config/sansaclipzip.h2
-rw-r--r--firmware/export/config/sansaconnect.h2
-rw-r--r--firmware/export/config/sansae200.h2
-rw-r--r--firmware/export/config/sansae200v2.h2
-rw-r--r--firmware/export/config/sansafuze.h2
-rw-r--r--firmware/export/config/sansafuzeplus.h2
-rw-r--r--firmware/export/config/sansafuzev2.h2
-rw-r--r--firmware/export/config/sansam200.h2
-rw-r--r--firmware/export/config/sansam200v4.h2
-rw-r--r--firmware/export/config/sansaview.h2
-rw-r--r--firmware/export/config/sdlapp.h5
-rw-r--r--firmware/export/config/sim.h5
-rw-r--r--firmware/export/config/tatungtpj1022.h2
-rw-r--r--firmware/export/config/vibe500.h2
-rw-r--r--firmware/export/config/zenvisionm30gb.h2
-rw-r--r--firmware/export/config/zenvisionm60gb.h2
-rw-r--r--firmware/export/power.h3
-rw-r--r--firmware/export/powermgmt.h17
-rw-r--r--firmware/powermgmt.c252
-rw-r--r--firmware/target/arm/as3525/sansa-m200v4/powermgmt-m200v4.c2
-rw-r--r--firmware/target/arm/imx233/debug-imx233.c2
-rw-r--r--firmware/target/arm/imx233/powermgmt-imx233.c2
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c6
-rw-r--r--firmware/target/arm/ipod/1g2g/powermgmt-1g2g.c2
-rw-r--r--firmware/target/arm/ipod/powermgmt-ipod-pcf.c2
-rw-r--r--firmware/target/arm/iriver/h10/powermgmt-h10.c2
-rw-r--r--firmware/target/arm/olympus/mrobe-100/powermgmt-mr100.c2
-rw-r--r--firmware/target/arm/pbell/vibe500/powermgmt-vibe500.c2
-rw-r--r--firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c2
-rw-r--r--firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c2
-rw-r--r--firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c2
-rw-r--r--firmware/target/arm/powermgmt-ascodec.c4
-rw-r--r--firmware/target/arm/rk27xx/hm60x/powermgmt-hm60x.c2
-rw-r--r--firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c2
-rw-r--r--firmware/target/arm/rk27xx/rk27generic/powermgmt-rk27generic.c2
-rw-r--r--firmware/target/arm/s3c2440/gigabeat-fx/powermgmt-meg-fx.c2
-rw-r--r--firmware/target/arm/s3c2440/mini2440/powermgmt-mini2440.c2
-rw-r--r--firmware/target/arm/s5l8700/ipodnano2g/powermgmt-nano2g.c2
-rw-r--r--firmware/target/arm/s5l8700/meizu-m3/powermgmt-m3.c2
-rw-r--r--firmware/target/arm/s5l8700/meizu-m6sp/powermgmt-m6sp.c2
-rw-r--r--firmware/target/arm/s5l8702/ipod6g/powermgmt-ipod6g.c2
-rw-r--r--firmware/target/arm/samsung/yh820/powermgmt-yh820.c2
-rw-r--r--firmware/target/arm/samsung/yh920/powermgmt-yh920.c2
-rw-r--r--firmware/target/arm/samsung/yh925/powermgmt-yh925.c2
-rw-r--r--firmware/target/arm/sandisk/sansa-view/powermgmt-view.c2
-rw-r--r--firmware/target/arm/tatung/tpj1022/powermgmt-tpj1022.c2
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/powermgmt-iaudio7.c2
-rw-r--r--firmware/target/arm/tcc77x/powermgmt-tcc77x.c2
-rw-r--r--firmware/target/arm/tcc780x/cowond2/powermgmt-cowond2.c2
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c2
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c2
-rw-r--r--firmware/target/arm/tms320dm320/sansa-connect/powermgmt-sansaconnect.c2
-rw-r--r--firmware/target/coldfire/iaudio/m3/powermgmt-m3.c2
-rw-r--r--firmware/target/coldfire/iaudio/powermgmt-iaudio.c2
-rw-r--r--firmware/target/coldfire/iriver/h100/powermgmt-h100.c2
-rw-r--r--firmware/target/coldfire/iriver/h300/powermgmt-h300.c2
-rw-r--r--firmware/target/coldfire/mpio/hd200/powermgmt-hd200.c2
-rw-r--r--firmware/target/coldfire/mpio/hd300/powermgmt-hd300.c2
-rw-r--r--firmware/target/hosted/android/powermgmt-android.c28
-rw-r--r--firmware/target/hosted/android/system-android.c2
-rw-r--r--firmware/target/hosted/maemo/maemo-thread.c30
-rw-r--r--firmware/target/hosted/powermgmt.c56
-rw-r--r--firmware/target/hosted/sdl/system-sdl.c2
-rw-r--r--firmware/target/hosted/ypr0/powermgmt-ypr0.c4
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c2
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c2
-rw-r--r--firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c2
-rw-r--r--firmware/target/sh/archos/ondio/powermgmt-ondio.c2
-rw-r--r--firmware/target/sh/archos/player/powermgmt-player.c2
-rw-r--r--firmware/target/sh/archos/recorder/powermgmt-recorder.c2
-rw-r--r--uisimulator/common/SOURCES5
-rw-r--r--uisimulator/common/lcd-common.c6
-rw-r--r--uisimulator/common/powermgmt-sim.c60
-rw-r--r--uisimulator/common/stubs.c26
156 files changed, 525 insertions, 384 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index b4d917a3eb..340407176c 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -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
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c
index 169c4a36fd..bae8ae8f8e 100644
--- a/apps/gui/skin_engine/skin_tokens.c
+++ b/apps/gui/skin_engine/skin_tokens.c
@@ -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:
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c
index cefc395b3d..b7472a6849 100644
--- a/apps/menus/main_menu.c
+++ b/apps/menus/main_menu.c
@@ -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;
diff --git a/apps/menus/theme_menu.c b/apps/menus/theme_menu.c
index e1077a5efd..5e04191ed1 100644
--- a/apps/menus/theme_menu.c
+++ b/apps/menus/theme_menu.c
@@ -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 */
/* */
diff --git a/apps/misc.c b/apps/misc.c
index b1def596ab..30c747113c 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -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
{
diff --git a/apps/plugin.c b/apps/plugin.c
index f17ad3c57a..25280750ce 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -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
diff --git a/apps/plugin.h b/apps/plugin.h
index 0bb7262bd8..918206ab69 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -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
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES
index 1b14c0dd5e..a72579e3da 100644
--- a/apps/plugins/SOURCES
+++ b/apps/plugins/SOURCES
@@ -1,5 +1,5 @@
/* plugins common to all models */
-#ifndef SIMULATOR
+#if !defined(SIMULATOR) && (CONFIG_BATTERY_MEASURE != 0)
battery_bench.c
#endif
chessclock.c
diff --git a/apps/settings.h b/apps/settings.h
index 676e5bfb56..d0fd3204e9 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -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
diff --git a/apps/settings_list.c b/apps/settings_list.c
index c9003bb8f3..dff5ed26f4 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -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
diff --git a/bootloader/gigabeat-s.c b/bootloader/gigabeat-s.c
index 909194e1b2..04c32423a0 100644
--- a/bootloader/gigabeat-s.c
+++ b/bootloader/gigabeat-s.c
@@ -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();
diff --git a/bootloader/iaudio_coldfire.c b/bootloader/iaudio_coldfire.c
index 9c829c4a34..b22af0e006 100644
--- a/bootloader/iaudio_coldfire.c
+++ b/bootloader/iaudio_coldfire.c
@@ -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;
diff --git a/bootloader/iriver_h1x0.c b/bootloader/iriver_h1x0.c
index 1afbafa830..9042737406 100644
--- a/bootloader/iriver_h1x0.c
+++ b/bootloader/iriver_h1x0.c
@@ -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;
diff --git a/bootloader/iriver_h300.c b/bootloader/iriver_h300.c
index 893532cac7..b6d7da20fa 100644
--- a/bootloader/iriver_h300.c
+++ b/bootloader/iriver_h300.c
@@ -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;
diff --git a/bootloader/mpio_hd200_hd300.c b/bootloader/mpio_hd200_hd300.c
index be36daf2ef..3e4ba76c83 100644
--- a/bootloader/mpio_hd200_hd300.c
+++ b/bootloader/mpio_hd200_hd300.c
@@ -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;
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 0143b9c2d5..2dd8b7b5b4 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -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
diff --git a/firmware/drivers/audio/android.c b/firmware/drivers/audio/android.c
index 300bb08482..8bd026320c 100644
--- a/firmware/drivers/audio/android.c
+++ b/firmware/drivers/audio/android.c
@@ -59,3 +59,5 @@ void audiohw_set_balance(int balance)
{
(void)balance;
}
+
+void audiohw_close(void) {}
diff --git a/firmware/drivers/audio/sdl.c b/firmware/drivers/audio/sdl.c
index 1a42466e2e..b9df35b852 100644
--- a/firmware/drivers/audio/sdl.c
+++ b/firmware/drivers/audio/sdl.c
@@ -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)
diff --git a/firmware/export/config.h b/firmware/export/config.h
index f5bc7788d7..85c83015bd 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -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
diff --git a/firmware/export/config/android.h b/firmware/export/config/android.h
index 41ecacfb9d..6261a80b06 100644
--- a/firmware/export/config/android.h
+++ b/firmware/export/config/android.h
@@ -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
diff --git a/firmware/export/config/archosfmrecorder.h b/firmware/export/config/archosfmrecorder.h
index 3e2c7e932e..6b1f07f752 100644
--- a/firmware/export/config/archosfmrecorder.h
+++ b/firmware/export/config/archosfmrecorder.h
@@ -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 */
diff --git a/firmware/export/config/archosondiofm.h b/firmware/export/config/archosondiofm.h
index 516845e49d..1a1115f318 100644
--- a/firmware/export/config/archosondiofm.h
+++ b/firmware/export/config/archosondiofm.h
@@ -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
diff --git a/firmware/export/config/archosondiosp.h b/firmware/export/config/archosondiosp.h
index ba957f7f44..aad66b7f45 100644
--- a/firmware/export/config/archosondiosp.h
+++ b/firmware/export/config/archosondiosp.h
@@ -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
diff --git a/firmware/export/config/archosplayer.h b/firmware/export/config/archosplayer.h
index bc75433950..af125571ba 100644
--- a/firmware/export/config/archosplayer.h
+++ b/firmware/export/config/archosplayer.h
@@ -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 */
diff --git a/firmware/export/config/archosrecorder.h b/firmware/export/config/archosrecorder.h
index be7c872b0e..6c708fb450 100644
--- a/firmware/export/config/archosrecorder.h
+++ b/firmware/export/config/archosrecorder.h
@@ -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
diff --git a/firmware/export/config/archosrecorderv2.h b/firmware/export/config/archosrecorderv2.h
index e2f3b66a82..dae34ef226 100644
--- a/firmware/export/config/archosrecorderv2.h
+++ b/firmware/export/config/archosrecorderv2.h
@@ -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 */
diff --git a/firmware/export/config/cowond2.h b/firmware/export/config/cowond2.h
index ebaa636ac7..03fbb4fbb8 100644
--- a/firmware/export/config/cowond2.h
+++ b/firmware/export/config/cowond2.h
@@ -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
diff --git a/firmware/export/config/creativezv.h b/firmware/export/config/creativezv.h
index 0fd216aae6..568144b698 100644
--- a/firmware/export/config/creativezv.h
+++ b/firmware/export/config/creativezv.h
@@ -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
diff --git a/firmware/export/config/gigabeatfx.h b/firmware/export/config/gigabeatfx.h
index b64f3f5b3b..fbaa4a0f31 100644
--- a/firmware/export/config/gigabeatfx.h
+++ b/firmware/export/config/gigabeatfx.h
@@ -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
diff --git a/firmware/export/config/gigabeats.h b/firmware/export/config/gigabeats.h
index 685076bfa3..f7fdc449c4 100644
--- a/firmware/export/config/gigabeats.h
+++ b/firmware/export/config/gigabeats.h
@@ -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 */
diff --git a/firmware/export/config/gogearhdd1630.h b/firmware/export/config/gogearhdd1630.h
index e9bbfb872a..05f1a472a6 100644
--- a/firmware/export/config/gogearhdd1630.h
+++ b/firmware/export/config/gogearhdd1630.h
@@ -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
diff --git a/firmware/export/config/gogearhdd6330.h b/firmware/export/config/gogearhdd6330.h
index fc326dac89..b8ee918da1 100644
--- a/firmware/export/config/gogearhdd6330.h
+++ b/firmware/export/config/gogearhdd6330.h
@@ -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
diff --git a/firmware/export/config/gogearsa9200.h b/firmware/export/config/gogearsa9200.h
index b91430e6de..e29c8dcddc 100644
--- a/firmware/export/config/gogearsa9200.h
+++ b/firmware/export/config/gogearsa9200.h
@@ -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
diff --git a/firmware/export/config/hifimanhm60x.h b/firmware/export/config/hifimanhm60x.h
index 6ac43803f3..bdc6124833 100644
--- a/firmware/export/config/hifimanhm60x.h
+++ b/firmware/export/config/hifimanhm60x.h
@@ -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
diff --git a/firmware/export/config/hifimanhm801.h b/firmware/export/config/hifimanhm801.h
index 469c423a27..a5b5aeead8 100644
--- a/firmware/export/config/hifimanhm801.h
+++ b/firmware/export/config/hifimanhm801.h
@@ -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
diff --git a/firmware/export/config/iaudio7.h b/firmware/export/config/iaudio7.h
index 8a04bc06c2..0664ff00ed 100644
--- a/firmware/export/config/iaudio7.h
+++ b/firmware/export/config/iaudio7.h
@@ -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 */
diff --git a/firmware/export/config/iaudiom3.h b/firmware/export/config/iaudiom3.h
index 6fdf11ca77..d2f90641db 100644
--- a/firmware/export/config/iaudiom3.h
+++ b/firmware/export/config/iaudiom3.h
@@ -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
diff --git a/firmware/export/config/iaudiom5.h b/firmware/export/config/iaudiom5.h
index ad86308667..0bc3ed5630 100644
--- a/firmware/export/config/iaudiom5.h
+++ b/firmware/export/config/iaudiom5.h
@@ -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
diff --git a/firmware/export/config/iaudiox5.h b/firmware/export/config/iaudiox5.h
index 2083095c2b..b88583c4b1 100644
--- a/firmware/export/config/iaudiox5.h
+++ b/firmware/export/config/iaudiox5.h
@@ -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
diff --git a/firmware/export/config/ipod1g2g.h b/firmware/export/config/ipod1g2g.h
index 0ce5d45590..b2b1f4a498 100644
--- a/firmware/export/config/ipod1g2g.h
+++ b/firmware/export/config/ipod1g2g.h
@@ -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
diff --git a/firmware/export/config/ipod3g.h b/firmware/export/config/ipod3g.h
index e7d8bff53b..16bd1072b4 100644
--- a/firmware/export/config/ipod3g.h
+++ b/firmware/export/config/ipod3g.h
@@ -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
diff --git a/firmware/export/config/ipod4g.h b/firmware/export/config/ipod4g.h
index 957e3a4da5..5ddde1b186 100644
--- a/firmware/export/config/ipod4g.h
+++ b/firmware/export/config/ipod4g.h
@@ -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
diff --git a/firmware/export/config/ipod6g.h b/firmware/export/config/ipod6g.h
index 95837cce12..08c0f27ef0 100644
--- a/firmware/export/config/ipod6g.h
+++ b/firmware/export/config/ipod6g.h
@@ -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
diff --git a/firmware/export/config/ipodcolor.h b/firmware/export/config/ipodcolor.h
index cf021019b4..9768ac38aa 100644
--- a/firmware/export/config/ipodcolor.h
+++ b/firmware/export/config/ipodcolor.h
@@ -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
diff --git a/firmware/export/config/ipodmini1g.h b/firmware/export/config/ipodmini1g.h
index 04fa68e500..b1f6fa1b1a 100644
--- a/firmware/export/config/ipodmini1g.h
+++ b/firmware/export/config/ipodmini1g.h
@@ -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 */
diff --git a/firmware/export/config/ipodmini2g.h b/firmware/export/config/ipodmini2g.h
index c10284e7a4..27edf100ae 100644
--- a/firmware/export/config/ipodmini2g.h
+++ b/firmware/export/config/ipodmini2g.h
@@ -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 */
diff --git a/firmware/export/config/ipodnano1g.h b/firmware/export/config/ipodnano1g.h
index 50f0511384..40f6cf28aa 100644
--- a/firmware/export/config/ipodnano1g.h
+++ b/firmware/export/config/ipodnano1g.h
@@ -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
diff --git a/firmware/export/config/ipodnano2g.h b/firmware/export/config/ipodnano2g.h
index e0941e03b0..2e4f189d31 100644
--- a/firmware/export/config/ipodnano2g.h
+++ b/firmware/export/config/ipodnano2g.h
@@ -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
diff --git a/firmware/export/config/ipodvideo.h b/firmware/export/config/ipodvideo.h
index c4e2cb2986..7e123d08d7 100644
--- a/firmware/export/config/ipodvideo.h
+++ b/firmware/export/config/ipodvideo.h
@@ -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
diff --git a/firmware/export/config/iriverh10.h b/firmware/export/config/iriverh10.h
index d2d7a0cb7a..3611093913 100644
--- a/firmware/export/config/iriverh10.h
+++ b/firmware/export/config/iriverh10.h
@@ -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
diff --git a/firmware/export/config/iriverh100.h b/firmware/export/config/iriverh100.h
index 1a89c7ca2d..644726541f 100644
--- a/firmware/export/config/iriverh100.h
+++ b/firmware/export/config/iriverh100.h
@@ -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
diff --git a/firmware/export/config/iriverh10_5gb.h b/firmware/export/config/iriverh10_5gb.h
index 0ad83cb85d..84c0b370ab 100644
--- a/firmware/export/config/iriverh10_5gb.h
+++ b/firmware/export/config/iriverh10_5gb.h
@@ -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
diff --git a/firmware/export/config/iriverh120.h b/firmware/export/config/iriverh120.h
index 199b948245..5bab810df2 100644
--- a/firmware/export/config/iriverh120.h
+++ b/firmware/export/config/iriverh120.h
@@ -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
diff --git a/firmware/export/config/iriverh300.h b/firmware/export/config/iriverh300.h
index dbe701362a..4250153c04 100644
--- a/firmware/export/config/iriverh300.h
+++ b/firmware/export/config/iriverh300.h
@@ -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
diff --git a/firmware/export/config/iriverifp7xx.h b/firmware/export/config/iriverifp7xx.h
index 78c0783d27..1de6adc25a 100644
--- a/firmware/export/config/iriverifp7xx.h
+++ b/firmware/export/config/iriverifp7xx.h
@@ -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
diff --git a/firmware/export/config/logikdax.h b/firmware/export/config/logikdax.h
index 45f5651a43..ed6cbba531 100644
--- a/firmware/export/config/logikdax.h
+++ b/firmware/export/config/logikdax.h
@@ -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
diff --git a/firmware/export/config/lyreproto1.h b/firmware/export/config/lyreproto1.h
index 1413adc7e3..95808cf2f5 100644
--- a/firmware/export/config/lyreproto1.h
+++ b/firmware/export/config/lyreproto1.h
@@ -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 */
diff --git a/firmware/export/config/meizum3.h b/firmware/export/config/meizum3.h
index 7cba1c7e7f..d1a2b8f34a 100644
--- a/firmware/export/config/meizum3.h
+++ b/firmware/export/config/meizum3.h
@@ -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
diff --git a/firmware/export/config/meizum6sl.h b/firmware/export/config/meizum6sl.h
index 28c0fc0286..e0e5e9d43c 100644
--- a/firmware/export/config/meizum6sl.h
+++ b/firmware/export/config/meizum6sl.h
@@ -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
diff --git a/firmware/export/config/meizum6sp.h b/firmware/export/config/meizum6sp.h
index f88be0420c..34d7c92480 100644
--- a/firmware/export/config/meizum6sp.h
+++ b/firmware/export/config/meizum6sp.h
@@ -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
diff --git a/firmware/export/config/mini2440.h b/firmware/export/config/mini2440.h
index 4b4a137110..9b794ecb0a 100644
--- a/firmware/export/config/mini2440.h
+++ b/firmware/export/config/mini2440.h
@@ -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
+
/***************************************************************************/
diff --git a/firmware/export/config/mpiohd200.h b/firmware/export/config/mpiohd200.h
index f85b9a28fd..13691722f9 100644
--- a/firmware/export/config/mpiohd200.h
+++ b/firmware/export/config/mpiohd200.h
@@ -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 */
diff --git a/firmware/export/config/mpiohd300.h b/firmware/export/config/mpiohd300.h
index 6728d5cccb..8343a90938 100644
--- a/firmware/export/config/mpiohd300.h
+++ b/firmware/export/config/mpiohd300.h
@@ -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 */
diff --git a/firmware/export/config/mrobe100.h b/firmware/export/config/mrobe100.h
index 1b373a9799..510475d0f4 100644
--- a/firmware/export/config/mrobe100.h
+++ b/firmware/export/config/mrobe100.h
@@ -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
diff --git a/firmware/export/config/mrobe500.h b/firmware/export/config/mrobe500.h
index 590f8a95f9..6f8bc6c568 100644
--- a/firmware/export/config/mrobe500.h
+++ b/firmware/export/config/mrobe500.h
@@ -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 */
diff --git a/firmware/export/config/nokian8xx.h b/firmware/export/config/nokian8xx.h
index f11fa87021..55f96f76c3 100644
--- a/firmware/export/config/nokian8xx.h
+++ b/firmware/export/config/nokian8xx.h
@@ -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 */
/*
diff --git a/firmware/export/config/nokian900.h b/firmware/export/config/nokian900.h
index a36aebf8db..1e74fd527e 100644
--- a/firmware/export/config/nokian900.h
+++ b/firmware/export/config/nokian900.h
@@ -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
*/
diff --git a/firmware/export/config/ondavx747.h b/firmware/export/config/ondavx747.h
index e01c6ccc46..45aec00bb8 100644
--- a/firmware/export/config/ondavx747.h
+++ b/firmware/export/config/ondavx747.h
@@ -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
diff --git a/firmware/export/config/ondavx767.h b/firmware/export/config/ondavx767.h
index b2bac4f851..44a7aa0229 100644
--- a/firmware/export/config/ondavx767.h
+++ b/firmware/export/config/ondavx767.h
@@ -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
diff --git a/firmware/export/config/ondavx777.h b/firmware/export/config/ondavx777.h
index b9167e04ae..0319816d26 100644
--- a/firmware/export/config/ondavx777.h
+++ b/firmware/export/config/ondavx777.h
@@ -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
diff --git a/firmware/export/config/rk27generic.h b/firmware/export/config/rk27generic.h
index d7b63f0ac2..6cebb8ce2a 100644
--- a/firmware/export/config/rk27generic.h
+++ b/firmware/export/config/rk27generic.h
@@ -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
diff --git a/firmware/export/config/samsungyh820.h b/firmware/export/config/samsungyh820.h
index d7d54112f0..74cd05209e 100644
--- a/firmware/export/config/samsungyh820.h
+++ b/firmware/export/config/samsungyh820.h
@@ -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
diff --git a/firmware/export/config/samsungyh920.h b/firmware/export/config/samsungyh920.h
index 5255a05359..73f226d6c9 100644
--- a/firmware/export/config/samsungyh920.h
+++ b/firmware/export/config/samsungyh920.h
@@ -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
diff --git a/firmware/export/config/samsungyh925.h b/firmware/export/config/samsungyh925.h
index 3e072ddb86..c95d1e50d1 100644
--- a/firmware/export/config/samsungyh925.h
+++ b/firmware/export/config/samsungyh925.h
@@ -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
diff --git a/firmware/export/config/samsungypr0.h b/firmware/export/config/samsungypr0.h
index 2de36dcb74..735db1fcad 100644
--- a/firmware/export/config/samsungypr0.h
+++ b/firmware/export/config/samsungypr0.h
@@ -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
diff --git a/firmware/export/config/samsungyps3.h b/firmware/export/config/samsungyps3.h
index 3062d5c58e..cef3b60207 100644
--- a/firmware/export/config/samsungyps3.h
+++ b/firmware/export/config/samsungyps3.h
@@ -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
diff --git a/firmware/export/config/sansac100.h b/firmware/export/config/sansac100.h
index e61e42639c..5aabfc284c 100644
--- a/firmware/export/config/sansac100.h
+++ b/firmware/export/config/sansac100.h
@@ -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
diff --git a/firmware/export/config/sansac200.h b/firmware/export/config/sansac200.h
index 74d3d94b78..479623f078 100644
--- a/firmware/export/config/sansac200.h
+++ b/firmware/export/config/sansac200.h
@@ -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
diff --git a/firmware/export/config/sansac200v2.h b/firmware/export/config/sansac200v2.h
index a5b857fe81..742d66f20d 100644
--- a/firmware/export/config/sansac200v2.h
+++ b/firmware/export/config/sansac200v2.h
@@ -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
diff --git a/firmware/export/config/sansaclip.h b/firmware/export/config/sansaclip.h
index 4e214669b1..617e661555 100644
--- a/firmware/export/config/sansaclip.h
+++ b/firmware/export/config/sansaclip.h
@@ -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
diff --git a/firmware/export/config/sansaclipplus.h b/firmware/export/config/sansaclipplus.h
index 083b96a8f7..b753f585e2 100644
--- a/firmware/export/config/sansaclipplus.h
+++ b/firmware/export/config/sansaclipplus.h
@@ -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
diff --git a/firmware/export/config/sansaclipv2.h b/firmware/export/config/sansaclipv2.h
index cb2392ac76..4358fe5507 100644
--- a/firmware/export/config/sansaclipv2.h
+++ b/firmware/export/config/sansaclipv2.h
@@ -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
diff --git a/firmware/export/config/sansaclipzip.h b/firmware/export/config/sansaclipzip.h
index 043b1025fb..696125e963 100644
--- a/firmware/export/config/sansaclipzip.h
+++ b/firmware/export/config/sansaclipzip.h
@@ -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
diff --git a/firmware/export/config/sansaconnect.h b/firmware/export/config/sansaconnect.h
index 714534d6ad..a0f517992b 100644
--- a/firmware/export/config/sansaconnect.h
+++ b/firmware/export/config/sansaconnect.h
@@ -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 */
diff --git a/firmware/export/config/sansae200.h b/firmware/export/config/sansae200.h
index dd5747a9ca..c5b53e6ea2 100644
--- a/firmware/export/config/sansae200.h
+++ b/firmware/export/config/sansae200.h
@@ -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
diff --git a/firmware/export/config/sansae200v2.h b/firmware/export/config/sansae200v2.h
index a03dfe05a6..19346dbfb6 100644
--- a/firmware/export/config/sansae200v2.h
+++ b/firmware/export/config/sansae200v2.h
@@ -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
diff --git a/firmware/export/config/sansafuze.h b/firmware/export/config/sansafuze.h
index 2e9c261a04..f905bc7862 100644
--- a/firmware/export/config/sansafuze.h
+++ b/firmware/export/config/sansafuze.h
@@ -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
diff --git a/firmware/export/config/sansafuzeplus.h b/firmware/export/config/sansafuzeplus.h
index 880bbae458..1c8fdadb31 100644
--- a/firmware/export/config/sansafuzeplus.h
+++ b/firmware/export/config/sansafuzeplus.h
@@ -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
diff --git a/firmware/export/config/sansafuzev2.h b/firmware/export/config/sansafuzev2.h
index 8231236104..ae25592d1a 100644
--- a/firmware/export/config/sansafuzev2.h
+++ b/firmware/export/config/sansafuzev2.h
@@ -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
diff --git a/firmware/export/config/sansam200.h b/firmware/export/config/sansam200.h
index c5eade88e9..2c37f91a99 100644
--- a/firmware/export/config/sansam200.h
+++ b/firmware/export/config/sansam200.h
@@ -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
diff --git a/firmware/export/config/sansam200v4.h b/firmware/export/config/sansam200v4.h
index 7559361d4c..ef371e53dd 100644
--- a/firmware/export/config/sansam200v4.h
+++ b/firmware/export/config/sansam200v4.h
@@ -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
diff --git a/firmware/export/config/sansaview.h b/firmware/export/config/sansaview.h
index 829f67ab3e..89da94338f 100644
--- a/firmware/export/config/sansaview.h
+++ b/firmware/export/config/sansaview.h
@@ -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
diff --git a/firmware/export/config/sdlapp.h b/firmware/export/config/sdlapp.h
index a55b7e3be3..ac43a0fb14 100644
--- a/firmware/export/config/sdlapp.h
+++ b/firmware/export/config/sdlapp.h
@@ -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
diff --git a/firmware/export/config/sim.h b/firmware/export/config/sim.h
index f0c9f47a2f..f565e6192e 100644
--- a/firmware/export/config/sim.h
+++ b/firmware/export/config/sim.h
@@ -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
diff --git a/firmware/export/config/tatungtpj1022.h b/firmware/export/config/tatungtpj1022.h
index 247ca4780b..15d5cf2456 100644
--- a/firmware/export/config/tatungtpj1022.h
+++ b/firmware/export/config/tatungtpj1022.h
@@ -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
diff --git a/firmware/export/config/vibe500.h b/firmware/export/config/vibe500.h
index ad2299061a..da53005c5c 100644
--- a/firmware/export/config/vibe500.h
+++ b/firmware/export/config/vibe500.h
@@ -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
diff --git a/firmware/export/config/zenvisionm30gb.h b/firmware/export/config/zenvisionm30gb.h
index 335257d102..c6448132a7 100644
--- a/firmware/export/config/zenvisionm30gb.h
+++ b/firmware/export/config/zenvisionm30gb.h
@@ -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
diff --git a/firmware/export/config/zenvisionm60gb.h b/firmware/export/config/zenvisionm60gb.h
index 62353089f8..321dd5d164 100644
--- a/firmware/export/config/zenvisionm60gb.h
+++ b/firmware/export/config/zenvisionm60gb.h
@@ -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
diff --git a/firmware/export/power.h b/firmware/export/power.h
index 2aea20c27e..d46b9ba924 100644
--- a/firmware/export/power.h
+++ b/firmware/export/power.h
@@ -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_ */
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h
index 837767f56b..9e9d3d0fd8 100644
--- a/firmware/export/powermgmt.h
+++ b/firmware/export/powermgmt.h
@@ -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 */
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 008e4a45cb..b4f8aab815 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -86,7 +86,14 @@ void handle_auto_poweroff(void);
static int poweroff_timeout = 0;
static long last_event_tick = 0;
-#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0)
+#if (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE) == PERCENTAGE_MEASURE
+int _battery_voltage(void) { return -1; }
+
+const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11];
+const unsigned short percent_to_volt_charge[11];
+
+#elif (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE) == VOLTAGE_MEASURE
+int _battery_level(void) { return -1; }
/*
* Average battery voltage and charger voltage, filtered via a digital
* exponential filter (aka. exponential moving average, scaled):
@@ -95,10 +102,22 @@ static long last_event_tick = 0;
static unsigned int avgbat;
/* filtered battery voltage, millivolts */
static unsigned int battery_millivolts;
+#elif (CONFIG_BATTERY_MEASURE == 0)
+int _battery_voltage(void) { return -1; }
+int _battery_level(void) { return -1; }
+
+const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11];
+const unsigned short percent_to_volt_charge[11];
+#endif
+
+#if !(CONFIG_BATTERY_MEASURE & TIME_MEASURE)
+static int powermgmt_est_runningtime_min;
+int _battery_time(void) { return powermgmt_est_runningtime_min; }
+#endif
+
/* default value, mAh */
static int battery_capacity = BATTERY_CAPACITY_DEFAULT;
-
#if BATTERY_TYPES_COUNT > 1
static int battery_type = 0;
#else
@@ -115,7 +134,6 @@ static char power_stack[DEFAULT_STACK_SIZE/2 + POWERMGMT_DEBUG_STACK];
#endif
static const char power_thread_name[] = "power";
-static int powermgmt_est_runningtime_min = -1;
static int voltage_to_battery_level(int battery_millivolts);
static void battery_status_update(void);
@@ -126,13 +144,18 @@ static int runcurrent(void);
void battery_read_info(int *voltage, int *level)
{
- int millivolts = battery_adc_voltage();
+ int millivolts = _battery_voltage();
+ int percent;
if (voltage)
*voltage = millivolts;
- if (level)
- *level = voltage_to_battery_level(millivolts);
+ if (level) {
+ percent = voltage_to_battery_level(millivolts);
+ if (percent < 0)
+ percent = _battery_level();
+ *level = percent;
+ }
}
#if BATTERY_TYPES_COUNT > 1
@@ -148,6 +171,7 @@ void set_battery_type(int type)
}
#endif
+#ifdef BATTERY_CAPACITY_MIN
void set_battery_capacity(int capacity)
{
if (capacity > BATTERY_CAPACITY_MAX)
@@ -159,6 +183,7 @@ void set_battery_capacity(int capacity)
battery_status_update(); /* recalculate the battery status */
}
+#endif
int get_battery_capacity(void)
{
@@ -167,7 +192,16 @@ int get_battery_capacity(void)
int battery_time(void)
{
- return powermgmt_est_runningtime_min;
+#if ((CONFIG_BATTERY_MEASURE & TIME_MEASURE) == 0)
+
+#ifndef CURRENT_NORMAL /* no estimation without current */
+ return -1;
+#endif
+ if (battery_capacity <= 0) /* nor without capacity */
+ return -1;
+
+#endif
+ return _battery_time();
}
/* Returns battery level in percent */
@@ -180,17 +214,13 @@ int battery_level(void)
return battery_percent;
}
-/* Returns filtered battery voltage [millivolts] */
-unsigned int battery_voltage(void)
-{
- return battery_millivolts;
-}
-
/* Tells if the battery level is safe for disk writes */
bool battery_level_safe(void)
{
#if defined(NO_LOW_BATTERY_SHUTDOWN)
return true;
+#elif (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE)
+ return (battery_percent > 0);
#elif defined(HAVE_BATTERY_SWITCH)
/* Cannot rely upon the battery reading to be valid and the
* device could be powered externally. */
@@ -228,6 +258,9 @@ static int voltage_to_battery_level(int battery_millivolts)
{
int level;
+ if (battery_millivolts < 0)
+ return -1;
+
#if CONFIG_CHARGING >= CHARGING_MONITOR
if (charging_state()) {
/* battery level is defined to be < 100% until charging is finished */
@@ -249,7 +282,8 @@ static int voltage_to_battery_level(int battery_millivolts)
static void battery_status_update(void)
{
- int level = voltage_to_battery_level(battery_millivolts);
+ int millivolt, level;
+ battery_read_info(&millivolt, &level);
#ifdef CURRENT_NORMAL /*don't try to estimate run or charge
time without normal current defined*/
@@ -264,7 +298,8 @@ static void battery_status_update(void)
#endif
/* discharging: remaining running time */
- if (battery_millivolts > percent_to_volt_discharge[0][0]) {
+ if (level > 0 && (millivolt > percent_to_volt_discharge[battery_type][0]
+ || millivolt < 0)) {
/* linear extrapolation */
powermgmt_est_runningtime_min = (level + battery_percent)*60
* battery_capacity / 200 / runcurrent();
@@ -272,8 +307,6 @@ static void battery_status_update(void)
if (0 > powermgmt_est_runningtime_min) {
powermgmt_est_runningtime_min = 0;
}
-#else
- powermgmt_est_runningtime_min=-1;
#endif
battery_percent = level;
@@ -348,6 +381,8 @@ bool query_force_shutdown(void)
{
#if defined(NO_LOW_BATTERY_SHUTDOWN)
return false;
+#elif CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE
+ return battery_percent == 0;
#elif defined(HAVE_BATTERY_SWITCH)
/* Cannot rely upon the battery reading to be valid and the
* device could be powered externally. */
@@ -490,6 +525,101 @@ static inline bool detect_charger(unsigned int pwr)
}
#endif /* CONFIG_CHARGING */
+
+#if CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE
+/* Returns filtered battery voltage [millivolts] */
+int battery_voltage(void)
+{
+ return battery_millivolts;
+}
+
+static void average_init(void)
+{
+ /* initialize the voltages for the exponential filter */
+ avgbat = _battery_voltage() + 15;
+
+#ifdef HAVE_DISK_STORAGE /* this adjustment is only needed for HD based */
+ /* The battery voltage is usually a little lower directly after
+ turning on, because the disk was used heavily. Raise it by 5% */
+#if CONFIG_CHARGING
+ if (!charger_inserted()) /* only if charger not connected */
+#endif
+ {
+ avgbat += (percent_to_volt_discharge[battery_type][6] -
+ percent_to_volt_discharge[battery_type][5]) / 2;
+ }
+#endif /* HAVE_DISK_STORAGE */
+
+ avgbat = avgbat * BATT_AVE_SAMPLES;
+ battery_millivolts = power_history[0] = avgbat / BATT_AVE_SAMPLES;
+}
+
+static void average_step(void)
+{
+ avgbat += _battery_voltage() - avgbat / BATT_AVE_SAMPLES;
+ /*
+ * battery_millivolts is the millivolt-scaled filtered battery value.
+ */
+ battery_millivolts = avgbat / BATT_AVE_SAMPLES;
+}
+
+static void average_step_low(void)
+{
+ battery_millivolts = (_battery_voltage() + battery_millivolts + 1) / 2;
+ avgbat += battery_millivolts - avgbat / BATT_AVE_SAMPLES;
+}
+
+static void init_battery_percent(void)
+{
+#if CONFIG_CHARGING
+ if (charger_inserted()) {
+ battery_percent = voltage_to_percent(battery_millivolts,
+ percent_to_volt_charge);
+ }
+ else
+#endif
+ {
+ battery_percent = voltage_to_percent(battery_millivolts,
+ percent_to_volt_discharge[battery_type]);
+ battery_percent += battery_percent < 100;
+ }
+
+}
+
+static int power_hist_item(void)
+{
+ return battery_millivolts;
+}
+#define power_history_unit() battery_millivolts
+
+#else
+int battery_voltage(void)
+{
+ return -1;
+}
+
+static void average_init(void) {}
+static void average_step(void) {}
+static void average_step_low(void) {}
+static void init_battery_percent(void)
+{
+ battery_percent = _battery_level();
+}
+
+static int power_hist_item(void)
+{
+ return battery_percent;
+}
+#endif
+
+static void collect_power_history(void)
+{
+ /* rotate the power history */
+ memmove(&power_history[1], &power_history[0],
+ sizeof(power_history) - sizeof(power_history[0]));
+ power_history[0] = power_hist_item();
+}
+
/*
* Monitor the presence of a charger and perform critical frequent steps
* such as running the battery voltage filter.
@@ -519,33 +649,23 @@ static inline void power_thread_step(void)
|| charger_input_state == CHARGER
#endif
) {
- avgbat += battery_adc_voltage() - avgbat / BATT_AVE_SAMPLES;
- /*
- * battery_millivolts is the millivolt-scaled filtered battery value.
- */
- battery_millivolts = avgbat / BATT_AVE_SAMPLES;
-
+ average_step();
/* update battery status every time an update is available */
battery_status_update();
}
else if (battery_percent < 8) {
+ average_step_low();
+ /* update battery status every time an update is available */
+ battery_status_update();
+
/*
* If battery is low, observe voltage during disk activity.
* Shut down if voltage drops below shutoff level and we are not
* using NiMH or Alkaline batteries.
*/
- battery_millivolts = (battery_adc_voltage() +
- battery_millivolts + 1) / 2;
-
- /* update battery status every time an update is available */
- battery_status_update();
-
if (!shutdown_timeout && query_force_shutdown()) {
sys_poweroff();
}
- else {
- avgbat += battery_millivolts - avgbat / BATT_AVE_SAMPLES;
- }
}
} /* power_thread_step */
@@ -555,7 +675,7 @@ static void power_thread(void)
/* Delay reading the first battery level */
#ifdef MROBE_100
- while (battery_adc_voltage() > 4200) /* gives false readings initially */
+ while (_battery_voltage() > 4200) /* gives false readings initially */
#endif
{
sleep(HZ/100);
@@ -566,38 +686,13 @@ static void power_thread(void)
power_thread_inputs = power_input_status();
#endif
- /* initialize the voltages for the exponential filter */
- avgbat = battery_adc_voltage() + 15;
-
-#ifdef HAVE_DISK_STORAGE /* this adjustment is only needed for HD based */
- /* The battery voltage is usually a little lower directly after
- turning on, because the disk was used heavily. Raise it by 5% */
-#if CONFIG_CHARGING
- if (!charger_inserted()) /* only if charger not connected */
-#endif
- {
- avgbat += (percent_to_volt_discharge[battery_type][6] -
- percent_to_volt_discharge[battery_type][5]) / 2;
- }
-#endif /* HAVE_DISK_STORAGE */
-
- avgbat = avgbat * BATT_AVE_SAMPLES;
- battery_millivolts = avgbat / BATT_AVE_SAMPLES;
- power_history[0] = battery_millivolts;
-
-#if CONFIG_CHARGING
- if (charger_inserted()) {
- battery_percent = voltage_to_percent(battery_millivolts,
- percent_to_volt_charge);
- }
- else
-#endif
- {
- battery_percent = voltage_to_percent(battery_millivolts,
- percent_to_volt_discharge[battery_type]);
- battery_percent += battery_percent < 100;
- }
-
+ /* initialize voltage averaging (if available) */
+ average_init();
+ /* get initial battery level value (in %) */
+ init_battery_percent();
+ /* get some initial data for the power curve */
+ collect_power_history();
+ /* call target specific init now */
powermgmt_init_target();
next_power_hist = current_tick + HZ*60;
@@ -609,7 +704,7 @@ static void power_thread(void)
#ifdef HAVE_BATTERY_SWITCH
if ((pwr ^ power_thread_inputs) & POWER_INPUT_BATTERY) {
sleep(HZ/10);
- reset_battery_filter(battery_adc_voltage());
+ reset_battery_filter(_battery_voltage());
}
#endif
power_thread_inputs = pwr;
@@ -627,21 +722,15 @@ static void power_thread(void)
/* Perform target tasks */
charging_algorithm_step();
- if (TIME_BEFORE(current_tick, next_power_hist))
- continue;
-
- /* increment to ensure there is a record for every minute
- * rather than go forward from the current tick */
- next_power_hist += HZ*60;
-
- /* rotate the power history */
- memmove(&power_history[1], &power_history[0],
- sizeof(power_history) - sizeof(power_history[0]));
-
- /* insert new value at the start, in millivolts 8-) */
- power_history[0] = battery_millivolts;
-
+ /* check if some idle or sleep timer wears off */
handle_auto_poweroff();
+
+ if (TIME_AFTER(current_tick, next_power_hist)) {
+ /* increment to ensure there is a record for every minute
+ * rather than go forward from the current tick */
+ next_power_hist += HZ*60;
+ collect_power_history();
+ }
}
} /* power_thread */
@@ -701,7 +790,6 @@ void shutdown_hw(void)
sleep(HZ/4);
power_off();
}
-#endif /* PLATFORM_NATIVE */
void set_poweroff_timeout(int timeout)
{
@@ -855,12 +943,10 @@ void handle_auto_poweroff(void)
last_event_tick = current_tick;
}
-#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0)
if (!shutdown_timeout && query_force_shutdown()) {
backlight_on();
sys_poweroff();
}
-#endif
if (timeout &&
#if CONFIG_TUNER
diff --git a/firmware/target/arm/as3525/sansa-m200v4/powermgmt-m200v4.c b/firmware/target/arm/as3525/sansa-m200v4/powermgmt-m200v4.c
index cbd2c4bf27..829ed36a8e 100644
--- a/firmware/target/arm/as3525/sansa-m200v4/powermgmt-m200v4.c
+++ b/firmware/target/arm/as3525/sansa-m200v4/powermgmt-m200v4.c
@@ -52,7 +52,7 @@ const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_VBAT) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/imx233/debug-imx233.c b/firmware/target/arm/imx233/debug-imx233.c
index 228d2abcdb..82ad86f148 100644
--- a/firmware/target/arm/imx233/debug-imx233.c
+++ b/firmware/target/arm/imx233/debug-imx233.c
@@ -153,7 +153,7 @@ bool dbg_hw_info_adc(void)
lcd_clear_display();
/* add battery readout in mV, this it is not the direct output of a channel */
- lcd_putsf(0, 0, "Battery(mV) %d", battery_adc_voltage());
+ lcd_putsf(0, 0, "Battery(mV) %d", _battery_voltage());
for(unsigned i = 0; i < NUM_ADC_CHANNELS; i++)
{
lcd_putsf(0, i + 1, "%s %d", imx233_adc_channel_name[i],
diff --git a/firmware/target/arm/imx233/powermgmt-imx233.c b/firmware/target/arm/imx233/powermgmt-imx233.c
index 87c48e7655..0f3336d602 100644
--- a/firmware/target/arm/imx233/powermgmt-imx233.c
+++ b/firmware/target/arm/imx233/powermgmt-imx233.c
@@ -38,7 +38,7 @@ static int timeout_topping_off; /* timeout before stopping charging after toppin
static int timeout_4p2_ilimit_increase; /* timeout before increasing 4p2 ilimit */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
/* battery value is in 8mV LSB */
return __XTRACT(HW_POWER_BATTMONITOR, BATT_VAL) * 8;
diff --git a/firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c
index d87e367cba..1a8e12182a 100644
--- a/firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c
@@ -53,7 +53,7 @@ const unsigned short percent_to_volt_charge[11] =
};
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
/* ADC reading 0-1023 = 2400mV-4700mV */
return ((adc_read(ADC_BATTERY) * 2303) >> 10) + 2400;
@@ -249,7 +249,7 @@ static int stat_battery_reading(int type)
switch (type)
{
case ADC_BATTERY:
- reading = battery_adc_voltage();
+ reading = _battery_voltage();
break;
case ADC_CHARGER_CURRENT:
@@ -780,7 +780,7 @@ static void charger_control(void)
/* Battery voltage may have dropped and a charge cycle should
* start again. Debounced. */
if (autorecharge_counter < 0 &&
- battery_adc_voltage() < BATT_FULL_VOLTAGE)
+ _battery_voltage() < BATT_FULL_VOLTAGE)
{
/* Try starting a cycle now if battery isn't already topped
* off to allow user to ensure the battery is full. */
diff --git a/firmware/target/arm/ipod/1g2g/powermgmt-1g2g.c b/firmware/target/arm/ipod/1g2g/powermgmt-1g2g.c
index 1bc5de9986..c3eca14332 100644
--- a/firmware/target/arm/ipod/1g2g/powermgmt-1g2g.c
+++ b/firmware/target/arm/ipod/1g2g/powermgmt-1g2g.c
@@ -57,7 +57,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^8) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
unsigned adcval = adc_read(ADC_UNREG_POWER);
diff --git a/firmware/target/arm/ipod/powermgmt-ipod-pcf.c b/firmware/target/arm/ipod/powermgmt-ipod-pcf.c
index 44e908a4a2..1241f47302 100644
--- a/firmware/target/arm/ipod/powermgmt-ipod-pcf.c
+++ b/firmware/target/arm/ipod/powermgmt-ipod-pcf.c
@@ -109,7 +109,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/iriver/h10/powermgmt-h10.c b/firmware/target/arm/iriver/h10/powermgmt-h10.c
index 9970c292bc..c20d802983 100644
--- a/firmware/target/arm/iriver/h10/powermgmt-h10.c
+++ b/firmware/target/arm/iriver/h10/powermgmt-h10.c
@@ -67,7 +67,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/olympus/mrobe-100/powermgmt-mr100.c b/firmware/target/arm/olympus/mrobe-100/powermgmt-mr100.c
index c8d5584305..ae33fc5ca3 100644
--- a/firmware/target/arm/olympus/mrobe-100/powermgmt-mr100.c
+++ b/firmware/target/arm/olympus/mrobe-100/powermgmt-mr100.c
@@ -58,7 +58,7 @@ const unsigned short percent_to_volt_charge[11] =
*/
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/pbell/vibe500/powermgmt-vibe500.c b/firmware/target/arm/pbell/vibe500/powermgmt-vibe500.c
index d84881cea1..dbd7d8cbf7 100644
--- a/firmware/target/arm/pbell/vibe500/powermgmt-vibe500.c
+++ b/firmware/target/arm/pbell/vibe500/powermgmt-vibe500.c
@@ -51,7 +51,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c b/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c
index 8090c624df..7d132523e6 100644
--- a/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c
+++ b/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c
@@ -57,7 +57,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
/* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */
diff --git a/firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c b/firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c
index 8090c624df..7d132523e6 100644
--- a/firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c
+++ b/firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c
@@ -57,7 +57,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
/* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c
index 76646d368c..4ce90a4c4f 100644
--- a/firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c
+++ b/firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c
@@ -48,7 +48,7 @@ const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/powermgmt-ascodec.c b/firmware/target/arm/powermgmt-ascodec.c
index 3232a9a6fb..c05fc7bf7a 100644
--- a/firmware/target/arm/powermgmt-ascodec.c
+++ b/firmware/target/arm/powermgmt-ascodec.c
@@ -67,7 +67,7 @@ static unsigned int batt_threshold = 0;
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_BATTERY) * 5125 + 512) >> 10;
}
@@ -85,7 +85,7 @@ static void battery_voltage_sync(void)
unsigned int mv;
for (i = 0, mv = 0; i < 5; i++)
- mv += battery_adc_voltage();
+ mv += _battery_voltage();
reset_battery_filter(mv / 5);
}
diff --git a/firmware/target/arm/rk27xx/hm60x/powermgmt-hm60x.c b/firmware/target/arm/rk27xx/hm60x/powermgmt-hm60x.c
index 7b5b171ccb..6ab761672a 100644
--- a/firmware/target/arm/rk27xx/hm60x/powermgmt-hm60x.c
+++ b/firmware/target/arm/rk27xx/hm60x/powermgmt-hm60x.c
@@ -60,7 +60,7 @@ const unsigned short percent_to_volt_charge[11] =
#define BATTERY_SCALE_FACTOR 6000
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c b/firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c
index a815d893b2..dc555be4cf 100644
--- a/firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c
+++ b/firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c
@@ -54,7 +54,7 @@ const unsigned short percent_to_volt_charge[11] =
/* TODO: simple uncalibrated curve */
{ 425, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520 };
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return adc_read(ADC_BATTERY);
}
diff --git a/firmware/target/arm/rk27xx/rk27generic/powermgmt-rk27generic.c b/firmware/target/arm/rk27xx/rk27generic/powermgmt-rk27generic.c
index 3960dab2c1..ccbc098d91 100644
--- a/firmware/target/arm/rk27xx/rk27generic/powermgmt-rk27generic.c
+++ b/firmware/target/arm/rk27xx/rk27generic/powermgmt-rk27generic.c
@@ -60,7 +60,7 @@ const unsigned short percent_to_volt_charge[11] =
#define BATTERY_SCALE_FACTOR 6000
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/powermgmt-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/powermgmt-meg-fx.c
index 49f7e2e049..4cc43d038a 100644
--- a/firmware/target/arm/s3c2440/gigabeat-fx/powermgmt-meg-fx.c
+++ b/firmware/target/arm/s3c2440/gigabeat-fx/powermgmt-meg-fx.c
@@ -54,7 +54,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/s3c2440/mini2440/powermgmt-mini2440.c b/firmware/target/arm/s3c2440/mini2440/powermgmt-mini2440.c
index 5281b10698..9a05cd37c6 100644
--- a/firmware/target/arm/s3c2440/mini2440/powermgmt-mini2440.c
+++ b/firmware/target/arm/s3c2440/mini2440/powermgmt-mini2440.c
@@ -52,7 +52,7 @@ const unsigned short percent_to_volt_charge[11] =
/* Returns battery voltage from ADC [millivolts] */
/* full-scale (2^10) in millivolt */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
/* Since we have no battery, return a fully charged value */
return 4000 * 1024 / 1000;
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/powermgmt-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/powermgmt-nano2g.c
index 52491cf480..647c13ed79 100644
--- a/firmware/target/arm/s5l8700/ipodnano2g/powermgmt-nano2g.c
+++ b/firmware/target/arm/s5l8700/ipodnano2g/powermgmt-nano2g.c
@@ -55,7 +55,7 @@ const unsigned short percent_to_volt_charge[11] =
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
int compensation = (10 * (pmu_read_battery_current() - 7)) / 12;
if (charging_state()) return pmu_read_battery_voltage() - compensation;
diff --git a/firmware/target/arm/s5l8700/meizu-m3/powermgmt-m3.c b/firmware/target/arm/s5l8700/meizu-m3/powermgmt-m3.c
index 3960dab2c1..ccbc098d91 100644
--- a/firmware/target/arm/s5l8700/meizu-m3/powermgmt-m3.c
+++ b/firmware/target/arm/s5l8700/meizu-m3/powermgmt-m3.c
@@ -60,7 +60,7 @@ const unsigned short percent_to_volt_charge[11] =
#define BATTERY_SCALE_FACTOR 6000
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/s5l8700/meizu-m6sp/powermgmt-m6sp.c b/firmware/target/arm/s5l8700/meizu-m6sp/powermgmt-m6sp.c
index 86b6e46b4d..b59d0fac45 100644
--- a/firmware/target/arm/s5l8700/meizu-m6sp/powermgmt-m6sp.c
+++ b/firmware/target/arm/s5l8700/meizu-m6sp/powermgmt-m6sp.c
@@ -58,7 +58,7 @@ const unsigned short percent_to_volt_charge[11] =
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/s5l8702/ipod6g/powermgmt-ipod6g.c b/firmware/target/arm/s5l8702/ipod6g/powermgmt-ipod6g.c
index 6caeafd8fc..b88ac16d55 100644
--- a/firmware/target/arm/s5l8702/ipod6g/powermgmt-ipod6g.c
+++ b/firmware/target/arm/s5l8702/ipod6g/powermgmt-ipod6g.c
@@ -55,7 +55,7 @@ const unsigned short percent_to_volt_charge[11] =
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
int compensation = (10 * (pmu_read_battery_current() - 7)) / 12;
if (charging_state()) return pmu_read_battery_voltage() - compensation;
diff --git a/firmware/target/arm/samsung/yh820/powermgmt-yh820.c b/firmware/target/arm/samsung/yh820/powermgmt-yh820.c
index 495590413c..180194c704 100644
--- a/firmware/target/arm/samsung/yh820/powermgmt-yh820.c
+++ b/firmware/target/arm/samsung/yh820/powermgmt-yh820.c
@@ -52,7 +52,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
/* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */
return 4100;
diff --git a/firmware/target/arm/samsung/yh920/powermgmt-yh920.c b/firmware/target/arm/samsung/yh920/powermgmt-yh920.c
index 0ea3c5d50e..f33afb31bd 100644
--- a/firmware/target/arm/samsung/yh920/powermgmt-yh920.c
+++ b/firmware/target/arm/samsung/yh920/powermgmt-yh920.c
@@ -52,7 +52,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/samsung/yh925/powermgmt-yh925.c b/firmware/target/arm/samsung/yh925/powermgmt-yh925.c
index 3eb5dd6c61..ab9cbcdfc1 100644
--- a/firmware/target/arm/samsung/yh925/powermgmt-yh925.c
+++ b/firmware/target/arm/samsung/yh925/powermgmt-yh925.c
@@ -52,7 +52,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/sandisk/sansa-view/powermgmt-view.c b/firmware/target/arm/sandisk/sansa-view/powermgmt-view.c
index 459b60dd45..870a883087 100644
--- a/firmware/target/arm/sandisk/sansa-view/powermgmt-view.c
+++ b/firmware/target/arm/sandisk/sansa-view/powermgmt-view.c
@@ -23,7 +23,7 @@
#include "adc.h"
#include "powermgmt.h"
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return 0;
}
diff --git a/firmware/target/arm/tatung/tpj1022/powermgmt-tpj1022.c b/firmware/target/arm/tatung/tpj1022/powermgmt-tpj1022.c
index ef7919d5aa..cc91012fcd 100644
--- a/firmware/target/arm/tatung/tpj1022/powermgmt-tpj1022.c
+++ b/firmware/target/arm/tatung/tpj1022/powermgmt-tpj1022.c
@@ -56,7 +56,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/tcc77x/iaudio7/powermgmt-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/powermgmt-iaudio7.c
index 9b65bbde1f..bc7ead61f0 100644
--- a/firmware/target/arm/tcc77x/iaudio7/powermgmt-iaudio7.c
+++ b/firmware/target/arm/tcc77x/iaudio7/powermgmt-iaudio7.c
@@ -59,7 +59,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
static unsigned last_tick = 0;
diff --git a/firmware/target/arm/tcc77x/powermgmt-tcc77x.c b/firmware/target/arm/tcc77x/powermgmt-tcc77x.c
index 90c66d30e6..07a56777d0 100644
--- a/firmware/target/arm/tcc77x/powermgmt-tcc77x.c
+++ b/firmware/target/arm/tcc77x/powermgmt-tcc77x.c
@@ -59,7 +59,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return current_voltage;
}
diff --git a/firmware/target/arm/tcc780x/cowond2/powermgmt-cowond2.c b/firmware/target/arm/tcc780x/cowond2/powermgmt-cowond2.c
index 9b2320b7cf..91361fe5f4 100644
--- a/firmware/target/arm/tcc780x/cowond2/powermgmt-cowond2.c
+++ b/firmware/target/arm/tcc780x/cowond2/powermgmt-cowond2.c
@@ -61,7 +61,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
static unsigned last_tick = 0;
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c
index a6d19347c4..23ee9c6abe 100644
--- a/firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c
+++ b/firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c
@@ -50,7 +50,7 @@ const unsigned short percent_to_volt_charge[11] =
};
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return current_voltage;
}
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
index 5da03692f7..78f9bbb9c2 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
@@ -60,7 +60,7 @@ const unsigned short percent_to_volt_charge[11] =
};
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
short bat1, bat2, aux;
static unsigned last_tick = 0;
diff --git a/firmware/target/arm/tms320dm320/sansa-connect/powermgmt-sansaconnect.c b/firmware/target/arm/tms320dm320/sansa-connect/powermgmt-sansaconnect.c
index c42f56b0b3..8b3f05107c 100644
--- a/firmware/target/arm/tms320dm320/sansa-connect/powermgmt-sansaconnect.c
+++ b/firmware/target/arm/tms320dm320/sansa-connect/powermgmt-sansaconnect.c
@@ -53,7 +53,7 @@ const unsigned short percent_to_volt_charge[11] =
};
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return current_battery_level;
}
diff --git a/firmware/target/coldfire/iaudio/m3/powermgmt-m3.c b/firmware/target/coldfire/iaudio/m3/powermgmt-m3.c
index bb8f5cf811..b97d6913f2 100644
--- a/firmware/target/coldfire/iaudio/m3/powermgmt-m3.c
+++ b/firmware/target/coldfire/iaudio/m3/powermgmt-m3.c
@@ -52,7 +52,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^8) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 8;
}
diff --git a/firmware/target/coldfire/iaudio/powermgmt-iaudio.c b/firmware/target/coldfire/iaudio/powermgmt-iaudio.c
index 4bfea20432..56915266da 100644
--- a/firmware/target/coldfire/iaudio/powermgmt-iaudio.c
+++ b/firmware/target/coldfire/iaudio/powermgmt-iaudio.c
@@ -53,7 +53,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/coldfire/iriver/h100/powermgmt-h100.c b/firmware/target/coldfire/iriver/h100/powermgmt-h100.c
index e238711120..20e1a88d4a 100644
--- a/firmware/target/coldfire/iriver/h100/powermgmt-h100.c
+++ b/firmware/target/coldfire/iriver/h100/powermgmt-h100.c
@@ -53,7 +53,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^8) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 8;
}
diff --git a/firmware/target/coldfire/iriver/h300/powermgmt-h300.c b/firmware/target/coldfire/iriver/h300/powermgmt-h300.c
index 95a5741759..00aad31279 100644
--- a/firmware/target/coldfire/iriver/h300/powermgmt-h300.c
+++ b/firmware/target/coldfire/iriver/h300/powermgmt-h300.c
@@ -53,7 +53,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/coldfire/mpio/hd200/powermgmt-hd200.c b/firmware/target/coldfire/mpio/hd200/powermgmt-hd200.c
index 9d95938ff9..964d551de1 100644
--- a/firmware/target/coldfire/mpio/hd200/powermgmt-hd200.c
+++ b/firmware/target/coldfire/mpio/hd200/powermgmt-hd200.c
@@ -51,7 +51,7 @@ const unsigned short percent_to_volt_charge[11] =
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 11;
}
diff --git a/firmware/target/coldfire/mpio/hd300/powermgmt-hd300.c b/firmware/target/coldfire/mpio/hd300/powermgmt-hd300.c
index bdfe9b5fc4..ffd0190073 100644
--- a/firmware/target/coldfire/mpio/hd300/powermgmt-hd300.c
+++ b/firmware/target/coldfire/mpio/hd300/powermgmt-hd300.c
@@ -51,7 +51,7 @@ const unsigned short percent_to_volt_charge[11] =
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 11;
}
diff --git a/firmware/target/hosted/android/powermgmt-android.c b/firmware/target/hosted/android/powermgmt-android.c
index dcbd7a6214..1e70a81753 100644
--- a/firmware/target/hosted/android/powermgmt-android.c
+++ b/firmware/target/hosted/android/powermgmt-android.c
@@ -28,10 +28,10 @@ extern JNIEnv *env_ptr;
extern jclass RockboxService_class;
extern jobject RockboxService_instance;
-static jfieldID _battery_level;
+static jfieldID __battery_level;
static jobject BatteryMonitor_instance;
-void powermgmt_init_target(void)
+static void new_battery_monitor(void)
{
JNIEnv e = *env_ptr;
jclass class = e->FindClass(env_ptr, "org/rockbox/monitors/BatteryMonitor");
@@ -43,29 +43,15 @@ void powermgmt_init_target(void)
RockboxService_instance);
/* cache the battery level field id */
- _battery_level = (*env_ptr)->GetFieldID(env_ptr,
+ __battery_level = (*env_ptr)->GetFieldID(env_ptr,
class,
"mBattLevel", "I");
}
-int battery_level(void)
+int _battery_level(void)
{
- return (*env_ptr)->GetIntField(env_ptr, BatteryMonitor_instance, _battery_level);
+ if (!BatteryMonitor_instance)
+ new_battery_monitor();
+ return (*env_ptr)->GetIntField(env_ptr, BatteryMonitor_instance, __battery_level);
}
-int battery_time(void)
-{ /* cannot calculate yet */
- return 0;
-}
-
-/* should always be safe on android targets, the host shuts us down before */
-bool battery_level_safe(void)
-{
- return true;
-}
-
-/* TODO */
-unsigned battery_voltage(void)
-{
- return 0;
-}
diff --git a/firmware/target/hosted/android/system-android.c b/firmware/target/hosted/android/system-android.c
index fba7ff4e2c..e48e910c0c 100644
--- a/firmware/target/hosted/android/system-android.c
+++ b/firmware/target/hosted/android/system-android.c
@@ -45,7 +45,7 @@ void system_reboot(void) { }
/* this is used to return from the entry point of the native library. */
static jmp_buf poweroff_buf;
-void shutdown_hw(void)
+void power_off(void)
{
longjmp(poweroff_buf, 1);
}
diff --git a/firmware/target/hosted/maemo/maemo-thread.c b/firmware/target/hosted/maemo/maemo-thread.c
index a32a563459..2f1d033baa 100644
--- a/firmware/target/hosted/maemo/maemo-thread.c
+++ b/firmware/target/hosted/maemo/maemo-thread.c
@@ -163,40 +163,14 @@ int maemo_thread_func (void *wait_for_osso_startup)
return 0;
}
-/** Rockbox battery related functions */
-void battery_status_update(void)
-{
- battery_percent = maemo_battery_level;
- send_battery_level_event();
-}
-
-/* Returns true if any power input is connected - charging-capable
- * or not. */
-bool power_input_present(void)
-{
- return false;
-}
-
-unsigned battery_voltage(void)
-{
- return 0;
-}
-
/* Returns battery level in percent */
-int battery_level(void)
+int _battery_level(void)
{
- battery_status_update();
return maemo_battery_level;
}
/* Return remaining battery time in minutes */
-int battery_time(void)
+int _battery_time(void)
{
- battery_status_update();
return maemo_remaining_time_sec / 60;
}
-
-bool battery_level_safe(void)
-{
- return battery_level() >= 5;
-}
diff --git a/firmware/target/hosted/powermgmt.c b/firmware/target/hosted/powermgmt.c
deleted file mode 100644
index bf05e5ff19..0000000000
--- a/firmware/target/hosted/powermgmt.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2011 by Thomas Jarosch
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-#include "config.h"
-#include "powermgmt.h"
-#include "thread.h"
-#include "kernel.h"
-
-static char power_stack[DEFAULT_STACK_SIZE];
-static const char power_thread_name[] = "power";
-
-void powermgmt_init_target(void);
-
-#if !(CONFIG_PLATFORM & PLATFORM_ANDROID)
-void powermgmt_init_target(void)
-{
- /* Nothing to do */
-}
-#endif
-
-static void power_thread(void)
-{
- powermgmt_init_target();
-
- while (1)
- {
- /* Sleep two seconds */
- sleep(HZ*2);
-
- handle_auto_poweroff();
- }
-} /* power_thread */
-
-void powermgmt_init(void)
-{
- create_thread(power_thread, power_stack, sizeof(power_stack), 0,
- power_thread_name IF_PRIO(, PRIORITY_SYSTEM)
- IF_COP(, CPU));
-}
diff --git a/firmware/target/hosted/sdl/system-sdl.c b/firmware/target/hosted/sdl/system-sdl.c
index 93a8a7cb66..87b2e0ccd1 100644
--- a/firmware/target/hosted/sdl/system-sdl.c
+++ b/firmware/target/hosted/sdl/system-sdl.c
@@ -196,7 +196,7 @@ static int sdl_event_thread(void * param)
return 0;
}
-void shutdown_hw(void)
+void power_off(void)
{
/* Shut down SDL event loop */
SDL_Event event;
diff --git a/firmware/target/hosted/ypr0/powermgmt-ypr0.c b/firmware/target/hosted/ypr0/powermgmt-ypr0.c
index 0c162a619d..9c90f7ea02 100644
--- a/firmware/target/hosted/ypr0/powermgmt-ypr0.c
+++ b/firmware/target/hosted/ypr0/powermgmt-ypr0.c
@@ -70,7 +70,7 @@ unsigned int power_input_status(void)
/* Returns battery voltage from ADC [millivolts],
* adc returns voltage in 5mV steps */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return adc_read(3) * 5;
}
@@ -80,5 +80,5 @@ bool charging_state(void)
const unsigned short charged_thres = 4170;
bool ret = (power_input_status() == POWER_INPUT_MAIN_CHARGER);
/* dont indicate for > ~95% */
- return ret && (battery_adc_voltage() <= charged_thres);
+ return ret && (_battery_voltage() <= charged_thres);
}
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
index 99d73fa3c7..e6f0cd9cc3 100644
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
@@ -102,7 +102,7 @@ const unsigned short percent_to_volt_charge[11] =
#define BATTERY_SCALE_FACTOR 7500
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
unsigned int dummy, bat_val;
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c b/firmware/target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c
index 98dbf08fe9..710da6b729 100644
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c
@@ -67,7 +67,7 @@ const unsigned short percent_to_volt_charge[11] =
#define BATTERY_SCALE_FACTOR 1875
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
unsigned int dummy, timeout=HZ/4;
diff --git a/firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c b/firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c
index 20596ddedb..5dd7f26d2f 100644
--- a/firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c
+++ b/firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c
@@ -54,7 +54,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/sh/archos/ondio/powermgmt-ondio.c b/firmware/target/sh/archos/ondio/powermgmt-ondio.c
index dc0c37b9f9..dc3cab031f 100644
--- a/firmware/target/sh/archos/ondio/powermgmt-ondio.c
+++ b/firmware/target/sh/archos/ondio/powermgmt-ondio.c
@@ -46,7 +46,7 @@ const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/sh/archos/player/powermgmt-player.c b/firmware/target/sh/archos/player/powermgmt-player.c
index b9a4fe3277..8aa03d88a5 100644
--- a/firmware/target/sh/archos/player/powermgmt-player.c
+++ b/firmware/target/sh/archos/player/powermgmt-player.c
@@ -56,7 +56,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/sh/archos/recorder/powermgmt-recorder.c b/firmware/target/sh/archos/recorder/powermgmt-recorder.c
index 47f0093456..0bce1585cd 100644
--- a/firmware/target/sh/archos/recorder/powermgmt-recorder.c
+++ b/firmware/target/sh/archos/recorder/powermgmt-recorder.c
@@ -60,7 +60,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/uisimulator/common/SOURCES b/uisimulator/common/SOURCES
index a632706a6b..939f1638c3 100644
--- a/uisimulator/common/SOURCES
+++ b/uisimulator/common/SOURCES
@@ -9,10 +9,7 @@ sim_tasks.c
fmradio.c
backlight-sim.c
stubs.c
+powermgmt-sim.c
#endif
io.c
-/* this is still needed for application since it has some stubs */
-#if !(CONFIG_PLATFORM & PLATFORM_MAEMO)
-powermgmt-sim.c
-#endif
diff --git a/uisimulator/common/lcd-common.c b/uisimulator/common/lcd-common.c
index 2acf4b386d..47ca114cbc 100644
--- a/uisimulator/common/lcd-common.c
+++ b/uisimulator/common/lcd-common.c
@@ -119,3 +119,9 @@ bool lcd_active(void)
return retval;
}
#endif
+
+#ifdef HAVE_LCD_SHUTDOWN
+void lcd_shutdown(void)
+{
+}
+#endif
diff --git a/uisimulator/common/powermgmt-sim.c b/uisimulator/common/powermgmt-sim.c
index e747d7d782..2d9acab51d 100644
--- a/uisimulator/common/powermgmt-sim.c
+++ b/uisimulator/common/powermgmt-sim.c
@@ -24,24 +24,25 @@
#include <time.h>
#include "kernel.h"
#include "powermgmt.h"
+#include "power.h"
-#define BATT_MINMVOLT 2500 /* minimum millivolts of battery */
-#define BATT_MAXMVOLT 4500 /* maximum millivolts of battery */
+#define BATT_MINMVOLT 3300 /* minimum millivolts of battery */
+#define BATT_MAXMVOLT 4300 /* maximum millivolts of battery */
#define BATT_MAXRUNTIME (10 * 60) /* maximum runtime with full battery in
minutes */
extern void send_battery_level_event(void);
extern int last_sent_battery_level;
extern int battery_percent;
+static bool charging = false;
static unsigned int battery_millivolts = BATT_MAXMVOLT;
-/* estimated remaining time in minutes */
-static int powermgmt_est_runningtime_min = BATT_MAXRUNTIME;
+
+void powermgmt_init_target(void) {}
static void battery_status_update(void)
{
static time_t last_change = 0;
- static bool charging = false;
time_t now;
time(&now);
@@ -76,57 +77,34 @@ static void battery_status_update(void)
battery_percent = 100 * (battery_millivolts - BATT_MINMVOLT) /
(BATT_MAXMVOLT - BATT_MINMVOLT);
-
- powermgmt_est_runningtime_min =
- battery_percent * BATT_MAXRUNTIME / 100;
}
-
- send_battery_level_event();
}
-void battery_read_info(int *voltage, int *level)
-{
- battery_status_update();
+const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = { 3200 };
+const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = { 3200 };
- if (voltage)
- *voltage = battery_millivolts;
+/* make the simulated curve nicely linear */
+const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
+{ { 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300 } };
+const unsigned short percent_to_volt_charge[11] =
+{ 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300 };
- if (level)
- *level = battery_percent;
-}
-unsigned int battery_voltage(void)
+int _battery_voltage(void)
{
battery_status_update();
return battery_millivolts;
}
-int battery_level(void)
-{
- battery_status_update();
- return battery_percent;
-}
-
-int battery_time(void)
-{
- battery_status_update();
- return powermgmt_est_runningtime_min;
-}
-
-bool battery_level_safe(void)
-{
- return battery_level() >= 10;
-}
-
-void set_battery_capacity(int capacity)
+#if CONFIG_CHARGING
+unsigned int power_input_status(void)
{
- (void)capacity;
+ return charging ? POWER_INPUT_NONE : POWER_INPUT_MAIN;
}
-#if BATTERY_TYPES_COUNT > 1
-void set_battery_type(int type)
+bool charging_state(void)
{
- (void)type;
+ return charging;
}
#endif
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c
index f8b8fdc912..ba4faff6e2 100644
--- a/uisimulator/common/stubs.c
+++ b/uisimulator/common/stubs.c
@@ -317,32 +317,6 @@ bool usb_charging_enable(bool on)
}
#endif
-#if CONFIG_CHARGING
-bool charger_inserted(void)
-{
- return false;
-}
-
-bool power_input_present(void)
-{
- return false;
-}
-
-unsigned int power_input_status(void)
-{
-#ifdef HAVE_BATTERY_SWITCH
- return POWER_INPUT_BATTERY;
-#else
- return POWER_INPUT_NONE;
-#endif
-}
-
-bool charging_state(void)
-{
- return false;
-}
-#endif /* CONFIG_CHARGING */
-
#ifndef USB_NONE
bool usb_inserted(void)
{