1
0
Fork 0
forked from len0rd/rockbox

First lame attempt to show correct battery level on the iRiver

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6258 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Linus Nielsen Feltzing 2005-04-06 23:53:19 +00:00
parent 09e55a9218
commit 43bf39edb7
6 changed files with 26 additions and 4 deletions

View file

@ -825,6 +825,8 @@ bool dbg_ports(void)
char buf[128]; char buf[128];
int button; int button;
int line; int line;
int battery_voltage;
int batt_int, batt_frac;
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
lcd_setmargins(0, 0); lcd_setmargins(0, 0);
@ -873,6 +875,14 @@ bool dbg_ports(void)
snprintf(buf, sizeof(buf), "ADC_BATTERY: %02x", adc_battery); snprintf(buf, sizeof(buf), "ADC_BATTERY: %02x", adc_battery);
lcd_puts(0, line++, buf); lcd_puts(0, line++, buf);
battery_voltage = (adc_battery * BATTERY_SCALE_FACTOR) / 10000;
batt_int = battery_voltage / 100;
batt_frac = battery_voltage % 100;
snprintf(buf, 32, "Batt: %d.%02dV %d%% ", batt_int, batt_frac,
battery_level());
lcd_puts(0, line++, buf);
lcd_update(); lcd_update();
button = button_get_w_tmo(HZ/10); button = button_get_w_tmo(HZ/10);

View file

@ -202,6 +202,8 @@ void adc_init(void)
GPIO_OUT |= 0x80; /* CS high */ GPIO_OUT |= 0x80; /* CS high */
GPIO_OUT &= ~0x00400000; /* CLK low */ GPIO_OUT &= ~0x00400000; /* CLK low */
adc_scan(ADC_BATTERY);
tick_add_task(adc_tick); tick_add_task(adc_tick);
} }

View file

@ -21,9 +21,9 @@
#define CONFIG_I2C I2C_H100 #define CONFIG_I2C I2C_H100
/* Type of mobile power */ /* Type of mobile power */
#define CONFIG_BATTERY BATT_IRIVER #define CONFIG_BATTERY BATT_LIPOL1300
#define BATTERY_SCALE_FACTOR 6465 /* FIX: this value is picked at random */ #define BATTERY_SCALE_FACTOR 16665 /* FIX: this value is picked at random */
/* Define this if the platform can charge batteries */ /* Define this if the platform can charge batteries */
#define HAVE_CHARGING 1 #define HAVE_CHARGING 1

View file

@ -48,7 +48,7 @@
#define BATT_LIION2200 2200 /* FM/V2 recorder type */ #define BATT_LIION2200 2200 /* FM/V2 recorder type */
#define BATT_4AA_NIMH 1500 #define BATT_4AA_NIMH 1500
#define BATT_3AAA 1000 /* Ondio */ #define BATT_3AAA 1000 /* Ondio */
#define BATT_IRIVER 2 /* the type used in iRiver h1x0 models */ #define BATT_LIPOL1300 1300 /* the type used in iRiver h1x0 models */
/* CONFIG_LCD */ /* CONFIG_LCD */
#define LCD_GMINI100 0 #define LCD_GMINI100 0

View file

@ -35,6 +35,14 @@
#define BATTERY_CAPACITY_MIN 500 #define BATTERY_CAPACITY_MIN 500
#define BATTERY_CAPACITY_MAX 1500 /* max. capacity selectable in settings */ #define BATTERY_CAPACITY_MAX 1500 /* max. capacity selectable in settings */
#define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */ #define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */
#elif CONFIG_BATTERY == BATT_LIPOL1300 /* iRiver H1x0 */
#define BATTERY_LEVEL_SHUTDOWN 306 /* 3.06V */
#define BATTERY_LEVEL_EMPTY 330 /* 3.30V */
#define BATTERY_LEVEL_DANGEROUS 339 /* 3.39V */
#define BATTERY_LEVEL_FULL 400 /* 4.00V */
#define BATTERY_CAPACITY_MIN 1300
#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable in settings */
#define BATTERY_TYPES_COUNT 1
#else /* Recorder, NiMH */ #else /* Recorder, NiMH */
#define BATTERY_LEVEL_SHUTDOWN 450 /* 4.50V */ #define BATTERY_LEVEL_SHUTDOWN 450 /* 4.50V */
#define BATTERY_LEVEL_EMPTY 465 /* 4.65V */ #define BATTERY_LEVEL_EMPTY 465 /* 4.65V */

View file

@ -110,7 +110,9 @@ static const short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
#elif CONFIG_BATTERY == BATT_3AAA #elif CONFIG_BATTERY == BATT_3AAA
/* measured values */ /* measured values */
{ 280, 325, 341, 353, 364, 374, 385, 395, 409, 427, 475 }, /* alkaline */ { 280, 325, 341, 353, 364, 374, 385, 395, 409, 427, 475 }, /* alkaline */
{ 310, 355, 363, 369, 372, 374, 376, 378, 380, 386, 405 } /* NiMH */ { 310, 355, 363, 369, 372, 374, 378, 378, 380, 386, 405 } /* NiMH */
#elif CONFIG_BATTERY == BATT_LIPOL1300
{ 333, 341, 349, 358, 365, 373, 370, 386, 393, 400, 409 }
#else /* NiMH */ #else /* NiMH */
/* original values were taken directly after charging, but it should show /* original values were taken directly after charging, but it should show
100% after turning off the device for some hours, too */ 100% after turning off the device for some hours, too */