Samsung YP-S3: update backlight brightness curve again (can't go all the way down to 1/256 brightness) and update yp-s3 bootloader demo.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22117 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Bertrik Sikken 2009-08-02 16:43:58 +00:00
parent 322fae4299
commit ee0ab03286
2 changed files with 53 additions and 35 deletions

View file

@ -69,13 +69,6 @@ static inline void delay(unsigned int duration)
// forward declaration // forward declaration
static int rds_decode(int line, struct si4700_dbg_info *nfo); static int rds_decode(int line, struct si4700_dbg_info *nfo);
static int count = 0;
static void timer_callback(void)
{
count++;
}
void main(void) void main(void)
{ {
char mystring[64]; char mystring[64];
@ -83,9 +76,10 @@ void main(void)
unsigned char read_data[16]; unsigned char read_data[16];
int i; int i;
struct si4700_dbg_info si4700_info; struct si4700_dbg_info si4700_info;
// unsigned int data;
int brightness = 0;
unsigned int button;
line = 1;
// enable all peripherals // enable all peripherals
PWRCON = 0; PWRCON = 0;
@ -119,22 +113,18 @@ void main(void)
fmradio_i2c_init(); fmradio_i2c_init();
adc_init(); adc_init();
_backlight_init(); _backlight_init();
timer_register(1, NULL, 3 * TIMER_FREQ, timer_callback);
// LED outputs
PCON3 = (PCON3 & ~(0x0000FF00)) | 0x00001100;
PDAT3 |= (1 << 2) | (1 << 3);
// FM power // FM power
si4700_init(); si4700_init();
tuner_power(true); tuner_power(true);
si4700_set(RADIO_SLEEP, 0); si4700_set(RADIO_SLEEP, 0);
si4700_set(RADIO_MUTE, 0); si4700_set(RADIO_MUTE, 0);
si4700_set(RADIO_FREQUENCY, 100700000); si4700_set(RADIO_FREQUENCY, 100700000);
lcd_puts_scroll(0,0,"+++ this is a very very long line to test scrolling. ---"); lcd_puts_scroll(0,0,"+++ this is a very very long line to test scrolling. ---");
button_init_device();
while (true) while (true)
{ {
line = 1; line = 1;
@ -198,28 +188,54 @@ void main(void)
lcd_puts(0, line++, mystring); lcd_puts(0, line++, mystring);
#endif #endif
#if 1 /* enable to see timer/counter info */ #if 1 /* button lights controlled by keypad */
snprintf(mystring, 64, "TIMER: %08X", count); button = button_read_device();
lcd_puts(0, line++, mystring); if (button & (BUTTON_UP | BUTTON_DOWN | BUTTON_LEFT | BUTTON_RIGHT)) {
snprintf(mystring, 64, "current_tick: %08X", current_tick); PDAT3 |= (1 << 3);
lcd_puts(0, line++, mystring); }
snprintf(mystring, 64, "TIMER %04X %04X %04X", TDCON, TDPRE, TDDATA0); else {
PDAT3 &= ~(1 << 3);
}
if (button & (BUTTON_BACK | BUTTON_MENU)) {
PDAT3 |= (1 << 2);
}
else {
PDAT3 &= ~(1 << 2);
}
if (button & (BUTTON_SELECT)) {
PDAT4 |= (1 << 2);
}
else {
PDAT4 &= ~(1 << 2);
}
#endif
#if 1 /* backlight brightness controlled by up/down keys */
if (button_read_device() & BUTTON_UP) {
if (brightness < MAX_BRIGHTNESS_SETTING) {
brightness++;
_backlight_set_brightness(brightness);
}
}
else if (button_read_device() & BUTTON_DOWN) {
if (brightness > MIN_BRIGHTNESS_SETTING) {
brightness--;
_backlight_set_brightness(brightness);
}
}
snprintf(mystring, 64, "bright %3d", brightness);
lcd_puts(0, line++, mystring); lcd_puts(0, line++, mystring);
#endif #endif
#if 1 /* enable this to control backlight brightness with the hold switch */
if (PDAT4 & (1 << 3)) { #if 1 /* button info */
_backlight_set_brightness(10); snprintf(mystring, 64, "BUTTONS %08X, %s", button_read_device(),
PDAT3 &= ~(1 << 4); headphones_inserted() ? "HP" : "hp");
} lcd_puts(0, line++, mystring);
else {
_backlight_set_brightness(15);
PDAT3 |= (1 << 4);
}
#endif #endif
lcd_update(); lcd_update();
} }
} }

View file

@ -37,9 +37,9 @@
void _backlight_set_brightness(int brightness) void _backlight_set_brightness(int brightness)
{ {
/* pwm = round(sqrt(2)**x), where brightness level x = 1..16 */ /* pwm = round(16 * 16**(x/16)), where brightness level x = 1..16 */
static const unsigned int logtable[] = static const unsigned int logtable[] =
{1, 2, 3, 4, 6, 8, 11, 16, 23, 32, 45, 64, 91, 128, 181, 256}; {19, 23, 27, 32, 38, 45, 54, 64, 76, 91, 108, 128, 152, 181, 215, 256};
/* set PWM width */ /* set PWM width */
TADATA0 = logtable[brightness]; TADATA0 = logtable[brightness];
@ -77,6 +77,8 @@ bool _backlight_init(void)
/* Enable button LEDs: P3.2 (menu/back), P3.3 (cursor), P4.2 (middle) */ /* Enable button LEDs: P3.2 (menu/back), P3.3 (cursor), P4.2 (middle) */
PCON3 = (PCON3 & ~0x0000FF00) | 0x00001100; PCON3 = (PCON3 & ~0x0000FF00) | 0x00001100;
PCON4 = (PCON4 & ~0x00000F00) | 0x00000100; PCON4 = (PCON4 & ~0x00000F00) | 0x00000100;
PDAT3 &= ~(3 << 2);
PDAT4 &= ~(1 << 2);
/* enable timer clock */ /* enable timer clock */
PWRCON &= ~(1 << 4); PWRCON &= ~(1 << 4);