diff --git a/ChangeLog b/ChangeLog
index 2900b25..a4896b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -26,6 +26,10 @@ v.0.5dev (ongoing development)
+ add MD8800 driver for LCDs in Medion MD8800 PCs (Stefan Herdler/Martin Møller)
* make bigclock client screen more flexible: centered, require only 14 chars
* correct axis mapping logic for joystick driver (Jannis Achstetter)
+ * fixes to the CFontz driver
+ + new unified serial sub-driver for hd44780 (Matteo Pillon)
+ - obsolete hd44780 subdrivers-removed: lcdserializer, picanlcd
+ * character mapping for special HD44780 modules (Matteo Pillon)
v0.5.0
This version has split off from unstable-0.4.3. Includes major changes.
diff --git a/LCDd.conf b/LCDd.conf
index 0acc9bc..be41698 100644
--- a/LCDd.conf
+++ b/LCDd.conf
@@ -345,11 +345,17 @@ Speed=19200
## Hitachi HD44780 driver ##
[hd44780]
+# Select what type of connection. See documentation for types.
+ConnectionType=4bit
+
# Port where the LPT is. Usual values are 0x278, 0x378 and 0x3BC
Port=0x378
-# Select what type of connection. See documentation for types.
-ConnectionType=4bit
+# Device of the serial interface (default is /dev/lcd)
+Device=/dev/ttyS0
+
+# Bitrate of the serial port (0 for interface default)
+Speed=0
# If you have a keypad connected.
# You may also need to configure the keypad layout further on in this file.
@@ -382,6 +388,10 @@ Size=20x4
# This flag is NOT the old obsolete Extended option.
#ExtendedMode=yes
+# Character map to to map ISO-8859-1 to the LCD's character set
+# [default: hd44780_default; legal: hd44780_default, ea_ks0073 ]
+Charmap=hd44780_default
+
# If your display is slow and cannot keep up with the flow of data from
# LCDd, garbage can appear on the LCDd. Set this delay factor to 2 or 4
# to increase the delays. Default: 1.
diff --git a/acinclude.m4 b/acinclude.m4
index 4219f85..2e8fed0 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -146,7 +146,7 @@ dnl else
actdrivers=["$actdrivers glk"]
;;
hd44780)
- HD44780_DRIVERS="hd44780-hd44780-picanlcd.o hd44780-hd44780-lcdserializer.o hd44780-hd44780-lis2.o"
+ HD44780_DRIVERS="hd44780-hd44780-serial.o hd44780-hd44780-lis2.o"
if test "$ac_cv_port_have_lpt" = yes ; then
HD44780_DRIVERS="$HD44780_DRIVERS hd44780-hd44780-4bit.o hd44780-hd44780-ext8bit.o hd44780-lcd_sem.o hd44780-hd44780-winamp.o hd44780-hd44780-serialLpt.o"
fi
diff --git a/docs/lcdproc-user/drivers/hd44780.docbook b/docs/lcdproc-user/drivers/hd44780.docbook
index e08dfcc..182767f 100644
--- a/docs/lcdproc-user/drivers/hd44780.docbook
+++ b/docs/lcdproc-user/drivers/hd44780.docbook
@@ -1233,6 +1233,40 @@ that. The BL output below should be connected to the BL input in the
+
+LIS2 USB device "lis2"
+
+
+LIS2 from VLSystem (http://www.vlsys.co.kr) is a full featured usb vfd module
+with four channel fan controls. This device can be access as a serial device with
+help of the kernel modules ftdi_sio which map the USB port to a serial port (/dev/ttyUSBx).
+
+
+
+
+
+LCD on Serial panel device "cwlos-panel"
+
+
+See http://www.xs4all.nl/~mlf/los/
+for information on this device.
+
+
+
+
+
+VDR LCD iserial device "vdr-lcd"
+
+
+ ... to b documented ...
+
+
+
+Please address Matteo Pillon for further information.
+
+
+
+
PIC-an-LCD serial device "picanlcd"
@@ -1253,17 +1287,6 @@ by Dale Wheat.
-
-LIS2 USB device "lis2"
-
-
-LIS2 from VLSystem (http://www.vlsys.co.kr) is a full featured usb vfd module
-with four channel fan controls. This device can be access as a serial device with
-help of the kernel modules ftdi_sio which map the USB port to a serial port (/dev/ttyUSBx).
-
-
-
-
LCD serializer device "lcdserializer"
@@ -1596,6 +1619,19 @@ can be done by specifying "--enable-drivers=all" or by
+
+
+ Device=
+ DEVICE
+
+
+ If you are using a serial connection, you must
+ set this parameter to the device your lcd is connected to. For
+ example, if it's connected to the first serial port, you have to
+ set Device to /dev/ttyS0. The default value is /dev/lcd.
+
+
+
ConnectionType=
@@ -1678,6 +1714,37 @@ can be done by specifying "--enable-drivers=all" or by
+
+
+ Speed=
+ BITRATE
+
+
+ For a serial connection, set to the serial port bitrate. To use
+ the default value for the chosen interface, just set to 0.
+
+
+
+
+
+ Charmap=
+
+
+ hd44780_default
+ ea_ks0073
+
+
+
+
+ You need to set this parameter only if you don't have a standard
+ hd44780 display. ea_ks0073 is the charmap for Electronic
+ Assembly's KS0073 based displays. These devices have a richer
+ charset, including many icons and many more characters of the
+ ISO-8859-1 than standard hd44780s. Refer to hd44780-charset.h
+ for more informations.
+
+
+
Keypad=
diff --git a/server/drivers/Makefile.am b/server/drivers/Makefile.am
index e98940d..724a3a3 100644
--- a/server/drivers/Makefile.am
+++ b/server/drivers/Makefile.am
@@ -63,7 +63,7 @@ CwLnx_SOURCES = lcd.h lcd_lib.h CwLnx.c CwLnx.h report.h
glcdlib_SOURCES = lcd.h lcd_lib.h glcdlib.h glcdlib.c report.h
glk_SOURCES = lcd.h glk.c glk.h glkproto.c glkproto.h report.h
hd44780_SOURCES = lcd.h lcd_lib.h hd44780.h hd44780.c hd44780-drivers.h hd44780-low.h hd44780-charmap.h report.h adv_bignum.h
-EXTRA_hd44780_SOURCES = hd44780-4bit.c hd44780-4bit.h hd44780-ext8bit.c hd44780-ext8bit.h lcd_sem.c lcd_sem.h hd44780-serialLpt.c hd44780-serialLpt.h hd44780-winamp.c hd44780-winamp.h hd44780-picanlcd.c hd44780-picanlcd.h hd44780-bwct-usb.c hd44780-bwct-usb.h hd44780-lcdserializer.c hd44780-lcdserializer.h hd44780-lis2.c hd44780-lis2.h hd44780-i2c.c hd44780-i2c.h port.h lpt-port.h timing.h
+EXTRA_hd44780_SOURCES = hd44780-4bit.c hd44780-4bit.h hd44780-ext8bit.c hd44780-ext8bit.h lcd_sem.c lcd_sem.h hd44780-serialLpt.c hd44780-serialLpt.h hd44780-serial.c hd44780-serial.h hd44780-winamp.c hd44780-winamp.h hd44780-bwct-usb.c hd44780-bwct-usb.h hd44780-lis2.c hd44780-lis2.h hd44780-i2c.c hd44780-i2c.h port.h lpt-port.h timing.h
icp_a106_SOURCES = lcd.h lcd_lib.h icp_a106.c icp_a106.h report.h
imon_SOURCES = lcd.h lcd_lib.h imon.h imon.c report.h
diff --git a/server/drivers/hd44780-charmap.h b/server/drivers/hd44780-charmap.h
index 0477899..f40b78f 100644
--- a/server/drivers/hd44780-charmap.h
+++ b/server/drivers/hd44780-charmap.h
@@ -1,14 +1,21 @@
/*
* Character mapping for HD44780 devices by Mark Haemmerling .
*
- * Translates ISO 8859-1 to HD44780 charset.
- * HD44780 charset reference: http://markh.de/hd44780-charset.png
+ * Translates ISO 8859-1 to any HD44780 charset.
+ *
+ * Charmap selector (C) 2006 Pillon Matteo
+ *
+ * This file is released under the GNU General Public License.
+ * Refer to the COPYING file distributed with this package.
+ */
+
+/*
+ * HD44780 table
*
* Initial table taken from lcd.o Linux kernel driver by
* Nils Faerber . Thanks!
*
- * This file is released under the GNU General Public License.
- * Refer to the COPYING file distributed with this package.
+ * HD44780 charset reference: http://markh.de/hd44780-charset.png
*
* The following translations are being performed:
* - map umlaut accent characters to the corresponding umlaut characters
@@ -65,3 +72,81 @@ const unsigned char HD44780_charmap[] = {
111, 110, 111, 111, 111, 111, 239, 253,
48, 117, 117, 117, 245, 121, 240, 255
};
+
+/*
+ * Electronic Assembly's KS0073 based LCDs table
+ * http://www.lcd-module.de/eng/pdf/doma/dip204-4e.pdf
+ *
+ * This map is more similar to a ISO-8859-15, but with fractions from
+ * ISO-8859-1 (0xBC, 0xBD).
+ *
+ * ~ (126) is mapped to right arrow, even though it exists, for
+ * compatibility with some clients. 127 is left arrow.
+ *
+ * There's no backtick, substituded with '.
+ *
+ * | is substituted with another similar charachter as the code is
+ * used by some serial drivers.
+ *
+ * Charset of the display offers a nice set of icons, they are mapped
+ * from 128 to 159. I mapped these intervals to, in order: 16-28,
+ * 140-151, 180-182, 187, 207, 222, 224.
+ *
+ * (C) 2006 Pillon Matteo
+ *
+ */
+
+const unsigned char EA_KS0073_charmap[] = {
+ /* #0 */
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31,
+ /* #32 */
+ 32, 33, 34, 35, 36, 37, 38, 39,
+ 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55,
+ 56, 57, 58, 59, 60, 61, 62, 63,
+ /* #64 */
+ 64, 65, 66, 67, 68, 69, 70, 71,
+ 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81, 82, 83, 84, 85, 86, 87,
+ 88, 89, 90, 250, 251, 252, 29, 196,
+ /* #96 */
+ 39, 97, 98, 99, 100, 101, 102, 103,
+ 104, 105, 106, 107, 108, 109, 110, 111,
+ 112, 113, 114, 115, 116, 117, 118, 119,
+ 120, 121, 122, 253, 218, 255, 223, 225,
+ /* #128 */
+ 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 140, 141, 142,
+ 143, 144, 145, 146, 147, 148, 149, 150,
+ 151, 180, 181, 182, 187, 207, 222, 224,
+ /* #160 */
+ 160, 64, 177, 161, 36, 163, 243, 95,
+ 248, 67, 170, 20, 172, 173, 82, 175,
+ 128, 140, 130, 131, 249, 143, 182, 221,
+ 244, 129, 128, 21, 139, 138, 190, 96,
+ /* #192 */
+ 174, 226, 174, 174, 91, 174, 188, 169,
+ 197, 191, 198, 69, 73, 73, 73, 73,
+ 68, 93, 168, 228, 236, 79, 92, 120,
+ 171, 238, 229, 238, 94, 230, 178, 190,
+ /* #224 */
+ 127, 231, 175, 175, 123, 175, 189, 200,
+ 164, 165, 199, 101, 167, 232, 105, 105,
+ 111, 125, 168, 233, 237, 111, 124, 58,
+ 172, 166, 234, 239, 126, 235, 178, 255
+};
+
+#define MAX_CHARMAP_NAME_LENGHT 16
+
+struct charmap {
+ char name[MAX_CHARMAP_NAME_LENGHT];
+ const unsigned char *charmap;
+};
+
+const struct charmap available_charmaps[] = {
+ {"hd44780_default", HD44780_charmap},
+ {"ea_ks0073", EA_KS0073_charmap}
+};
diff --git a/server/drivers/hd44780-drivers.h b/server/drivers/hd44780-drivers.h
index 81f319c..6ea5c72 100644
--- a/server/drivers/hd44780-drivers.h
+++ b/server/drivers/hd44780-drivers.h
@@ -20,8 +20,7 @@
#ifdef HAVE_LIBUSB
# include "hd44780-bwct-usb.h"
#endif
-#include "hd44780-picanlcd.h"
-#include "hd44780-lcdserializer.h"
+#include "hd44780-serial.h"
#include "hd44780-lis2.h"
#ifdef HAVE_I2C
# include "hd44780-i2c.h"
@@ -39,8 +38,12 @@ static const ConnectionMapping connectionMapping[] = {
{"serialLpt", hd_init_serialLpt, "\tnone\n"},
{"winamp", hd_init_winamp, "\tnone\n"},
#endif
- {"picanlcd", hd_init_picanlcd, "\tnone\n"},
- {"lcdserializer", hd_init_lcdserializer, "\tnone\n"},
+ /* Serial connectiontypes */
+ {"picanlcd", hd_init_serial, "\tnone\n"},
+ {"lcdserializer", hd_init_serial, "\tnone\n"},
+ {"los-panel", hd_init_serial, "\tnone\n"},
+ {"vdr-lcd", hd_init_serial, "\tnone\n"},
+ /* End serial connectiontypes */
{"lis2", hd_init_lis2, "\tnone\n"},
#ifdef HAVE_LIBUSB
{"bwctusb", hd_init_bwct_usb, "\tnone\n"},
diff --git a/server/drivers/hd44780-lcdserializer.c b/server/drivers/hd44780-lcdserializer.c
deleted file mode 100644
index 02d399e..0000000
--- a/server/drivers/hd44780-lcdserializer.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * LCD Serializer driver
- * Modification of the code of the PIC-an-LCD driver
- *
- * Copyright (c) 1997, Matthias Prinke
- * 1998, Richard Rognlie
- * 1999, Ethan Dicks
- * 1999-2000, Benjamin Tse
- * 2001, Rene Wagner
- * 2001-2002, Joris Robijn
- * 2005, Pillon Matteo
- *
- * This file is released under the GNU General Public License. Refer to the
- * COPYING file distributed with this package.
- *
- * LCD Serializer code and documentation:
- * http://www.mindspring.com/~tcoonan/lcd.html
- *
- */
-
-#include "hd44780-lcdserializer.h"
-#include "hd44780-low.h"
-
-#include "report.h"
-
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-#include
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-// Generally, any function that accesses the LCD control lines needs to be
-// implemented separately for each HW design. This is typically (but not
-// restricted to):
-// HD44780_senddata
-// HD44780_readkeypad
-
-void lcdserializer_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
-void lcdserializer_HD44780_backlight (PrivateData *p, unsigned char state);
-unsigned char lcdserializer_HD44780_scankeypad (PrivateData *p);
-
-#define LCDSERIALIZER_LCDI '\xFE'
-
-#define DEFAULT_DEVICE "/dev/lcd"
-
-// initialise the driver
-int
-hd_init_lcdserializer (Driver *drvthis)
-{
- PrivateData *p = (PrivateData*) drvthis->private_data;
-
- struct termios portset;
- char device[256] = DEFAULT_DEVICE;
-
- /* READ CONFIG FILE */
-
- /* Get serial device to use */
- strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(device));
- device[sizeof(device)-1] = '\0';
- report(RPT_INFO, "HD44780: LCD Serializer: Using device: %s", device);
-
- // Set up io port correctly, and open it...
- p->fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
- if (p->fd == -1) {
- report(RPT_ERR, "HD44780: LCD Serializer: could not open device %s (%s)", device, strerror(errno));
- return -1;
- }
-
- /* Get serial device parameters */
- tcgetattr(p->fd, &portset);
-
- /* We use RAW mode */
-#ifdef HAVE_CFMAKERAW
- /* The easy way */
- cfmakeraw(&portset);
-#else
- /* The hard way */
- portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP
- | INLCR | IGNCR | ICRNL | IXON );
- portset.c_oflag &= ~OPOST;
- portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN );
- portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS );
- portset.c_cflag |= CS8 | CREAD | CLOCAL ;
-#endif
- /* Set port speed to 9600 baud */
- cfsetospeed(&portset, B9600);
-
- /* Set TCSANOW mode of serial device */
- tcsetattr(p->fd, TCSANOW, &portset);
-
- p->hd44780_functions->senddata = lcdserializer_HD44780_senddata;
- p->hd44780_functions->backlight = lcdserializer_HD44780_backlight;
- p->hd44780_functions->scankeypad = lcdserializer_HD44780_scankeypad;
-
- common_init(p, IF_8BIT);
-
- return 0;
-}
-
-void
-lcdserializer_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
-{
- static const char instr_byte = LCDSERIALIZER_LCDI;
-
- if (flags == RS_DATA) {
- write(p->fd, &ch, 1);
- }
- else {
- write(p->fd, &instr_byte, 1);
- write(p->fd, &ch, 1);
- }
-}
-
-void
-lcdserializer_HD44780_backlight (PrivateData *p, unsigned char state)
-{
- /* No backlight control */
-}
-
-unsigned char
-lcdserializer_HD44780_scankeypad (PrivateData *p)
-{
- return 0;
-}
diff --git a/server/drivers/hd44780-lcdserializer.h b/server/drivers/hd44780-lcdserializer.h
deleted file mode 100644
index ba40653..0000000
--- a/server/drivers/hd44780-lcdserializer.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef HD_LCDSERIALIZER_H
-#define HD_LCDSERIALIZER_H
-
-#include "lcd.h" /* for Driver */
-
-// initialise this particular driver
-int hd_init_lcdserializer (Driver *drvthis);
-
-#endif
diff --git a/server/drivers/hd44780-low.h b/server/drivers/hd44780-low.h
index 410d895..0196cce 100644
--- a/server/drivers/hd44780-low.h
+++ b/server/drivers/hd44780-low.h
@@ -53,7 +53,11 @@ typedef struct driver_private_data {
unsigned int port;
- int fd; /* for picanlcd connection type */
+ /* for serial connection type */
+ int fd;
+ int serial_type;
+
+ int charmap;
int width, height;
int cellwidth, cellheight;
diff --git a/server/drivers/hd44780-picanlcd.c b/server/drivers/hd44780-picanlcd.c
deleted file mode 100644
index 14d0ee2..0000000
--- a/server/drivers/hd44780-picanlcd.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * "PIC-an-LCD" serial driver module for Hitachi HD44780 based LCD displays.
- *
- * Copyright (c) 1997, Matthias Prinke
- * 1998, Richard Rognlie
- * 1999, Ethan Dicks
- * 1999-2000, Benjamin Tse
- * 2001, Rene Wagner
- * 2001-2002, Joris Robijn
- *
- * This file is released under the GNU General Public License. Refer to the
- * COPYING file distributed with this package.
- *
- * See the PIC-an-LCD documentation for data on how it should be connected
- * to the computer.
- * http://dalewheat.com/pdf/PIC-an-LCD.pdf
- *
- */
-
-#include "hd44780-picanlcd.h"
-#include "hd44780-low.h"
-
-#include "report.h"
-
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-#include
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-// Generally, any function that accesses the LCD control lines needs to be
-// implemented separately for each HW design. This is typically (but not
-// restricted to):
-// HD44780_senddata
-// HD44780_readkeypad
-
-void picanlcd_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
-void picanlcd_HD44780_backlight (PrivateData *p, unsigned char state);
-unsigned char picanlcd_HD44780_scankeypad (PrivateData *p);
-
-// PIC-an-LCD ASCII commands
-//#define PICANLCD_HOME '\001'
-//#define PICANLCD_CLR '\014'
-#define PICANLCD_LED '\025'
-#define PICANLCD_LCDI '\021'
-#define PICANLCD_LCDD '\022'
-
-#define DEFAULT_DEVICE "/dev/lcd"
-
-// initialise the driver
-int
-hd_init_picanlcd (Driver *drvthis)
-{
- PrivateData *p = (PrivateData*) drvthis->private_data;
-
- struct termios portset;
- char device[256] = DEFAULT_DEVICE;
-
- /* READ CONFIG FILE */
-
- /* Get serial device to use */
- strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(device));
- device[sizeof(device)-1] = '\0';
- report(RPT_INFO,"HD44780: PIC-an-LCD: Using device: %s", device);
-
- // Set up io port correctly, and open it...
- p->fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
- if (p->fd == -1) {
- report(RPT_ERR, "HD44780: PIC-an-LCD: could not open device %s (%s)",
- device, strerror(errno));
- return -1;
- }
-
- /* Get serial device parameters */
- tcgetattr(p->fd, &portset);
-
- /* We use RAW mode */
-#ifdef HAVE_CFMAKERAW
- /* The easy way */
- cfmakeraw(&portset);
-#else
- /* The hard way */
- portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP
- | INLCR | IGNCR | ICRNL | IXON );
- portset.c_oflag &= ~OPOST;
- portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN );
- portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS );
- portset.c_cflag |= CS8 | CREAD | CLOCAL ;
-#endif
- /* Set port speed to 9600 baud */
- cfsetospeed(&portset, B9600);
-
- /* Set TCSANOW mode of serial device */
- tcsetattr(p->fd, TCSANOW, &portset);
-
- p->hd44780_functions->senddata = picanlcd_HD44780_senddata;
- p->hd44780_functions->backlight = picanlcd_HD44780_backlight;
- p->hd44780_functions->scankeypad = picanlcd_HD44780_scankeypad;
-
- common_init (p, IF_8BIT);
-
- return 0;
-}
-
-// picanlcd_HD44780_senddata
-void
-picanlcd_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
-{
- static const char data_byte = PICANLCD_LCDD;
- static const char instr_byte = PICANLCD_LCDI;
-
- if (flags == RS_DATA) {
- // Do we need a DATA indicator byte ?
- if (ch < 32) {
- write(p->fd, &data_byte, 1);
- }
- write( p->fd, &ch, 1 );
- }
- else {
- write(p->fd, &instr_byte, 1);
- write(p->fd, &ch, 1);
- }
-}
-
-void
-picanlcd_HD44780_backlight (PrivateData *p, unsigned char state)
-{
- /* Anyone wants to implement this ? */
-}
-
-unsigned char
-picanlcd_HD44780_scankeypad (PrivateData *p)
-{
- return 0;
-}
diff --git a/server/drivers/hd44780-picanlcd.h b/server/drivers/hd44780-picanlcd.h
deleted file mode 100644
index bac51fb..0000000
--- a/server/drivers/hd44780-picanlcd.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef HD_PICANLCD_H
-#define HD_PICANLCD_H
-
-#include "lcd.h" /* for Driver */
-
-// initialise this particular driver
-int hd_init_picanlcd (Driver *drvthis);
-
-#endif
diff --git a/server/drivers/hd44780.c b/server/drivers/hd44780.c
index efd1ff0..0be523e 100644
--- a/server/drivers/hd44780.c
+++ b/server/drivers/hd44780.c
@@ -27,6 +27,9 @@
*
* Modified October 2001 to read the configfile.
*
+ * Modified August 2006 by Pillon Matteo to
+ * allow user selecting charmaps
+ *
* Moved the delay timing code by Charles Steinkuehler to timing.h.
* Guillaume Filion , December 2001
*
@@ -116,6 +119,9 @@ MODULE_EXPORT int stay_in_foreground = 0;
MODULE_EXPORT int supports_multiple = 1; // yes, we have no global variables (except for constants)
MODULE_EXPORT char *symbol_prefix = "HD44780_";
+#define IF_TYPE_PARPORT 0
+#define IF_TYPE_USB 1
+#define IF_TYPE_SERIAL 2
/////////////////////////////////////////////////////////////////
// Opens com port and sets baud correctly...
@@ -128,7 +134,7 @@ HD44780_init (Driver * drvthis)
char buf[40];
char *s;
int i;
- int usb = 0;
+ int if_type = IF_TYPE_PARPORT;
PrivateData *p;
// Alocate and store private data
@@ -163,10 +169,16 @@ HD44780_init (Driver * drvthis)
return -1; // fatal error
} else {
p->connectiontype_index = i;
- /* check if ConnectionType contains the string "USB" or "usb" */
- if ((strstr(connectionMapping[i].name, "usb") != NULL) ||
- (strstr(connectionMapping[i].name, "USB") != NULL))
- usb = 1;
+ /* check if ConnectionType contains the string "usb" or "USB" */
+ if ((strstr(connectionMapping[p->connectiontype_index].name, "usb") != NULL) ||
+ (strstr(connectionMapping[p->connectiontype_index].name, "USB") != NULL))
+ if_type = IF_TYPE_USB;
+ /* check if it is the serial driver */
+ for (i = 0; i < (sizeof(serial_interfaces)/sizeof(SerialInterface)); i++) {
+ if (strcasecmp(connectionMapping[p->connectiontype_index].name,
+ serial_interfaces[i].name)==0)
+ if_type = IF_TYPE_SERIAL;
+ }
}
// Get and parse vspan only when specified
@@ -284,6 +296,28 @@ HD44780_init (Driver * drvthis)
}
}
+ // Get configured charmap
+ char conf_charmap[MAX_CHARMAP_NAME_LENGHT];
+
+ strncpy(conf_charmap, drvthis->config_get_string(drvthis->name, "charmap", 0, "hd44780_default"), MAX_CHARMAP_NAME_LENGHT);
+ conf_charmap[MAX_CHARMAP_NAME_LENGHT-1]='\0';
+ p->charmap=0;
+ for (i=0; i<(sizeof(available_charmaps)/sizeof(struct charmap)); i++) {
+ if (strcasecmp(conf_charmap, available_charmaps[i].name) == 0) {
+ p->charmap=i;
+ break;
+ }
+ }
+ if (p->charmap != i) {
+ report(RPT_ERR, "%s: Charmap %s is unknown", drvthis->name, conf_charmap);
+ report(RPT_ERR, "%s: Available charmaps:", drvthis->name);
+ for (i=0; i<(sizeof(available_charmaps)/sizeof(struct charmap)); i++) {
+ report(RPT_ERR, " %s", available_charmaps[i].name);
+ }
+ return -1;
+ }
+ report(RPT_INFO, "%s: Using %s charmap", drvthis->name, available_charmaps[p->charmap].name);
+
// Output latch state - init to a non-valid value
p->output_state = 999999;
@@ -303,18 +337,28 @@ HD44780_init (Driver * drvthis)
HD44780_clear (drvthis);
sprintf (buf, "HD44780 %dx%d", p->width, p->height );
HD44780_string (drvthis, 1, 1, buf);
- if (usb) {
- sprintf(buf, "USB %s%s%s",
- (p->have_backlight ? " bl" : ""),
- (p->have_keypad ? " key" : ""),
- (p->have_output ? " out" : ""));
- }
- else {
- sprintf(buf, "LPT 0x%03X%s%s%s", p->port,
- (p->have_backlight ? " bl" : ""),
- (p->have_keypad ? " key" : ""),
- (p->have_output ? " out" : ""));
- }
+ switch(if_type) {
+ case IF_TYPE_USB:
+ sprintf (buf, "USB %s%s%s",
+ (p->have_backlight?" bl":""),
+ (p->have_keypad?" key":""),
+ (p->have_output?" out":"")
+ );
+ break;
+ case IF_TYPE_SERIAL:
+ sprintf (buf, "SERIAL %s%s%s",
+ (p->have_backlight?" bl":""),
+ (p->have_keypad?" key":""),
+ (p->have_output?" out":"")
+ );
+ break;
+ default:
+ sprintf (buf, "LPT 0x%x%s%s%s", p->port,
+ (p->have_backlight?" bl":""),
+ (p->have_keypad?" key":""),
+ (p->have_output?" out":"")
+ );
+ }
HD44780_string (drvthis, 1, 2, buf);
HD44780_flush (drvthis);
sleep (2);
@@ -475,7 +519,7 @@ HD44780_flush (Driver *drvthis)
drawing = 1;
HD44780_position(drvthis,x,y);
}
- p->hd44780_functions->senddata (p, p->spanList[y], RS_DATA, HD44780_charmap[(unsigned char)ch]);
+ p->hd44780_functions->senddata (p, p->spanList[y], RS_DATA, available_charmaps[p->charmap].charmap[(unsigned char)ch]);
p->hd44780_functions->uPause (p, 40); // Minimum exec time for all commands
p->lcd_contents[(y*wid)+x] = ch;
count++;