summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2004-09-10 10:51:54 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2004-09-10 10:51:54 +0000
commit24c7c0489971d0ede3c23ea85b097990963d8ea1 (patch)
tree911195d6162a12409aa7c5993b02dfa3f31ce08a /firmware
parent6c1afd7a9e128f2ff628e3e4d2584024c2d8951f (diff)
downloadrockbox-24c7c0489971d0ede3c23ea85b097990963d8ea1.tar.gz
rockbox-24c7c0489971d0ede3c23ea85b097990963d8ea1.zip
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
Diffstat (limited to 'firmware')
-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
4 files changed, 103 insertions, 16 deletions
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