diff options
Diffstat (limited to 'drv_picoLCD.c')
-rw-r--r-- | drv_picoLCD.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/drv_picoLCD.c b/drv_picoLCD.c index a0c03e9..311958e 100644 --- a/drv_picoLCD.c +++ b/drv_picoLCD.c @@ -1,9 +1,9 @@ -/* $Id: drv_picoLCD.c 773 2007-02-25 12:39:09Z michael $ - * $URL: https://ssl.bulix.org/svn/lcd4linux/branches/0.10.1/drv_picoLCD.c $ +/* $Id: drv_picoLCD.c 1143 2011-02-12 22:46:19Z mzuther $ + * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/drv_picoLCD.c $ * * driver for picoLCD displays from mini-box.com * - * Copyright (C) 2005 Michael Reinelt <reinelt@eunet.at> + * Copyright (C) 2005 Michael Reinelt <michael@reinelt.co.at> * Copyright (C) 2005, 2006, 2007 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net> * * Copyright (C) 2007 Nicu Pavel, Mini-Box.com <npavel@mini-box.com> @@ -75,7 +75,6 @@ static char *Buffer; static char *BufPtr; static usb_dev_handle *lcd; -extern int usb_debug; @@ -97,7 +96,7 @@ static int drv_pL_open(void) info("%s: scanning for picoLCD...", Name); - usb_debug = 0; + usb_set_debug(0); usb_init(); usb_find_busses(); @@ -162,6 +161,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 +205,21 @@ 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( __attribute__ ((unused)) + 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 */ @@ -286,7 +306,7 @@ static int drv_pL_start(const char *section, const int quiet) /* Init the command buffer */ Buffer = (char *) malloc(1024); if (Buffer == NULL) { - error("%s: coommand buffer could not be allocated: malloc() failed", Name); + error("%s: command buffer could not be allocated: malloc() failed", Name); return -1; } BufPtr = Buffer; @@ -343,7 +363,6 @@ static void plugin_gpo(RESULT * result, RESULT * argv[]) SetResult(&result, R_NUMBER, &gpo); } - /****************************************/ /*** widget callbacks ***/ /****************************************/ @@ -362,7 +381,7 @@ static void plugin_gpo(RESULT * result, RESULT * argv[]) /* list models */ int drv_pL_list(void) { - printf("generic"); + printf("picoLCD 20x2 Text LCD"); return 0; } @@ -373,7 +392,7 @@ int drv_pL_init(const char *section, const int quiet) WIDGET_CLASS wc; int ret; - info("%s: %s", Name, "$Rev: 773 $"); + info("%s: %s", Name, "$Rev: 1143 $"); /* display preferences */ XRES = 5; /* pixel width of one char */ @@ -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) |