From f07c8ba7b5f7d70bd5990119c97dcf1baa8cd15d Mon Sep 17 00:00:00 2001 From: marschap Date: Fri, 2 Feb 2007 16:46:07 +0000 Subject: [PATCH] fixes for the serial hd44780 subdrivers (Matteo Pillon) --- ChangeLog | 1 + server/drivers/hd44780-low.h | 3 +++ server/drivers/hd44780-serial.c | 12 +++++++++++- server/drivers/hd44780-serial.h | 15 ++++++++------- server/drivers/hd44780.c | 4 ++++ 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 83786b4..8103a62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,6 +28,7 @@ v.0.5dev (ongoing development) * replace obsolete index() by strchr() (Guillaume LECERF) * fixes for CwLinux driver (Gideon Tsang) + new ConnectionType vdr-wakeup in hd44780 driver + * fixes for the hd44780-serial drivers (Matteo Pillon) v.0.5.1 + config file support in lcdproc client (Andrew Foss) diff --git a/server/drivers/hd44780-low.h b/server/drivers/hd44780-low.h index 0196cce..2397413 100644 --- a/server/drivers/hd44780-low.h +++ b/server/drivers/hd44780-low.h @@ -150,6 +150,9 @@ typedef struct hwDependentFns { // Output "data" to output latch if there is one void (*output) (PrivateData *p, int data); + // Close the interface on shutdown + void (*close) (PrivateData *p); + } HD44780_functions; /* for want of a better name :-) */ diff --git a/server/drivers/hd44780-serial.c b/server/drivers/hd44780-serial.c index fd25694..fc38880 100644 --- a/server/drivers/hd44780-serial.c +++ b/server/drivers/hd44780-serial.c @@ -1,6 +1,6 @@ /* * Driver for serial connected hd44780 LCDs - * Copyright (C) 2006 Matteo Pillon + * Copyright (C) 2006-2007 Matteo Pillon * * Some parts are based on the original pic-an-lcd driver code * Copyright (C) 1997, Matthias Prinke @@ -121,6 +121,7 @@ static int lastdisplayID; void serial_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch); void serial_HD44780_backlight (PrivateData *p, unsigned char state); unsigned char serial_HD44780_scankeypad (PrivateData *p); +void serial_HD44780_close (PrivateData *p); // initialize the driver int @@ -224,6 +225,7 @@ hd_init_serial (Driver *drvthis) p->hd44780_functions->backlight = serial_HD44780_backlight; if (p->have_keypad) p->hd44780_functions->scankeypad = serial_HD44780_scankeypad; + p->hd44780_functions->close = serial_HD44780_close; /* Do initialization */ if (SERIAL_IF.if_bits == 8) { @@ -298,3 +300,11 @@ serial_HD44780_scankeypad (PrivateData *p) } return 0; } + +void +serial_HD44780_close (PrivateData *p) +{ + if (SERIAL_IF.end_code) + write(p->fd, &SERIAL_IF.end_code, 1); + close(p->fd); +} diff --git a/server/drivers/hd44780-serial.h b/server/drivers/hd44780-serial.h index 6576bc1..67333ee 100644 --- a/server/drivers/hd44780-serial.h +++ b/server/drivers/hd44780-serial.h @@ -21,18 +21,19 @@ typedef struct SerialInterface { char backlight_escape; /* leave to 0 is the interface uses on/off codes */ char backlight_off; char backlight_on; /* leave these two to 0 is backlight_escape is set */ - char multiple_displays; + char multiple_displays; + char end_code; /* code to send on shutdown */ } SerialInterface; /* List of connectiontypes managed by this driver, if you change something here, remember also to change hd44780-drivers.h */ static const SerialInterface serial_interfaces[] = { - /* name instr data v ^ bitrate bits K esc B Besc Boff Bon Multi */ - { "picanlcd", 0x11, 0x12, 0x00, 0x20, 9600, 8, 0, 0x00, 0, 0, 0, 0, 0 }, - { "lcdserializer", 0xFE, 0, 0x00, 0x00, 9600, 8, 0, 0x00, 0, 0, 0, 0, 0 }, - { "los-panel", 0xFE, 0, 0x00, 0x00, 9600, 4, 1, 0xFE, 1, 0xFF, 0, 0, 0 }, - { "vdr-lcd", 0xFE, 0, 0x00, 0x00, 9600, 4, 0, 0x00, 0, 0, 0, 0, 0 }, - { "vdr-wakeup", 0xC0, 0xC4, 0xC0, 0xD0, 9600, 4, 0, 0x00, 1, 0, 0xC9, 0xC8, 1 } + /* name instr data v ^ bitrate bits K esc B Besc Boff Bon Multi End */ + { "picanlcd", 0x11, 0x12, 0x00, 0x20, 9600, 8, 0, 0x00, 0, 0, 0, 0, 0, 0 }, + { "lcdserializer", 0xFE, 0, 0x00, 0x00, 9600, 8, 0, 0x00, 0, 0, 0, 0, 0, 0 }, + { "los-panel", 0xFE, 0, 0x00, 0x00, 9600, 4, 1, 0xFE, 1, 0xFF, 0, 0, 0, 0 }, + { "vdr-lcd", 0xFE, 0, 0x00, 0x00, 9600, 4, 0, 0x00, 0, 0, 0, 0, 0, 0 }, + { "vdr-wakeup", 0xC0, 0xC4, 0xC0, 0xD0, 9600, 4, 0, 0x00, 1, 0, 0xC9, 0xC8, 1, 0xCF } }; /* initialize this particular driver */ diff --git a/server/drivers/hd44780.c b/server/drivers/hd44780.c index 93f66b1..8595660 100644 --- a/server/drivers/hd44780.c +++ b/server/drivers/hd44780.c @@ -328,6 +328,7 @@ HD44780_init (Driver * drvthis) p->hd44780_functions->uPause = uPause; p->hd44780_functions->scankeypad = HD44780_scankeypad; p->hd44780_functions->output = NULL; + p->hd44780_functions->close = NULL; // Do connection type specific display init if (connectionMapping[p->connectiontype_index].init_fn(drvthis) != 0) @@ -409,6 +410,9 @@ HD44780_close(Driver *drvthis) { PrivateData *p = (PrivateData *) drvthis->private_data; + if (p->hd44780_functions->close) + p->hd44780_functions->close(p); + if (p != NULL) { if (p->framebuf) free(p->framebuf);