From 0fdc92e156185dad666cfbb50188c2c36d9cac0c Mon Sep 17 00:00:00 2001 From: mmdolze Date: Wed, 2 Nov 2011 20:04:36 +0000 Subject: [PATCH] hd44780/serial: Fix handling of keys for LoS-Panel (by M. Kirchner) and change backlight handling: Previously if keypad=yes was configured in LCDd.conf a value for the backlight was sent, regardless of the configuration in hd44780-serial.c. Now it decides upon the backlight flag from that file (enabling it in LCDd.conf is still required). If the backlight flag indicates the device supports backlight, the backlight_on / backlight_off values are sent (even if they are 0x00)! --- ChangeLog | 2 ++ docs/lcdproc-user/drivers/hd44780.docbook | 20 +++++++++++ server/drivers/hd44780-serial.c | 43 ++++++++++++++++------- server/drivers/hd44780-serial.h | 10 +++--- 4 files changed, 57 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index fd11dae..3d420aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,8 @@ v0.5dev (ongoing development) * curses: Fix missed keystrokes (from Debian) * curses: Correct the name of the info function. + new driver: vlsys_m428 driver for Moneual MonCaso 320 (W. Hauck) + * hd44780/serial: Fix handling of keys for LoS-Panel (M. Kirchner) + * hd44780/serial: Change backlight handling (see commit message) v0.5.5 + sed1330 driver: Add support for HG25504 (L. Lagendijk) diff --git a/docs/lcdproc-user/drivers/hd44780.docbook b/docs/lcdproc-user/drivers/hd44780.docbook index c5230df..134a558 100644 --- a/docs/lcdproc-user/drivers/hd44780.docbook +++ b/docs/lcdproc-user/drivers/hd44780.docbook @@ -2004,6 +2004,26 @@ module ftdi_sio.ko that maps the USB port to a serial port LCD on Serial panel device "los-panel" +The LoS-Panel is a DIY device built using an Atmel ATtiny2313 and +supports the following features: + + Drives displays with one controller. + Switchable backlight. + One 4x4 matrix keypad and 4 direct keys. + + + + + + The direct keys are reported as a fifth column of a matrix keypad to LCDd. + + + Column and rows are reported reverse (column 1 / row 1 is in the lower + right corner) to LCDd which expects (1/1) to be the upper left corner. + You have to take this into account when configuring keys. + + + See for more information on this device. diff --git a/server/drivers/hd44780-serial.c b/server/drivers/hd44780-serial.c index 31e297e..74bcb5e 100644 --- a/server/drivers/hd44780-serial.c +++ b/server/drivers/hd44780-serial.c @@ -302,18 +302,17 @@ serial_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char f void serial_HD44780_backlight(PrivateData *p, unsigned char state) { - unsigned char send[1]; - if (p->have_backlight) { + unsigned char send; + + if (SERIAL_IF.backlight) { if (SERIAL_IF.backlight_escape) { - send[0] = SERIAL_IF.backlight_escape; + send = SERIAL_IF.backlight_escape; write(p->fd, &send, 1); } - if (SERIAL_IF.backlight_on && SERIAL_IF.backlight_off) { - send[0] = state ? SERIAL_IF.backlight_on : SERIAL_IF.backlight_off; - } - else { - send[0] = state ? 0 : 0xFF; - } + if (state == BACKLIGHT_ON) + send = SERIAL_IF.backlight_on; + else + send = SERIAL_IF.backlight_off; write(p->fd, &send, 1); } } @@ -322,7 +321,7 @@ serial_HD44780_backlight(PrivateData *p, unsigned char state) /** * Read keypress. * \param p Pointer to driver's private data structure. - * \return Bitmap of the pressed keys. + * \return Scancode of the pressed keys. */ unsigned char serial_HD44780_scankeypad(PrivateData *p) @@ -331,11 +330,31 @@ serial_HD44780_scankeypad(PrivateData *p) char hangcheck = 100; read(p->fd, &buffer, 1); - if (buffer == SERIAL_IF.keypad_escape) { + if (buffer == (SERIAL_IF.keypad_escape & 0xFF)) { while (hangcheck > 0) { /* Check if I can read another byte */ if (read(p->fd, &buffer, 1) == 1) { - return buffer; + if (SERIAL_IF.connectiontype == HD44780_CT_LOS_PANEL) { + unsigned char retval = 0; + char i; + + /* + * LoS-Panel needs some conversion here: + * Row/column nibbles need to be swapped + * and rows are returned as a bitmap of + * keys pressed. + */ + for (i = 3; i >= 0; i--) { + if ((buffer % (1 << i)) == 0) { + retval = ((i << 4) + (buffer >> 4)) + 0x11; + break; + } + } + return retval; + } + else { + return buffer; + } } hangcheck--; } diff --git a/server/drivers/hd44780-serial.h b/server/drivers/hd44780-serial.h index c0985eb..b464099 100644 --- a/server/drivers/hd44780-serial.h +++ b/server/drivers/hd44780-serial.h @@ -22,14 +22,12 @@ struct hd44780_SerialInterface { unsigned int default_bitrate; /**< Bitrate device is set to by default */ char if_bits; /**< Initialize to 8 or 4 bit interface */ char keypad; /**< Flag: keypad available */ - char keypad_escape; /**< Keys must escaped with this character */ + char keypad_escape; /**< Keys are escaped with this character */ char backlight; /**< Flag: backlight available */ /** Escape character to send to indicate a backlight state change */ char backlight_escape; - /** Character to send to set display off. If not configured 0xFF is sent */ - char backlight_off; - /** Character to send to set display on. If not configured 0x00 is sent */ - char backlight_on; + char backlight_off; /**< Character sent to set display off */ + char backlight_on; /**< Character sent to set display on */ /** Flag: Device has multiple controllers. If enabled, the displayID * is added to data escape */ char multiple_displays; @@ -44,7 +42,7 @@ static const struct hd44780_SerialInterface serial_interfaces[] = { /* type instr data v ^ bitrate bits K esc B Besc Boff Bon Multi End */ { HD44780_CT_PICANLCD, 0x11, 0x12, 0x00, 0x20, 9600, 8, 0, 0x00, 0, 0, 0, 0, 0, 0 }, { HD44780_CT_LCDSERIALIZER, 0xFE, 0, 0x00, 0x00, 9600, 8, 0, 0x00, 0, 0, 0, 0, 0, 0 }, - { HD44780_CT_LOS_PANEL, 0xFE, 0, 0x00, 0x00, 9600, 4, 1, 0xFE, 1, 0xFF, 0, 0, 0, 0 }, + { HD44780_CT_LOS_PANEL, 0xFE, 0, 0x00, 0x00, 9600, 4, 1, 0xFE, 1, 0xFD, 0, 0xFF, 0, 0 }, { HD44780_CT_VDR_LCD, 0xFE, 0, 0x00, 0x00, 9600, 4, 0, 0x00, 0, 0, 0, 0, 0, 0 }, { HD44780_CT_VDR_WAKEUP, 0xC0, 0xC4, 0xC0, 0xD0, 9600, 4, 0, 0x00, 1, 0, 0xC9, 0xC8, 1, 0xCF }, { HD44780_CT_PERTELIAN, 0xFE, 0, 0x00, 0x00, 9600, 8, 0, 0x00, 1, 0xFE, 0x02, 0x03, 0, 0 },