diff options
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) | |||
900 | return simplelist_show_list(&info); | 900 | return simplelist_show_list(&info); |
901 | } | 901 | } |
902 | #endif | 902 | #endif |
903 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0) | 903 | #if (CONFIG_BATTERY_MEASURE != 0) && defined(HAVE_LCD_BITMAP) && !defined(SIMULATOR) |
904 | #ifdef HAVE_LCD_BITMAP | ||
905 | /* | 904 | /* |
906 | * view_battery() shows a automatically scaled graph of the battery voltage | 905 | * view_battery() shows a automatically scaled graph of the battery voltage |
907 | * over time. Usable for estimating battery life / charging rate. | 906 | * over time. Usable for estimating battery life / charging rate. |
@@ -909,13 +908,14 @@ static bool tsc2100_debug(void) | |||
909 | */ | 908 | */ |
910 | 909 | ||
911 | #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN) | 910 | #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN) |
912 | #define BAT_YSPACE (LCD_HEIGHT - 20) | 911 | #define BAT_TSPACE 20 |
912 | #define BAT_YSPACE (LCD_HEIGHT - BAT_TSPACE) | ||
913 | 913 | ||
914 | 914 | ||
915 | static bool view_battery(void) | 915 | static bool view_battery(void) |
916 | { | 916 | { |
917 | int view = 0; | 917 | int view = 0; |
918 | int i, x, y, y1, y2, grid, graph; | 918 | int i, x, y, z, y1, y2, grid, graph; |
919 | unsigned short maxv, minv; | 919 | unsigned short maxv, minv; |
920 | 920 | ||
921 | lcd_setfont(FONT_SYSFIXED); | 921 | lcd_setfont(FONT_SYSFIXED); |
@@ -934,19 +934,28 @@ static bool view_battery(void) | |||
934 | if (power_history[i] < minv) | 934 | if (power_history[i] < minv) |
935 | minv = power_history[i]; | 935 | minv = power_history[i]; |
936 | } | 936 | } |
937 | 937 | /* print header */ | |
938 | #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE) | ||
938 | /* adjust grid scale */ | 939 | /* adjust grid scale */ |
939 | if ((maxv - minv) > 50) | 940 | if ((maxv - minv) > 50) |
940 | grid = 50; | 941 | grid = 50; |
941 | else | 942 | else |
942 | grid = 5; | 943 | grid = 5; |
943 | 944 | ||
944 | /* print header */ | ||
945 | lcd_putsf(0, 0, "battery %d.%03dV", power_history[0] / 1000, | 945 | lcd_putsf(0, 0, "battery %d.%03dV", power_history[0] / 1000, |
946 | power_history[0] % 1000); | 946 | power_history[0] % 1000); |
947 | lcd_putsf(0, 1, "%d.%03d-%d.%03dV (%2dmV)", | 947 | lcd_putsf(0, 1, "%d.%03d-%d.%03dV (%2dmV)", |
948 | minv / 1000, minv % 1000, maxv / 1000, maxv % 1000, | 948 | minv / 1000, minv % 1000, maxv / 1000, maxv % 1000, |
949 | grid); | 949 | grid); |
950 | #elif (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE) | ||
951 | /* adjust grid scale */ | ||
952 | if ((maxv - minv) > 10) | ||
953 | grid = 10; | ||
954 | else | ||
955 | grid = 1; | ||
956 | lcd_putsf(0, 0, "battery %d%%", power_history[0]); | ||
957 | lcd_putsf(0, 1, "%d%%-%d%% (%d %%)", minv, maxv, grid); | ||
958 | #endif | ||
950 | 959 | ||
951 | i = 1; | 960 | i = 1; |
952 | while ((y = (minv - (minv % grid)+i*grid)) < maxv) | 961 | while ((y = (minv - (minv % grid)+i*grid)) < maxv) |
@@ -971,11 +980,11 @@ static bool view_battery(void) | |||
971 | { | 980 | { |
972 | y1 = (power_history[i] - minv) * BAT_YSPACE / | 981 | y1 = (power_history[i] - minv) * BAT_YSPACE / |
973 | (maxv - minv); | 982 | (maxv - minv); |
974 | y1 = MIN(MAX(LCD_HEIGHT-1 - y1, 20), | 983 | y1 = MIN(MAX(LCD_HEIGHT-1 - y1, BAT_TSPACE), |
975 | LCD_HEIGHT-1); | 984 | LCD_HEIGHT-1); |
976 | y2 = (power_history[i-1] - minv) * BAT_YSPACE / | 985 | y2 = (power_history[i-1] - minv) * BAT_YSPACE / |
977 | (maxv - minv); | 986 | (maxv - minv); |
978 | y2 = MIN(MAX(LCD_HEIGHT-1 - y2, 20), | 987 | y2 = MIN(MAX(LCD_HEIGHT-1 - y2, BAT_TSPACE), |
979 | LCD_HEIGHT-1); | 988 | LCD_HEIGHT-1); |
980 | 989 | ||
981 | lcd_set_drawmode(DRMODE_SOLID); | 990 | lcd_set_drawmode(DRMODE_SOLID); |
@@ -999,10 +1008,13 @@ static bool view_battery(void) | |||
999 | lcd_putsf(0, 0, "Pwr status: %s", | 1008 | lcd_putsf(0, 0, "Pwr status: %s", |
1000 | charging_state() ? "charging" : "discharging"); | 1009 | charging_state() ? "charging" : "discharging"); |
1001 | #else | 1010 | #else |
1002 | lcd_puts(0, 0, "Power status:"); | 1011 | lcd_puts(0, 0, "Power status: unknown"); |
1003 | #endif | 1012 | #endif |
1004 | battery_read_info(&y, NULL); | 1013 | battery_read_info(&y, &z); |
1005 | lcd_putsf(0, 1, "Battery: %d.%03d V", y / 1000, y % 1000); | 1014 | if (y > 0) |
1015 | lcd_putsf(0, 1, "Battery: %d.%03d V (%d %%)", y / 1000, y % 1000, z); | ||
1016 | else if (z > 0) | ||
1017 | lcd_putsf(0, 1, "Battery: %d %%", z); | ||
1006 | #ifdef ADC_EXT_POWER | 1018 | #ifdef ADC_EXT_POWER |
1007 | y = (adc_read(ADC_EXT_POWER) * EXT_SCALE_FACTOR) / 1000; | 1019 | y = (adc_read(ADC_EXT_POWER) * EXT_SCALE_FACTOR) / 1000; |
1008 | lcd_putsf(0, 2, "External: %d.%03d V", y / 1000, y % 1000); | 1020 | lcd_putsf(0, 2, "External: %d.%03d V", y / 1000, y % 1000); |
@@ -1169,16 +1181,23 @@ static bool view_battery(void) | |||
1169 | #endif /* target type */ | 1181 | #endif /* target type */ |
1170 | #endif /* CONFIG_CHARGING */ | 1182 | #endif /* CONFIG_CHARGING */ |
1171 | break; | 1183 | break; |
1172 | |||
1173 | case 2: /* voltage deltas: */ | 1184 | case 2: /* voltage deltas: */ |
1185 | #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE) | ||
1174 | lcd_puts(0, 0, "Voltage deltas:"); | 1186 | lcd_puts(0, 0, "Voltage deltas:"); |
1175 | 1187 | for (i = 0; i < POWER_HISTORY_LEN-1; i++) { | |
1176 | for (i = 0; i <= 6; i++) { | ||
1177 | y = power_history[i] - power_history[i+1]; | 1188 | y = power_history[i] - power_history[i+1]; |
1178 | lcd_putsf(0, i+1, "-%d min: %s%d.%03d V", i, | 1189 | lcd_putsf(0, i+1, "-%d min: %c%d.%03d V", i, |
1179 | (y < 0) ? "-" : "", ((y < 0) ? y * -1 : y) / 1000, | 1190 | (y < 0) ? '-' : ' ', ((y < 0) ? y * -1 : y) / 1000, |
1180 | ((y < 0) ? y * -1 : y ) % 1000); | 1191 | ((y < 0) ? y * -1 : y ) % 1000); |
1181 | } | 1192 | } |
1193 | #elif (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE) | ||
1194 | lcd_puts(0, 0, "Percentage deltas:"); | ||
1195 | for (i = 0; i < POWER_HISTORY_LEN-1; i++) { | ||
1196 | y = power_history[i] - power_history[i+1]; | ||
1197 | lcd_putsf(0, i+1, "-%d min: %c%d%%", i, | ||
1198 | (y < 0) ? '-' : ' ', ((y < 0) ? y * -1 : y)); | ||
1199 | } | ||
1200 | #endif | ||
1182 | break; | 1201 | break; |
1183 | 1202 | ||
1184 | case 3: /* remaining time estimation: */ | 1203 | case 3: /* remaining time estimation: */ |
@@ -1195,13 +1214,19 @@ static bool view_battery(void) | |||
1195 | lcd_putsf(0, 4, "Trickle sec: %d/60", trickle_sec); | 1214 | lcd_putsf(0, 4, "Trickle sec: %d/60", trickle_sec); |
1196 | #endif /* ARCHOS_RECORDER */ | 1215 | #endif /* ARCHOS_RECORDER */ |
1197 | 1216 | ||
1217 | #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE) | ||
1198 | lcd_putsf(0, 5, "Last PwrHist: %d.%03dV", | 1218 | lcd_putsf(0, 5, "Last PwrHist: %d.%03dV", |
1199 | power_history[0] / 1000, | 1219 | power_history[0] / 1000, |
1200 | power_history[0] % 1000); | 1220 | power_history[0] % 1000); |
1221 | #endif | ||
1201 | 1222 | ||
1202 | lcd_putsf(0, 6, "battery level: %d%%", battery_level()); | 1223 | lcd_putsf(0, 6, "battery level: %d%%", battery_level()); |
1203 | 1224 | ||
1204 | lcd_putsf(0, 7, "Est. remain: %d m", battery_time()); | 1225 | int time_left = battery_time(); |
1226 | if (time_left >= 0) | ||
1227 | lcd_putsf(0, 7, "Est. remain: %d m", time_left); | ||
1228 | else | ||
1229 | lcd_puts(0, 7, "Estimation n/a"); | ||
1205 | break; | 1230 | break; |
1206 | } | 1231 | } |
1207 | 1232 | ||
@@ -1228,8 +1253,7 @@ static bool view_battery(void) | |||
1228 | return false; | 1253 | return false; |
1229 | } | 1254 | } |
1230 | 1255 | ||
1231 | #endif /* HAVE_LCD_BITMAP */ | 1256 | #endif /* (CONFIG_BATTERY_MEASURE != 0) && HAVE_LCD_BITMAP */ |
1232 | #endif | ||
1233 | 1257 | ||
1234 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | 1258 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
1235 | #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD) | 1259 | #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD) |
@@ -2168,7 +2192,7 @@ static const struct the_menu_item menuitems[] = { | |||
2168 | { "View CPU stats", dbg_cpuinfo }, | 2192 | { "View CPU stats", dbg_cpuinfo }, |
2169 | #endif | 2193 | #endif |
2170 | #ifdef HAVE_LCD_BITMAP | 2194 | #ifdef HAVE_LCD_BITMAP |
2171 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0) | 2195 | #if (CONFIG_BATTERY_MEASURE != 0) && !defined(SIMULATOR) |
2172 | { "View battery", view_battery }, | 2196 | { "View battery", view_battery }, |
2173 | #endif | 2197 | #endif |
2174 | #ifndef APPLICATION | 2198 | #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, | |||
1068 | 1068 | ||
1069 | case SKIN_TOKEN_BATTERY_VOLTS: | 1069 | case SKIN_TOKEN_BATTERY_VOLTS: |
1070 | { | 1070 | { |
1071 | unsigned int v = battery_voltage(); | 1071 | int v = battery_voltage(); |
1072 | snprintf(buf, buf_size, "%d.%02d", v / 1000, (v % 1000) / 10); | 1072 | if (v >= 0) { |
1073 | return buf; | 1073 | snprintf(buf, buf_size, "%d.%02d", v / 1000, (v % 1000) / 10); |
1074 | return buf; | ||
1075 | } else { | ||
1076 | return "?"; | ||
1077 | } | ||
1074 | } | 1078 | } |
1075 | 1079 | ||
1076 | case SKIN_TOKEN_BATTERY_TIME: | 1080 | 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, | |||
210 | snprintf(buffer, buffer_len, str(LANG_BATTERY_TIME), | 210 | snprintf(buffer, buffer_len, str(LANG_BATTERY_TIME), |
211 | battery_level(), battery_time() / 60, battery_time() % 60); | 211 | battery_level(), battery_time() / 60, battery_time() % 60); |
212 | else | 212 | else |
213 | return "(n/a)"; | 213 | return "Battery n/a"; /* translating worth it? */ |
214 | break; | 214 | break; |
215 | case INFO_DISK1: /* disk usage 1 */ | 215 | case INFO_DISK1: /* disk usage 1 */ |
216 | #ifdef HAVE_MULTIVOLUME | 216 | #ifdef HAVE_MULTIVOLUME |
@@ -289,9 +289,11 @@ static int info_speak_item(int selected_item, void * data) | |||
289 | #endif /* CONFIG_CHARGING = */ | 289 | #endif /* CONFIG_CHARGING = */ |
290 | if (battery_level() >= 0) | 290 | if (battery_level() >= 0) |
291 | { | 291 | { |
292 | int time_left = battery_time(); | ||
292 | talk_id(LANG_BATTERY_TIME, false); | 293 | talk_id(LANG_BATTERY_TIME, false); |
293 | talk_value(battery_level(), UNIT_PERCENT, true); | 294 | talk_value(battery_level(), UNIT_PERCENT, true); |
294 | talk_value(battery_time() *60, UNIT_TIME, true); | 295 | if (time_left >= 0) |
296 | talk_value(time_left * 60, UNIT_TIME, true); | ||
295 | } | 297 | } |
296 | else talk_id(VOICE_BLANK, false); | 298 | else talk_id(VOICE_BLANK, false); |
297 | break; | 299 | 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, | |||
219 | #if CONFIG_KEYPAD == RECORDER_PAD | 219 | #if CONFIG_KEYPAD == RECORDER_PAD |
220 | &buttonbar, | 220 | &buttonbar, |
221 | #endif | 221 | #endif |
222 | &volume_type, &battery_display); | 222 | &volume_type |
223 | #if (CONFIG_BATTERY_MEASURE != 0) | ||
224 | , &battery_display | ||
225 | #endif | ||
226 | ); | ||
223 | #endif /* HAVE_LCD_BITMAP */ | 227 | #endif /* HAVE_LCD_BITMAP */ |
224 | 228 | ||
225 | /* */ | 229 | /* */ |
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) | |||
277 | 277 | ||
278 | if (batt_safe) | 278 | if (batt_safe) |
279 | { | 279 | { |
280 | int level; | ||
280 | #ifdef HAVE_TAGCACHE | 281 | #ifdef HAVE_TAGCACHE |
281 | if (!tagcache_prepare_shutdown()) | 282 | if (!tagcache_prepare_shutdown()) |
282 | { | 283 | { |
@@ -285,7 +286,8 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter) | |||
285 | return false; | 286 | return false; |
286 | } | 287 | } |
287 | #endif | 288 | #endif |
288 | if (battery_level() > 10) | 289 | level = battery_level(); |
290 | if (level > 10 || level < 0) | ||
289 | splash(0, str(LANG_SHUTTINGDOWN)); | 291 | splash(0, str(LANG_SHUTTINGDOWN)); |
290 | else | 292 | else |
291 | { | 293 | { |
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 = { | |||
664 | battery_level, | 664 | battery_level, |
665 | battery_level_safe, | 665 | battery_level_safe, |
666 | battery_time, | 666 | battery_time, |
667 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0) | ||
668 | battery_voltage, | 667 | battery_voltage, |
669 | #endif | ||
670 | #if CONFIG_CHARGING | 668 | #if CONFIG_CHARGING |
671 | charger_inserted, | 669 | charger_inserted, |
672 | # if CONFIG_CHARGING >= CHARGING_MONITOR | 670 | # 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 { | |||
794 | int (*battery_level)(void); | 794 | int (*battery_level)(void); |
795 | bool (*battery_level_safe)(void); | 795 | bool (*battery_level_safe)(void); |
796 | int (*battery_time)(void); | 796 | int (*battery_time)(void); |
797 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0) | 797 | int (*battery_voltage)(void); |
798 | unsigned int (*battery_voltage)(void); | ||
799 | #endif | ||
800 | #if CONFIG_CHARGING | 798 | #if CONFIG_CHARGING |
801 | bool (*charger_inserted)(void); | 799 | bool (*charger_inserted)(void); |
802 | # if CONFIG_CHARGING >= CHARGING_MONITOR | 800 | # 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 @@ | |||
1 | /* plugins common to all models */ | 1 | /* plugins common to all models */ |
2 | #ifndef SIMULATOR | 2 | #if !defined(SIMULATOR) && (CONFIG_BATTERY_MEASURE != 0) |
3 | battery_bench.c | 3 | battery_bench.c |
4 | #endif | 4 | #endif |
5 | chessclock.c | 5 | 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 | |||
638 | 638 | ||
639 | /* power settings */ | 639 | /* power settings */ |
640 | int poweroff; /* idle power off timer */ | 640 | int poweroff; /* idle power off timer */ |
641 | #ifdef BATTERY_CAPACITY_DEFAULT | 641 | #if BATTERY_CAPACITY_DEFAULT > 0 |
642 | int battery_capacity; /* in mAh */ | 642 | int battery_capacity; /* in mAh */ |
643 | #endif | 643 | #endif |
644 | 644 | ||
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[] = { | |||
838 | NULL, NULL, NULL), | 838 | NULL, NULL, NULL), |
839 | /* use this setting for user code even if there's no exchangable battery | 839 | /* use this setting for user code even if there's no exchangable battery |
840 | * support enabled */ | 840 | * support enabled */ |
841 | #ifdef BATTERY_CAPACITY_DEFAULT | 841 | #if BATTERY_CAPACITY_DEFAULT > 0 |
842 | /* define min/max/inc for this file if there's only one battery */ | 842 | /* define min/max/inc for this file if there's only one battery */ |
843 | #ifndef BATTERY_CAPACITY_MIN | 843 | #ifndef BATTERY_CAPACITY_MIN |
844 | #define BATTERY_CAPACITY_MIN BATTERY_CAPACITY_DEFAULT | 844 | #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) | |||
358 | printf("Version " RBVERSION); | 358 | printf("Version " RBVERSION); |
359 | 359 | ||
360 | adc_init(); | 360 | adc_init(); |
361 | batt = battery_adc_voltage(); | 361 | batt = _battery_voltage(); |
362 | printf("Battery: %d.%03d V", batt / 1000, batt % 1000); | 362 | printf("Battery: %d.%03d V", batt / 1000, batt % 1000); |
363 | check_battery_safe(); | 363 | check_battery_safe(); |
364 | 364 | ||
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) | |||
110 | { | 110 | { |
111 | int battery_voltage, batt_int, batt_frac; | 111 | int battery_voltage, batt_int, batt_frac; |
112 | 112 | ||
113 | battery_voltage = battery_adc_voltage(); | 113 | battery_voltage = _battery_voltage(); |
114 | batt_int = battery_voltage / 1000; | 114 | batt_int = battery_voltage / 1000; |
115 | batt_frac = (battery_voltage % 1000) / 10; | 115 | batt_frac = (battery_voltage % 1000) / 10; |
116 | 116 | ||
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) | |||
170 | { | 170 | { |
171 | int battery_voltage, batt_int, batt_frac; | 171 | int battery_voltage, batt_int, batt_frac; |
172 | 172 | ||
173 | battery_voltage = battery_adc_voltage(); | 173 | battery_voltage = _battery_voltage(); |
174 | batt_int = battery_voltage / 1000; | 174 | batt_int = battery_voltage / 1000; |
175 | batt_frac = (battery_voltage % 1000) / 10; | 175 | batt_frac = (battery_voltage % 1000) / 10; |
176 | 176 | ||
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) | |||
112 | { | 112 | { |
113 | int battery_voltage, batt_int, batt_frac; | 113 | int battery_voltage, batt_int, batt_frac; |
114 | 114 | ||
115 | battery_voltage = battery_adc_voltage(); | 115 | battery_voltage = _battery_voltage(); |
116 | batt_int = battery_voltage / 1000; | 116 | batt_int = battery_voltage / 1000; |
117 | batt_frac = (battery_voltage % 1000) / 10; | 117 | batt_frac = (battery_voltage % 1000) / 10; |
118 | 118 | ||
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) | |||
160 | 160 | ||
161 | int battery_voltage, batt_int, batt_frac; | 161 | int battery_voltage, batt_int, batt_frac; |
162 | 162 | ||
163 | battery_voltage = battery_adc_voltage(); | 163 | battery_voltage = _battery_voltage(); |
164 | batt_int = battery_voltage / 1000; | 164 | batt_int = battery_voltage / 1000; |
165 | batt_frac = (battery_voltage % 1000) / 10; | 165 | batt_frac = (battery_voltage % 1000) / 10; |
166 | 166 | ||
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 | |||
14 | #endif | 14 | #endif |
15 | 15 | ||
16 | #ifndef SAMSUNG_YPR0 /* uses as3514 rtc */ | 16 | #ifndef SAMSUNG_YPR0 /* uses as3514 rtc */ |
17 | target/hosted/powermgmt.c | ||
18 | target/hosted/rtc.c | 17 | target/hosted/rtc.c |
19 | #endif | 18 | #endif |
20 | #endif | 19 | #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) | |||
59 | { | 59 | { |
60 | (void)balance; | 60 | (void)balance; |
61 | } | 61 | } |
62 | |||
63 | 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) | |||
167 | void audiohw_set_depth_3d(int value) | 167 | void audiohw_set_depth_3d(int value) |
168 | { (void)value; } | 168 | { (void)value; } |
169 | #endif | 169 | #endif |
170 | |||
171 | void audiohw_close(void) {} | ||
172 | |||
170 | #ifdef CONFIG_SAMPR_TYPES | 173 | #ifdef CONFIG_SAMPR_TYPES |
171 | unsigned int pcm_sampr_to_hw_sampr(unsigned int samplerate, | 174 | unsigned int pcm_sampr_to_hw_sampr(unsigned int samplerate, |
172 | unsigned int type) | 175 | 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 @@ | |||
184 | * charging or specific programming is required to | 184 | * charging or specific programming is required to |
185 | * use the charging hardware. */ | 185 | * use the charging hardware. */ |
186 | 186 | ||
187 | /* CONFIG_BATTERY_MEASURE bits */ | ||
188 | #define VOLTAGE_MEASURE 1 /* Target can report battery voltage | ||
189 | * Usually native ports */ | ||
190 | #define PERCENTAGE_MEASURE 2 /* Target can report remaining capacity in % | ||
191 | * Usually application/hosted ports */ | ||
192 | #define TIME_MEASURE 4 /* Target can report remaining time estimation | ||
193 | Usually application ports, and only | ||
194 | if the estimation is better that ours | ||
195 | (which it probably is) */ | ||
187 | /* CONFIG_LCD */ | 196 | /* CONFIG_LCD */ |
188 | #define LCD_SSD1815 1 /* as used by Archos Recorders and Ondios */ | 197 | #define LCD_SSD1815 1 /* as used by Archos Recorders and Ondios */ |
189 | #define LCD_SSD1801 2 /* as used by Archos Player/Studio */ | 198 | #define LCD_SSD1801 2 /* as used by Archos Player/Studio */ |
@@ -603,6 +612,11 @@ Lyre prototype 1 */ | |||
603 | #define CONFIG_CHARGING 0 | 612 | #define CONFIG_CHARGING 0 |
604 | #endif | 613 | #endif |
605 | 614 | ||
615 | #ifndef CONFIG_BATTERY_MEASURE | ||
616 | #define CONFIG_BATTERY_MEASURE 0 | ||
617 | #define NO_LOW_BATTERY_SHUTDOWN | ||
618 | #endif | ||
619 | |||
606 | #ifndef CONFIG_RTC | 620 | #ifndef CONFIG_RTC |
607 | #define CONFIG_RTC 0 | 621 | #define CONFIG_RTC 0 |
608 | #endif | 622 | #endif |
@@ -611,6 +625,10 @@ Lyre prototype 1 */ | |||
611 | #define BATTERY_TYPES_COUNT 0 | 625 | #define BATTERY_TYPES_COUNT 0 |
612 | #endif | 626 | #endif |
613 | 627 | ||
628 | #ifndef BATTERY_CAPACITY_DEFAULT | ||
629 | #define BATTERY_CAPACITY_DEFAULT 0 | ||
630 | #endif | ||
631 | |||
614 | #ifndef BATTERY_CAPACITY_INC | 632 | #ifndef BATTERY_CAPACITY_INC |
615 | #define BATTERY_CAPACITY_INC 0 | 633 | #define BATTERY_CAPACITY_INC 0 |
616 | #endif | 634 | #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 @@ | |||
86 | 86 | ||
87 | #define HAVE_HEADPHONE_DETECTION | 87 | #define HAVE_HEADPHONE_DETECTION |
88 | 88 | ||
89 | /* Define current usage levels. */ | 89 | #define CONFIG_BATTERY_MEASURE PERCENTAGE_MEASURE |
90 | #define CURRENT_NORMAL 88 /* 18 hours from a 1600 mAh battery */ | ||
91 | #define CURRENT_BACKLIGHT 30 /* TBD */ | ||
92 | #define CURRENT_RECORD 0 /* no recording yet */ | ||
93 | 90 | ||
91 | #define NO_LOW_BATTERY_SHUTDOWN | ||
94 | /* Define this to the CPU frequency */ | 92 | /* Define this to the CPU frequency */ |
95 | /* | 93 | /* |
96 | #define CPU_FREQ 48000000 | 94 | #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 @@ | |||
91 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 91 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
92 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 92 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
93 | 93 | ||
94 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
95 | |||
94 | #define CURRENT_NORMAL 145 /* usual current in mA */ | 96 | #define CURRENT_NORMAL 145 /* usual current in mA */ |
95 | #define CURRENT_RECORD 35 /* additional recording current */ | 97 | #define CURRENT_RECORD 35 /* additional recording current */ |
96 | #define CURRENT_USB 500 /* usual current in mA in USB mode */ | 98 | #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 @@ | |||
73 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 73 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
74 | #define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */ | 74 | #define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */ |
75 | 75 | ||
76 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
77 | |||
76 | /* define this if the unit should not shut down on low battery. */ | 78 | /* define this if the unit should not shut down on low battery. */ |
77 | #define NO_LOW_BATTERY_SHUTDOWN | 79 | #define NO_LOW_BATTERY_SHUTDOWN |
78 | 80 | ||
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 @@ | |||
60 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 60 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
61 | #define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */ | 61 | #define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */ |
62 | 62 | ||
63 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
64 | |||
63 | /* define this if the unit should not shut down on low battery. */ | 65 | /* define this if the unit should not shut down on low battery. */ |
64 | #define NO_LOW_BATTERY_SHUTDOWN | 66 | #define NO_LOW_BATTERY_SHUTDOWN |
65 | 67 | ||
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 @@ | |||
49 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 49 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
50 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 50 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
51 | 51 | ||
52 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
53 | |||
52 | #define CURRENT_NORMAL 145 /* usual current in mA */ | 54 | #define CURRENT_NORMAL 145 /* usual current in mA */ |
53 | #define CURRENT_USB 500 /* usual current in mA in USB mode */ | 55 | #define CURRENT_USB 500 /* usual current in mA in USB mode */ |
54 | 56 | ||
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 @@ | |||
80 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 80 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
81 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 81 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
82 | 82 | ||
83 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
84 | |||
83 | #if MEMORYSIZE < 8 | 85 | #if MEMORYSIZE < 8 |
84 | #define CURRENT_NORMAL 145 /* usual current in mA */ | 86 | #define CURRENT_NORMAL 145 /* usual current in mA */ |
85 | #else | 87 | #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 @@ | |||
86 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 86 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
87 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 87 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
88 | 88 | ||
89 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
90 | |||
89 | #define CURRENT_NORMAL 145 /* usual current in mA */ | 91 | #define CURRENT_NORMAL 145 /* usual current in mA */ |
90 | #define CURRENT_RECORD 35 /* additional recording current */ | 92 | #define CURRENT_RECORD 35 /* additional recording current */ |
91 | #define CURRENT_USB 500 /* usual current in mA in USB mode */ | 93 | #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 @@ | |||
136 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 136 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
137 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 137 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
138 | 138 | ||
139 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
140 | |||
139 | /* Hardware controlled charging */ | 141 | /* Hardware controlled charging */ |
140 | #define CONFIG_CHARGING CHARGING_SIMPLE | 142 | #define CONFIG_CHARGING CHARGING_SIMPLE |
141 | 143 | ||
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 @@ | |||
130 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ | 130 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ |
131 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 131 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
132 | 132 | ||
133 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
134 | |||
133 | /* Hardware controlled charging with monitoring */ | 135 | /* Hardware controlled charging with monitoring */ |
134 | //#define CONFIG_CHARGING CHARGING_MONITOR | 136 | //#define CONFIG_CHARGING CHARGING_MONITOR |
135 | 137 | ||
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 @@ | |||
129 | #define BATTERY_CAPACITY_INC 25 /* capacity increment */ | 129 | #define BATTERY_CAPACITY_INC 25 /* capacity increment */ |
130 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 130 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
131 | 131 | ||
132 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
133 | |||
132 | /* Hardware controlled charging with monitoring */ | 134 | /* Hardware controlled charging with monitoring */ |
133 | #define CONFIG_CHARGING CHARGING_MONITOR | 135 | #define CONFIG_CHARGING CHARGING_MONITOR |
134 | 136 | ||
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 @@ | |||
173 | #define BATTERY_CAPACITY_INC 25 /* capacity increment */ | 173 | #define BATTERY_CAPACITY_INC 25 /* capacity increment */ |
174 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 174 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
175 | 175 | ||
176 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
177 | |||
176 | /* TODO: have a proper status displayed in the bootloader and have it | 178 | /* TODO: have a proper status displayed in the bootloader and have it |
177 | * work! */ | 179 | * work! */ |
178 | /* Charging implemented in a target-specific algorithm */ | 180 | /* 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 @@ | |||
141 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | 141 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ |
142 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 142 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
143 | 143 | ||
144 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
145 | |||
144 | /* Hardware controlled charging */ | 146 | /* Hardware controlled charging */ |
145 | #define CONFIG_CHARGING CHARGING_SIMPLE | 147 | #define CONFIG_CHARGING CHARGING_SIMPLE |
146 | 148 | ||
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 @@ | |||
144 | #define BATTERY_CAPACITY_INC 20 /* capacity increment */ | 144 | #define BATTERY_CAPACITY_INC 20 /* capacity increment */ |
145 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 145 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
146 | 146 | ||
147 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
148 | |||
147 | /* Hardware controlled charging */ | 149 | /* Hardware controlled charging */ |
148 | #define CONFIG_CHARGING CHARGING_SIMPLE | 150 | #define CONFIG_CHARGING CHARGING_SIMPLE |
149 | 151 | ||
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 @@ | |||
125 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | 125 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ |
126 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 126 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
127 | 127 | ||
128 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
129 | |||
128 | /* Charging implemented in a target-specific algorithm */ | 130 | /* Charging implemented in a target-specific algorithm */ |
129 | #define CONFIG_CHARGING CHARGING_TARGET | 131 | #define CONFIG_CHARGING CHARGING_TARGET |
130 | #define HAVE_POWEROFF_WHILE_CHARGING | 132 | #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 @@ | |||
130 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ | 130 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ |
131 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 131 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
132 | 132 | ||
133 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
134 | |||
133 | /* Hardware controlled charging with monitoring */ | 135 | /* Hardware controlled charging with monitoring */ |
134 | #define CONFIG_CHARGING CHARGING_MONITOR | 136 | #define CONFIG_CHARGING CHARGING_MONITOR |
135 | 137 | ||
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 @@ | |||
118 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 118 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
119 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 119 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
120 | 120 | ||
121 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
122 | |||
121 | /* Hardware controlled charging with monitoring */ | 123 | /* Hardware controlled charging with monitoring */ |
122 | #define CONFIG_CHARGING CHARGING_MONITOR | 124 | #define CONFIG_CHARGING CHARGING_MONITOR |
123 | 125 | ||
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 @@ | |||
131 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 131 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
132 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 132 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
133 | 133 | ||
134 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
135 | |||
134 | #define CONFIG_CHARGING CHARGING_SIMPLE | 136 | #define CONFIG_CHARGING CHARGING_SIMPLE |
135 | 137 | ||
136 | /* Define this if you have a TCC770 */ | 138 | /* 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 @@ | |||
114 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 114 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
115 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 115 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
116 | 116 | ||
117 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
118 | |||
117 | /* Hardware controlled charging? FIXME */ | 119 | /* Hardware controlled charging? FIXME */ |
118 | #define CONFIG_CHARGING CHARGING_SIMPLE | 120 | #define CONFIG_CHARGING CHARGING_SIMPLE |
119 | 121 | ||
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 @@ | |||
138 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 138 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
139 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 139 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
140 | 140 | ||
141 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
142 | |||
141 | /* Hardware controlled charging? FIXME */ | 143 | /* Hardware controlled charging? FIXME */ |
142 | #define CONFIG_CHARGING CHARGING_SIMPLE | 144 | #define CONFIG_CHARGING CHARGING_SIMPLE |
143 | 145 | ||
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 @@ | |||
141 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 141 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
142 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 142 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
143 | 143 | ||
144 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
145 | |||
144 | /* Hardware controlled charging? FIXME */ | 146 | /* Hardware controlled charging? FIXME */ |
145 | #define CONFIG_CHARGING CHARGING_SIMPLE | 147 | #define CONFIG_CHARGING CHARGING_SIMPLE |
146 | 148 | ||
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 @@ | |||
130 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 130 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
131 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 131 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
132 | 132 | ||
133 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
134 | |||
133 | /* Hardware controlled charging? FIXME */ | 135 | /* Hardware controlled charging? FIXME */ |
134 | //#define CONFIG_CHARGING CHARGING_SIMPLE | 136 | //#define CONFIG_CHARGING CHARGING_SIMPLE |
135 | 137 | ||
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 @@ | |||
137 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ | 137 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ |
138 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 138 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
139 | 139 | ||
140 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
141 | |||
140 | /* Hardware controlled charging? FIXME */ | 142 | /* Hardware controlled charging? FIXME */ |
141 | #define CONFIG_CHARGING CHARGING_SIMPLE | 143 | #define CONFIG_CHARGING CHARGING_SIMPLE |
142 | 144 | ||
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 @@ | |||
143 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ | 143 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ |
144 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 144 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
145 | 145 | ||
146 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
147 | |||
146 | /* Hardware controlled charging? */ | 148 | /* Hardware controlled charging? */ |
147 | #define CONFIG_CHARGING CHARGING_MONITOR | 149 | #define CONFIG_CHARGING CHARGING_MONITOR |
148 | 150 | ||
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 @@ | |||
145 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ | 145 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ |
146 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 146 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
147 | 147 | ||
148 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
149 | |||
148 | /* Hardware controlled charging with monitoring */ | 150 | /* Hardware controlled charging with monitoring */ |
149 | #define CONFIG_CHARGING CHARGING_MONITOR | 151 | #define CONFIG_CHARGING CHARGING_MONITOR |
150 | 152 | ||
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 @@ | |||
130 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ | 130 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ |
131 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 131 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
132 | 132 | ||
133 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
134 | |||
133 | /* Hardware controlled charging? */ | 135 | /* Hardware controlled charging? */ |
134 | #define CONFIG_CHARGING CHARGING_MONITOR | 136 | #define CONFIG_CHARGING CHARGING_MONITOR |
135 | 137 | ||
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 @@ | |||
141 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ | 141 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ |
142 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 142 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
143 | 143 | ||
144 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
145 | |||
144 | /* define current usage levels */ | 146 | /* define current usage levels */ |
145 | #define CURRENT_NORMAL 50 /* PP5024 uses ~40mA, so add some for disk */ | 147 | #define CURRENT_NORMAL 50 /* PP5024 uses ~40mA, so add some for disk */ |
146 | #define CURRENT_BACKLIGHT 20 /* FIXME: This needs to be measured */ | 148 | #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 @@ | |||
142 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 142 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
143 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 143 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
144 | 144 | ||
145 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
146 | |||
145 | /* define current usage levels */ | 147 | /* define current usage levels */ |
146 | #define CURRENT_NORMAL 50 /* PP5024 uses ~40mA, so add some for disk */ | 148 | #define CURRENT_NORMAL 50 /* PP5024 uses ~40mA, so add some for disk */ |
147 | #define CURRENT_BACKLIGHT 20 /* FIXME: This needs to be measured */ | 149 | #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 @@ | |||
134 | #define BATTERY_CAPACITY_INC 20 /* capacity increment */ | 134 | #define BATTERY_CAPACITY_INC 20 /* capacity increment */ |
135 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 135 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
136 | 136 | ||
137 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
138 | |||
137 | /* Hardware controlled charging with monitoring */ | 139 | /* Hardware controlled charging with monitoring */ |
138 | #define CONFIG_CHARGING CHARGING_MONITOR | 140 | #define CONFIG_CHARGING CHARGING_MONITOR |
139 | 141 | ||
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 @@ | |||
148 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ | 148 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ |
149 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 149 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
150 | 150 | ||
151 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
152 | |||
151 | /* Hardware controlled charging with monitoring */ | 153 | /* Hardware controlled charging with monitoring */ |
152 | #define CONFIG_CHARGING CHARGING_MONITOR | 154 | #define CONFIG_CHARGING CHARGING_MONITOR |
153 | 155 | ||
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 @@ | |||
149 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 149 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
150 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 150 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
151 | 151 | ||
152 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
153 | |||
152 | /* Hardware controlled charging with monitoring */ | 154 | /* Hardware controlled charging with monitoring */ |
153 | #define CONFIG_CHARGING CHARGING_MONITOR | 155 | #define CONFIG_CHARGING CHARGING_MONITOR |
154 | 156 | ||
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 @@ | |||
127 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 127 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
128 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 128 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
129 | 129 | ||
130 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
131 | |||
130 | /* Hardware controlled charging */ | 132 | /* Hardware controlled charging */ |
131 | #define CONFIG_CHARGING CHARGING_SIMPLE | 133 | #define CONFIG_CHARGING CHARGING_SIMPLE |
132 | 134 | ||
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 @@ | |||
131 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 131 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
132 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 132 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
133 | 133 | ||
134 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
135 | |||
134 | /* Hardware controlled charging */ | 136 | /* Hardware controlled charging */ |
135 | #define CONFIG_CHARGING CHARGING_SIMPLE | 137 | #define CONFIG_CHARGING CHARGING_SIMPLE |
136 | 138 | ||
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 @@ | |||
110 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ | 110 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ |
111 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 111 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
112 | 112 | ||
113 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
114 | |||
113 | /* Hardware controlled charging */ | 115 | /* Hardware controlled charging */ |
114 | #define CONFIG_CHARGING CHARGING_SIMPLE | 116 | #define CONFIG_CHARGING CHARGING_SIMPLE |
115 | 117 | ||
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 @@ | |||
135 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 135 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
136 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 136 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
137 | 137 | ||
138 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
139 | |||
138 | /* Hardware controlled charging */ | 140 | /* Hardware controlled charging */ |
139 | #define CONFIG_CHARGING CHARGING_SIMPLE | 141 | #define CONFIG_CHARGING CHARGING_SIMPLE |
140 | 142 | ||
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 @@ | |||
130 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 130 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
131 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 131 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
132 | 132 | ||
133 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
134 | |||
133 | /* Hardware controlled charging with monitoring */ | 135 | /* Hardware controlled charging with monitoring */ |
134 | #define CONFIG_CHARGING CHARGING_MONITOR | 136 | #define CONFIG_CHARGING CHARGING_MONITOR |
135 | 137 | ||
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 @@ | |||
70 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 70 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
71 | #define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */ | 71 | #define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */ |
72 | 72 | ||
73 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
74 | |||
73 | /* define this if the unit should not shut down on low battery. */ | 75 | /* define this if the unit should not shut down on low battery. */ |
74 | #define NO_LOW_BATTERY_SHUTDOWN | 76 | #define NO_LOW_BATTERY_SHUTDOWN |
75 | 77 | ||
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 @@ | |||
102 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 102 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
103 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 103 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
104 | 104 | ||
105 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
106 | |||
105 | /* define this if the unit should not shut down on low battery. */ | 107 | /* define this if the unit should not shut down on low battery. */ |
106 | #define NO_LOW_BATTERY_SHUTDOWN | 108 | #define NO_LOW_BATTERY_SHUTDOWN |
107 | 109 | ||
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 @@ | |||
84 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ | 84 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ |
85 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 85 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
86 | 86 | ||
87 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
88 | |||
87 | #define CONFIG_CPU AT91SAM9260 | 89 | #define CONFIG_CPU AT91SAM9260 |
88 | 90 | ||
89 | /* Define this to the CPU frequency */ | 91 | /* 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 @@ | |||
119 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 119 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
120 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 120 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
121 | 121 | ||
122 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
123 | |||
122 | /* Hardware controlled charging, software can monitor plug and charge state */ | 124 | /* Hardware controlled charging, software can monitor plug and charge state */ |
123 | #define CONFIG_CHARGING CHARGING_MONITOR | 125 | #define CONFIG_CHARGING CHARGING_MONITOR |
124 | 126 | ||
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 @@ | |||
119 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 119 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
120 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 120 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
121 | 121 | ||
122 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
123 | |||
122 | /* Hardware controlled charging? FIXME */ | 124 | /* Hardware controlled charging? FIXME */ |
123 | #define CONFIG_CHARGING CHARGING_SIMPLE | 125 | #define CONFIG_CHARGING CHARGING_SIMPLE |
124 | 126 | ||
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 @@ | |||
125 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 125 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
126 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 126 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
127 | 127 | ||
128 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
129 | |||
128 | /* Hardware controlled charging? FIXME */ | 130 | /* Hardware controlled charging? FIXME */ |
129 | #define CONFIG_CHARGING CHARGING_SIMPLE | 131 | #define CONFIG_CHARGING CHARGING_SIMPLE |
130 | 132 | ||
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 @@ | |||
95 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ | 95 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ |
96 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 96 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
97 | 97 | ||
98 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
99 | |||
98 | 100 | ||
99 | 101 | ||
100 | /***************************************************************************/ | 102 | /***************************************************************************/ |
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 @@ | |||
116 | #define CODEC_SRCTRL_88200HZ (0x1E << 1) | 116 | #define CODEC_SRCTRL_88200HZ (0x1E << 1) |
117 | 117 | ||
118 | #define BATTERY_TYPES_COUNT 1 | 118 | #define BATTERY_TYPES_COUNT 1 |
119 | |||
120 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
119 | #define BATTERY_CAPACITY_DEFAULT 850 /* this is wild guess */ | 121 | #define BATTERY_CAPACITY_DEFAULT 850 /* this is wild guess */ |
120 | #define BATTERY_CAPACITY_MIN 800 /* min. capacity selectable */ | 122 | #define BATTERY_CAPACITY_MIN 800 /* min. capacity selectable */ |
121 | #define BATTERY_CAPACITY_MAX 2500 /* max. capacity selectable */ | 123 | #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 @@ | |||
119 | #define CODEC_SRCTRL_88200HZ (0x1E << 1) | 119 | #define CODEC_SRCTRL_88200HZ (0x1E << 1) |
120 | 120 | ||
121 | #define BATTERY_TYPES_COUNT 1 | 121 | #define BATTERY_TYPES_COUNT 1 |
122 | |||
123 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
122 | #define BATTERY_CAPACITY_DEFAULT 1200 /* this is wild guess */ | 124 | #define BATTERY_CAPACITY_DEFAULT 1200 /* this is wild guess */ |
123 | #define BATTERY_CAPACITY_MIN 800 /* min. capacity selectable */ | 125 | #define BATTERY_CAPACITY_MIN 800 /* min. capacity selectable */ |
124 | #define BATTERY_CAPACITY_MAX 2500 /* max. capacity selectable */ | 126 | #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 @@ | |||
142 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | 142 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ |
143 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 143 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
144 | 144 | ||
145 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
146 | |||
145 | /* Hardware controlled charging */ | 147 | /* Hardware controlled charging */ |
146 | #define CONFIG_CHARGING CHARGING_SIMPLE | 148 | #define CONFIG_CHARGING CHARGING_SIMPLE |
147 | 149 | ||
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 @@ | |||
197 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ | 197 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ |
198 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 198 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
199 | 199 | ||
200 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
201 | |||
200 | /* define current usage levels */ | 202 | /* define current usage levels */ |
201 | #define CURRENT_NORMAL 85 /* Measured */ | 203 | #define CURRENT_NORMAL 85 /* Measured */ |
202 | #define CURRENT_BACKLIGHT 200 /* Over 200 mA total measured when on */ | 204 | #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 @@ | |||
74 | #define HAVE_SDL | 74 | #define HAVE_SDL |
75 | #define HAVE_SDL_AUDIO | 75 | #define HAVE_SDL_AUDIO |
76 | 76 | ||
77 | #define HAVE_SW_TONE_CONTROLS | 77 | #define HAVE_SW_TONE_CONTROLS |
78 | 78 | ||
79 | /* Define current usage levels. */ | 79 | /* can provide both remaining percentage and time information */ |
80 | #define CURRENT_NORMAL 88 /* 18 hours from a 1600 mAh battery */ | 80 | #define CONFIG_BATTERY_MEASURE (PERCENTAGE_MEASURE|TIME_MEASURE) |
81 | #define CURRENT_BACKLIGHT 30 /* TBD */ | 81 | #define NO_LOW_BATTERY_SHUTDOWN |
82 | #define CURRENT_RECORD 0 /* no recording yet */ | ||
83 | 82 | ||
84 | /* Define this to the CPU frequency */ | 83 | /* Define this to the CPU frequency */ |
85 | /* | 84 | /* |
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 @@ | |||
74 | #define HAVE_SDL | 74 | #define HAVE_SDL |
75 | #define HAVE_SDL_AUDIO | 75 | #define HAVE_SDL_AUDIO |
76 | 76 | ||
77 | #define HAVE_SW_TONE_CONTROLS | 77 | #define HAVE_SW_TONE_CONTROLS |
78 | 78 | ||
79 | /* Define current usage levels. */ | 79 | /* can provide both remaining percentage and time information */ |
80 | #define CURRENT_NORMAL 88 /* 18 hours from a 1600 mAh battery */ | 80 | #define CONFIG_BATTERY_MEASURE (PERCENTAGE_MEASURE|TIME_MEASURE) |
81 | #define CURRENT_BACKLIGHT 30 /* TBD */ | 81 | #define NO_LOW_BATTERY_SHUTDOWN |
82 | #define CURRENT_RECORD 0 /* no recording yet */ | ||
83 | |||
84 | /* Define this to the CPU frequency */ | ||
85 | /* | 82 | /* |
86 | #define CPU_FREQ 48000000 | 83 | #define CPU_FREQ 48000000 |
87 | */ | 84 | */ |
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 @@ | |||
157 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ | 157 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ |
158 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 158 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
159 | 159 | ||
160 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
161 | |||
160 | /* Hardware controlled charging with monitoring */ | 162 | /* Hardware controlled charging with monitoring */ |
161 | #define CONFIG_CHARGING CHARGING_MONITOR | 163 | #define CONFIG_CHARGING CHARGING_MONITOR |
162 | 164 | ||
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 @@ | |||
132 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ | 132 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ |
133 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 133 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
134 | 134 | ||
135 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
136 | |||
135 | /* Hardware controlled charging with monitoring */ | 137 | /* Hardware controlled charging with monitoring */ |
136 | //#define CONFIG_CHARGING CHARGING_MONITOR | 138 | //#define CONFIG_CHARGING CHARGING_MONITOR |
137 | 139 | ||
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 @@ | |||
151 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ | 151 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ |
152 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 152 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
153 | 153 | ||
154 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
155 | |||
154 | /* Hardware controlled charging with monitoring */ | 156 | /* Hardware controlled charging with monitoring */ |
155 | #define CONFIG_CHARGING CHARGING_MONITOR | 157 | #define CONFIG_CHARGING CHARGING_MONITOR |
156 | 158 | ||
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 @@ | |||
136 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ | 136 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ |
137 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 137 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
138 | 138 | ||
139 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
140 | |||
139 | /* Hardware controlled charging with monitoring */ | 141 | /* Hardware controlled charging with monitoring */ |
140 | #define CONFIG_CHARGING CHARGING_MONITOR | 142 | #define CONFIG_CHARGING CHARGING_MONITOR |
141 | 143 | ||
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 @@ | |||
134 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 134 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
135 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 135 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
136 | 136 | ||
137 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
138 | |||
137 | /* Hardware controlled charging */ | 139 | /* Hardware controlled charging */ |
138 | #define CONFIG_CHARGING CHARGING_SIMPLE | 140 | #define CONFIG_CHARGING CHARGING_SIMPLE |
139 | 141 | ||
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 @@ | |||
141 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 141 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
142 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 142 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
143 | 143 | ||
144 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
145 | |||
144 | /* Hardware controlled charging */ | 146 | /* Hardware controlled charging */ |
145 | #define CONFIG_CHARGING CHARGING_SIMPLE | 147 | #define CONFIG_CHARGING CHARGING_SIMPLE |
146 | 148 | ||
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 @@ | |||
138 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 138 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
139 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 139 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
140 | 140 | ||
141 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
142 | |||
141 | /* Hardware controlled charging */ | 143 | /* Hardware controlled charging */ |
142 | #define CONFIG_CHARGING CHARGING_SIMPLE | 144 | #define CONFIG_CHARGING CHARGING_SIMPLE |
143 | 145 | ||
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 @@ | |||
132 | #define CURRENT_NORMAL 24 /* ~25h, on 600mAh that's about 24mA */ | 132 | #define CURRENT_NORMAL 24 /* ~25h, on 600mAh that's about 24mA */ |
133 | #define CURRENT_BACKLIGHT 62 /* ~6,5h -> 92mA. Minus 24mA normal that gives us 68mA */ | 133 | #define CURRENT_BACKLIGHT 62 /* ~6,5h -> 92mA. Minus 24mA normal that gives us 68mA */ |
134 | 134 | ||
135 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
136 | |||
135 | /* Linux controlls charging, we can monitor */ | 137 | /* Linux controlls charging, we can monitor */ |
136 | #define CONFIG_CHARGING CHARGING_MONITOR | 138 | #define CONFIG_CHARGING CHARGING_MONITOR |
137 | 139 | ||
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 @@ | |||
118 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | 118 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ |
119 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 119 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
120 | 120 | ||
121 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
122 | |||
121 | /* Hardware controlled charging, software can monitor plug and charge state */ | 123 | /* Hardware controlled charging, software can monitor plug and charge state */ |
122 | #define CONFIG_CHARGING CHARGING_MONITOR | 124 | #define CONFIG_CHARGING CHARGING_MONITOR |
123 | 125 | ||
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 @@ | |||
92 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 92 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
93 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 93 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
94 | 94 | ||
95 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
96 | |||
95 | /* define this if the unit should not shut down on low battery. */ | 97 | /* define this if the unit should not shut down on low battery. */ |
96 | #define NO_LOW_BATTERY_SHUTDOWN | 98 | #define NO_LOW_BATTERY_SHUTDOWN |
97 | 99 | ||
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 @@ | |||
142 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | 142 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ |
143 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 143 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
144 | 144 | ||
145 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
146 | |||
145 | /* Charging implemented in a target-specific algorithm */ | 147 | /* Charging implemented in a target-specific algorithm */ |
146 | #define CONFIG_CHARGING CHARGING_TARGET | 148 | #define CONFIG_CHARGING CHARGING_TARGET |
147 | #define HAVE_POWEROFF_WHILE_CHARGING | 149 | #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 @@ | |||
138 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | 138 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ |
139 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 139 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
140 | 140 | ||
141 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
142 | |||
141 | /* Charging implemented in a target-specific algorithm */ | 143 | /* Charging implemented in a target-specific algorithm */ |
142 | #define CONFIG_CHARGING CHARGING_TARGET | 144 | #define CONFIG_CHARGING CHARGING_TARGET |
143 | 145 | ||
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 @@ | |||
141 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | 141 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ |
142 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 142 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
143 | 143 | ||
144 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
145 | |||
144 | /* Charging implemented in a target-specific algorithm */ | 146 | /* Charging implemented in a target-specific algorithm */ |
145 | #define CONFIG_CHARGING CHARGING_TARGET | 147 | #define CONFIG_CHARGING CHARGING_TARGET |
146 | 148 | ||
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 @@ | |||
148 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | 148 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ |
149 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 149 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
150 | 150 | ||
151 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
152 | |||
151 | /* Charging implemented in a target-specific algorithm */ | 153 | /* Charging implemented in a target-specific algorithm */ |
152 | #define CONFIG_CHARGING CHARGING_TARGET | 154 | #define CONFIG_CHARGING CHARGING_TARGET |
153 | 155 | ||
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 @@ | |||
144 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | 144 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ |
145 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 145 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
146 | 146 | ||
147 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
148 | |||
147 | /* Charging implemented in a target-specific algorithm */ | 149 | /* Charging implemented in a target-specific algorithm */ |
148 | #define CONFIG_CHARGING CHARGING_TARGET | 150 | #define CONFIG_CHARGING CHARGING_TARGET |
149 | 151 | ||
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 @@ | |||
149 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | 149 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ |
150 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 150 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
151 | 151 | ||
152 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
153 | |||
152 | /* Charging implemented in a target-specific algorithm */ | 154 | /* Charging implemented in a target-specific algorithm */ |
153 | #define CONFIG_CHARGING CHARGING_TARGET | 155 | #define CONFIG_CHARGING CHARGING_TARGET |
154 | 156 | ||
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 @@ | |||
149 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ | 149 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ |
150 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 150 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
151 | 151 | ||
152 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
153 | |||
152 | /* define current usage levels */ | 154 | /* define current usage levels */ |
153 | #if 0 | 155 | #if 0 |
154 | /* TODO */ | 156 | /* 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 @@ | |||
142 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | 142 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ |
143 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 143 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
144 | 144 | ||
145 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
146 | |||
145 | /* Charging implemented in a target-specific algorithm */ | 147 | /* Charging implemented in a target-specific algorithm */ |
146 | #define CONFIG_CHARGING CHARGING_TARGET | 148 | #define CONFIG_CHARGING CHARGING_TARGET |
147 | #define HAVE_POWEROFF_WHILE_CHARGING | 149 | #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 @@ | |||
152 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | 152 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ |
153 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 153 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
154 | 154 | ||
155 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
156 | |||
155 | /* Charging implemented in a target-specific algorithm */ | 157 | /* Charging implemented in a target-specific algorithm */ |
156 | #define CONFIG_CHARGING CHARGING_TARGET | 158 | #define CONFIG_CHARGING CHARGING_TARGET |
157 | 159 | ||
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 @@ | |||
156 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | 156 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ |
157 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 157 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
158 | 158 | ||
159 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
160 | |||
159 | /* Charging implemented in a target-specific algorithm */ | 161 | /* Charging implemented in a target-specific algorithm */ |
160 | #define CONFIG_CHARGING CHARGING_TARGET | 162 | #define CONFIG_CHARGING CHARGING_TARGET |
161 | 163 | ||
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 @@ | |||
140 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | 140 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ |
141 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 141 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
142 | 142 | ||
143 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
144 | |||
143 | /* Charging implemented in a target-specific algorithm */ | 145 | /* Charging implemented in a target-specific algorithm */ |
144 | #define CONFIG_CHARGING CHARGING_TARGET | 146 | #define CONFIG_CHARGING CHARGING_TARGET |
145 | 147 | ||
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 @@ | |||
161 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | 161 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ |
162 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 162 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
163 | 163 | ||
164 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
165 | |||
164 | /* Charging implemented in a target-specific algorithm */ | 166 | /* Charging implemented in a target-specific algorithm */ |
165 | #define CONFIG_CHARGING CHARGING_TARGET | 167 | #define CONFIG_CHARGING CHARGING_TARGET |
166 | 168 | ||
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 @@ | |||
98 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 98 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
99 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 99 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
100 | 100 | ||
101 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
102 | |||
101 | /* define this if the unit should not shut down on low battery. */ | 103 | /* define this if the unit should not shut down on low battery. */ |
102 | #define NO_LOW_BATTERY_SHUTDOWN | 104 | #define NO_LOW_BATTERY_SHUTDOWN |
103 | 105 | ||
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 @@ | |||
118 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 118 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
119 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 119 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
120 | 120 | ||
121 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
122 | |||
121 | /* define this if the unit should not shut down on low battery. */ | 123 | /* define this if the unit should not shut down on low battery. */ |
122 | #define NO_LOW_BATTERY_SHUTDOWN | 124 | #define NO_LOW_BATTERY_SHUTDOWN |
123 | 125 | ||
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 @@ | |||
129 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | 129 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ |
130 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 130 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
131 | 131 | ||
132 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
133 | |||
132 | /* Charging implemented in a target-specific algorithm */ | 134 | /* Charging implemented in a target-specific algorithm */ |
133 | #define CONFIG_CHARGING CHARGING_SIMPLE | 135 | #define CONFIG_CHARGING CHARGING_SIMPLE |
134 | #define HAVE_POWEROFF_WHILE_CHARGING | 136 | #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 @@ | |||
80 | 80 | ||
81 | #define HAVE_SW_TONE_CONTROLS | 81 | #define HAVE_SW_TONE_CONTROLS |
82 | 82 | ||
83 | /* Define current usage levels. */ | ||
84 | #define CURRENT_NORMAL 88 /* 18 hours from a 1600 mAh battery */ | ||
85 | #define CURRENT_BACKLIGHT 30 /* TBD */ | ||
86 | #define CURRENT_RECORD 0 /* no recording yet */ | ||
87 | |||
88 | /* Define this to the CPU frequency */ | 83 | /* Define this to the CPU frequency */ |
89 | /* | 84 | /* |
90 | #define CPU_FREQ 48000000 | 85 | #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 @@ | |||
36 | 36 | ||
37 | #undef CONFIG_STORAGE | 37 | #undef CONFIG_STORAGE |
38 | 38 | ||
39 | #if defined(CONFIG_CHARGING) && CONFIG_CHARGING > CHARGING_MONITOR | ||
40 | #undef CONFIG_CHARGING | ||
41 | #define CONFIG_CHARGING CHARGING_MONITOR | ||
42 | #endif | ||
43 | |||
39 | #undef CONFIG_USBOTG | 44 | #undef CONFIG_USBOTG |
40 | 45 | ||
41 | #undef USB_HANDLED_BY_OF | 46 | #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 @@ | |||
85 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ | 85 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ |
86 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 86 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
87 | 87 | ||
88 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
89 | |||
88 | /* Hardware controlled charging? FIXME */ | 90 | /* Hardware controlled charging? FIXME */ |
89 | #define CONFIG_CHARGING CHARGING_SIMPLE | 91 | #define CONFIG_CHARGING CHARGING_SIMPLE |
90 | 92 | ||
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 @@ | |||
126 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 126 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
127 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 127 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
128 | 128 | ||
129 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
130 | |||
129 | /* Hardware controlled charging, software can monitor plug and charge state */ | 131 | /* Hardware controlled charging, software can monitor plug and charge state */ |
130 | #define CONFIG_CHARGING CHARGING_SIMPLE | 132 | #define CONFIG_CHARGING CHARGING_SIMPLE |
131 | 133 | ||
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 @@ | |||
131 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ | 131 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ |
132 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 132 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
133 | 133 | ||
134 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
135 | |||
134 | /* Hardware controlled charging with monitoring */ | 136 | /* Hardware controlled charging with monitoring */ |
135 | //#define CONFIG_CHARGING CHARGING_MONITOR | 137 | //#define CONFIG_CHARGING CHARGING_MONITOR |
136 | 138 | ||
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 @@ | |||
130 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ | 130 | #define BATTERY_CAPACITY_INC 100 /* capacity increment */ |
131 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 131 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
132 | 132 | ||
133 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
134 | |||
133 | /* Hardware controlled charging with monitoring */ | 135 | /* Hardware controlled charging with monitoring */ |
134 | //#define CONFIG_CHARGING CHARGING_MONITOR | 136 | //#define CONFIG_CHARGING CHARGING_MONITOR |
135 | 137 | ||
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 @@ | |||
23 | 23 | ||
24 | #include "config.h" | 24 | #include "config.h" |
25 | 25 | ||
26 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0) || defined(SIMULATOR) | ||
27 | #if CONFIG_CHARGING | 26 | #if CONFIG_CHARGING |
28 | enum power_input_flags { | 27 | enum power_input_flags { |
29 | /* No external power source? Default. */ | 28 | /* No external power source? Default. */ |
@@ -101,6 +100,4 @@ bool tuner_power(bool status); | |||
101 | bool tuner_powered(void); | 100 | bool tuner_powered(void); |
102 | #endif | 101 | #endif |
103 | 102 | ||
104 | #endif | ||
105 | |||
106 | #endif /* _POWER_H_ */ | 103 | #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; | |||
78 | /* Start up power management thread */ | 78 | /* Start up power management thread */ |
79 | void powermgmt_init(void) INIT_ATTR; | 79 | void powermgmt_init(void) INIT_ATTR; |
80 | 80 | ||
81 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0) | ||
82 | |||
83 | /* Generic current values that are intentionally meaningless - config header | 81 | /* Generic current values that are intentionally meaningless - config header |
84 | * should define proper numbers.*/ | 82 | * should define proper numbers.*/ |
85 | 83 | ||
@@ -130,13 +128,18 @@ extern const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11]; | |||
130 | extern const unsigned short percent_to_volt_charge[11]; | 128 | extern const unsigned short percent_to_volt_charge[11]; |
131 | #endif | 129 | #endif |
132 | 130 | ||
133 | #endif /* PLATFORM_NATIVE */ | 131 | /* Returns battery status, filtered for runtime estimation */ |
134 | |||
135 | /* Returns battery statust */ | ||
136 | int battery_level(void); /* percent */ | 132 | int battery_level(void); /* percent */ |
137 | int battery_time(void); /* minutes */ | 133 | int battery_time(void); /* minutes */ |
138 | unsigned int battery_adc_voltage(void); /* voltage from ADC in millivolts */ | 134 | int battery_voltage(void); /* filtered batt. voltage in millivolts */ |
139 | unsigned int battery_voltage(void); /* filtered batt. voltage in millivolts */ | 135 | |
136 | /* Implemented by the target, unfiltered */ | ||
137 | int _battery_level(void); /* percent */ | ||
138 | int _battery_time(void); /* minutes */ | ||
139 | int _battery_voltage(void); /* voltage in millivolts */ | ||
140 | #if CONFIG_CHARGING >= CHARGING_TARGET | ||
141 | void powermgmt_init_target(void); | ||
142 | #endif | ||
140 | 143 | ||
141 | #ifdef HAVE_BATTERY_SWITCH | 144 | #ifdef HAVE_BATTERY_SWITCH |
142 | unsigned int input_millivolts(void); /* voltage that device is running from */ | 145 | 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); | |||
86 | static int poweroff_timeout = 0; | 86 | static int poweroff_timeout = 0; |
87 | static long last_event_tick = 0; | 87 | static long last_event_tick = 0; |
88 | 88 | ||
89 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0) | 89 | #if (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE) == PERCENTAGE_MEASURE |
90 | int _battery_voltage(void) { return -1; } | ||
91 | |||
92 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11]; | ||
93 | const unsigned short percent_to_volt_charge[11]; | ||
94 | |||
95 | #elif (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE) == VOLTAGE_MEASURE | ||
96 | int _battery_level(void) { return -1; } | ||
90 | /* | 97 | /* |
91 | * Average battery voltage and charger voltage, filtered via a digital | 98 | * Average battery voltage and charger voltage, filtered via a digital |
92 | * exponential filter (aka. exponential moving average, scaled): | 99 | * exponential filter (aka. exponential moving average, scaled): |
@@ -95,10 +102,22 @@ static long last_event_tick = 0; | |||
95 | static unsigned int avgbat; | 102 | static unsigned int avgbat; |
96 | /* filtered battery voltage, millivolts */ | 103 | /* filtered battery voltage, millivolts */ |
97 | static unsigned int battery_millivolts; | 104 | static unsigned int battery_millivolts; |
105 | #elif (CONFIG_BATTERY_MEASURE == 0) | ||
106 | int _battery_voltage(void) { return -1; } | ||
107 | int _battery_level(void) { return -1; } | ||
108 | |||
109 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11]; | ||
110 | const unsigned short percent_to_volt_charge[11]; | ||
111 | #endif | ||
112 | |||
113 | #if !(CONFIG_BATTERY_MEASURE & TIME_MEASURE) | ||
114 | static int powermgmt_est_runningtime_min; | ||
115 | int _battery_time(void) { return powermgmt_est_runningtime_min; } | ||
116 | #endif | ||
117 | |||
98 | /* default value, mAh */ | 118 | /* default value, mAh */ |
99 | static int battery_capacity = BATTERY_CAPACITY_DEFAULT; | 119 | static int battery_capacity = BATTERY_CAPACITY_DEFAULT; |
100 | 120 | ||
101 | |||
102 | #if BATTERY_TYPES_COUNT > 1 | 121 | #if BATTERY_TYPES_COUNT > 1 |
103 | static int battery_type = 0; | 122 | static int battery_type = 0; |
104 | #else | 123 | #else |
@@ -115,7 +134,6 @@ static char power_stack[DEFAULT_STACK_SIZE/2 + POWERMGMT_DEBUG_STACK]; | |||
115 | #endif | 134 | #endif |
116 | static const char power_thread_name[] = "power"; | 135 | static const char power_thread_name[] = "power"; |
117 | 136 | ||
118 | static int powermgmt_est_runningtime_min = -1; | ||
119 | 137 | ||
120 | static int voltage_to_battery_level(int battery_millivolts); | 138 | static int voltage_to_battery_level(int battery_millivolts); |
121 | static void battery_status_update(void); | 139 | static void battery_status_update(void); |
@@ -126,13 +144,18 @@ static int runcurrent(void); | |||
126 | 144 | ||
127 | void battery_read_info(int *voltage, int *level) | 145 | void battery_read_info(int *voltage, int *level) |
128 | { | 146 | { |
129 | int millivolts = battery_adc_voltage(); | 147 | int millivolts = _battery_voltage(); |
148 | int percent; | ||
130 | 149 | ||
131 | if (voltage) | 150 | if (voltage) |
132 | *voltage = millivolts; | 151 | *voltage = millivolts; |
133 | 152 | ||
134 | if (level) | 153 | if (level) { |
135 | *level = voltage_to_battery_level(millivolts); | 154 | percent = voltage_to_battery_level(millivolts); |
155 | if (percent < 0) | ||
156 | percent = _battery_level(); | ||
157 | *level = percent; | ||
158 | } | ||
136 | } | 159 | } |
137 | 160 | ||
138 | #if BATTERY_TYPES_COUNT > 1 | 161 | #if BATTERY_TYPES_COUNT > 1 |
@@ -148,6 +171,7 @@ void set_battery_type(int type) | |||
148 | } | 171 | } |
149 | #endif | 172 | #endif |
150 | 173 | ||
174 | #ifdef BATTERY_CAPACITY_MIN | ||
151 | void set_battery_capacity(int capacity) | 175 | void set_battery_capacity(int capacity) |
152 | { | 176 | { |
153 | if (capacity > BATTERY_CAPACITY_MAX) | 177 | if (capacity > BATTERY_CAPACITY_MAX) |
@@ -159,6 +183,7 @@ void set_battery_capacity(int capacity) | |||
159 | 183 | ||
160 | battery_status_update(); /* recalculate the battery status */ | 184 | battery_status_update(); /* recalculate the battery status */ |
161 | } | 185 | } |
186 | #endif | ||
162 | 187 | ||
163 | int get_battery_capacity(void) | 188 | int get_battery_capacity(void) |
164 | { | 189 | { |
@@ -167,7 +192,16 @@ int get_battery_capacity(void) | |||
167 | 192 | ||
168 | int battery_time(void) | 193 | int battery_time(void) |
169 | { | 194 | { |
170 | return powermgmt_est_runningtime_min; | 195 | #if ((CONFIG_BATTERY_MEASURE & TIME_MEASURE) == 0) |
196 | |||
197 | #ifndef CURRENT_NORMAL /* no estimation without current */ | ||
198 | return -1; | ||
199 | #endif | ||
200 | if (battery_capacity <= 0) /* nor without capacity */ | ||
201 | return -1; | ||
202 | |||
203 | #endif | ||
204 | return _battery_time(); | ||
171 | } | 205 | } |
172 | 206 | ||
173 | /* Returns battery level in percent */ | 207 | /* Returns battery level in percent */ |
@@ -180,17 +214,13 @@ int battery_level(void) | |||
180 | return battery_percent; | 214 | return battery_percent; |
181 | } | 215 | } |
182 | 216 | ||
183 | /* Returns filtered battery voltage [millivolts] */ | ||
184 | unsigned int battery_voltage(void) | ||
185 | { | ||
186 | return battery_millivolts; | ||
187 | } | ||
188 | |||
189 | /* Tells if the battery level is safe for disk writes */ | 217 | /* Tells if the battery level is safe for disk writes */ |
190 | bool battery_level_safe(void) | 218 | bool battery_level_safe(void) |
191 | { | 219 | { |
192 | #if defined(NO_LOW_BATTERY_SHUTDOWN) | 220 | #if defined(NO_LOW_BATTERY_SHUTDOWN) |
193 | return true; | 221 | return true; |
222 | #elif (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE) | ||
223 | return (battery_percent > 0); | ||
194 | #elif defined(HAVE_BATTERY_SWITCH) | 224 | #elif defined(HAVE_BATTERY_SWITCH) |
195 | /* Cannot rely upon the battery reading to be valid and the | 225 | /* Cannot rely upon the battery reading to be valid and the |
196 | * device could be powered externally. */ | 226 | * device could be powered externally. */ |
@@ -228,6 +258,9 @@ static int voltage_to_battery_level(int battery_millivolts) | |||
228 | { | 258 | { |
229 | int level; | 259 | int level; |
230 | 260 | ||
261 | if (battery_millivolts < 0) | ||
262 | return -1; | ||
263 | |||
231 | #if CONFIG_CHARGING >= CHARGING_MONITOR | 264 | #if CONFIG_CHARGING >= CHARGING_MONITOR |
232 | if (charging_state()) { | 265 | if (charging_state()) { |
233 | /* battery level is defined to be < 100% until charging is finished */ | 266 | /* battery level is defined to be < 100% until charging is finished */ |
@@ -249,7 +282,8 @@ static int voltage_to_battery_level(int battery_millivolts) | |||
249 | 282 | ||
250 | static void battery_status_update(void) | 283 | static void battery_status_update(void) |
251 | { | 284 | { |
252 | int level = voltage_to_battery_level(battery_millivolts); | 285 | int millivolt, level; |
286 | battery_read_info(&millivolt, &level); | ||
253 | 287 | ||
254 | #ifdef CURRENT_NORMAL /*don't try to estimate run or charge | 288 | #ifdef CURRENT_NORMAL /*don't try to estimate run or charge |
255 | time without normal current defined*/ | 289 | time without normal current defined*/ |
@@ -264,7 +298,8 @@ static void battery_status_update(void) | |||
264 | #endif | 298 | #endif |
265 | 299 | ||
266 | /* discharging: remaining running time */ | 300 | /* discharging: remaining running time */ |
267 | if (battery_millivolts > percent_to_volt_discharge[0][0]) { | 301 | if (level > 0 && (millivolt > percent_to_volt_discharge[battery_type][0] |
302 | || millivolt < 0)) { | ||
268 | /* linear extrapolation */ | 303 | /* linear extrapolation */ |
269 | powermgmt_est_runningtime_min = (level + battery_percent)*60 | 304 | powermgmt_est_runningtime_min = (level + battery_percent)*60 |
270 | * battery_capacity / 200 / runcurrent(); | 305 | * battery_capacity / 200 / runcurrent(); |
@@ -272,8 +307,6 @@ static void battery_status_update(void) | |||
272 | if (0 > powermgmt_est_runningtime_min) { | 307 | if (0 > powermgmt_est_runningtime_min) { |
273 | powermgmt_est_runningtime_min = 0; | 308 | powermgmt_est_runningtime_min = 0; |
274 | } | 309 | } |
275 | #else | ||
276 | powermgmt_est_runningtime_min=-1; | ||
277 | #endif | 310 | #endif |
278 | 311 | ||
279 | battery_percent = level; | 312 | battery_percent = level; |
@@ -348,6 +381,8 @@ bool query_force_shutdown(void) | |||
348 | { | 381 | { |
349 | #if defined(NO_LOW_BATTERY_SHUTDOWN) | 382 | #if defined(NO_LOW_BATTERY_SHUTDOWN) |
350 | return false; | 383 | return false; |
384 | #elif CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE | ||
385 | return battery_percent == 0; | ||
351 | #elif defined(HAVE_BATTERY_SWITCH) | 386 | #elif defined(HAVE_BATTERY_SWITCH) |
352 | /* Cannot rely upon the battery reading to be valid and the | 387 | /* Cannot rely upon the battery reading to be valid and the |
353 | * device could be powered externally. */ | 388 | * device could be powered externally. */ |
@@ -490,6 +525,101 @@ static inline bool detect_charger(unsigned int pwr) | |||
490 | } | 525 | } |
491 | #endif /* CONFIG_CHARGING */ | 526 | #endif /* CONFIG_CHARGING */ |
492 | 527 | ||
528 | |||
529 | #if CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE | ||
530 | /* Returns filtered battery voltage [millivolts] */ | ||
531 | int battery_voltage(void) | ||
532 | { | ||
533 | return battery_millivolts; | ||
534 | } | ||
535 | |||
536 | static void average_init(void) | ||
537 | { | ||
538 | /* initialize the voltages for the exponential filter */ | ||
539 | avgbat = _battery_voltage() + 15; | ||
540 | |||
541 | #ifdef HAVE_DISK_STORAGE /* this adjustment is only needed for HD based */ | ||
542 | /* The battery voltage is usually a little lower directly after | ||
543 | turning on, because the disk was used heavily. Raise it by 5% */ | ||
544 | #if CONFIG_CHARGING | ||
545 | if (!charger_inserted()) /* only if charger not connected */ | ||
546 | #endif | ||
547 | { | ||
548 | avgbat += (percent_to_volt_discharge[battery_type][6] - | ||
549 | percent_to_volt_discharge[battery_type][5]) / 2; | ||
550 | } | ||
551 | #endif /* HAVE_DISK_STORAGE */ | ||
552 | |||
553 | avgbat = avgbat * BATT_AVE_SAMPLES; | ||
554 | battery_millivolts = power_history[0] = avgbat / BATT_AVE_SAMPLES; | ||
555 | } | ||
556 | |||
557 | static void average_step(void) | ||
558 | { | ||
559 | avgbat += _battery_voltage() - avgbat / BATT_AVE_SAMPLES; | ||
560 | /* | ||
561 | * battery_millivolts is the millivolt-scaled filtered battery value. | ||
562 | */ | ||
563 | battery_millivolts = avgbat / BATT_AVE_SAMPLES; | ||
564 | } | ||
565 | |||
566 | static void average_step_low(void) | ||
567 | { | ||
568 | battery_millivolts = (_battery_voltage() + battery_millivolts + 1) / 2; | ||
569 | avgbat += battery_millivolts - avgbat / BATT_AVE_SAMPLES; | ||
570 | } | ||
571 | |||
572 | static void init_battery_percent(void) | ||
573 | { | ||
574 | #if CONFIG_CHARGING | ||
575 | if (charger_inserted()) { | ||
576 | battery_percent = voltage_to_percent(battery_millivolts, | ||
577 | percent_to_volt_charge); | ||
578 | } | ||
579 | else | ||
580 | #endif | ||
581 | { | ||
582 | battery_percent = voltage_to_percent(battery_millivolts, | ||
583 | percent_to_volt_discharge[battery_type]); | ||
584 | battery_percent += battery_percent < 100; | ||
585 | } | ||
586 | |||
587 | } | ||
588 | |||
589 | static int power_hist_item(void) | ||
590 | { | ||
591 | return battery_millivolts; | ||
592 | } | ||
593 | #define power_history_unit() battery_millivolts | ||
594 | |||
595 | #else | ||
596 | int battery_voltage(void) | ||
597 | { | ||
598 | return -1; | ||
599 | } | ||
600 | |||
601 | static void average_init(void) {} | ||
602 | static void average_step(void) {} | ||
603 | static void average_step_low(void) {} | ||
604 | static void init_battery_percent(void) | ||
605 | { | ||
606 | battery_percent = _battery_level(); | ||
607 | } | ||
608 | |||
609 | static int power_hist_item(void) | ||
610 | { | ||
611 | return battery_percent; | ||
612 | } | ||
613 | #endif | ||
614 | |||
615 | static void collect_power_history(void) | ||
616 | { | ||
617 | /* rotate the power history */ | ||
618 | memmove(&power_history[1], &power_history[0], | ||
619 | sizeof(power_history) - sizeof(power_history[0])); | ||
620 | power_history[0] = power_hist_item(); | ||
621 | } | ||
622 | |||
493 | /* | 623 | /* |
494 | * Monitor the presence of a charger and perform critical frequent steps | 624 | * Monitor the presence of a charger and perform critical frequent steps |
495 | * such as running the battery voltage filter. | 625 | * such as running the battery voltage filter. |
@@ -519,33 +649,23 @@ static inline void power_thread_step(void) | |||
519 | || charger_input_state == CHARGER | 649 | || charger_input_state == CHARGER |
520 | #endif | 650 | #endif |
521 | ) { | 651 | ) { |
522 | avgbat += battery_adc_voltage() - avgbat / BATT_AVE_SAMPLES; | 652 | average_step(); |
523 | /* | ||
524 | * battery_millivolts is the millivolt-scaled filtered battery value. | ||
525 | */ | ||
526 | battery_millivolts = avgbat / BATT_AVE_SAMPLES; | ||
527 | |||
528 | /* update battery status every time an update is available */ | 653 | /* update battery status every time an update is available */ |
529 | battery_status_update(); | 654 | battery_status_update(); |
530 | } | 655 | } |
531 | else if (battery_percent < 8) { | 656 | else if (battery_percent < 8) { |
657 | average_step_low(); | ||
658 | /* update battery status every time an update is available */ | ||
659 | battery_status_update(); | ||
660 | |||
532 | /* | 661 | /* |
533 | * If battery is low, observe voltage during disk activity. | 662 | * If battery is low, observe voltage during disk activity. |
534 | * Shut down if voltage drops below shutoff level and we are not | 663 | * Shut down if voltage drops below shutoff level and we are not |
535 | * using NiMH or Alkaline batteries. | 664 | * using NiMH or Alkaline batteries. |
536 | */ | 665 | */ |
537 | battery_millivolts = (battery_adc_voltage() + | ||
538 | battery_millivolts + 1) / 2; | ||
539 | |||
540 | /* update battery status every time an update is available */ | ||
541 | battery_status_update(); | ||
542 | |||
543 | if (!shutdown_timeout && query_force_shutdown()) { | 666 | if (!shutdown_timeout && query_force_shutdown()) { |
544 | sys_poweroff(); | 667 | sys_poweroff(); |
545 | } | 668 | } |
546 | else { | ||
547 | avgbat += battery_millivolts - avgbat / BATT_AVE_SAMPLES; | ||
548 | } | ||
549 | } | 669 | } |
550 | } /* power_thread_step */ | 670 | } /* power_thread_step */ |
551 | 671 | ||
@@ -555,7 +675,7 @@ static void power_thread(void) | |||
555 | 675 | ||
556 | /* Delay reading the first battery level */ | 676 | /* Delay reading the first battery level */ |
557 | #ifdef MROBE_100 | 677 | #ifdef MROBE_100 |
558 | while (battery_adc_voltage() > 4200) /* gives false readings initially */ | 678 | while (_battery_voltage() > 4200) /* gives false readings initially */ |
559 | #endif | 679 | #endif |
560 | { | 680 | { |
561 | sleep(HZ/100); | 681 | sleep(HZ/100); |
@@ -566,38 +686,13 @@ static void power_thread(void) | |||
566 | power_thread_inputs = power_input_status(); | 686 | power_thread_inputs = power_input_status(); |
567 | #endif | 687 | #endif |
568 | 688 | ||
569 | /* initialize the voltages for the exponential filter */ | 689 | /* initialize voltage averaging (if available) */ |
570 | avgbat = battery_adc_voltage() + 15; | 690 | average_init(); |
571 | 691 | /* get initial battery level value (in %) */ | |
572 | #ifdef HAVE_DISK_STORAGE /* this adjustment is only needed for HD based */ | 692 | init_battery_percent(); |
573 | /* The battery voltage is usually a little lower directly after | 693 | /* get some initial data for the power curve */ |
574 | turning on, because the disk was used heavily. Raise it by 5% */ | 694 | collect_power_history(); |
575 | #if CONFIG_CHARGING | 695 | /* call target specific init now */ |
576 | if (!charger_inserted()) /* only if charger not connected */ | ||
577 | #endif | ||
578 | { | ||
579 | avgbat += (percent_to_volt_discharge[battery_type][6] - | ||
580 | percent_to_volt_discharge[battery_type][5]) / 2; | ||
581 | } | ||
582 | #endif /* HAVE_DISK_STORAGE */ | ||
583 | |||
584 | avgbat = avgbat * BATT_AVE_SAMPLES; | ||
585 | battery_millivolts = avgbat / BATT_AVE_SAMPLES; | ||
586 | power_history[0] = battery_millivolts; | ||
587 | |||
588 | #if CONFIG_CHARGING | ||
589 | if (charger_inserted()) { | ||
590 | battery_percent = voltage_to_percent(battery_millivolts, | ||
591 | percent_to_volt_charge); | ||
592 | } | ||
593 | else | ||
594 | #endif | ||
595 | { | ||
596 | battery_percent = voltage_to_percent(battery_millivolts, | ||
597 | percent_to_volt_discharge[battery_type]); | ||
598 | battery_percent += battery_percent < 100; | ||
599 | } | ||
600 | |||
601 | powermgmt_init_target(); | 696 | powermgmt_init_target(); |
602 | 697 | ||
603 | next_power_hist = current_tick + HZ*60; | 698 | next_power_hist = current_tick + HZ*60; |
@@ -609,7 +704,7 @@ static void power_thread(void) | |||
609 | #ifdef HAVE_BATTERY_SWITCH | 704 | #ifdef HAVE_BATTERY_SWITCH |
610 | if ((pwr ^ power_thread_inputs) & POWER_INPUT_BATTERY) { | 705 | if ((pwr ^ power_thread_inputs) & POWER_INPUT_BATTERY) { |
611 | sleep(HZ/10); | 706 | sleep(HZ/10); |
612 | reset_battery_filter(battery_adc_voltage()); | 707 | reset_battery_filter(_battery_voltage()); |
613 | } | 708 | } |
614 | #endif | 709 | #endif |
615 | power_thread_inputs = pwr; | 710 | power_thread_inputs = pwr; |
@@ -627,21 +722,15 @@ static void power_thread(void) | |||
627 | /* Perform target tasks */ | 722 | /* Perform target tasks */ |
628 | charging_algorithm_step(); | 723 | charging_algorithm_step(); |
629 | 724 | ||
630 | if (TIME_BEFORE(current_tick, next_power_hist)) | 725 | /* check if some idle or sleep timer wears off */ |
631 | continue; | ||
632 | |||
633 | /* increment to ensure there is a record for every minute | ||
634 | * rather than go forward from the current tick */ | ||
635 | next_power_hist += HZ*60; | ||
636 | |||
637 | /* rotate the power history */ | ||
638 | memmove(&power_history[1], &power_history[0], | ||
639 | sizeof(power_history) - sizeof(power_history[0])); | ||
640 | |||
641 | /* insert new value at the start, in millivolts 8-) */ | ||
642 | power_history[0] = battery_millivolts; | ||
643 | |||
644 | handle_auto_poweroff(); | 726 | handle_auto_poweroff(); |
727 | |||
728 | if (TIME_AFTER(current_tick, next_power_hist)) { | ||
729 | /* increment to ensure there is a record for every minute | ||
730 | * rather than go forward from the current tick */ | ||
731 | next_power_hist += HZ*60; | ||
732 | collect_power_history(); | ||
733 | } | ||
645 | } | 734 | } |
646 | } /* power_thread */ | 735 | } /* power_thread */ |
647 | 736 | ||
@@ -701,7 +790,6 @@ void shutdown_hw(void) | |||
701 | sleep(HZ/4); | 790 | sleep(HZ/4); |
702 | power_off(); | 791 | power_off(); |
703 | } | 792 | } |
704 | #endif /* PLATFORM_NATIVE */ | ||
705 | 793 | ||
706 | void set_poweroff_timeout(int timeout) | 794 | void set_poweroff_timeout(int timeout) |
707 | { | 795 | { |
@@ -855,12 +943,10 @@ void handle_auto_poweroff(void) | |||
855 | last_event_tick = current_tick; | 943 | last_event_tick = current_tick; |
856 | } | 944 | } |
857 | 945 | ||
858 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0) | ||
859 | if (!shutdown_timeout && query_force_shutdown()) { | 946 | if (!shutdown_timeout && query_force_shutdown()) { |
860 | backlight_on(); | 947 | backlight_on(); |
861 | sys_poweroff(); | 948 | sys_poweroff(); |
862 | } | 949 | } |
863 | #endif | ||
864 | 950 | ||
865 | if (timeout && | 951 | if (timeout && |
866 | #if CONFIG_TUNER | 952 | #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] = | |||
52 | /* full-scale ADC readout (2^10) in millivolt */ | 52 | /* full-scale ADC readout (2^10) in millivolt */ |
53 | 53 | ||
54 | /* Returns battery voltage from ADC [millivolts] */ | 54 | /* Returns battery voltage from ADC [millivolts] */ |
55 | unsigned int battery_adc_voltage(void) | 55 | int _battery_voltage(void) |
56 | { | 56 | { |
57 | return (adc_read(ADC_VBAT) * BATTERY_SCALE_FACTOR) >> 10; | 57 | return (adc_read(ADC_VBAT) * BATTERY_SCALE_FACTOR) >> 10; |
58 | } | 58 | } |
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) | |||
153 | lcd_clear_display(); | 153 | lcd_clear_display(); |
154 | 154 | ||
155 | /* add battery readout in mV, this it is not the direct output of a channel */ | 155 | /* add battery readout in mV, this it is not the direct output of a channel */ |
156 | lcd_putsf(0, 0, "Battery(mV) %d", battery_adc_voltage()); | 156 | lcd_putsf(0, 0, "Battery(mV) %d", _battery_voltage()); |
157 | for(unsigned i = 0; i < NUM_ADC_CHANNELS; i++) | 157 | for(unsigned i = 0; i < NUM_ADC_CHANNELS; i++) |
158 | { | 158 | { |
159 | lcd_putsf(0, i + 1, "%s %d", imx233_adc_channel_name[i], | 159 | 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 | |||
38 | static int timeout_4p2_ilimit_increase; /* timeout before increasing 4p2 ilimit */ | 38 | static int timeout_4p2_ilimit_increase; /* timeout before increasing 4p2 ilimit */ |
39 | 39 | ||
40 | /* Returns battery voltage from ADC [millivolts] */ | 40 | /* Returns battery voltage from ADC [millivolts] */ |
41 | unsigned int battery_adc_voltage(void) | 41 | int _battery_voltage(void) |
42 | { | 42 | { |
43 | /* battery value is in 8mV LSB */ | 43 | /* battery value is in 8mV LSB */ |
44 | return __XTRACT(HW_POWER_BATTMONITOR, BATT_VAL) * 8; | 44 | 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] = | |||
53 | }; | 53 | }; |
54 | 54 | ||
55 | /* Returns battery voltage from ADC [millivolts] */ | 55 | /* Returns battery voltage from ADC [millivolts] */ |
56 | unsigned int battery_adc_voltage(void) | 56 | int _battery_voltage(void) |
57 | { | 57 | { |
58 | /* ADC reading 0-1023 = 2400mV-4700mV */ | 58 | /* ADC reading 0-1023 = 2400mV-4700mV */ |
59 | return ((adc_read(ADC_BATTERY) * 2303) >> 10) + 2400; | 59 | return ((adc_read(ADC_BATTERY) * 2303) >> 10) + 2400; |
@@ -249,7 +249,7 @@ static int stat_battery_reading(int type) | |||
249 | switch (type) | 249 | switch (type) |
250 | { | 250 | { |
251 | case ADC_BATTERY: | 251 | case ADC_BATTERY: |
252 | reading = battery_adc_voltage(); | 252 | reading = _battery_voltage(); |
253 | break; | 253 | break; |
254 | 254 | ||
255 | case ADC_CHARGER_CURRENT: | 255 | case ADC_CHARGER_CURRENT: |
@@ -780,7 +780,7 @@ static void charger_control(void) | |||
780 | /* Battery voltage may have dropped and a charge cycle should | 780 | /* Battery voltage may have dropped and a charge cycle should |
781 | * start again. Debounced. */ | 781 | * start again. Debounced. */ |
782 | if (autorecharge_counter < 0 && | 782 | if (autorecharge_counter < 0 && |
783 | battery_adc_voltage() < BATT_FULL_VOLTAGE) | 783 | _battery_voltage() < BATT_FULL_VOLTAGE) |
784 | { | 784 | { |
785 | /* Try starting a cycle now if battery isn't already topped | 785 | /* Try starting a cycle now if battery isn't already topped |
786 | * off to allow user to ensure the battery is full. */ | 786 | * 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] = | |||
57 | /* full-scale ADC readout (2^8) in millivolt */ | 57 | /* full-scale ADC readout (2^8) in millivolt */ |
58 | 58 | ||
59 | /* Returns battery voltage from ADC [millivolts] */ | 59 | /* Returns battery voltage from ADC [millivolts] */ |
60 | unsigned int battery_adc_voltage(void) | 60 | int _battery_voltage(void) |
61 | { | 61 | { |
62 | unsigned adcval = adc_read(ADC_UNREG_POWER); | 62 | unsigned adcval = adc_read(ADC_UNREG_POWER); |
63 | 63 | ||
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] = | |||
109 | /* full-scale ADC readout (2^10) in millivolt */ | 109 | /* full-scale ADC readout (2^10) in millivolt */ |
110 | 110 | ||
111 | /* Returns battery voltage from ADC [millivolts] */ | 111 | /* Returns battery voltage from ADC [millivolts] */ |
112 | unsigned int battery_adc_voltage(void) | 112 | int _battery_voltage(void) |
113 | { | 113 | { |
114 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | 114 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; |
115 | } | 115 | } |
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] = | |||
67 | /* full-scale ADC readout (2^10) in millivolt */ | 67 | /* full-scale ADC readout (2^10) in millivolt */ |
68 | 68 | ||
69 | /* Returns battery voltage from ADC [millivolts] */ | 69 | /* Returns battery voltage from ADC [millivolts] */ |
70 | unsigned int battery_adc_voltage(void) | 70 | int _battery_voltage(void) |
71 | { | 71 | { |
72 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | 72 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; |
73 | } | 73 | } |
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] = | |||
58 | */ | 58 | */ |
59 | 59 | ||
60 | /* Returns battery voltage from ADC [millivolts] */ | 60 | /* Returns battery voltage from ADC [millivolts] */ |
61 | unsigned int battery_adc_voltage(void) | 61 | int _battery_voltage(void) |
62 | { | 62 | { |
63 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | 63 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; |
64 | } | 64 | } |
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] = | |||
51 | /* full-scale ADC readout (2^10) in millivolt */ | 51 | /* full-scale ADC readout (2^10) in millivolt */ |
52 | 52 | ||
53 | /* Returns battery voltage from ADC [millivolts] */ | 53 | /* Returns battery voltage from ADC [millivolts] */ |
54 | unsigned int battery_adc_voltage(void) | 54 | int _battery_voltage(void) |
55 | { | 55 | { |
56 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | 56 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; |
57 | } | 57 | } |
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] = | |||
57 | /* full-scale ADC readout (2^10) in millivolt */ | 57 | /* full-scale ADC readout (2^10) in millivolt */ |
58 | 58 | ||
59 | /* Returns battery voltage from ADC [millivolts] */ | 59 | /* Returns battery voltage from ADC [millivolts] */ |
60 | unsigned int battery_adc_voltage(void) | 60 | int _battery_voltage(void) |
61 | { | 61 | { |
62 | /* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */ | 62 | /* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */ |
63 | 63 | ||
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] = | |||
57 | /* full-scale ADC readout (2^10) in millivolt */ | 57 | /* full-scale ADC readout (2^10) in millivolt */ |
58 | 58 | ||
59 | /* Returns battery voltage from ADC [millivolts] */ | 59 | /* Returns battery voltage from ADC [millivolts] */ |
60 | unsigned int battery_adc_voltage(void) | 60 | int _battery_voltage(void) |
61 | { | 61 | { |
62 | /* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */ | 62 | /* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */ |
63 | 63 | ||
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] = | |||
48 | /* full-scale ADC readout (2^10) in millivolt */ | 48 | /* full-scale ADC readout (2^10) in millivolt */ |
49 | 49 | ||
50 | /* Returns battery voltage from ADC [millivolts] */ | 50 | /* Returns battery voltage from ADC [millivolts] */ |
51 | unsigned int battery_adc_voltage(void) | 51 | int _battery_voltage(void) |
52 | { | 52 | { |
53 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | 53 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; |
54 | } | 54 | } |
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; | |||
67 | /* full-scale ADC readout (2^10) in millivolt */ | 67 | /* full-scale ADC readout (2^10) in millivolt */ |
68 | 68 | ||
69 | /* Returns battery voltage from ADC [millivolts] */ | 69 | /* Returns battery voltage from ADC [millivolts] */ |
70 | unsigned int battery_adc_voltage(void) | 70 | int _battery_voltage(void) |
71 | { | 71 | { |
72 | return (adc_read(ADC_BATTERY) * 5125 + 512) >> 10; | 72 | return (adc_read(ADC_BATTERY) * 5125 + 512) >> 10; |
73 | } | 73 | } |
@@ -85,7 +85,7 @@ static void battery_voltage_sync(void) | |||
85 | unsigned int mv; | 85 | unsigned int mv; |
86 | 86 | ||
87 | for (i = 0, mv = 0; i < 5; i++) | 87 | for (i = 0, mv = 0; i < 5; i++) |
88 | mv += battery_adc_voltage(); | 88 | mv += _battery_voltage(); |
89 | 89 | ||
90 | reset_battery_filter(mv / 5); | 90 | reset_battery_filter(mv / 5); |
91 | } | 91 | } |
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] = | |||
60 | #define BATTERY_SCALE_FACTOR 6000 | 60 | #define BATTERY_SCALE_FACTOR 6000 |
61 | 61 | ||
62 | /* Returns battery voltage from ADC [millivolts] */ | 62 | /* Returns battery voltage from ADC [millivolts] */ |
63 | unsigned int battery_adc_voltage(void) | 63 | int _battery_voltage(void) |
64 | { | 64 | { |
65 | return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10; | 65 | return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10; |
66 | } | 66 | } |
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] = | |||
54 | /* TODO: simple uncalibrated curve */ | 54 | /* TODO: simple uncalibrated curve */ |
55 | { 425, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520 }; | 55 | { 425, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520 }; |
56 | 56 | ||
57 | unsigned int battery_adc_voltage(void) | 57 | int _battery_voltage(void) |
58 | { | 58 | { |
59 | return adc_read(ADC_BATTERY); | 59 | return adc_read(ADC_BATTERY); |
60 | } | 60 | } |
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] = | |||
60 | #define BATTERY_SCALE_FACTOR 6000 | 60 | #define BATTERY_SCALE_FACTOR 6000 |
61 | 61 | ||
62 | /* Returns battery voltage from ADC [millivolts] */ | 62 | /* Returns battery voltage from ADC [millivolts] */ |
63 | unsigned int battery_adc_voltage(void) | 63 | int _battery_voltage(void) |
64 | { | 64 | { |
65 | return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10; | 65 | return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10; |
66 | } | 66 | } |
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] = | |||
54 | /* full-scale ADC readout (2^10) in millivolt */ | 54 | /* full-scale ADC readout (2^10) in millivolt */ |
55 | 55 | ||
56 | /* Returns battery voltage from ADC [millivolts] */ | 56 | /* Returns battery voltage from ADC [millivolts] */ |
57 | unsigned int battery_adc_voltage(void) | 57 | int _battery_voltage(void) |
58 | { | 58 | { |
59 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | 59 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; |
60 | } | 60 | } |
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] = | |||
52 | 52 | ||
53 | /* Returns battery voltage from ADC [millivolts] */ | 53 | /* Returns battery voltage from ADC [millivolts] */ |
54 | /* full-scale (2^10) in millivolt */ | 54 | /* full-scale (2^10) in millivolt */ |
55 | unsigned int battery_adc_voltage(void) | 55 | int _battery_voltage(void) |
56 | { | 56 | { |
57 | /* Since we have no battery, return a fully charged value */ | 57 | /* Since we have no battery, return a fully charged value */ |
58 | return 4000 * 1024 / 1000; | 58 | 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] = | |||
55 | 55 | ||
56 | 56 | ||
57 | /* Returns battery voltage from ADC [millivolts] */ | 57 | /* Returns battery voltage from ADC [millivolts] */ |
58 | unsigned int battery_adc_voltage(void) | 58 | int _battery_voltage(void) |
59 | { | 59 | { |
60 | int compensation = (10 * (pmu_read_battery_current() - 7)) / 12; | 60 | int compensation = (10 * (pmu_read_battery_current() - 7)) / 12; |
61 | if (charging_state()) return pmu_read_battery_voltage() - compensation; | 61 | 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] = | |||
60 | #define BATTERY_SCALE_FACTOR 6000 | 60 | #define BATTERY_SCALE_FACTOR 6000 |
61 | 61 | ||
62 | /* Returns battery voltage from ADC [millivolts] */ | 62 | /* Returns battery voltage from ADC [millivolts] */ |
63 | unsigned int battery_adc_voltage(void) | 63 | int _battery_voltage(void) |
64 | { | 64 | { |
65 | return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10; | 65 | return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10; |
66 | } | 66 | } |
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] = | |||
58 | 58 | ||
59 | 59 | ||
60 | /* Returns battery voltage from ADC [millivolts] */ | 60 | /* Returns battery voltage from ADC [millivolts] */ |
61 | unsigned int battery_adc_voltage(void) | 61 | int _battery_voltage(void) |
62 | { | 62 | { |
63 | return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10; | 63 | return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10; |
64 | } | 64 | } |
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] = | |||
55 | 55 | ||
56 | 56 | ||
57 | /* Returns battery voltage from ADC [millivolts] */ | 57 | /* Returns battery voltage from ADC [millivolts] */ |
58 | unsigned int battery_adc_voltage(void) | 58 | int _battery_voltage(void) |
59 | { | 59 | { |
60 | int compensation = (10 * (pmu_read_battery_current() - 7)) / 12; | 60 | int compensation = (10 * (pmu_read_battery_current() - 7)) / 12; |
61 | if (charging_state()) return pmu_read_battery_voltage() - compensation; | 61 | 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] = | |||
52 | /* full-scale ADC readout (2^10) in millivolt */ | 52 | /* full-scale ADC readout (2^10) in millivolt */ |
53 | 53 | ||
54 | /* Returns battery voltage from ADC [millivolts] */ | 54 | /* Returns battery voltage from ADC [millivolts] */ |
55 | unsigned int battery_adc_voltage(void) | 55 | int _battery_voltage(void) |
56 | { | 56 | { |
57 | /* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */ | 57 | /* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */ |
58 | return 4100; | 58 | 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] = | |||
52 | /* full-scale ADC readout (2^10) in millivolt */ | 52 | /* full-scale ADC readout (2^10) in millivolt */ |
53 | 53 | ||
54 | /* Returns battery voltage from ADC [millivolts] */ | 54 | /* Returns battery voltage from ADC [millivolts] */ |
55 | unsigned int battery_adc_voltage(void) | 55 | int _battery_voltage(void) |
56 | { | 56 | { |
57 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | 57 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; |
58 | } | 58 | } |
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] = | |||
52 | /* full-scale ADC readout (2^10) in millivolt */ | 52 | /* full-scale ADC readout (2^10) in millivolt */ |
53 | 53 | ||
54 | /* Returns battery voltage from ADC [millivolts] */ | 54 | /* Returns battery voltage from ADC [millivolts] */ |
55 | unsigned int battery_adc_voltage(void) | 55 | int _battery_voltage(void) |
56 | { | 56 | { |
57 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | 57 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; |
58 | } | 58 | } |
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 @@ | |||
23 | #include "adc.h" | 23 | #include "adc.h" |
24 | #include "powermgmt.h" | 24 | #include "powermgmt.h" |
25 | 25 | ||
26 | unsigned int battery_adc_voltage(void) | 26 | int _battery_voltage(void) |
27 | { | 27 | { |
28 | return 0; | 28 | return 0; |
29 | } | 29 | } |
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] = | |||
56 | /* full-scale ADC readout (2^10) in millivolt */ | 56 | /* full-scale ADC readout (2^10) in millivolt */ |
57 | 57 | ||
58 | /* Returns battery voltage from ADC [millivolts] */ | 58 | /* Returns battery voltage from ADC [millivolts] */ |
59 | unsigned int battery_adc_voltage(void) | 59 | int _battery_voltage(void) |
60 | { | 60 | { |
61 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | 61 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; |
62 | } | 62 | } |
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] = | |||
59 | /* full-scale ADC readout (2^10) in millivolt */ | 59 | /* full-scale ADC readout (2^10) in millivolt */ |
60 | 60 | ||
61 | /* Returns battery voltage from ADC [millivolts] */ | 61 | /* Returns battery voltage from ADC [millivolts] */ |
62 | unsigned int battery_adc_voltage(void) | 62 | int _battery_voltage(void) |
63 | { | 63 | { |
64 | static unsigned last_tick = 0; | 64 | static unsigned last_tick = 0; |
65 | 65 | ||
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] = | |||
59 | /* full-scale ADC readout (2^10) in millivolt */ | 59 | /* full-scale ADC readout (2^10) in millivolt */ |
60 | 60 | ||
61 | /* Returns battery voltage from ADC [millivolts] */ | 61 | /* Returns battery voltage from ADC [millivolts] */ |
62 | unsigned int battery_adc_voltage(void) | 62 | int _battery_voltage(void) |
63 | { | 63 | { |
64 | return current_voltage; | 64 | return current_voltage; |
65 | } | 65 | } |
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] = | |||
61 | /* full-scale ADC readout (2^10) in millivolt */ | 61 | /* full-scale ADC readout (2^10) in millivolt */ |
62 | 62 | ||
63 | /* Returns battery voltage from ADC [millivolts] */ | 63 | /* Returns battery voltage from ADC [millivolts] */ |
64 | unsigned int battery_adc_voltage(void) | 64 | int _battery_voltage(void) |
65 | { | 65 | { |
66 | static unsigned last_tick = 0; | 66 | static unsigned last_tick = 0; |
67 | 67 | ||
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] = | |||
50 | }; | 50 | }; |
51 | 51 | ||
52 | /* Returns battery voltage from ADC [millivolts] */ | 52 | /* Returns battery voltage from ADC [millivolts] */ |
53 | unsigned int battery_adc_voltage(void) | 53 | int _battery_voltage(void) |
54 | { | 54 | { |
55 | return current_voltage; | 55 | return current_voltage; |
56 | } | 56 | } |
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] = | |||
60 | }; | 60 | }; |
61 | 61 | ||
62 | /* Returns battery voltage from ADC [millivolts] */ | 62 | /* Returns battery voltage from ADC [millivolts] */ |
63 | unsigned int battery_adc_voltage(void) | 63 | int _battery_voltage(void) |
64 | { | 64 | { |
65 | short bat1, bat2, aux; | 65 | short bat1, bat2, aux; |
66 | static unsigned last_tick = 0; | 66 | 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] = | |||
53 | }; | 53 | }; |
54 | 54 | ||
55 | /* Returns battery voltage from ADC [millivolts] */ | 55 | /* Returns battery voltage from ADC [millivolts] */ |
56 | unsigned int battery_adc_voltage(void) | 56 | int _battery_voltage(void) |
57 | { | 57 | { |
58 | return current_battery_level; | 58 | return current_battery_level; |
59 | } | 59 | } |
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] = | |||
52 | /* full-scale ADC readout (2^8) in millivolt */ | 52 | /* full-scale ADC readout (2^8) in millivolt */ |
53 | 53 | ||
54 | /* Returns battery voltage from ADC [millivolts] */ | 54 | /* Returns battery voltage from ADC [millivolts] */ |
55 | unsigned int battery_adc_voltage(void) | 55 | int _battery_voltage(void) |
56 | { | 56 | { |
57 | return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 8; | 57 | return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 8; |
58 | } | 58 | } |
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] = | |||
53 | /* full-scale ADC readout (2^10) in millivolt */ | 53 | /* full-scale ADC readout (2^10) in millivolt */ |
54 | 54 | ||
55 | /* Returns battery voltage from ADC [millivolts] */ | 55 | /* Returns battery voltage from ADC [millivolts] */ |
56 | unsigned int battery_adc_voltage(void) | 56 | int _battery_voltage(void) |
57 | { | 57 | { |
58 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | 58 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; |
59 | } | 59 | } |
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] = | |||
53 | /* full-scale ADC readout (2^8) in millivolt */ | 53 | /* full-scale ADC readout (2^8) in millivolt */ |
54 | 54 | ||
55 | /* Returns battery voltage from ADC [millivolts] */ | 55 | /* Returns battery voltage from ADC [millivolts] */ |
56 | unsigned int battery_adc_voltage(void) | 56 | int _battery_voltage(void) |
57 | { | 57 | { |
58 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 8; | 58 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 8; |
59 | } | 59 | } |
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] = | |||
53 | /* full-scale ADC readout (2^10) in millivolt */ | 53 | /* full-scale ADC readout (2^10) in millivolt */ |
54 | 54 | ||
55 | /* Returns battery voltage from ADC [millivolts] */ | 55 | /* Returns battery voltage from ADC [millivolts] */ |
56 | unsigned int battery_adc_voltage(void) | 56 | int _battery_voltage(void) |
57 | { | 57 | { |
58 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | 58 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; |
59 | } | 59 | } |
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] = | |||
51 | 51 | ||
52 | 52 | ||
53 | /* Returns battery voltage from ADC [millivolts] */ | 53 | /* Returns battery voltage from ADC [millivolts] */ |
54 | unsigned int battery_adc_voltage(void) | 54 | int _battery_voltage(void) |
55 | { | 55 | { |
56 | return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 11; | 56 | return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 11; |
57 | } | 57 | } |
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] = | |||
51 | 51 | ||
52 | 52 | ||
53 | /* Returns battery voltage from ADC [millivolts] */ | 53 | /* Returns battery voltage from ADC [millivolts] */ |
54 | unsigned int battery_adc_voltage(void) | 54 | int _battery_voltage(void) |
55 | { | 55 | { |
56 | return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 11; | 56 | return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 11; |
57 | } | 57 | } |
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; | |||
28 | extern jclass RockboxService_class; | 28 | extern jclass RockboxService_class; |
29 | extern jobject RockboxService_instance; | 29 | extern jobject RockboxService_instance; |
30 | 30 | ||
31 | static jfieldID _battery_level; | 31 | static jfieldID __battery_level; |
32 | static jobject BatteryMonitor_instance; | 32 | static jobject BatteryMonitor_instance; |
33 | 33 | ||
34 | void powermgmt_init_target(void) | 34 | static void new_battery_monitor(void) |
35 | { | 35 | { |
36 | JNIEnv e = *env_ptr; | 36 | JNIEnv e = *env_ptr; |
37 | jclass class = e->FindClass(env_ptr, "org/rockbox/monitors/BatteryMonitor"); | 37 | jclass class = e->FindClass(env_ptr, "org/rockbox/monitors/BatteryMonitor"); |
@@ -43,29 +43,15 @@ void powermgmt_init_target(void) | |||
43 | RockboxService_instance); | 43 | RockboxService_instance); |
44 | 44 | ||
45 | /* cache the battery level field id */ | 45 | /* cache the battery level field id */ |
46 | _battery_level = (*env_ptr)->GetFieldID(env_ptr, | 46 | __battery_level = (*env_ptr)->GetFieldID(env_ptr, |
47 | class, | 47 | class, |
48 | "mBattLevel", "I"); | 48 | "mBattLevel", "I"); |
49 | } | 49 | } |
50 | 50 | ||
51 | int battery_level(void) | 51 | int _battery_level(void) |
52 | { | 52 | { |
53 | return (*env_ptr)->GetIntField(env_ptr, BatteryMonitor_instance, _battery_level); | 53 | if (!BatteryMonitor_instance) |
54 | new_battery_monitor(); | ||
55 | return (*env_ptr)->GetIntField(env_ptr, BatteryMonitor_instance, __battery_level); | ||
54 | } | 56 | } |
55 | 57 | ||
56 | int battery_time(void) | ||
57 | { /* cannot calculate yet */ | ||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | /* should always be safe on android targets, the host shuts us down before */ | ||
62 | bool battery_level_safe(void) | ||
63 | { | ||
64 | return true; | ||
65 | } | ||
66 | |||
67 | /* TODO */ | ||
68 | unsigned battery_voltage(void) | ||
69 | { | ||
70 | return 0; | ||
71 | } | ||
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) { } | |||
45 | 45 | ||
46 | /* this is used to return from the entry point of the native library. */ | 46 | /* this is used to return from the entry point of the native library. */ |
47 | static jmp_buf poweroff_buf; | 47 | static jmp_buf poweroff_buf; |
48 | void shutdown_hw(void) | 48 | void power_off(void) |
49 | { | 49 | { |
50 | longjmp(poweroff_buf, 1); | 50 | longjmp(poweroff_buf, 1); |
51 | } | 51 | } |
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) | |||
163 | return 0; | 163 | return 0; |
164 | } | 164 | } |
165 | 165 | ||
166 | /** Rockbox battery related functions */ | ||
167 | void battery_status_update(void) | ||
168 | { | ||
169 | battery_percent = maemo_battery_level; | ||
170 | send_battery_level_event(); | ||
171 | } | ||
172 | |||
173 | /* Returns true if any power input is connected - charging-capable | ||
174 | * or not. */ | ||
175 | bool power_input_present(void) | ||
176 | { | ||
177 | return false; | ||
178 | } | ||
179 | |||
180 | unsigned battery_voltage(void) | ||
181 | { | ||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | /* Returns battery level in percent */ | 166 | /* Returns battery level in percent */ |
186 | int battery_level(void) | 167 | int _battery_level(void) |
187 | { | 168 | { |
188 | battery_status_update(); | ||
189 | return maemo_battery_level; | 169 | return maemo_battery_level; |
190 | } | 170 | } |
191 | 171 | ||
192 | /* Return remaining battery time in minutes */ | 172 | /* Return remaining battery time in minutes */ |
193 | int battery_time(void) | 173 | int _battery_time(void) |
194 | { | 174 | { |
195 | battery_status_update(); | ||
196 | return maemo_remaining_time_sec / 60; | 175 | return maemo_remaining_time_sec / 60; |
197 | } | 176 | } |
198 | |||
199 | bool battery_level_safe(void) | ||
200 | { | ||
201 | return battery_level() >= 5; | ||
202 | } | ||
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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Thomas Jarosch | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "config.h" | ||
22 | #include "powermgmt.h" | ||
23 | #include "thread.h" | ||
24 | #include "kernel.h" | ||
25 | |||
26 | static char power_stack[DEFAULT_STACK_SIZE]; | ||
27 | static const char power_thread_name[] = "power"; | ||
28 | |||
29 | void powermgmt_init_target(void); | ||
30 | |||
31 | #if !(CONFIG_PLATFORM & PLATFORM_ANDROID) | ||
32 | void powermgmt_init_target(void) | ||
33 | { | ||
34 | /* Nothing to do */ | ||
35 | } | ||
36 | #endif | ||
37 | |||
38 | static void power_thread(void) | ||
39 | { | ||
40 | powermgmt_init_target(); | ||
41 | |||
42 | while (1) | ||
43 | { | ||
44 | /* Sleep two seconds */ | ||
45 | sleep(HZ*2); | ||
46 | |||
47 | handle_auto_poweroff(); | ||
48 | } | ||
49 | } /* power_thread */ | ||
50 | |||
51 | void powermgmt_init(void) | ||
52 | { | ||
53 | create_thread(power_thread, power_stack, sizeof(power_stack), 0, | ||
54 | power_thread_name IF_PRIO(, PRIORITY_SYSTEM) | ||
55 | IF_COP(, CPU)); | ||
56 | } | ||
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) | |||
196 | return 0; | 196 | return 0; |
197 | } | 197 | } |
198 | 198 | ||
199 | void shutdown_hw(void) | 199 | void power_off(void) |
200 | { | 200 | { |
201 | /* Shut down SDL event loop */ | 201 | /* Shut down SDL event loop */ |
202 | SDL_Event event; | 202 | 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) | |||
70 | 70 | ||
71 | /* Returns battery voltage from ADC [millivolts], | 71 | /* Returns battery voltage from ADC [millivolts], |
72 | * adc returns voltage in 5mV steps */ | 72 | * adc returns voltage in 5mV steps */ |
73 | unsigned int battery_adc_voltage(void) | 73 | int _battery_voltage(void) |
74 | { | 74 | { |
75 | return adc_read(3) * 5; | 75 | return adc_read(3) * 5; |
76 | } | 76 | } |
@@ -80,5 +80,5 @@ bool charging_state(void) | |||
80 | const unsigned short charged_thres = 4170; | 80 | const unsigned short charged_thres = 4170; |
81 | bool ret = (power_input_status() == POWER_INPUT_MAIN_CHARGER); | 81 | bool ret = (power_input_status() == POWER_INPUT_MAIN_CHARGER); |
82 | /* dont indicate for > ~95% */ | 82 | /* dont indicate for > ~95% */ |
83 | return ret && (battery_adc_voltage() <= charged_thres); | 83 | return ret && (_battery_voltage() <= charged_thres); |
84 | } | 84 | } |
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] = | |||
102 | #define BATTERY_SCALE_FACTOR 7500 | 102 | #define BATTERY_SCALE_FACTOR 7500 |
103 | 103 | ||
104 | /* Returns battery voltage from ADC [millivolts] */ | 104 | /* Returns battery voltage from ADC [millivolts] */ |
105 | unsigned int battery_adc_voltage(void) | 105 | int _battery_voltage(void) |
106 | { | 106 | { |
107 | unsigned int dummy, bat_val; | 107 | unsigned int dummy, bat_val; |
108 | 108 | ||
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] = | |||
67 | #define BATTERY_SCALE_FACTOR 1875 | 67 | #define BATTERY_SCALE_FACTOR 1875 |
68 | 68 | ||
69 | /* Returns battery voltage from ADC [millivolts] */ | 69 | /* Returns battery voltage from ADC [millivolts] */ |
70 | unsigned int battery_adc_voltage(void) | 70 | int _battery_voltage(void) |
71 | { | 71 | { |
72 | unsigned int dummy, timeout=HZ/4; | 72 | unsigned int dummy, timeout=HZ/4; |
73 | 73 | ||
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] = | |||
54 | /* full-scale ADC readout (2^10) in millivolt */ | 54 | /* full-scale ADC readout (2^10) in millivolt */ |
55 | 55 | ||
56 | /* Returns battery voltage from ADC [millivolts] */ | 56 | /* Returns battery voltage from ADC [millivolts] */ |
57 | unsigned int battery_adc_voltage(void) | 57 | int _battery_voltage(void) |
58 | { | 58 | { |
59 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | 59 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; |
60 | } | 60 | } |
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] = | |||
46 | /* full-scale ADC readout (2^10) in millivolt */ | 46 | /* full-scale ADC readout (2^10) in millivolt */ |
47 | 47 | ||
48 | /* Returns battery voltage from ADC [millivolts] */ | 48 | /* Returns battery voltage from ADC [millivolts] */ |
49 | unsigned int battery_adc_voltage(void) | 49 | int _battery_voltage(void) |
50 | { | 50 | { |
51 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | 51 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; |
52 | } | 52 | } |
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] = | |||
56 | /* full-scale ADC readout (2^10) in millivolt */ | 56 | /* full-scale ADC readout (2^10) in millivolt */ |
57 | 57 | ||
58 | /* Returns battery voltage from ADC [millivolts] */ | 58 | /* Returns battery voltage from ADC [millivolts] */ |
59 | unsigned int battery_adc_voltage(void) | 59 | int _battery_voltage(void) |
60 | { | 60 | { |
61 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | 61 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; |
62 | } | 62 | } |
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] = | |||
60 | /* full-scale ADC readout (2^10) in millivolt */ | 60 | /* full-scale ADC readout (2^10) in millivolt */ |
61 | 61 | ||
62 | /* Returns battery voltage from ADC [millivolts] */ | 62 | /* Returns battery voltage from ADC [millivolts] */ |
63 | unsigned int battery_adc_voltage(void) | 63 | int _battery_voltage(void) |
64 | { | 64 | { |
65 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | 65 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; |
66 | } | 66 | } |
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 | |||
9 | fmradio.c | 9 | fmradio.c |
10 | backlight-sim.c | 10 | backlight-sim.c |
11 | stubs.c | 11 | stubs.c |
12 | powermgmt-sim.c | ||
12 | #endif | 13 | #endif |
13 | 14 | ||
14 | io.c | 15 | io.c |
15 | /* this is still needed for application since it has some stubs */ | ||
16 | #if !(CONFIG_PLATFORM & PLATFORM_MAEMO) | ||
17 | powermgmt-sim.c | ||
18 | #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) | |||
119 | return retval; | 119 | return retval; |
120 | } | 120 | } |
121 | #endif | 121 | #endif |
122 | |||
123 | #ifdef HAVE_LCD_SHUTDOWN | ||
124 | void lcd_shutdown(void) | ||
125 | { | ||
126 | } | ||
127 | #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 @@ | |||
24 | #include <time.h> | 24 | #include <time.h> |
25 | #include "kernel.h" | 25 | #include "kernel.h" |
26 | #include "powermgmt.h" | 26 | #include "powermgmt.h" |
27 | #include "power.h" | ||
27 | 28 | ||
28 | #define BATT_MINMVOLT 2500 /* minimum millivolts of battery */ | 29 | #define BATT_MINMVOLT 3300 /* minimum millivolts of battery */ |
29 | #define BATT_MAXMVOLT 4500 /* maximum millivolts of battery */ | 30 | #define BATT_MAXMVOLT 4300 /* maximum millivolts of battery */ |
30 | #define BATT_MAXRUNTIME (10 * 60) /* maximum runtime with full battery in | 31 | #define BATT_MAXRUNTIME (10 * 60) /* maximum runtime with full battery in |
31 | minutes */ | 32 | minutes */ |
32 | 33 | ||
33 | extern void send_battery_level_event(void); | 34 | extern void send_battery_level_event(void); |
34 | extern int last_sent_battery_level; | 35 | extern int last_sent_battery_level; |
35 | extern int battery_percent; | 36 | extern int battery_percent; |
37 | static bool charging = false; | ||
36 | 38 | ||
37 | static unsigned int battery_millivolts = BATT_MAXMVOLT; | 39 | static unsigned int battery_millivolts = BATT_MAXMVOLT; |
38 | /* estimated remaining time in minutes */ | 40 | |
39 | static int powermgmt_est_runningtime_min = BATT_MAXRUNTIME; | 41 | void powermgmt_init_target(void) {} |
40 | 42 | ||
41 | static void battery_status_update(void) | 43 | static void battery_status_update(void) |
42 | { | 44 | { |
43 | static time_t last_change = 0; | 45 | static time_t last_change = 0; |
44 | static bool charging = false; | ||
45 | time_t now; | 46 | time_t now; |
46 | 47 | ||
47 | time(&now); | 48 | time(&now); |
@@ -76,57 +77,34 @@ static void battery_status_update(void) | |||
76 | 77 | ||
77 | battery_percent = 100 * (battery_millivolts - BATT_MINMVOLT) / | 78 | battery_percent = 100 * (battery_millivolts - BATT_MINMVOLT) / |
78 | (BATT_MAXMVOLT - BATT_MINMVOLT); | 79 | (BATT_MAXMVOLT - BATT_MINMVOLT); |
79 | |||
80 | powermgmt_est_runningtime_min = | ||
81 | battery_percent * BATT_MAXRUNTIME / 100; | ||
82 | } | 80 | } |
83 | |||
84 | send_battery_level_event(); | ||
85 | } | 81 | } |
86 | 82 | ||
87 | void battery_read_info(int *voltage, int *level) | 83 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = { 3200 }; |
88 | { | 84 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = { 3200 }; |
89 | battery_status_update(); | ||
90 | 85 | ||
91 | if (voltage) | 86 | /* make the simulated curve nicely linear */ |
92 | *voltage = battery_millivolts; | 87 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = |
88 | { { 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300 } }; | ||
89 | const unsigned short percent_to_volt_charge[11] = | ||
90 | { 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300 }; | ||
93 | 91 | ||
94 | if (level) | ||
95 | *level = battery_percent; | ||
96 | } | ||
97 | 92 | ||
98 | unsigned int battery_voltage(void) | 93 | int _battery_voltage(void) |
99 | { | 94 | { |
100 | battery_status_update(); | 95 | battery_status_update(); |
101 | return battery_millivolts; | 96 | return battery_millivolts; |
102 | } | 97 | } |
103 | 98 | ||
104 | int battery_level(void) | 99 | #if CONFIG_CHARGING |
105 | { | 100 | unsigned int power_input_status(void) |
106 | battery_status_update(); | ||
107 | return battery_percent; | ||
108 | } | ||
109 | |||
110 | int battery_time(void) | ||
111 | { | ||
112 | battery_status_update(); | ||
113 | return powermgmt_est_runningtime_min; | ||
114 | } | ||
115 | |||
116 | bool battery_level_safe(void) | ||
117 | { | ||
118 | return battery_level() >= 10; | ||
119 | } | ||
120 | |||
121 | void set_battery_capacity(int capacity) | ||
122 | { | 101 | { |
123 | (void)capacity; | 102 | return charging ? POWER_INPUT_NONE : POWER_INPUT_MAIN; |
124 | } | 103 | } |
125 | 104 | ||
126 | #if BATTERY_TYPES_COUNT > 1 | 105 | bool charging_state(void) |
127 | void set_battery_type(int type) | ||
128 | { | 106 | { |
129 | (void)type; | 107 | return charging; |
130 | } | 108 | } |
131 | #endif | 109 | #endif |
132 | 110 | ||
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) | |||
317 | } | 317 | } |
318 | #endif | 318 | #endif |
319 | 319 | ||
320 | #if CONFIG_CHARGING | ||
321 | bool charger_inserted(void) | ||
322 | { | ||
323 | return false; | ||
324 | } | ||
325 | |||
326 | bool power_input_present(void) | ||
327 | { | ||
328 | return false; | ||
329 | } | ||
330 | |||
331 | unsigned int power_input_status(void) | ||
332 | { | ||
333 | #ifdef HAVE_BATTERY_SWITCH | ||
334 | return POWER_INPUT_BATTERY; | ||
335 | #else | ||
336 | return POWER_INPUT_NONE; | ||
337 | #endif | ||
338 | } | ||
339 | |||
340 | bool charging_state(void) | ||
341 | { | ||
342 | return false; | ||
343 | } | ||
344 | #endif /* CONFIG_CHARGING */ | ||
345 | |||
346 | #ifndef USB_NONE | 320 | #ifndef USB_NONE |
347 | bool usb_inserted(void) | 321 | bool usb_inserted(void) |
348 | { | 322 | { |