summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2010-07-03 20:20:42 +0000
committerMarcin Bukat <marcin.bukat@gmail.com>2010-07-03 20:20:42 +0000
commit8d3591ae80def909418affe56268e019d23a86a3 (patch)
tree97533ddbb4c4309851ad73ea78e98c7c4dc810fe
parent9a471e603ebe77a3aae4692d80ceb32da50c88eb (diff)
downloadrockbox-8d3591ae80def909418affe56268e019d23a86a3.tar.gz
rockbox-8d3591ae80def909418affe56268e019d23a86a3.tar.bz2
rockbox-8d3591ae80def909418affe56268e019d23a86a3.zip
HD200 - add support for remote in button_read_device()
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27258 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/coldfire/mpio/hd200/button-hd200.c60
1 files changed, 54 insertions, 6 deletions
diff --git a/firmware/target/coldfire/mpio/hd200/button-hd200.c b/firmware/target/coldfire/mpio/hd200/button-hd200.c
index e7272fa295..880f5fd338 100644
--- a/firmware/target/coldfire/mpio/hd200/button-hd200.c
+++ b/firmware/target/coldfire/mpio/hd200/button-hd200.c
@@ -28,9 +28,12 @@
void button_init_device(void)
{
- /* Set GPIO56 (main PLAY) as general purpose inputs */
- or_l((1<<24),&GPIO1_FUNCTION);
- and_l(~(1<<24),&GPIO1_ENABLE);
+ /* GPIO56 (main PLAY)
+ * GPIO41 (remote PLAY)
+ * as general purpose inputs
+ */
+ or_l((1<<24)|(1<<9),&GPIO1_FUNCTION);
+ and_l(~((1<<24)|(1<<9)),&GPIO1_ENABLE);
}
bool button_hold(void)
@@ -39,6 +42,10 @@ bool button_hold(void)
return (GPIO1_READ & (1<<4))?true:false;
}
+bool remote_button_hold(void)
+{
+ return adc_scan(ADC_REMOTE)<50?true:false;
+}
/*
* Get button pressed from hardware
@@ -48,15 +55,17 @@ int button_read_device(void)
int btn = BUTTON_NONE;
int data = 0;
static bool hold_button = false;
+ static bool remote_hold_button = false;
bool hold_button_old;
- /* normal buttons */
+ /* read hold buttons status */
hold_button_old = hold_button;
hold_button = button_hold();
-
+ remote_hold_button = remote_button_hold();
#ifndef BOOTLOADER
+ /* Only main hold affects backlight */
if (hold_button != hold_button_old)
backlight_hold_changed(hold_button);
#endif
@@ -65,7 +74,7 @@ int button_read_device(void)
{
data = adc_scan(ADC_BUTTONS);
- if (data < 2250) // valid button
+ if (data < 2250) /* valid button */
{
if (data < 900) /* middle */
{
@@ -101,12 +110,51 @@ int button_read_device(void)
}
}
+ if (!remote_hold_button)
+ {
+ data = adc_scan(ADC_REMOTE);
+
+ if (data < 2050) /* valid button */
+ {
+ if (data < 950) /* middle */
+ {
+ if (data < 650)
+ {
+ if (data < 400)
+ {
+ if (data > 250)
+ /* 250 - 400 */
+ btn = BUTTON_RC_VOL_DOWN;
+ }
+ else /* 650 - 400 */
+ btn = BUTTON_RC_VOL_UP;
+ }
+ else /* 950 - 650 */
+ btn = BUTTON_RC_NEXT;
+ }
+ else /* 2050 - 950 */
+ {
+ if (data < 1900)
+ {
+ if (data < 1350)
+ /* 1350 - 900 */
+ btn = BUTTON_RC_PREV;
+ }
+ else /* 2050 - 1900 */
+ btn = BUTTON_RC_SELECT;
+ }
+ }
+ }
data = GPIO1_READ;
/* GPIO56 active high main PLAY/PAUSE/ON */
if (!hold_button && ((data & (1<<24))))
btn |= BUTTON_PLAY;
+
+ /* GPIO41 active high remote PLAY/PAUSE/ON */
+ if (!remote_hold_button && ((data & (1<<9))))
+ btn |= BUTTON_RC_PLAY;
return btn;
}