mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 13:15:18 -05:00
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:
parent
322fae4299
commit
ee0ab03286
2 changed files with 53 additions and 35 deletions
|
|
@ -69,13 +69,6 @@ static inline void delay(unsigned int duration)
|
|||
// forward declaration
|
||||
static int rds_decode(int line, struct si4700_dbg_info *nfo);
|
||||
|
||||
static int count = 0;
|
||||
|
||||
static void timer_callback(void)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
char mystring[64];
|
||||
|
|
@ -83,8 +76,9 @@ void main(void)
|
|||
unsigned char read_data[16];
|
||||
int i;
|
||||
struct si4700_dbg_info si4700_info;
|
||||
|
||||
line = 1;
|
||||
// unsigned int data;
|
||||
int brightness = 0;
|
||||
unsigned int button;
|
||||
|
||||
// enable all peripherals
|
||||
PWRCON = 0;
|
||||
|
|
@ -120,12 +114,6 @@ void main(void)
|
|||
adc_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
|
||||
si4700_init();
|
||||
tuner_power(true);
|
||||
|
|
@ -135,6 +123,8 @@ void main(void)
|
|||
|
||||
lcd_puts_scroll(0,0,"+++ this is a very very long line to test scrolling. ---");
|
||||
|
||||
button_init_device();
|
||||
|
||||
while (true)
|
||||
{
|
||||
line = 1;
|
||||
|
|
@ -198,24 +188,50 @@ void main(void)
|
|||
lcd_puts(0, line++, mystring);
|
||||
#endif
|
||||
|
||||
#if 1 /* enable to see timer/counter info */
|
||||
snprintf(mystring, 64, "TIMER: %08X", count);
|
||||
lcd_puts(0, line++, mystring);
|
||||
snprintf(mystring, 64, "current_tick: %08X", current_tick);
|
||||
lcd_puts(0, line++, mystring);
|
||||
snprintf(mystring, 64, "TIMER %04X %04X %04X", TDCON, TDPRE, TDDATA0);
|
||||
#if 1 /* button lights controlled by keypad */
|
||||
button = button_read_device();
|
||||
if (button & (BUTTON_UP | BUTTON_DOWN | BUTTON_LEFT | BUTTON_RIGHT)) {
|
||||
PDAT3 |= (1 << 3);
|
||||
}
|
||||
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);
|
||||
#endif
|
||||
|
||||
#if 1 /* enable this to control backlight brightness with the hold switch */
|
||||
if (PDAT4 & (1 << 3)) {
|
||||
_backlight_set_brightness(10);
|
||||
PDAT3 &= ~(1 << 4);
|
||||
}
|
||||
else {
|
||||
_backlight_set_brightness(15);
|
||||
PDAT3 |= (1 << 4);
|
||||
}
|
||||
|
||||
#if 1 /* button info */
|
||||
snprintf(mystring, 64, "BUTTONS %08X, %s", button_read_device(),
|
||||
headphones_inserted() ? "HP" : "hp");
|
||||
lcd_puts(0, line++, mystring);
|
||||
#endif
|
||||
|
||||
lcd_update();
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@
|
|||
|
||||
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[] =
|
||||
{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 */
|
||||
TADATA0 = logtable[brightness];
|
||||
|
|
@ -77,6 +77,8 @@ bool _backlight_init(void)
|
|||
/* Enable button LEDs: P3.2 (menu/back), P3.3 (cursor), P4.2 (middle) */
|
||||
PCON3 = (PCON3 & ~0x0000FF00) | 0x00001100;
|
||||
PCON4 = (PCON4 & ~0x00000F00) | 0x00000100;
|
||||
PDAT3 &= ~(3 << 2);
|
||||
PDAT4 &= ~(1 << 2);
|
||||
|
||||
/* enable timer clock */
|
||||
PWRCON &= ~(1 << 4);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue