summaryrefslogtreecommitdiff
path: root/firmware/drivers/button.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/button.c')
-rw-r--r--firmware/drivers/button.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index ea3ffadffd..ebf606ac25 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -191,10 +191,19 @@ int button_get_w_tmo(int ticks)
191 * DOWN, PLAY, LEFT, and RIGHT are likewise connected to AN5. */ 191 * DOWN, PLAY, LEFT, and RIGHT are likewise connected to AN5. */
192 192
193/* Button analog voltage levels */ 193/* Button analog voltage levels */
194#ifdef HAVE_FMADC
195/* FM Recorder super-special levels */
196#define LEVEL1 150
197#define LEVEL2 385
198#define LEVEL3 545
199#define LEVEL4 700
200#else
201/* plain bog standard Recorder levels */
194#define LEVEL1 250 202#define LEVEL1 250
195#define LEVEL2 500 203#define LEVEL2 500
196#define LEVEL3 700 204#define LEVEL3 700
197#define LEVEL4 900 205#define LEVEL4 900
206#endif
198 207
199/* 208/*
200 *Initialize buttons 209 *Initialize buttons
@@ -219,11 +228,22 @@ static int button_read(void)
219 int btn = BUTTON_NONE; 228 int btn = BUTTON_NONE;
220 229
221 /* Check port B pins for ON and OFF */ 230 /* Check port B pins for ON and OFF */
222 int data = PBDR; 231 int data;
232
233#ifdef HAVE_FMADC
234 /* TODO: use proper defines here, and not the numerics in the
235 function argument */
236 if ( adc_read(3) < 512 )
237 btn |= BUTTON_ON;
238 if ( adc_read(2) > 512 )
239 btn |= BUTTON_OFF;
240#else
241 data = PBDR;
223 if ((data & PBDR_BTN_ON) == 0) 242 if ((data & PBDR_BTN_ON) == 0)
224 btn |= BUTTON_ON; 243 btn |= BUTTON_ON;
225 else if ((data & PBDR_BTN_OFF) == 0) 244 else if ((data & PBDR_BTN_OFF) == 0)
226 btn |= BUTTON_OFF; 245 btn |= BUTTON_OFF;
246#endif
227 247
228 /* Check F1-3 and UP */ 248 /* Check F1-3 and UP */
229 data = adc_read(ADC_BUTTON_ROW1); 249 data = adc_read(ADC_BUTTON_ROW1);
@@ -245,12 +265,22 @@ static int button_read(void)
245 data = adc_read(ADC_BUTTON_ROW2); 265 data = adc_read(ADC_BUTTON_ROW2);
246 if (data >= LEVEL4) 266 if (data >= LEVEL4)
247 btn |= BUTTON_DOWN; 267 btn |= BUTTON_DOWN;
248 else if (data >= LEVEL3) 268 else if (data >= LEVEL3) {
269#ifdef HAVE_FMADC
270 btn |= BUTTON_RIGHT;
271#else
249 btn |= BUTTON_PLAY; 272 btn |= BUTTON_PLAY;
273#endif
274 }
250 else if (data >= LEVEL2) 275 else if (data >= LEVEL2)
251 btn |= BUTTON_LEFT; 276 btn |= BUTTON_LEFT;
252 else if (data >= LEVEL1) 277 else if (data >= LEVEL1) {
278#ifdef HAVE_FMADC
279 btn |= BUTTON_PLAY;
280#else
253 btn |= BUTTON_RIGHT; 281 btn |= BUTTON_RIGHT;
282#endif
283 }
254 } 284 }
255 285
256 return btn; 286 return btn;