diff --git a/CREDITS b/CREDITS index ff4fbb4..13e87fd 100644 --- a/CREDITS +++ b/CREDITS @@ -245,6 +245,9 @@ Thomas Jarosch Christian Jodar - mx5000 driver +Mariusz Bialonczyk + - ethlcd connection type for HD44780 + Further developers in the sourceforge lcdproc team: diff --git a/ChangeLog b/ChangeLog index c6e9598..43f6f94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -53,6 +53,7 @@ v.0.5dev (ongoing development) + IOWarrior driver: add ExtendedMode option * lcdproc: unbreak compilation on OS X 1.5 and higher (Topher Fangio) * server: fix interpretation of numeric priorities (Andrew M. Bishop) + + hd44780 driver: new ConnectionType ethlcd (Mariusz Bialonczyk) v.0.5.2 * fix switching on/off the Load screen in lcdproc client using the menu diff --git a/acinclude.m4 b/acinclude.m4 index f3c9e42..c674dfe 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -198,6 +198,9 @@ dnl else if test "$enable_libftdi" = yes ; then HD44780_DRIVERS="$HD44780_DRIVERS hd44780-hd44780-ftdi.o" fi + if test "$enable_ethlcd" = yes ; then + HD44780_DRIVERS="$HD44780_DRIVERS hd44780-hd44780-ethlcd.o" + fi AC_CHECK_HEADER(linux/i2c-dev.h, HD44780_DRIVERS="$HD44780_DRIVERS hd44780-hd44780-i2c.o" AC_DEFINE(HAVE_I2C,[1],[Define to 1 if you have the i2c headers]) diff --git a/configure.in b/configure.in index 9909490..cdea0a9 100644 --- a/configure.in +++ b/configure.in @@ -269,6 +269,21 @@ fi AC_SUBST(LIBFTDI_LIBS) AC_SUBST(LIBFTDI_CFLAGS) +dnl ###################################################################### +dnl ethlcd support +dnl ###################################################################### +AC_MSG_CHECKING([if ethlcd support has been enabled]); +AC_ARG_ENABLE(ethlcd, + [AS_HELP_STRING([--disable-ethlcd],[disable ethlcd connection type for HD44780])], + [ if test "$enableval" != "no"; then + enable_ethlcd=yes + fi ], + [ enable_ethlcd=yes ] +) +AC_MSG_RESULT($enable_ethlcd) + + + dnl Select drivers to build LCD_DRIVERS_SELECT diff --git a/docs/LCDd.8.in b/docs/LCDd.8.in index 4b4c7f0..e289f14 100644 --- a/docs/LCDd.8.in +++ b/docs/LCDd.8.in @@ -166,6 +166,9 @@ LCD in 4-bit mode driven by PCF8574(A) / PCA9554(A), connected via I2C bus .TP .B ftdi USB connection via a FTDI FT2232D chip in bitbang mode +.TP +.B ethlcd +TCP connection using open source/open hardware ethlcd (http://manio.skyboo.net/ethlcd/) .RE .TP .B icp_a106 diff --git a/docs/lcdproc-user/drivers/hd44780.docbook b/docs/lcdproc-user/drivers/hd44780.docbook index dd02961..0aa49ca 100644 --- a/docs/lcdproc-user/drivers/hd44780.docbook +++ b/docs/lcdproc-user/drivers/hd44780.docbook @@ -118,6 +118,11 @@ more important. Here are the USB connection types the HD44780 driver supports: ftdi: Display connected to a dual channel FTDI 2232D USB chip + + + ethlcd: + Display connected via TCP to PoE powered ethlcd device () + @@ -1849,6 +1854,20 @@ please look at the driver source if you really need that. + +ethlcd device + + +ethlcd () +is a PoE powered device controlled via TCP. It has a 3-state (ON, HALF, OFF) backlight +control, 6 buttons and a beeper. The hardware and software are open source. +To use it, specify the device IP address or hostname, on which the ethlcd device is +accessible by setting in config file the Device value. +The default is ethlcd. + + + + LIS2 USB device "lis2" diff --git a/server/drivers/Makefile.am b/server/drivers/Makefile.am index b63b35c..aba3b4f 100644 --- a/server/drivers/Makefile.am +++ b/server/drivers/Makefile.am @@ -80,7 +80,7 @@ g15_SOURCES = lcd.h lcd_lib.h g15.h g15-num.c g15.c 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-serial.c hd44780-serial.h hd44780-winamp.c hd44780-winamp.h hd44780-bwct-usb.c hd44780-bwct-usb.h hd44780-lcd2usb.c hd44780-lcd2usb.h hd44780-lis2.c hd44780-lis2.h hd44780-i2c.c hd44780-i2c.h hd44780-ftdi.c hd44780-ftdi.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-lcd2usb.c hd44780-lcd2usb.h hd44780-lis2.c hd44780-lis2.h hd44780-i2c.c hd44780-i2c.h hd44780-ftdi.c hd44780-ftdi.h hd44780-ethlcd.c hd44780-ethlcd.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-drivers.h b/server/drivers/hd44780-drivers.h index 61f09bd..a52f96c 100644 --- a/server/drivers/hd44780-drivers.h +++ b/server/drivers/hd44780-drivers.h @@ -29,6 +29,7 @@ #ifdef HAVE_I2C # include "hd44780-i2c.h" #endif +# include "hd44780-ethlcd.h" // add new connection type header files here @@ -67,6 +68,8 @@ static const ConnectionMapping connectionMapping[] = { #ifdef HAVE_I2C { "i2c", HD44780_CT_I2C, IF_TYPE_I2C, hd_init_i2c }, #endif + /* TCP socket connection types */ + { "ethlcd", HD44780_CT_ETHLCD, IF_TYPE_TCP, hd_init_ethlcd }, // add new connection types here // .... // default, end of structure element (do not delete) diff --git a/server/drivers/hd44780-ethlcd.c b/server/drivers/hd44780-ethlcd.c new file mode 100644 index 0000000..53c8ffd --- /dev/null +++ b/server/drivers/hd44780-ethlcd.c @@ -0,0 +1,154 @@ +/** \file hd44780-ethlcd.c + * \c ethlcd connection type of \c hd44780 driver for Hitachi HD44780 based LCD displays. + */ + +/* + * ethlcd ethernet driver module for Hitachi HD44780 based LCD displays + * ethlcd is an opensource project based on atmel's atmega microcontroller + * and enc28j60 ethernet device. The device is connected via ethernet, has own + * IP address and is available via TCP protocol. More info at project homepage: + * http://manio.skyboo.net/ethlcd/ + * + * Copyright (c) 2008 Mariusz Bialonczyk + * + * This file is released under the GNU General Public License. Refer to the + * COPYING file distributed with this package. + * + */ + +#include "hd44780-ethlcd.h" +#include "hd44780-low.h" +#include "../../shared/sockets.h" +#include "report.h" + +#include +#include +#include +#include + + +void ethlcd_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch); +unsigned char ethlcd_HD44780_scankeypad(PrivateData *p); +void ethlcd_HD44780_backlight(PrivateData *p, unsigned char state); +void ethlcd_HD44780_close(PrivateData *p); +// fake pause function (pausing is handled by ethlcd device itself) +void ethlcd_HD44780_uPause(PrivateData *p, int usecs) {} + + +// initialisation function +int hd_init_ethlcd(Driver *drvthis) +{ + char hostname[HOST_NAME_MAX]; + long flags; + + PrivateData *p = (PrivateData*) drvthis->private_data; + HD44780_functions *hd44780_functions = p->hd44780_functions; + + hd44780_functions->senddata = ethlcd_HD44780_senddata; + hd44780_functions->backlight = ethlcd_HD44780_backlight; + hd44780_functions->scankeypad = ethlcd_HD44780_scankeypad; + hd44780_functions->uPause = ethlcd_HD44780_uPause; + hd44780_functions->close = ethlcd_HD44780_close; + + //reading configuration file + strncpy(hostname, drvthis->config_get_string(drvthis->name, "Device", 0, "ethlcd"), sizeof(hostname)); + + p->sock = sock_connect(hostname, DEFAULT_ETHLCD_PORT); + if (p->sock < 0) { + report(RPT_ERR, "Connecting to %s:%d failed", hostname, DEFAULT_ETHLCD_PORT); + return -1; + } + + //we need to have a blocking read back again: + if (fcntl(p->sock, F_GETFL, &flags) < 0) + { + report(RPT_ERR, "Cannot set the socket to blocking mode"); + return -1; + } + flags &= ~O_NONBLOCK; + fcntl(p->sock, F_SETFL, flags); + + // Set up two-line, small character (5x8) mode + hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | IF_4BIT | TWOLINE | SMALLCHAR); + + common_init(p, IF_4BIT); + + if (p->have_keypad) { + // Remember which input lines are stuck + p->stuckinputs = 0; + } + + return 0; +} + + +// ethlcd_HD44780_senddata +void ethlcd_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch) +{ + static char buff[2]; + + if (flags == RS_INSTR) + buff[0] = ETHLCD_SEND_INSTR; + else //if (flags == RS_DATA) + buff[0] = ETHLCD_SEND_DATA; + buff[1] = ch; + + sock_send(p->sock, buff, 2); //send data to device + sock_recv(p->sock, &buff, 1); //wait for reply +} + + +unsigned char ethlcd_HD44780_scankeypad(PrivateData *p) +{ + unsigned char readval; + static char buff[2]; + + buff[0] = ETHLCD_GET_BUTTONS; + + sock_send(p->sock, buff, 1); //send data to device + sock_recv(p->sock, &buff, 2); //wait for answer + + if (buff[0] != ETHLCD_GET_BUTTONS) //check if this is true reply for our packet + return 0; + //answer should be in second byte on bits 0-6 in negative logic: + readval = buff[1]; + + readval = ~readval & 0x3F; //reverse logic + switch (readval) + { + case 1: return(0x34); //C + case 2: return(0x24); //B + case 4: return(0x14); //A + case 8: return(0x25); //F + case 16: return(0x15); //E + case 32: return(0x44); //D + default: return('\0'); + } +} + + +void ethlcd_HD44780_backlight(PrivateData *p, unsigned char state) +{ + static char buff[2]; + + buff[0] = ETHLCD_SET_BACKLIGHT; + + if (state == BACKLIGHT_ON) + { + if (p->brightness >= 500) + buff[1] = ETHLCD_BACKLIGHT_ON; + else + buff[1] = ETHLCD_BACKLIGHT_HALF; + } + else + buff[1] = ETHLCD_BACKLIGHT_OFF; + + sock_send(p->sock, buff, 2); //send data to device + sock_recv(p->sock, &buff, 1); //wait for reply +} + + +void ethlcd_HD44780_close(PrivateData *p) +{ + sock_close(p->sock); +} diff --git a/server/drivers/hd44780-ethlcd.h b/server/drivers/hd44780-ethlcd.h new file mode 100644 index 0000000..a68f2cb --- /dev/null +++ b/server/drivers/hd44780-ethlcd.h @@ -0,0 +1,27 @@ +#ifndef HD_ETHLCD_H +#define HD_ETHLCD_H + +#include "lcd.h" /* for Driver */ + +// initialise this particular driver +int hd_init_ethlcd(Driver *drvthis); + +#define DEFAULT_ETHLCD_PORT 2425 + +// ethlcd protocol constants: +#define ETHLCD_SEND_INSTR 0x01 +#define ETHLCD_SEND_DATA 0x02 +#define ETHLCD_GET_BUTTONS 0x03 +#define ETHLCD_SET_BACKLIGHT 0x04 +#define ETHLCD_SET_BEEP 0x05 +#define ETHLCD_GET_FIRMWARE_VERSION 0x06 +#define ETHLCD_GET_PROTOCOL_VERSION 0x07 +#define ETHLCD_GET_ENC_REVISION 0x08 +#define ETHLCD_CLOSE_CONN 0x09 +#define ETHLCD_UNRECOGNIZED_COMMAND 0x0A + +#define ETHLCD_BACKLIGHT_ON 0x01 +#define ETHLCD_BACKLIGHT_HALF 0x02 +#define ETHLCD_BACKLIGHT_OFF 0x03 + +#endif diff --git a/server/drivers/hd44780-low.h b/server/drivers/hd44780-low.h index 2c55186..f816755 100644 --- a/server/drivers/hd44780-low.h +++ b/server/drivers/hd44780-low.h @@ -47,6 +47,7 @@ #define HD44780_CT_LCDUSB 14 #define HD44780_CT_FTDI 15 #define HD44780_CT_I2C 16 +#define HD44780_CT_ETHLCD 17 // symbolic names for interface types #define IF_TYPE_UNKNOWN 0 @@ -54,6 +55,7 @@ #define IF_TYPE_SERIAL 2 #define IF_TYPE_USB 3 #define IF_TYPE_I2C 4 +#define IF_TYPE_TCP 5 // symbolic default values #define DEFAULT_CONTRAST 800 @@ -118,6 +120,8 @@ typedef struct driver_private_data { int ftdi_line_backlight; #endif + int sock; /* socket for TCP devices */ + int charmap; int width, height; diff --git a/server/drivers/hd44780.c b/server/drivers/hd44780.c index efb6207..ae3c2bb 100644 --- a/server/drivers/hd44780.c +++ b/server/drivers/hd44780.c @@ -439,6 +439,13 @@ HD44780_init(Driver *drvthis) (p->have_output?" out":"") ); break; + case IF_TYPE_TCP: + sprintf(buf, "TCP %s%s%s", + (p->have_backlight?" bl":""), + (p->have_keypad?" key":""), + (p->have_output?" out":"") + ); + break; case IF_TYPE_PARPORT: default: sprintf(buf, "LPT 0x%x%s%s%s", p->port,