diff options
-rw-r--r-- | apps/debug_menu.c | 10 | ||||
-rw-r--r-- | firmware/drivers/adc.c | 2 | ||||
-rw-r--r-- | firmware/export/config-h100.h | 4 | ||||
-rw-r--r-- | firmware/export/config.h | 2 | ||||
-rw-r--r-- | firmware/export/powermgmt.h | 8 | ||||
-rw-r--r-- | firmware/powermgmt.c | 4 |
6 files changed, 26 insertions, 4 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 2ab2194199..3969972ea8 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -825,6 +825,8 @@ bool dbg_ports(void) | |||
825 | char buf[128]; | 825 | char buf[128]; |
826 | int button; | 826 | int button; |
827 | int line; | 827 | int line; |
828 | int battery_voltage; | ||
829 | int batt_int, batt_frac; | ||
828 | 830 | ||
829 | #ifdef HAVE_LCD_BITMAP | 831 | #ifdef HAVE_LCD_BITMAP |
830 | lcd_setmargins(0, 0); | 832 | lcd_setmargins(0, 0); |
@@ -873,6 +875,14 @@ bool dbg_ports(void) | |||
873 | snprintf(buf, sizeof(buf), "ADC_BATTERY: %02x", adc_battery); | 875 | snprintf(buf, sizeof(buf), "ADC_BATTERY: %02x", adc_battery); |
874 | lcd_puts(0, line++, buf); | 876 | lcd_puts(0, line++, buf); |
875 | 877 | ||
878 | battery_voltage = (adc_battery * BATTERY_SCALE_FACTOR) / 10000; | ||
879 | batt_int = battery_voltage / 100; | ||
880 | batt_frac = battery_voltage % 100; | ||
881 | |||
882 | snprintf(buf, 32, "Batt: %d.%02dV %d%% ", batt_int, batt_frac, | ||
883 | battery_level()); | ||
884 | lcd_puts(0, line++, buf); | ||
885 | |||
876 | lcd_update(); | 886 | lcd_update(); |
877 | button = button_get_w_tmo(HZ/10); | 887 | button = button_get_w_tmo(HZ/10); |
878 | 888 | ||
diff --git a/firmware/drivers/adc.c b/firmware/drivers/adc.c index fd7916622c..69aeb2996e 100644 --- a/firmware/drivers/adc.c +++ b/firmware/drivers/adc.c | |||
@@ -202,6 +202,8 @@ void adc_init(void) | |||
202 | GPIO_OUT |= 0x80; /* CS high */ | 202 | GPIO_OUT |= 0x80; /* CS high */ |
203 | GPIO_OUT &= ~0x00400000; /* CLK low */ | 203 | GPIO_OUT &= ~0x00400000; /* CLK low */ |
204 | 204 | ||
205 | adc_scan(ADC_BATTERY); | ||
206 | |||
205 | tick_add_task(adc_tick); | 207 | tick_add_task(adc_tick); |
206 | } | 208 | } |
207 | 209 | ||
diff --git a/firmware/export/config-h100.h b/firmware/export/config-h100.h index d8453a96d1..5eef2c7270 100644 --- a/firmware/export/config-h100.h +++ b/firmware/export/config-h100.h | |||
@@ -21,9 +21,9 @@ | |||
21 | #define CONFIG_I2C I2C_H100 | 21 | #define CONFIG_I2C I2C_H100 |
22 | 22 | ||
23 | /* Type of mobile power */ | 23 | /* Type of mobile power */ |
24 | #define CONFIG_BATTERY BATT_IRIVER | 24 | #define CONFIG_BATTERY BATT_LIPOL1300 |
25 | 25 | ||
26 | #define BATTERY_SCALE_FACTOR 6465 /* FIX: this value is picked at random */ | 26 | #define BATTERY_SCALE_FACTOR 16665 /* FIX: this value is picked at random */ |
27 | 27 | ||
28 | /* Define this if the platform can charge batteries */ | 28 | /* Define this if the platform can charge batteries */ |
29 | #define HAVE_CHARGING 1 | 29 | #define HAVE_CHARGING 1 |
diff --git a/firmware/export/config.h b/firmware/export/config.h index 201b5317e3..a47581afc7 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h | |||
@@ -48,7 +48,7 @@ | |||
48 | #define BATT_LIION2200 2200 /* FM/V2 recorder type */ | 48 | #define BATT_LIION2200 2200 /* FM/V2 recorder type */ |
49 | #define BATT_4AA_NIMH 1500 | 49 | #define BATT_4AA_NIMH 1500 |
50 | #define BATT_3AAA 1000 /* Ondio */ | 50 | #define BATT_3AAA 1000 /* Ondio */ |
51 | #define BATT_IRIVER 2 /* the type used in iRiver h1x0 models */ | 51 | #define BATT_LIPOL1300 1300 /* the type used in iRiver h1x0 models */ |
52 | 52 | ||
53 | /* CONFIG_LCD */ | 53 | /* CONFIG_LCD */ |
54 | #define LCD_GMINI100 0 | 54 | #define LCD_GMINI100 0 |
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h index ccfdede9f9..97daf7ce59 100644 --- a/firmware/export/powermgmt.h +++ b/firmware/export/powermgmt.h | |||
@@ -35,6 +35,14 @@ | |||
35 | #define BATTERY_CAPACITY_MIN 500 | 35 | #define BATTERY_CAPACITY_MIN 500 |
36 | #define BATTERY_CAPACITY_MAX 1500 /* max. capacity selectable in settings */ | 36 | #define BATTERY_CAPACITY_MAX 1500 /* max. capacity selectable in settings */ |
37 | #define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */ | 37 | #define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */ |
38 | #elif CONFIG_BATTERY == BATT_LIPOL1300 /* iRiver H1x0 */ | ||
39 | #define BATTERY_LEVEL_SHUTDOWN 306 /* 3.06V */ | ||
40 | #define BATTERY_LEVEL_EMPTY 330 /* 3.30V */ | ||
41 | #define BATTERY_LEVEL_DANGEROUS 339 /* 3.39V */ | ||
42 | #define BATTERY_LEVEL_FULL 400 /* 4.00V */ | ||
43 | #define BATTERY_CAPACITY_MIN 1300 | ||
44 | #define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable in settings */ | ||
45 | #define BATTERY_TYPES_COUNT 1 | ||
38 | #else /* Recorder, NiMH */ | 46 | #else /* Recorder, NiMH */ |
39 | #define BATTERY_LEVEL_SHUTDOWN 450 /* 4.50V */ | 47 | #define BATTERY_LEVEL_SHUTDOWN 450 /* 4.50V */ |
40 | #define BATTERY_LEVEL_EMPTY 465 /* 4.65V */ | 48 | #define BATTERY_LEVEL_EMPTY 465 /* 4.65V */ |
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 5a1639ca1c..319a99fde6 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c | |||
@@ -110,7 +110,9 @@ static const short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | |||
110 | #elif CONFIG_BATTERY == BATT_3AAA | 110 | #elif CONFIG_BATTERY == BATT_3AAA |
111 | /* measured values */ | 111 | /* measured values */ |
112 | { 280, 325, 341, 353, 364, 374, 385, 395, 409, 427, 475 }, /* alkaline */ | 112 | { 280, 325, 341, 353, 364, 374, 385, 395, 409, 427, 475 }, /* alkaline */ |
113 | { 310, 355, 363, 369, 372, 374, 376, 378, 380, 386, 405 } /* NiMH */ | 113 | { 310, 355, 363, 369, 372, 374, 378, 378, 380, 386, 405 } /* NiMH */ |
114 | #elif CONFIG_BATTERY == BATT_LIPOL1300 | ||
115 | { 333, 341, 349, 358, 365, 373, 370, 386, 393, 400, 409 } | ||
114 | #else /* NiMH */ | 116 | #else /* NiMH */ |
115 | /* original values were taken directly after charging, but it should show | 117 | /* original values were taken directly after charging, but it should show |
116 | 100% after turning off the device for some hours, too */ | 118 | 100% after turning off the device for some hours, too */ |