summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2010-07-06 14:43:58 +0000
committerMarcin Bukat <marcin.bukat@gmail.com>2010-07-06 14:43:58 +0000
commit7c908bbeda55d313a8c769d5d1faece2e33b3059 (patch)
tree62b93b415ab3baf1aa2c76a95bb903261f7d0330
parent851e06617bd3d4ec5427226b49e13ab2efba0cad (diff)
downloadrockbox-7c908bbeda55d313a8c769d5d1faece2e33b3059.tar.gz
rockbox-7c908bbeda55d313a8c769d5d1faece2e33b3059.zip
HD200 - more work on remote handling
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27306 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/coldfire/mpio/hd200/button-hd200.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/firmware/target/coldfire/mpio/hd200/button-hd200.c b/firmware/target/coldfire/mpio/hd200/button-hd200.c
index 880f5fd338..fa0a5cf3cf 100644
--- a/firmware/target/coldfire/mpio/hd200/button-hd200.c
+++ b/firmware/target/coldfire/mpio/hd200/button-hd200.c
@@ -26,6 +26,15 @@
26#include "backlight.h" 26#include "backlight.h"
27#include "adc.h" 27#include "adc.h"
28 28
29static bool remote_detect(void)
30{
31 /* When there is no remote adc readout
32 * is exactly 0. We add some margin
33 * for ADC readout instability
34 */
35 return adc_scan(ADC_REMOTE)>10?true:false;
36}
37
29void button_init_device(void) 38void button_init_device(void)
30{ 39{
31 /* GPIO56 (main PLAY) 40 /* GPIO56 (main PLAY)
@@ -44,7 +53,11 @@ bool button_hold(void)
44 53
45bool remote_button_hold(void) 54bool remote_button_hold(void)
46{ 55{
47 return adc_scan(ADC_REMOTE)<50?true:false; 56 /* On my remote hold gives readout of 44 */
57 if (remote_detect())
58 return adc_scan(ADC_REMOTE)<50?true:false;
59 else
60 return false;
48} 61}
49 62
50/* 63/*
@@ -55,9 +68,13 @@ int button_read_device(void)
55 int btn = BUTTON_NONE; 68 int btn = BUTTON_NONE;
56 int data = 0; 69 int data = 0;
57 static bool hold_button = false; 70 static bool hold_button = false;
58 static bool remote_hold_button = false; 71 bool remote_hold_button = false;
59 72
60 bool hold_button_old; 73 bool hold_button_old;
74 bool remote_present;
75
76 /* check if we have remote connected */
77 remote_present = remote_detect();
61 78
62 /* read hold buttons status */ 79 /* read hold buttons status */
63 hold_button_old = hold_button; 80 hold_button_old = hold_button;
@@ -70,6 +87,7 @@ int button_read_device(void)
70 backlight_hold_changed(hold_button); 87 backlight_hold_changed(hold_button);
71#endif 88#endif
72 89
90 /* Skip if main hold is active */
73 if (!hold_button) 91 if (!hold_button)
74 { 92 {
75 data = adc_scan(ADC_BUTTONS); 93 data = adc_scan(ADC_BUTTONS);
@@ -110,7 +128,8 @@ int button_read_device(void)
110 } 128 }
111 } 129 }
112 130
113 if (!remote_hold_button) 131 /* Skip if remote is not present or remote_hold is active */
132 if (remote_present && !remote_hold_button)
114 { 133 {
115 data = adc_scan(ADC_REMOTE); 134 data = adc_scan(ADC_REMOTE);
116 135
@@ -146,6 +165,9 @@ int button_read_device(void)
146 } 165 }
147 } 166 }
148 167
168 /* PLAY buttons (both remote and main) are
169 * GPIOs not ADC
170 */
149 data = GPIO1_READ; 171 data = GPIO1_READ;
150 172
151 /* GPIO56 active high main PLAY/PAUSE/ON */ 173 /* GPIO56 active high main PLAY/PAUSE/ON */
@@ -153,7 +175,7 @@ int button_read_device(void)
153 btn |= BUTTON_PLAY; 175 btn |= BUTTON_PLAY;
154 176
155 /* GPIO41 active high remote PLAY/PAUSE/ON */ 177 /* GPIO41 active high remote PLAY/PAUSE/ON */
156 if (!remote_hold_button && ((data & (1<<9)))) 178 if (remote_present && !remote_hold_button && ((data & (1<<9))))
157 btn |= BUTTON_RC_PLAY; 179 btn |= BUTTON_RC_PLAY;
158 180
159 return btn; 181 return btn;