From 24c7c0489971d0ede3c23ea85b097990963d8ea1 Mon Sep 17 00:00:00 2001 From: Jörg Hohensohn Date: Fri, 10 Sep 2004 10:51:54 +0000 Subject: adjustment for the Ondio: button driver has an Odio part, for now it has a Player layout. Some fixes in the app code were necessary to remove dependencies of LCD, keypad, this wasn't independent everywhere. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5055 a1c6a512-1295-4272-9138-f99709370657 --- apps/debug_menu.c | 4 +- apps/main_menu.c | 4 +- apps/playlist.c | 6 +-- apps/screens.c | 2 + apps/settings_menu.c | 2 +- apps/sleeptimer.c | 4 +- apps/wps.c | 6 ++- firmware/drivers/button.c | 90 ++++++++++++++++++++++++++++++++++++++-- firmware/export/button.h | 15 +++++-- firmware/export/config-ondiofm.h | 7 +--- firmware/export/config-ondiosp.h | 7 +--- 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) /* Wait for a key to be pushed */ key = button_get_w_tmo(HZ); switch(key) { -#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) +#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD) case BUTTON_STOP | BUTTON_REL: #elif HAVE_RECORDER_KEYPAD case BUTTON_OFF | BUTTON_REL: @@ -1412,7 +1412,7 @@ static bool dbg_disk_info(void) /* Wait for a key to be pushed */ key = button_get_w_tmo(HZ*5); switch(key) { -#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) +#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD) case BUTTON_STOP | BUTTON_REL: #else 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) /* Wait for a key to be pushed */ key = button_get_w_tmo(HZ*5); switch(key) { -#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) +#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD) case BUTTON_STOP | BUTTON_REL: #else case BUTTON_LEFT | BUTTON_REL: @@ -240,7 +240,7 @@ bool show_info(void) done = true; break; -#ifdef HAVE_PLAYER_KEYPAD +#if defined(HAVE_RECORDER_KEYPAD) || defined(HAVE_ONDIO_KEYPAD) case BUTTON_LEFT: case BUTTON_RIGHT: 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, for (i=0; i 0) { /* user abort */ -#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) +#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD) if (button_get(false) == BUTTON_STOP) #else if (button_get(false) == BUTTON_OFF) @@ -2377,7 +2377,7 @@ int playlist_save(struct playlist_info* playlist, char *filename) int seek; /* user abort */ -#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) +#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD) if (button_get(false) == BUTTON_STOP) #else 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) case BUTTON_ON: done = true; break; +#if (BUTTON_ON != BUTTON_OFF) case BUTTON_OFF: done = true; tm->tm_year = -1; break; +#endif default: 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) return result; } -#ifdef HAVE_LCD_BITMAP +#ifdef HAVE_RTC static bool time_settings_menu(void) { 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) done = true; break; -#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) +#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD) case BUTTON_RIGHT: #else case BUTTON_UP: @@ -113,7 +113,7 @@ bool sleeptimer_screen(void) set_sleep_timer(newtime); break; -#ifdef HAVE_PLAYER_KEYPAD +#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_ONDIO_KEYPAD) case BUTTON_LEFT: #else 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; static struct mp3entry* nid3 = NULL; static char current_track_path[MAX_PATH+1]; -#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) +#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD) void player_change_volume(int button) { bool exit = false; @@ -577,9 +577,11 @@ static bool menu(void) /* show id3 tags */ #ifdef BUTTON_ON case BUTTON_MENU | BUTTON_ON: +#ifdef HAVE_LCD_CHARCELLS status_set_param(true); status_set_audio(true); #endif +#endif #else case BUTTON_F1 | BUTTON_ON: #endif @@ -811,8 +813,10 @@ int wps_show(void) case 0: /* otherwise, exit to browser */ #else +#ifdef HAVE_LCD_CHARCELLS status_set_record(false); status_set_audio(false); +#endif #endif lcd_stop_scroll(); 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 @@ struct event_queue button_queue; static int lastbtn; -#ifdef HAVE_RECORDER_KEYPAD +#if defined(HAVE_RECORDER_KEYPAD) || defined(HAVE_ONDIO_KEYPAD) static bool flipped; /* bottons can be flipped to match the LCD flip */ #endif @@ -337,7 +337,7 @@ static int button_read(void) return btn; } -#elif HAVE_PLAYER_KEYPAD +#elif defined(HAVE_PLAYER_KEYPAD) /* The player has two buttons on port pins: @@ -386,7 +386,7 @@ static int button_read(void) return btn; } -#elif HAVE_NEO_KEYPAD +#elif defined(HAVE_NEO_KEYPAD) static bool mStation = false; void button_init(void) { @@ -421,6 +421,90 @@ int button_add(unsigned int button) queue_post(&button_queue,button,NULL); return 1; } + +#elif defined HAVE_ONDIO_KEYPAD + +/* + * helper function to swap UP/DOWN, LEFT/RIGHT + */ +static int button_flip(int button) +{ + int newbutton; + + newbutton = button & + ~(BUTTON_UP | BUTTON_DOWN + | BUTTON_LEFT | BUTTON_RIGHT); + + if (button & BUTTON_UP) + newbutton |= BUTTON_DOWN; + if (button & BUTTON_DOWN) + newbutton |= BUTTON_UP; + if (button & BUTTON_LEFT) + newbutton |= BUTTON_RIGHT; + if (button & BUTTON_RIGHT) + newbutton |= BUTTON_LEFT; + + return newbutton; +} + + +/* + * set the flip attribute + * better only call this when the queue is empty + */ +void button_set_flip(bool flip) +{ + if (flip != flipped) /* not the current setting */ + { + /* avoid race condition with the button_tick() */ + int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); + lastbtn = button_flip(lastbtn); + flipped = flip; + set_irq_level(oldlevel); + } +} + + +/* The Ondio its 6 buttons on analog inputs: + OPTION: AN2 (used as MENU for now) + ON/OFF: AN3 + LEFT/RIGHT/UP/DOWN: AN4 + We map them like the player keys for now, although this is far from optimal. +*/ +void button_init(void) +{ + queue_init(&button_queue); + lastbtn = 0; + tick_add_task(button_tick); + + reset_poweroff_timer(); +} + +static int button_read(void) +{ + int btn = BUTTON_NONE; + int data = adc_read(4); + + if(adc_read(2) > 0x180) /* active high */ + btn |= BUTTON_MENU; + if(adc_read(3) < 0x180) /* active low */ + btn |= BUTTON_ON; + if(adc_read(3) < 0x180) + btn |= BUTTON_PLAY | BUTTON_UP; + + /* Check the 4 direction keys, hard-coded analog limits for now */ + if (data >= 0x2E5) + btn |= BUTTON_LEFT; + else if (data >= 0x23F) + btn |= BUTTON_RIGHT; + else if (data >= 0x197) + btn |= BUTTON_PLAY | BUTTON_UP; + else if (data >= 0x0A1) + btn |= BUTTON_STOP | BUTTON_DOWN; + + return btn; +} + #endif int 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); int button_get_w_tmo(int ticks); int button_status(void); void button_clear_queue(void); -#ifdef HAVE_RECORDER_KEYPAD +#if defined(HAVE_RECORDER_KEYPAD) || defined(HAVE_ONDIO_KEYPAD) void button_set_flip(bool flip); /* turn 180 degrees */ #endif @@ -108,14 +108,23 @@ void button_set_flip(bool flip); /* turn 180 degrees */ #define BUTTON_F2 0x0200 #define BUTTON_F3 0x0400 -#elif HAVE_PLAYER_KEYPAD +#elif defined(HAVE_PLAYER_KEYPAD) /* Jukebox 6000 and Studio specific button codes */ #define BUTTON_MENU 0x0002 #define BUTTON_PLAY BUTTON_UP #define BUTTON_STOP BUTTON_DOWN -#endif /* HAVE_PLAYER_KEYPAD */ +#elif defined HAVE_ONDIO_KEYPAD + +/* Ondio specific button codes */ +#define BUTTON_MENU 0x0002 +#define BUTTON_PLAY BUTTON_UP +#define BUTTON_STOP BUTTON_DOWN +/* ON is also interpreted as OFF, let's see if that helps a bit */ +#define BUTTON_OFF BUTTON_ON + +#endif /* HAVE_RECORDER/PLAYER/ONDIO_KEYPAD */ #endif /* HAVE_NEO_KEYPAD */ 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 @@ /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP 1 -/* define this if you have a Recorder style 10-key keyboard */ -#define HAVE_RECORDER_KEYPAD 0 - -/* define this if you have a real-time clock */ -#define HAVE_RTC 0 +/* define this if you have an Ondio style 6-key keyboard */ +#define HAVE_ONDIO_KEYPAD /* Define this if you have a MAS3587F */ #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 @@ /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP 1 -/* define this if you have a Recorder style 10-key keyboard */ -#define HAVE_RECORDER_KEYPAD 0 - -/* define this if you have a real-time clock */ -#define HAVE_RTC 0 +/* define this if you have an Ondio style 6-key keyboard */ +#define HAVE_ONDIO_KEYPAD /* Define this if you have a MAS3587F */ #define HAVE_MAS3587F -- cgit v1.2.3