From f9fae86de25a71e79571d8e692868be544ac1bfb Mon Sep 17 00:00:00 2001 From: Karl Kurbjun Date: Mon, 4 May 2009 04:14:52 +0000 Subject: M:Robe 500: Add backlight cleanups and fix power management so that dangerous and shutoff voltages are taken care of, carge discharge curves are better modeled. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20849 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/config-mrobe500.h | 4 ++-- .../target/arm/tms320dm320/mrobe-500/backlight-mr500.c | 9 ++++----- .../target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c | 16 ++++++++++++---- 3 files changed, 18 insertions(+), 11 deletions(-) (limited to 'firmware') diff --git a/firmware/export/config-mrobe500.h b/firmware/export/config-mrobe500.h index 5a97d8ba85..f8f3502152 100644 --- a/firmware/export/config-mrobe500.h +++ b/firmware/export/config-mrobe500.h @@ -131,6 +131,8 @@ #define HAVE_BACKLIGHT_BRIGHTNESS +#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING + /* Main LCD backlight brightness range and defaults */ #define MIN_BRIGHTNESS_SETTING 0 #define MAX_BRIGHTNESS_SETTING 127 @@ -186,8 +188,6 @@ /* Define this if you have ATA power-off control */ #define HAVE_ATA_POWER_OFF -#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_HW_REG - /* Virtual LED (icon) */ #define CONFIG_LED LED_VIRTUAL diff --git a/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c index 751a59da94..1596b83dc3 100644 --- a/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c +++ b/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c @@ -29,8 +29,6 @@ #include "spi-target.h" #include "lcd-target.h" -int _backlight_brightness=DEFAULT_BRIGHTNESS_SETTING; - static void _backlight_write_brightness(int brightness) { uint8_t bl_command[] = {0xa4, 0x00, brightness, 0xbb}; @@ -41,7 +39,9 @@ void _backlight_on(void) { lcd_awake(); /* power on lcd + visible display */ - _backlight_write_brightness(_backlight_brightness); +#if !defined(CONFIG_BACKLIGHT_FADING) + _backlight_write_brightness(backlight_brightness); +#endif } void _backlight_off(void) @@ -52,7 +52,6 @@ void _backlight_off(void) /* Assumes that the backlight has been initialized */ void _backlight_set_brightness(int brightness) { - _backlight_brightness=brightness; _backlight_write_brightness(brightness); } @@ -65,6 +64,6 @@ void __backlight_dim(bool dim_now) bool _backlight_init(void) { - _backlight_set_brightness(_backlight_brightness); + _backlight_set_brightness(backlight_brightness); return true; } diff --git a/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c index 60949b2c18..b81c34ac3b 100755 --- a/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c +++ b/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c @@ -25,29 +25,35 @@ #include "tsc2100.h" #include "kernel.h" +unsigned short current_bat2 = 3910; +unsigned short current_aux = 3910; static unsigned short current_voltage = 3910; const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = { - 0 + 3450 }; const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = { - 0 + 3400 }; +/* Right now these are linear translations, it would be good to model them + * appropriate to the actual battery curve. + */ + /* 6.10 format */ /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = { - { 375, 1125, 1500, 1875, 2250, 2625, 3000, 3375, 3750, 4500, 4950 }, + { 3400, 3300, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300, 4400 }, }; /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ const unsigned short percent_to_volt_charge[11] = { - 375, 1125, 1500, 1875, 2250, 2625, 3000, 3375, 3750, 4500, 4950, + 4000, 4105, 4210, 4315, 4420, 4525, 4630, 4735, 4840, 4945, 5050, }; /* Returns battery voltage from ADC [millivolts] */ @@ -59,6 +65,8 @@ unsigned int battery_adc_voltage(void) if(tsc2100_read_volt(&bat1, &bat2, &aux)){ current_voltage=((short)((int)(bat1<<10)/4096*6*2.5)); + current_bat2=((short)((int)(bat2<<10)/4096*6*2.5)); + current_aux=((short)((int)(aux<<10)/4096*6*2.5)); } if (TIME_BEFORE(last_tick+2*HZ, current_tick)) -- cgit v1.2.3