summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/debug_menu.c4
-rw-r--r--apps/main_menu.c4
-rw-r--r--apps/playlist.c6
-rw-r--r--apps/screens.c2
-rw-r--r--apps/settings_menu.c2
-rw-r--r--apps/sleeptimer.c4
-rw-r--r--apps/wps.c6
-rw-r--r--firmware/drivers/button.c90
-rw-r--r--firmware/export/button.h15
-rw-r--r--firmware/export/config-ondiofm.h7
-rw-r--r--firmware/export/config-ondiosp.h7
11 files changed, 120 insertions, 27 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 987007caad..12ba0c5fbe 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1233,7 +1233,7 @@ static bool view_runtime(void)
1233 /* Wait for a key to be pushed */ 1233 /* Wait for a key to be pushed */
1234 key = button_get_w_tmo(HZ); 1234 key = button_get_w_tmo(HZ);
1235 switch(key) { 1235 switch(key) {
1236#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) 1236#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
1237 case BUTTON_STOP | BUTTON_REL: 1237 case BUTTON_STOP | BUTTON_REL:
1238#elif HAVE_RECORDER_KEYPAD 1238#elif HAVE_RECORDER_KEYPAD
1239 case BUTTON_OFF | BUTTON_REL: 1239 case BUTTON_OFF | BUTTON_REL:
@@ -1412,7 +1412,7 @@ static bool dbg_disk_info(void)
1412 /* Wait for a key to be pushed */ 1412 /* Wait for a key to be pushed */
1413 key = button_get_w_tmo(HZ*5); 1413 key = button_get_w_tmo(HZ*5);
1414 switch(key) { 1414 switch(key) {
1415#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) 1415#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
1416 case BUTTON_STOP | BUTTON_REL: 1416 case BUTTON_STOP | BUTTON_REL:
1417#else 1417#else
1418 case BUTTON_OFF | BUTTON_REL: 1418 case BUTTON_OFF | BUTTON_REL:
diff --git a/apps/main_menu.c b/apps/main_menu.c
index b3c70a2c13..1d2978e65e 100644
--- a/apps/main_menu.c
+++ b/apps/main_menu.c
@@ -231,7 +231,7 @@ bool show_info(void)
231 /* Wait for a key to be pushed */ 231 /* Wait for a key to be pushed */
232 key = button_get_w_tmo(HZ*5); 232 key = button_get_w_tmo(HZ*5);
233 switch(key) { 233 switch(key) {
234#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) 234#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
235 case BUTTON_STOP | BUTTON_REL: 235 case BUTTON_STOP | BUTTON_REL:
236#else 236#else
237 case BUTTON_LEFT | BUTTON_REL: 237 case BUTTON_LEFT | BUTTON_REL:
@@ -240,7 +240,7 @@ bool show_info(void)
240 done = true; 240 done = true;
241 break; 241 break;
242 242
243#ifdef HAVE_PLAYER_KEYPAD 243#if defined(HAVE_RECORDER_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
244 case BUTTON_LEFT: 244 case BUTTON_LEFT:
245 case BUTTON_RIGHT: 245 case BUTTON_RIGHT:
246 if (state == 1) 246 if (state == 1)
diff --git a/apps/playlist.c b/apps/playlist.c
index e29e2f1757..8d4f62db68 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -557,7 +557,7 @@ static int add_directory_to_playlist(struct playlist_info* playlist,
557 for (i=0; i<num_files; i++) 557 for (i=0; i<num_files; i++)
558 { 558 {
559 /* user abort */ 559 /* user abort */
560#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) 560#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
561 if (button_get(false) == BUTTON_STOP) 561 if (button_get(false) == BUTTON_STOP)
562#else 562#else
563 if (button_get(false) == BUTTON_OFF) 563 if (button_get(false) == BUTTON_OFF)
@@ -2009,7 +2009,7 @@ int playlist_insert_playlist(struct playlist_info* playlist, char *filename,
2009 while ((max = read_line(fd, temp_buf, sizeof(temp_buf))) > 0) 2009 while ((max = read_line(fd, temp_buf, sizeof(temp_buf))) > 0)
2010 { 2010 {
2011 /* user abort */ 2011 /* user abort */
2012#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) 2012#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
2013 if (button_get(false) == BUTTON_STOP) 2013 if (button_get(false) == BUTTON_STOP)
2014#else 2014#else
2015 if (button_get(false) == BUTTON_OFF) 2015 if (button_get(false) == BUTTON_OFF)
@@ -2377,7 +2377,7 @@ int playlist_save(struct playlist_info* playlist, char *filename)
2377 int seek; 2377 int seek;
2378 2378
2379 /* user abort */ 2379 /* user abort */
2380#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) 2380#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
2381 if (button_get(false) == BUTTON_STOP) 2381 if (button_get(false) == BUTTON_STOP)
2382#else 2382#else
2383 if (button_get(false) == BUTTON_OFF) 2383 if (button_get(false) == BUTTON_OFF)
diff --git a/apps/screens.c b/apps/screens.c
index 1026973697..1cf74acd2a 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -1085,10 +1085,12 @@ bool set_time_screen(const char* string, struct tm *tm)
1085 case BUTTON_ON: 1085 case BUTTON_ON:
1086 done = true; 1086 done = true;
1087 break; 1087 break;
1088#if (BUTTON_ON != BUTTON_OFF)
1088 case BUTTON_OFF: 1089 case BUTTON_OFF:
1089 done = true; 1090 done = true;
1090 tm->tm_year = -1; 1091 tm->tm_year = -1;
1091 break; 1092 break;
1093#endif
1092 1094
1093 default: 1095 default:
1094 if (default_event_handler(button) == SYS_USB_CONNECTED) 1096 if (default_event_handler(button) == SYS_USB_CONNECTED)
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 90d14a604f..4d2e2f9a44 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -1266,7 +1266,7 @@ static bool disk_settings_menu(void)
1266 return result; 1266 return result;
1267} 1267}
1268 1268
1269#ifdef HAVE_LCD_BITMAP 1269#ifdef HAVE_RTC
1270static bool time_settings_menu(void) 1270static bool time_settings_menu(void)
1271{ 1271{
1272 int m; 1272 int m;
diff --git a/apps/sleeptimer.c b/apps/sleeptimer.c
index a236ed9ba7..4fc7515ac0 100644
--- a/apps/sleeptimer.c
+++ b/apps/sleeptimer.c
@@ -94,7 +94,7 @@ bool sleeptimer_screen(void)
94 done = true; 94 done = true;
95 break; 95 break;
96 96
97#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) 97#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
98 case BUTTON_RIGHT: 98 case BUTTON_RIGHT:
99#else 99#else
100 case BUTTON_UP: 100 case BUTTON_UP:
@@ -113,7 +113,7 @@ bool sleeptimer_screen(void)
113 set_sleep_timer(newtime); 113 set_sleep_timer(newtime);
114 break; 114 break;
115 115
116#ifdef HAVE_PLAYER_KEYPAD 116#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
117 case BUTTON_LEFT: 117 case BUTTON_LEFT:
118#else 118#else
119 case BUTTON_DOWN: 119 case BUTTON_DOWN:
diff --git a/apps/wps.c b/apps/wps.c
index 65b01b10a5..92b4e008b8 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -61,7 +61,7 @@ static struct mp3entry* id3 = NULL;
61static struct mp3entry* nid3 = NULL; 61static struct mp3entry* nid3 = NULL;
62static char current_track_path[MAX_PATH+1]; 62static char current_track_path[MAX_PATH+1];
63 63
64#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) 64#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
65void player_change_volume(int button) 65void player_change_volume(int button)
66{ 66{
67 bool exit = false; 67 bool exit = false;
@@ -577,9 +577,11 @@ static bool menu(void)
577 /* show id3 tags */ 577 /* show id3 tags */
578#ifdef BUTTON_ON 578#ifdef BUTTON_ON
579 case BUTTON_MENU | BUTTON_ON: 579 case BUTTON_MENU | BUTTON_ON:
580#ifdef HAVE_LCD_CHARCELLS
580 status_set_param(true); 581 status_set_param(true);
581 status_set_audio(true); 582 status_set_audio(true);
582#endif 583#endif
584#endif
583#else 585#else
584 case BUTTON_F1 | BUTTON_ON: 586 case BUTTON_F1 | BUTTON_ON:
585#endif 587#endif
@@ -811,9 +813,11 @@ int wps_show(void)
811 case 0: 813 case 0:
812 /* otherwise, exit to browser */ 814 /* otherwise, exit to browser */
813#else 815#else
816#ifdef HAVE_LCD_CHARCELLS
814 status_set_record(false); 817 status_set_record(false);
815 status_set_audio(false); 818 status_set_audio(false);
816#endif 819#endif
820#endif
817 lcd_stop_scroll(); 821 lcd_stop_scroll();
818 822
819 /* set dir browser to current playing song */ 823 /* set dir browser to current playing song */
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 69849598c2..51fc3b5a1a 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -36,7 +36,7 @@
36struct event_queue button_queue; 36struct event_queue button_queue;
37 37
38static int lastbtn; 38static int lastbtn;
39#ifdef HAVE_RECORDER_KEYPAD 39#if defined(HAVE_RECORDER_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
40static bool flipped; /* bottons can be flipped to match the LCD flip */ 40static bool flipped; /* bottons can be flipped to match the LCD flip */
41#endif 41#endif
42 42
@@ -337,7 +337,7 @@ static int button_read(void)
337 return btn; 337 return btn;
338} 338}
339 339
340#elif HAVE_PLAYER_KEYPAD 340#elif defined(HAVE_PLAYER_KEYPAD)
341 341
342/* The player has two buttons on port pins: 342/* The player has two buttons on port pins:
343 343
@@ -386,7 +386,7 @@ static int button_read(void)
386 return btn; 386 return btn;
387} 387}
388 388
389#elif HAVE_NEO_KEYPAD 389#elif defined(HAVE_NEO_KEYPAD)
390static bool mStation = false; 390static bool mStation = false;
391void button_init(void) 391void button_init(void)
392{ 392{
@@ -421,6 +421,90 @@ int button_add(unsigned int button)
421 queue_post(&button_queue,button,NULL); 421 queue_post(&button_queue,button,NULL);
422 return 1; 422 return 1;
423} 423}
424
425#elif defined HAVE_ONDIO_KEYPAD
426
427/*
428 * helper function to swap UP/DOWN, LEFT/RIGHT
429 */
430static int button_flip(int button)
431{
432 int newbutton;
433
434 newbutton = button &
435 ~(BUTTON_UP | BUTTON_DOWN
436 | BUTTON_LEFT | BUTTON_RIGHT);
437
438 if (button & BUTTON_UP)
439 newbutton |= BUTTON_DOWN;
440 if (button & BUTTON_DOWN)
441 newbutton |= BUTTON_UP;
442 if (button & BUTTON_LEFT)
443 newbutton |= BUTTON_RIGHT;
444 if (button & BUTTON_RIGHT)
445 newbutton |= BUTTON_LEFT;
446
447 return newbutton;
448}
449
450
451/*
452 * set the flip attribute
453 * better only call this when the queue is empty
454 */
455void button_set_flip(bool flip)
456{
457 if (flip != flipped) /* not the current setting */
458 {
459 /* avoid race condition with the button_tick() */
460 int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
461 lastbtn = button_flip(lastbtn);
462 flipped = flip;
463 set_irq_level(oldlevel);
464 }
465}
466
467
468/* The Ondio its 6 buttons on analog inputs:
469 OPTION: AN2 (used as MENU for now)
470 ON/OFF: AN3
471 LEFT/RIGHT/UP/DOWN: AN4
472 We map them like the player keys for now, although this is far from optimal.
473*/
474void button_init(void)
475{
476 queue_init(&button_queue);
477 lastbtn = 0;
478 tick_add_task(button_tick);
479
480 reset_poweroff_timer();
481}
482
483static int button_read(void)
484{
485 int btn = BUTTON_NONE;
486 int data = adc_read(4);
487
488 if(adc_read(2) > 0x180) /* active high */
489 btn |= BUTTON_MENU;
490 if(adc_read(3) < 0x180) /* active low */
491 btn |= BUTTON_ON;
492 if(adc_read(3) < 0x180)
493 btn |= BUTTON_PLAY | BUTTON_UP;
494
495 /* Check the 4 direction keys, hard-coded analog limits for now */
496 if (data >= 0x2E5)
497 btn |= BUTTON_LEFT;
498 else if (data >= 0x23F)
499 btn |= BUTTON_RIGHT;
500 else if (data >= 0x197)
501 btn |= BUTTON_PLAY | BUTTON_UP;
502 else if (data >= 0x0A1)
503 btn |= BUTTON_STOP | BUTTON_DOWN;
504
505 return btn;
506}
507
424#endif 508#endif
425 509
426int button_status(void) 510int button_status(void)
diff --git a/firmware/export/button.h b/firmware/export/button.h
index f174262de2..0b6a08a78b 100644
--- a/firmware/export/button.h
+++ b/firmware/export/button.h
@@ -30,7 +30,7 @@ int button_get (bool block);
30int button_get_w_tmo(int ticks); 30int button_get_w_tmo(int ticks);
31int button_status(void); 31int button_status(void);
32void button_clear_queue(void); 32void button_clear_queue(void);
33#ifdef HAVE_RECORDER_KEYPAD 33#if defined(HAVE_RECORDER_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
34void button_set_flip(bool flip); /* turn 180 degrees */ 34void button_set_flip(bool flip); /* turn 180 degrees */
35#endif 35#endif
36 36
@@ -108,14 +108,23 @@ void button_set_flip(bool flip); /* turn 180 degrees */
108#define BUTTON_F2 0x0200 108#define BUTTON_F2 0x0200
109#define BUTTON_F3 0x0400 109#define BUTTON_F3 0x0400
110 110
111#elif HAVE_PLAYER_KEYPAD 111#elif defined(HAVE_PLAYER_KEYPAD)
112 112
113/* Jukebox 6000 and Studio specific button codes */ 113/* Jukebox 6000 and Studio specific button codes */
114#define BUTTON_MENU 0x0002 114#define BUTTON_MENU 0x0002
115#define BUTTON_PLAY BUTTON_UP 115#define BUTTON_PLAY BUTTON_UP
116#define BUTTON_STOP BUTTON_DOWN 116#define BUTTON_STOP BUTTON_DOWN
117 117
118#endif /* HAVE_PLAYER_KEYPAD */ 118#elif defined HAVE_ONDIO_KEYPAD
119
120/* Ondio specific button codes */
121#define BUTTON_MENU 0x0002
122#define BUTTON_PLAY BUTTON_UP
123#define BUTTON_STOP BUTTON_DOWN
124/* ON is also interpreted as OFF, let's see if that helps a bit */
125#define BUTTON_OFF BUTTON_ON
126
127#endif /* HAVE_RECORDER/PLAYER/ONDIO_KEYPAD */
119 128
120#endif /* HAVE_NEO_KEYPAD */ 129#endif /* HAVE_NEO_KEYPAD */
121 130
diff --git a/firmware/export/config-ondiofm.h b/firmware/export/config-ondiofm.h
index 0f71ea6113..33ede51aea 100644
--- a/firmware/export/config-ondiofm.h
+++ b/firmware/export/config-ondiofm.h
@@ -4,11 +4,8 @@
4/* define this if you have a bitmap LCD display */ 4/* define this if you have a bitmap LCD display */
5#define HAVE_LCD_BITMAP 1 5#define HAVE_LCD_BITMAP 1
6 6
7/* define this if you have a Recorder style 10-key keyboard */ 7/* define this if you have an Ondio style 6-key keyboard */
8#define HAVE_RECORDER_KEYPAD 0 8#define HAVE_ONDIO_KEYPAD
9
10/* define this if you have a real-time clock */
11#define HAVE_RTC 0
12 9
13/* Define this if you have a MAS3587F */ 10/* Define this if you have a MAS3587F */
14#define HAVE_MAS3587F 11#define HAVE_MAS3587F
diff --git a/firmware/export/config-ondiosp.h b/firmware/export/config-ondiosp.h
index 8e2a9d6e0f..3e8116df9a 100644
--- a/firmware/export/config-ondiosp.h
+++ b/firmware/export/config-ondiosp.h
@@ -4,11 +4,8 @@
4/* define this if you have a bitmap LCD display */ 4/* define this if you have a bitmap LCD display */
5#define HAVE_LCD_BITMAP 1 5#define HAVE_LCD_BITMAP 1
6 6
7/* define this if you have a Recorder style 10-key keyboard */ 7/* define this if you have an Ondio style 6-key keyboard */
8#define HAVE_RECORDER_KEYPAD 0 8#define HAVE_ONDIO_KEYPAD
9
10/* define this if you have a real-time clock */
11#define HAVE_RTC 0
12 9
13/* Define this if you have a MAS3587F */ 10/* Define this if you have a MAS3587F */
14#define HAVE_MAS3587F 11#define HAVE_MAS3587F