summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 @@
28 28
29void button_init_device(void) 29void button_init_device(void)
30{ 30{
31 /* Set GPIO56 (main PLAY) as general purpose inputs */ 31 /* GPIO56 (main PLAY)
32 or_l((1<<24),&GPIO1_FUNCTION); 32 * GPIO41 (remote PLAY)
33 and_l(~(1<<24),&GPIO1_ENABLE); 33 * as general purpose inputs
34 */
35 or_l((1<<24)|(1<<9),&GPIO1_FUNCTION);
36 and_l(~((1<<24)|(1<<9)),&GPIO1_ENABLE);
34} 37}
35 38
36bool button_hold(void) 39bool button_hold(void)
@@ -39,6 +42,10 @@ bool button_hold(void)
39 return (GPIO1_READ & (1<<4))?true:false; 42 return (GPIO1_READ & (1<<4))?true:false;
40} 43}
41 44
45bool remote_button_hold(void)
46{
47 return adc_scan(ADC_REMOTE)<50?true:false;
48}
42 49
43/* 50/*
44 * Get button pressed from hardware 51 * Get button pressed from hardware
@@ -48,15 +55,17 @@ int button_read_device(void)
48 int btn = BUTTON_NONE; 55 int btn = BUTTON_NONE;
49 int data = 0; 56 int data = 0;
50 static bool hold_button = false; 57 static bool hold_button = false;
58 static bool remote_hold_button = false;
51 59
52 bool hold_button_old; 60 bool hold_button_old;
53 61
54 /* normal buttons */ 62 /* read hold buttons status */
55 hold_button_old = hold_button; 63 hold_button_old = hold_button;
56 hold_button = button_hold(); 64 hold_button = button_hold();
57 65 remote_hold_button = remote_button_hold();
58 66
59#ifndef BOOTLOADER 67#ifndef BOOTLOADER
68 /* Only main hold affects backlight */
60 if (hold_button != hold_button_old) 69 if (hold_button != hold_button_old)
61 backlight_hold_changed(hold_button); 70 backlight_hold_changed(hold_button);
62#endif 71#endif
@@ -65,7 +74,7 @@ int button_read_device(void)
65 { 74 {
66 data = adc_scan(ADC_BUTTONS); 75 data = adc_scan(ADC_BUTTONS);
67 76
68 if (data < 2250) // valid button 77 if (data < 2250) /* valid button */
69 { 78 {
70 if (data < 900) /* middle */ 79 if (data < 900) /* middle */
71 { 80 {
@@ -101,12 +110,51 @@ int button_read_device(void)
101 } 110 }
102 } 111 }
103 112
113 if (!remote_hold_button)
114 {
115 data = adc_scan(ADC_REMOTE);
116
117 if (data < 2050) /* valid button */
118 {
119 if (data < 950) /* middle */
120 {
121 if (data < 650)
122 {
123 if (data < 400)
124 {
125 if (data > 250)
126 /* 250 - 400 */
127 btn = BUTTON_RC_VOL_DOWN;
128 }
129 else /* 650 - 400 */
130 btn = BUTTON_RC_VOL_UP;
131 }
132 else /* 950 - 650 */
133 btn = BUTTON_RC_NEXT;
134 }
135 else /* 2050 - 950 */
136 {
137 if (data < 1900)
138 {
139 if (data < 1350)
140 /* 1350 - 900 */
141 btn = BUTTON_RC_PREV;
142 }
143 else /* 2050 - 1900 */
144 btn = BUTTON_RC_SELECT;
145 }
146 }
147 }
104 148
105 data = GPIO1_READ; 149 data = GPIO1_READ;
106 150
107 /* GPIO56 active high main PLAY/PAUSE/ON */ 151 /* GPIO56 active high main PLAY/PAUSE/ON */
108 if (!hold_button && ((data & (1<<24)))) 152 if (!hold_button && ((data & (1<<24))))
109 btn |= BUTTON_PLAY; 153 btn |= BUTTON_PLAY;
154
155 /* GPIO41 active high remote PLAY/PAUSE/ON */
156 if (!remote_hold_button && ((data & (1<<9))))
157 btn |= BUTTON_RC_PLAY;
110 158
111 return btn; 159 return btn;
112} 160}