mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-11 06:05:21 -05:00
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
This commit is contained in:
parent
ad031e903c
commit
f9fae86de2
3 changed files with 18 additions and 11 deletions
|
|
@ -131,6 +131,8 @@
|
||||||
|
|
||||||
#define HAVE_BACKLIGHT_BRIGHTNESS
|
#define HAVE_BACKLIGHT_BRIGHTNESS
|
||||||
|
|
||||||
|
#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING
|
||||||
|
|
||||||
/* Main LCD backlight brightness range and defaults */
|
/* Main LCD backlight brightness range and defaults */
|
||||||
#define MIN_BRIGHTNESS_SETTING 0
|
#define MIN_BRIGHTNESS_SETTING 0
|
||||||
#define MAX_BRIGHTNESS_SETTING 127
|
#define MAX_BRIGHTNESS_SETTING 127
|
||||||
|
|
@ -186,8 +188,6 @@
|
||||||
/* Define this if you have ATA power-off control */
|
/* Define this if you have ATA power-off control */
|
||||||
#define HAVE_ATA_POWER_OFF
|
#define HAVE_ATA_POWER_OFF
|
||||||
|
|
||||||
#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_HW_REG
|
|
||||||
|
|
||||||
/* Virtual LED (icon) */
|
/* Virtual LED (icon) */
|
||||||
#define CONFIG_LED LED_VIRTUAL
|
#define CONFIG_LED LED_VIRTUAL
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,6 @@
|
||||||
#include "spi-target.h"
|
#include "spi-target.h"
|
||||||
#include "lcd-target.h"
|
#include "lcd-target.h"
|
||||||
|
|
||||||
int _backlight_brightness=DEFAULT_BRIGHTNESS_SETTING;
|
|
||||||
|
|
||||||
static void _backlight_write_brightness(int brightness)
|
static void _backlight_write_brightness(int brightness)
|
||||||
{
|
{
|
||||||
uint8_t bl_command[] = {0xa4, 0x00, brightness, 0xbb};
|
uint8_t bl_command[] = {0xa4, 0x00, brightness, 0xbb};
|
||||||
|
|
@ -41,7 +39,9 @@ void _backlight_on(void)
|
||||||
{
|
{
|
||||||
lcd_awake(); /* power on lcd + visible display */
|
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)
|
void _backlight_off(void)
|
||||||
|
|
@ -52,7 +52,6 @@ void _backlight_off(void)
|
||||||
/* Assumes that the backlight has been initialized */
|
/* Assumes that the backlight has been initialized */
|
||||||
void _backlight_set_brightness(int brightness)
|
void _backlight_set_brightness(int brightness)
|
||||||
{
|
{
|
||||||
_backlight_brightness=brightness;
|
|
||||||
_backlight_write_brightness(brightness);
|
_backlight_write_brightness(brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,6 +64,6 @@ void __backlight_dim(bool dim_now)
|
||||||
|
|
||||||
bool _backlight_init(void)
|
bool _backlight_init(void)
|
||||||
{
|
{
|
||||||
_backlight_set_brightness(_backlight_brightness);
|
_backlight_set_brightness(backlight_brightness);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,29 +25,35 @@
|
||||||
#include "tsc2100.h"
|
#include "tsc2100.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
|
||||||
|
unsigned short current_bat2 = 3910;
|
||||||
|
unsigned short current_aux = 3910;
|
||||||
static unsigned short current_voltage = 3910;
|
static unsigned short current_voltage = 3910;
|
||||||
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
|
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
|
||||||
{
|
{
|
||||||
0
|
3450
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
|
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 */
|
/* 6.10 format */
|
||||||
|
|
||||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
|
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
|
||||||
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
|
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 */
|
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
|
||||||
const unsigned short percent_to_volt_charge[11] =
|
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] */
|
/* Returns battery voltage from ADC [millivolts] */
|
||||||
|
|
@ -59,6 +65,8 @@ unsigned int battery_adc_voltage(void)
|
||||||
|
|
||||||
if(tsc2100_read_volt(&bat1, &bat2, &aux)){
|
if(tsc2100_read_volt(&bat1, &bat2, &aux)){
|
||||||
current_voltage=((short)((int)(bat1<<10)/4096*6*2.5));
|
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))
|
if (TIME_BEFORE(last_tick+2*HZ, current_tick))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue