Use a logarithmic scale for the Onda VX747 backlight (thanks to Bertrik Sikken)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21492 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Maurus Cuelenaere 2009-06-24 19:52:03 +00:00
parent 763a7d7457
commit 5acfa34b9c
2 changed files with 14 additions and 14 deletions

View file

@ -116,9 +116,9 @@
#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_HW_REG
/* Main LCD backlight brightness range and defaults */
#define MIN_BRIGHTNESS_SETTING 1
#define MAX_BRIGHTNESS_SETTING 30
#define DEFAULT_BRIGHTNESS_SETTING 30 /* "full brightness" */
#define MIN_BRIGHTNESS_SETTING 0
#define MAX_BRIGHTNESS_SETTING 15
#define DEFAULT_BRIGHTNESS_SETTING 10 /* "full brightness" */
#define DEFAULT_DIMNESS_SETTING 1 /* "most dim" */
/* Define this if you have a software controlled poweroff */

View file

@ -32,23 +32,20 @@
* [PWM half rate, PWM full rate[ -> backlight on
* [PWM full rate, PWM full rate] -> counter reset to 0
*/
static int old_val;
static int old_val = MAX_BRIGHTNESS_SETTING;
static const unsigned char logtable[] = {255, 254, 253, 252, 250, 248, 245, 240, 233, 224, 211, 192, 165, 128, 75, 0};
static void set_backlight(int val)
{
/* The pulse repetition frequency should be greater than 100Hz so
the flickering is not perceptible to the human eye but
not greater than about 1kHz. */
if(val == old_val)
return;
/* Clock = 32 768 Hz */
/* 1 <= val <= 30 */
int cycle = (MAX_BRIGHTNESS_SETTING - val + 1);
__tcu_disable_pwm_output(BACKLIGHT_PWM);
__tcu_stop_counter(BACKLIGHT_PWM);
__tcu_set_count(BACKLIGHT_PWM, 0);
__tcu_set_half_data(BACKLIGHT_PWM, cycle-1);
__tcu_set_full_data(BACKLIGHT_PWM, cycle);
__tcu_set_half_data(BACKLIGHT_PWM, logtable[val]);
__tcu_set_full_data(BACKLIGHT_PWM, 256);
__tcu_start_counter(BACKLIGHT_PWM);
__tcu_enable_pwm_output(BACKLIGHT_PWM);
@ -58,7 +55,8 @@ static void set_backlight(int val)
static void set_backlight_on(void)
{
set_backlight(old_val);
__tcu_start_counter(BACKLIGHT_PWM);
__tcu_enable_pwm_output(BACKLIGHT_PWM);
}
static void set_backlight_off(void)
@ -83,7 +81,9 @@ bool _backlight_init(void)
__tcu_mask_half_match_irq(BACKLIGHT_PWM);
__tcu_mask_full_match_irq(BACKLIGHT_PWM);
old_val = MAX_BRIGHTNESS_SETTING;
__tcu_set_count(BACKLIGHT_PWM, 0);
__tcu_set_half_data(BACKLIGHT_PWM, 0);
__tcu_set_full_data(BACKLIGHT_PWM, 256);
return true;
}