summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Giacomelli <giac2000@hotmail.com>2010-03-16 17:13:25 +0000
committerMichael Giacomelli <giac2000@hotmail.com>2010-03-16 17:13:25 +0000
commit589abcd416165827f935c49e5c05582b2c35e9eb (patch)
tree61b25666deb1140a8a34f7118924edd16dbf969c
parent3b5418e8145152158fc6f72bace1eb8d4a7cb13e (diff)
downloadrockbox-589abcd416165827f935c49e5c05582b2c35e9eb.zip
rockbox-589abcd416165827f935c49e5c05582b2c35e9eb.tar.gz
rockbox-589abcd416165827f935c49e5c05582b2c35e9eb.tar.bz2
rockbox-589abcd416165827f935c49e5c05582b2c35e9eb.tar.xz
Disable runtime estimation altogether when there is no runtime current defined. It doens't work and people somehow got confused by seeing obviously wrong values. Now it will just return -1 if you try to estimate runtime without having the current defined.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25222 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/powermgmt.h6
-rw-r--r--firmware/powermgmt.c18
2 files changed, 15 insertions, 9 deletions
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h
index 23ef447..17519c5 100644
--- a/firmware/export/powermgmt.h
+++ b/firmware/export/powermgmt.h
@@ -77,12 +77,8 @@ extern unsigned int power_thread_inputs;
#ifndef SIMULATOR
/* Generic current values that are intentionally meaningless - config header
- * should define proper numbers. Use insane values here to remind people
- * to define the correct values in the proper header*/
+ * should define proper numbers.*/
-#ifndef CURRENT_NORMAL
-#define CURRENT_NORMAL 5 /* usual current in mA */
-#endif
#ifndef CURRENT_BACKLIGHT
#define CURRENT_BACKLIGHT 5 /* additional current when backlight always on */
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index f8c3995..f1dd83e 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -113,7 +113,10 @@ static long last_event_tick;
static int voltage_to_battery_level(int battery_millivolts);
static void battery_status_update(void);
+
+#ifdef CURRENT_NORMAL /*only used if we have run current*/
static int runcurrent(void);
+#endif
void battery_read_info(int *voltage, int *level)
{
@@ -272,6 +275,8 @@ static void battery_status_update(void)
{
int level = voltage_to_battery_level(battery_millivolts);
+#ifdef CURRENT_NORMAL /*don't try to estimate run or charge
+ time without normal current defined*/
/* calculate estimated remaining running time */
#if CONFIG_CHARGING >= CHARGING_MONITOR
if (charging_state()) {
@@ -281,6 +286,7 @@ static void battery_status_update(void)
}
else
#endif
+
/* discharging: remaining running time */
if (battery_millivolts > percent_to_volt_discharge[0][0]) {
/* linear extrapolation */
@@ -290,6 +296,9 @@ 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;
send_battery_level_event();
@@ -364,14 +373,14 @@ static void handle_auto_poweroff(void)
}
}
+#ifdef CURRENT_NORMAL /*check that we have a current defined in a config file*/
+
/*
* Estimate how much current we are drawing just to run.
*/
static int runcurrent(void)
{
- int current;
-
- current = CURRENT_NORMAL;
+ int current = CURRENT_NORMAL;
#ifndef BOOTLOADER
if (usb_inserted()
@@ -406,10 +415,11 @@ static int runcurrent(void)
current += CURRENT_REMOTE;
#endif
#endif /* BOOTLOADER */
-
+
return current;
}
+#endif /* CURRENT_NORMAL */
/* Check to see whether or not we've received an alarm in the last second */
#ifdef HAVE_RTC_ALARM