- unified hd44780 sub-driver that replaces picanlcd & lcdserializer while
providing the same functions (Matteo Pillon) - character mapping for special (almost) hd44780-compatible LCDs (Matteo Pillon)
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -1233,6 +1233,40 @@ that. The BL output below should be connected to the BL input in the
|
||||
|
||||
</sect3>
|
||||
|
||||
<sect3 id="hd44780-lis2">
|
||||
<title>LIS2 USB device "lis2"</title>
|
||||
|
||||
<para>
|
||||
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).
|
||||
</para>
|
||||
|
||||
</sect3>
|
||||
|
||||
<sect3 id="hd44780-los-panel">
|
||||
<title>LCD on Serial panel device "cwlos-panel"</title>
|
||||
|
||||
<para>
|
||||
See <ulink url="http://www.xs4all.nl/~mlf/los/">http://www.xs4all.nl/~mlf/los/</ulink>
|
||||
for information on this device.
|
||||
</para>
|
||||
|
||||
</sect3>
|
||||
|
||||
<sect3 id="hd44780-vdr-lcd">
|
||||
<title>VDR LCD iserial device "vdr-lcd"</title>
|
||||
|
||||
<para>
|
||||
... to b documented ...
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Please address Matteo Pillon for further information.
|
||||
</para>
|
||||
|
||||
</sect3>
|
||||
|
||||
<sect3 id="hd44780-picanlcd">
|
||||
<title>PIC-an-LCD serial device "picanlcd"</title>
|
||||
|
||||
@@ -1253,17 +1287,6 @@ by Dale Wheat.
|
||||
</sect3>
|
||||
|
||||
|
||||
<sect3 id="hd44780-lis2">
|
||||
<title>LIS2 USB device "lis2"</title>
|
||||
|
||||
<para>
|
||||
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).
|
||||
</para>
|
||||
|
||||
</sect3>
|
||||
|
||||
<sect3 id="hd44780-lcdserializer">
|
||||
<title>LCD serializer device "lcdserializer"</title>
|
||||
|
||||
@@ -1596,6 +1619,19 @@ can be done by specifying "--enable-drivers=all" or by
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>Device=</command>
|
||||
<arg choice="plain"><replaceable>DEVICE</replaceable></arg>
|
||||
</term>
|
||||
<listitem><para>
|
||||
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.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>ConnectionType=</command>
|
||||
@@ -1678,6 +1714,37 @@ can be done by specifying "--enable-drivers=all" or by
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>Speed=</command>
|
||||
<arg choice="plain"><replaceable>BITRATE</replaceable></arg>
|
||||
</term>
|
||||
<listitem><para>
|
||||
For a serial connection, set to the serial port bitrate. To use
|
||||
the default value for the chosen interface, just set to 0.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>Charmap=</command>
|
||||
<arg choice="plain">
|
||||
<group choice="req">
|
||||
<arg choice="plain"><literal><emphasis>hd44780_default</emphasis></literal></arg>
|
||||
<arg choice="plain"><literal>ea_ks0073</literal></arg>
|
||||
</group>
|
||||
</arg>
|
||||
</term>
|
||||
<listitem><para>
|
||||
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.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>Keypad=</command>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
/*
|
||||
* Character mapping for HD44780 devices by Mark Haemmerling <mail@markh.de>.
|
||||
*
|
||||
* 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 <matteo.pillon@email.it>
|
||||
*
|
||||
* 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 <nilsf@users.sourceforge.net>. 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 <matteo.pillon@email.it>
|
||||
*
|
||||
*/
|
||||
|
||||
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}
|
||||
};
|
||||
|
||||
@@ -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"},
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* LCD Serializer driver
|
||||
* Modification of the code of the PIC-an-LCD driver
|
||||
*
|
||||
* Copyright (c) 1997, Matthias Prinke <m.prinke@trashcan.mcnet.de>
|
||||
* 1998, Richard Rognlie <rrognlie@gamerz.net>
|
||||
* 1999, Ethan Dicks
|
||||
* 1999-2000, Benjamin Tse <blt@Comports.com>
|
||||
* 2001, Rene Wagner
|
||||
* 2001-2002, Joris Robijn <joris@robijn.net>
|
||||
* 2005, Pillon Matteo <matteo.pillon@email.it>
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
/*
|
||||
* "PIC-an-LCD" serial driver module for Hitachi HD44780 based LCD displays.
|
||||
*
|
||||
* Copyright (c) 1997, Matthias Prinke <m.prinke@trashcan.mcnet.de>
|
||||
* 1998, Richard Rognlie <rrognlie@gamerz.net>
|
||||
* 1999, Ethan Dicks
|
||||
* 1999-2000, Benjamin Tse <blt@Comports.com>
|
||||
* 2001, Rene Wagner
|
||||
* 2001-2002, Joris Robijn <joris@robijn.net>
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
@@ -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
|
||||
+62
-18
@@ -27,6 +27,9 @@
|
||||
*
|
||||
* Modified October 2001 to read the configfile.
|
||||
*
|
||||
* Modified August 2006 by Pillon Matteo <matteo.pillon@email.it> to
|
||||
* allow user selecting charmaps
|
||||
*
|
||||
* Moved the delay timing code by Charles Steinkuehler to timing.h.
|
||||
* Guillaume Filion <gfk@logidac.com>, 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++;
|
||||
|
||||
Reference in New Issue
Block a user