diff options
| author | Michael Sevakis <jethead71@rockbox.org> | 2006-09-10 02:00:40 +0000 |
|---|---|---|
| committer | Michael Sevakis <jethead71@rockbox.org> | 2006-09-10 02:00:40 +0000 |
| commit | 3d2e10bcbd13ec48decafe49f32afcc12c5e185a (patch) | |
| tree | 60c490e727a28fd2359c3d185cf2a4f5fd8c328b /firmware | |
| parent | 24ca76ffec3e0d782f75ac1cca2c0b2c8b71f5db (diff) | |
| download | rockbox-3d2e10bcbd13ec48decafe49f32afcc12c5e185a.zip rockbox-3d2e10bcbd13ec48decafe49f32afcc12c5e185a.tar.gz rockbox-3d2e10bcbd13ec48decafe49f32afcc12c5e185a.tar.bz2 rockbox-3d2e10bcbd13ec48decafe49f32afcc12c5e185a.tar.xz | |
Added remote backlight on hold option to players with remote hold switch. Disabled IRQs while reading pcf50606 ADC. This seems to have stopped buttons becoming unresponsive when using remote. Maybe fixes other button glitches as well?
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10911 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
| -rw-r--r-- | firmware/backlight.c | 57 | ||||
| -rw-r--r-- | firmware/drivers/adc.c | 2 | ||||
| -rw-r--r-- | firmware/drivers/button.c | 10 | ||||
| -rw-r--r-- | firmware/export/backlight.h | 23 | ||||
| -rwxr-xr-x | firmware/target/coldfire/iaudio/x5/adc-x5.c | 2 | ||||
| -rwxr-xr-x | firmware/target/coldfire/iaudio/x5/button-x5.c | 16 | ||||
| -rw-r--r-- | firmware/target/coldfire/iaudio/x5/pcf50606-x5.c | 2 |
7 files changed, 92 insertions, 20 deletions
diff --git a/firmware/backlight.c b/firmware/backlight.c index 6f7432c..bf88cbe 100644 --- a/firmware/backlight.c +++ b/firmware/backlight.c @@ -178,6 +178,9 @@ static int remote_backlight_timeout = 5*HZ; #ifdef CONFIG_CHARGING static int remote_backlight_timeout_plugged = 5*HZ; #endif +#ifdef HAS_REMOTE_BUTTON_HOLD +static int remote_backlight_on_button_hold = 0; +#endif #endif #ifdef HAVE_LCD_SLEEP @@ -461,6 +464,10 @@ static void remote_backlight_update_state(void) if (remote_backlight_timer < 0) { remote_backlight_timer = 0; /* Disable the timeout */ +#ifdef HAS_REMOTE_BUTTON_HOLD + if (remote_backlight_on_button_hold == 2 && remote_button_hold()) + return; /* Keep on if "On" */ +#endif __remote_backlight_off(); } else @@ -471,8 +478,18 @@ static void remote_backlight_update_state(void) backlight_update_state(); } else -#endif +#endif + { +#ifdef HAS_REMOTE_BUTTON_HOLD + if (remote_backlight_on_button_hold == 1 && remote_button_hold()) + { + /* Keep off if "Off". */ + remote_backlight_timer = 0; /* Disable the timeout */ + return; + } +#endif __remote_backlight_on(); + } } } #endif /* HAVE_REMOTE_LCD */ @@ -493,9 +510,15 @@ void backlight_thread(void) case REMOTE_BACKLIGHT_OFF: remote_backlight_timer = 0; /* Disable the timeout */ +#ifdef HAS_REMOTE_BUTTON_HOLD + if (remote_backlight_on_button_hold == 2 && + remote_button_hold()) + break; /* Keep on if "On" */ +#endif __remote_backlight_off(); break; -#endif +#endif /* HAVE_REMOTE_LCD */ + case BACKLIGHT_ON: backlight_update_state(); break; @@ -701,9 +724,7 @@ void backlight_hold_changed(bool hold_button) set to "Normal" */ /* Queue or freeze */ if (hold_button && backlight_on_button_hold == 1) - { backlight_off(); /* setting == Off */ - } else /* setting == On, Normal, no hold button, or anything else */ backlight_on(); } @@ -774,6 +795,34 @@ void remote_backlight_set_timeout_plugged(int index) } #endif /* CONFIG_CHARGING */ +#ifdef HAS_REMOTE_BUTTON_HOLD +/* Remote hold button change event handler. */ +void remote_backlight_hold_changed(bool rc_hold_button) +{ + /* Hold switch overrides all backlight behavior except when + set to "Normal" */ + /* Queue or freeze */ + if (rc_hold_button && remote_backlight_on_button_hold == 1) + remote_backlight_off(); /* setting == Off */ + else /* setting == On, Normal, no hold button, or anything else */ + remote_backlight_on(); + +} + +void remote_backlight_set_on_button_hold(int index) +{ + if ((unsigned)index >= 3) + /* if given a weird value, use default */ + index = 0; + + if (index == remote_backlight_on_button_hold) + return; + + remote_backlight_on_button_hold = index; + remote_backlight_hold_changed(remote_button_hold()); +} +#endif /* HAS_REMOTE_BUTTON_HOLD */ + /* return value in ticks; 0 means always on, <0 means always off */ int remote_backlight_get_current_timeout(void) { diff --git a/firmware/drivers/adc.c b/firmware/drivers/adc.c index 1ebac06..d00f899 100644 --- a/firmware/drivers/adc.c +++ b/firmware/drivers/adc.c @@ -123,6 +123,7 @@ static int channelnum[] = unsigned short adc_scan(int channel) { + int level = set_irq_level(HIGHEST_IRQ_LEVEL); unsigned char data; pcf50606_write(0x2f, 0x80 | (channelnum[channel] << 1) | 1); @@ -130,6 +131,7 @@ unsigned short adc_scan(int channel) adcdata[channel] = data; + set_irq_level(level); return data; } #else diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index f31ab33..5e6f6b4 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c @@ -845,6 +845,7 @@ static int button_read(void) static int prev_data = 0xff; static int last_valid = 0xff; bool hold_button_old; + bool remote_hold_button_old; /* normal buttons */ hold_button_old = hold_button; @@ -916,12 +917,13 @@ static int button_read(void) } /* remote buttons */ + remote_hold_button_old = remote_hold_button; remote_hold_button = remote_button_hold_only(); - if (remote_hold_button && !remote_button_hold_only()) - { - remote_backlight_on(); - } +#ifndef BOOTLOADER + if (remote_hold_button != remote_hold_button_old) + remote_backlight_hold_changed(remote_hold_button); +#endif if (!remote_hold_button) { diff --git a/firmware/export/backlight.h b/firmware/export/backlight.h index 62f0248..6875768 100644 --- a/firmware/export/backlight.h +++ b/firmware/export/backlight.h @@ -25,27 +25,35 @@ bool is_backlight_on(void); void backlight_on(void); void backlight_off(void); void backlight_set_timeout(int index); + #ifdef CONFIG_BACKLIGHT void backlight_init(void); + #if defined(IAUDIO_X5) && !defined(SIMULATOR) #define X5_BACKLIGHT_SHUTDOWN void x5_backlight_shutdown(void); #endif + int backlight_get_current_timeout(void); + #ifdef HAVE_BACKLIGHT_PWM_FADING void backlight_set_fade_in(int index); void backlight_set_fade_out(int index); #endif + void backlight_set_timeout_plugged(int index); extern const signed char backlight_timeout_value[]; + #ifdef HAS_BUTTON_HOLD -void backlight_set_on_button_hold(int index); void backlight_hold_changed(bool hold_button); +void backlight_set_on_button_hold(int index); #endif + #ifdef HAVE_LCD_SLEEP void lcd_set_sleep_after_backlight_off(int index); extern const signed char lcd_sleep_timeout_value[]; #endif + #else /* ndef CONFIG_BACKLIGHT */ #define backlight_init() #endif /* CONFIG_BACKLIGHT */ @@ -56,15 +64,20 @@ void remote_backlight_off(void); void remote_backlight_set_timeout(int index); void remote_backlight_set_timeout_plugged(int index); bool is_remote_backlight_on(void); + +#ifdef HAS_REMOTE_BUTTON_HOLD +void remote_backlight_hold_changed(bool rc_hold_button); +void remote_backlight_set_on_button_hold(int index); #endif +#endif /* HAVE_REMOTE_LCD */ #ifdef SIMULATOR void sim_backlight(int value); void sim_remote_backlight(int value); #endif -#endif #ifdef HAVE_BACKLIGHT_BRIGHTNESS + #ifdef IAUDIO_X5 /* PFC50506 can output 0%-100% duty cycle but D305A expects %15-100%. */ #define MIN_BRIGHTNESS_SETTING 1 /* 15/16 (93.75%) */ @@ -74,7 +87,9 @@ void sim_remote_backlight(int value); #define MIN_BRIGHTNESS_SETTING 2 /* 2/16 (12.50%) */ #define MAX_BRIGHTNESS_SETTING 15 /* 15/16 (93.75%) */ #define DEFAULT_BRIGHTNESS_SETTING 9 /* 9/16 (56.25%) */ -#endif /* HAVE_BACKLIGHT_BRIGHTNESS */ +#endif void backlight_set_brightness(int val); -#endif +#endif /* HAVE_BACKLIGHT_BRIGHTNESS */ + +#endif /* BACKLIGHT_H */ diff --git a/firmware/target/coldfire/iaudio/x5/adc-x5.c b/firmware/target/coldfire/iaudio/x5/adc-x5.c index e465f38..fc45da86 100755 --- a/firmware/target/coldfire/iaudio/x5/adc-x5.c +++ b/firmware/target/coldfire/iaudio/x5/adc-x5.c @@ -35,6 +35,7 @@ static int channelnum[] = unsigned short adc_scan(int channel) { + int level = set_irq_level(HIGHEST_IRQ_LEVEL); unsigned char data; pcf50606_write(0x2f, 0x80 | (channelnum[channel] << 1) | 1); @@ -42,6 +43,7 @@ unsigned short adc_scan(int channel) adcdata[channel] = data; + set_irq_level(level); return data; } diff --git a/firmware/target/coldfire/iaudio/x5/button-x5.c b/firmware/target/coldfire/iaudio/x5/button-x5.c index 287ee0e..84d1dbc 100755 --- a/firmware/target/coldfire/iaudio/x5/button-x5.c +++ b/firmware/target/coldfire/iaudio/x5/button-x5.c @@ -41,7 +41,7 @@ bool button_hold(void) bool remote_button_hold(void) { - return false; /* TODO X5 */ + return adc_scan(ADC_REMOTE) < 0x17; } int button_read_device(void) @@ -51,6 +51,7 @@ int button_read_device(void) static bool hold_button = false; static bool remote_hold_button = false; bool hold_button_old; + bool remote_hold_button_old; /* normal buttons */ hold_button_old = hold_button; @@ -90,14 +91,15 @@ int button_read_device(void) } /* remote buttons */ - - /* TODO: add light handling for the remote */ - - remote_hold_button = remote_button_hold(); + remote_hold_button_old = remote_hold_button; data = adc_scan(ADC_REMOTE); - if(data < 0x17) - remote_hold_button = true; + remote_hold_button = data < 0x17; + +#ifndef BOOTLOADER + if (remote_hold_button != remote_hold_button_old) + remote_backlight_hold_changed(remote_hold_button); +#endif if(!remote_hold_button) { diff --git a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c b/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c index dde20d8..032c308 100644 --- a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c +++ b/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c @@ -177,7 +177,7 @@ void pcf50606_init(void) and_l(~0x00000001, &GPIO_ENABLE); or_l(0x00000001, &GPIO_FUNCTION); or_l(0x00000100, &GPIO_INT_EN); /* GPI0 H-L */ - INTPRI5 |= 0x00000006; /* INT32 - Priority 6 */ + INTPRI5 |= (6 << 0); /* INT32 - Priority 6 */ pcf50606_write(0x39, 0x00); /* GPOOD0 = green led OFF */ pcf50606_write(0x3a, 0x00); /* GPOOD1 = red led OFF */ |