aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormichux <michux@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2008-03-03 16:54:18 +0000
committermichux <michux@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2008-03-03 16:54:18 +0000
commit18a456a67cf01005a3b322d9a86e760a8f1b9fd9 (patch)
tree1a2659dbf930e27fcd5c5268d4ff2dcce7c823f3
parentd17583d65d5751809f4daaa1d866db38a7044a06 (diff)
downloadlcd4linux-18a456a67cf01005a3b322d9a86e760a8f1b9fd9.tar.gz
add keypad support for module lcm162
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@856 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
-rw-r--r--drv_HD44780.c25
-rw-r--r--drv_generic_keypad.h2
2 files changed, 26 insertions, 1 deletions
diff --git a/drv_HD44780.c b/drv_HD44780.c
index e2a693d..e85f9e1 100644
--- a/drv_HD44780.c
+++ b/drv_HD44780.c
@@ -69,6 +69,8 @@
#ifdef WITH_PARPORT
#include "drv_generic_parport.h"
+#include "drv_generic_keypad.h"
+#include "widget_keypad.h"
#endif
#ifdef WITH_I2C
@@ -979,6 +981,12 @@ static int drv_HD_GPO(const int num, const int val)
#ifdef WITH_PARPORT
+
+static int drv_HD_LCM162_keypad_handler(const int num)
+{
+ return num;
+}
+
static void drv_HD_LCM162_timer(void __attribute__ ((unused)) * notused)
{
static unsigned char data = 0x00;
@@ -1000,8 +1008,21 @@ static void drv_HD_LCM162_timer(void __attribute__ ((unused)) * notused)
if (data != temp) {
data = temp;
+ int KEYPAD_VAL=0;
keynum = (data & mask3 ? 1 : 0) + (data & mask5 ? 2 : 0);
+ switch(keynum)
+ {
+ default:
+ case 0: KEYPAD_VAL=WIDGET_KEY_CANCEL; break;
+ case 1: KEYPAD_VAL=WIDGET_KEY_UP; break;
+ case 2: KEYPAD_VAL=WIDGET_KEY_CONFIRM; break;
+ case 3: KEYPAD_VAL=WIDGET_KEY_DOWN; break;
+ }
+
updown = (data & mask6 ? 1 : 0);
+ KEYPAD_VAL += updown ? WIDGET_KEY_PRESSED : WIDGET_KEY_RELEASED;
+
+ drv_generic_keypad_press(KEYPAD_VAL);
debug("key %d press %d", keynum, updown);
}
@@ -1212,6 +1233,7 @@ static int drv_HD_start(const char *section, const int quiet)
#ifdef WITH_PARPORT
if (Capabilities & CAP_LCM162) {
timer_add(drv_HD_LCM162_timer, NULL, 10, 0);
+ drv_generic_keypad_real_press = drv_HD_LCM162_keypad_handler;
}
#endif
@@ -1332,6 +1354,9 @@ int drv_HD_init(const char *section, const int quiet)
if ((ret = drv_generic_gpio_init(section, Name)) != 0)
return ret;
+ if ((ret = drv_generic_keypad_init(section, Name)) != 0)
+ return ret;
+
/* register text widget */
wc = Widget_Text;
wc.draw = drv_generic_text_draw;
diff --git a/drv_generic_keypad.h b/drv_generic_keypad.h
index 392ed40..5b0c5c9 100644
--- a/drv_generic_keypad.h
+++ b/drv_generic_keypad.h
@@ -27,7 +27,7 @@
#include "widget.h"
-/* these functinos must be implemented by the real driver */
+/* these functions must be implemented by the real driver */
extern int (*drv_generic_keypad_real_press) (const int num);
/* generic functions and widget callbacks */