aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2008-10-06 04:29:12 +0000
committermichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2008-10-06 04:29:12 +0000
commita80978985167df7650209888a5a89ea8089c091d (patch)
tree65b31609dee978fb320fe5249eddbc40203d5be2
parentc43556a211b45fefe29b73d912c7cc6ff6d8bfdf (diff)
downloadlcd4linux-a80978985167df7650209888a5a89ea8089c091d.tar.gz
adding GPI to picoLCD for reading button events by Igor Mammedov <niallain@gmail.com>
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@898 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
-rw-r--r--drv_picoLCD.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/drv_picoLCD.c b/drv_picoLCD.c
index 85031f4..c567518 100644
--- a/drv_picoLCD.c
+++ b/drv_picoLCD.c
@@ -162,6 +162,12 @@ static void drv_pL_send(unsigned char *data, int size)
usb_interrupt_write(lcd, USB_ENDPOINT_OUT + 1, (char *) data, size, 1000);
}
+static int drv_pL_read(unsigned char *data, int size)
+{
+ return usb_interrupt_read(lcd, USB_ENDPOINT_OUT + 1, (char *) data, size, 1000);
+}
+
+
static void drv_pL_clear(void)
{
@@ -200,6 +206,20 @@ static int drv_pL_backlight(int backlight)
return backlight;
}
+#define _USBLCD_MAX_DATA_LEN 24
+#define IN_REPORT_KEY_STATE 0x11
+static int drv_pL_gpi(int num)
+{
+ int ret;
+ unsigned char read_packet[_USBLCD_MAX_DATA_LEN];
+ ret = drv_pL_read(read_packet, _USBLCD_MAX_DATA_LEN);
+ if ((ret > 0) && (read_packet[0] == IN_REPORT_KEY_STATE)) {
+ debug("picoLCD: pressed key= 0x%02x\n", read_packet[1]);
+ return read_packet[1];
+ }
+ return 0;
+}
+
static int drv_pL_gpo(int num, int val)
{
unsigned char cmd[2] = { 0x81 }; /* set GPO */
@@ -343,7 +363,6 @@ static void plugin_gpo(RESULT * result, RESULT * argv[])
SetResult(&result, R_NUMBER, &gpo);
}
-
/****************************************/
/*** widget callbacks ***/
/****************************************/
@@ -381,6 +400,7 @@ int drv_pL_init(const char *section, const int quiet)
CHARS = 8; /* number of user-defineable characters */
CHAR0 = 0; /* ASCII of first user-defineable char */
GPOS = 8;
+ GPIS = 1;
INVALIDATE = 1;
GOTO_COST = 2; /* number of bytes a goto command requires */
@@ -388,6 +408,7 @@ int drv_pL_init(const char *section, const int quiet)
drv_generic_text_real_write = drv_pL_write;
drv_generic_text_real_defchar = drv_pL_defchar;
drv_generic_gpio_real_set = drv_pL_gpo;
+ drv_generic_gpio_real_get = drv_pL_gpi;
/* start display */
if ((ret = drv_pL_start(section, quiet)) != 0)