1
0
Fork 0
forked from len0rd/rockbox

Implement software pwm to control c200v2 display brightness.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25300 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Tobias Diedrich 2010-03-23 05:27:32 +00:00
parent 47ab95904e
commit 62ff88b717
3 changed files with 162 additions and 6 deletions

View file

@ -27,6 +27,32 @@
#include "as3514.h"
int buttonlight_is_on = 0;
int backlight_is_on = 0;
static int backlight_level = 0;
/* logarithmic lookup table for brightness s*/
static const int brightness_table[MAX_BRIGHTNESS_SETTING+1] = {
0, 21, 47, 78, 118, 165, 224, 296, 386, 495, 630, 796, 1000
};
static void _ll_backlight_on(void)
{
GPIOA_PIN(5) = 1<<5;
}
static void _ll_backlight_off(void)
{
GPIOA_PIN(5) = 0;
}
void _backlight_pwm(int on)
{
if (on) {
_ll_backlight_on();
} else {
_ll_backlight_off();
}
}
bool _backlight_init(void)
{
@ -36,6 +62,8 @@ bool _backlight_init(void)
void _backlight_set_brightness(int brightness)
{
backlight_level = brightness_table[brightness];
if (brightness > 0)
_backlight_on();
else
@ -47,12 +75,17 @@ void _backlight_on(void)
#ifdef HAVE_LCD_ENABLE
lcd_enable(true); /* power on lcd + visible display */
#endif
GPIOA_PIN(5) = 1<<5;
if (!backlight_is_on)
_ll_backlight_on();
_set_timer2_pwm_ratio(backlight_level);
backlight_is_on = 1;
}
void _backlight_off(void)
{
GPIOA_PIN(5) = 0;
backlight_is_on = 0;
_set_timer2_pwm_ratio(0);
_ll_backlight_off();
#ifdef HAVE_LCD_ENABLE
lcd_enable(false); /* power off visible display */
#endif

View file

@ -24,6 +24,7 @@
#include <stdbool.h>
bool _backlight_init(void);
void _backlight_pwm(int on);
void _backlight_on(void);
void _backlight_off(void);
void _backlight_set_brightness(int brightness);
@ -31,4 +32,10 @@ int __backlight_is_on(void);
void _buttonlight_on(void);
void _buttonlight_off(void);
/*
* FIXME: This may be better off in kernel.h, but...
*/
void _set_timer2_pwm_ratio(int ratio);
#endif