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)!
This commit is contained in:
mmdolze
2011-11-02 20:04:36 +00:00
parent 760ea0a21a
commit 0fdc92e156
4 changed files with 57 additions and 18 deletions
+31 -12
View File
@@ -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--;
}