diff --git a/README b/README index aaaf546..06d2ff4 100644 --- a/README +++ b/README @@ -5,7 +5,7 @@ devices. The server works with different display sizes and supports several serial devices: Matrix Orbital, Crystal Fontz, Bayrad, LB216, LCDM001 (kernelconcepts.de), Wirz-SLI and PIC-an-LCD; some devices connected to the parallel port: HD44780, STV5730, T6963, SED1520 and SED1330; and also -some displays connected via USB: CFonz633, CwLnx, USBLCD, IOWarrior and +some displays connected via USB: CFonz633, CwLnx, USBLCD, IOWarrior, LIS2 and HD44780 (ConnectionType=bwctusb). Various clients are available that display things like CPU load, system load, memory usage, uptime, and a lot more. diff --git a/acinclude.m4 b/acinclude.m4 index 97fd98b..7853afc 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -138,9 +138,9 @@ dnl else ;; hd44780) if test "$ac_cv_port_have_lpt" = yes ; then - HD44780_DRIVERS="hd44780-4bit.o hd44780-ext8bit.o lcd_sem.o hd44780-winamp.o hd44780-serialLpt.o hd44780-picanlcd.o hd44780-lcdserializer.o" + HD44780_DRIVERS="hd44780-4bit.o hd44780-ext8bit.o lcd_sem.o hd44780-winamp.o hd44780-serialLpt.o hd44780-picanlcd.o hd44780-lcdserializer.o hd44780-lis2.o" else - HD44780_DRIVERS="hd44780-picanlcd.o hd44780-lcdserializer.o" + HD44780_DRIVERS="hd44780-picanlcd.o hd44780-lcdserializer.o hd44780-lis2.o" fi if test "$enable_libusb" = yes ; then HD44780_DRIVERS="$HD44780_DRIVERS hd44780-bwct-usb.o" diff --git a/docs/hd44780_howto.txt b/docs/hd44780_howto.txt index 94c9094..ad9e45b 100644 --- a/docs/hd44780_howto.txt +++ b/docs/hd44780_howto.txt @@ -544,6 +544,77 @@ To use it, specify the device to which you have connected the module in the config file with the Device= setting. The default is /dev/lcd. It does not support a keypad nor backlight switching. +1.7 LIS2 Usb device +=================== + +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 wich map the usb port to a serial port (/dev/ttyUSBx). + +To use LIS2 with LCDproc, you will need a few settings in the config file : + +[server] + Driver=hd44780 + +[hd44780] + size=20x2 + ConnectionType=lis2 + #Device=/dev/ttyUSB0 + extendedmode=false + +Size of the display (size=20x2), driver to use in ConnectionType: lis2, the serial Usb +device as device settings (default is /dev/ttyUSB0), and extendedmode should be left to false, +as this device don't seems to support hd44780 extended mode. + +The device support only a subset of the hd44780 specification. For now, I find this function: + +Function #1 : Clear Screen + +Send char(0) +Send char(160) +Send char(0) +Send char(167) + +Function #2 : Cursors move: (x,y) + +Send char(0) +Send char(160 + y) +Send char(x) +Send char(167) + +Function #3 : Write a char + +Send char(asciiCode) : asciiCode 0 to 7 can be redefine to user charset (see below). + +Function #4 : Redefine a char + +Send char(0) +Send char(171) +Send char(matriceNum) : Ascii code of char to refine, from 0 to 7 +Send char(line) : the line to change +Send char(pixel) : define wich pixel of the line is on or off. +There's 5 pixels by line, adresse by power of 2, from right to left (16, 8, 4, 2, 1). + +Function #5 : Fan Control + +Send char(0) +Send char(174) +Send char(0) +Send char(0) +Send char(fan1) +Send char(0) +Send char(fan2) +Send char(0) +Send char(fan3) +Send char(0) +Send char(fan4) +Send char(0) +Send char(0) + +fanX is a value from 0 to 255, 0 is fan off, 255 is fan full speed. + + + 1.5.1 Keypad ------------ diff --git a/server/drivers/Makefile.am b/server/drivers/Makefile.am index d821531..9d06f92 100644 --- a/server/drivers/Makefile.am +++ b/server/drivers/Makefile.am @@ -50,7 +50,7 @@ CFontz633_SOURCES = lcd.h CFontz633.c CFontz633.h CFontz-charmap.h CFontz633io. curses_SOURCES = lcd.h curses_drv.h curses_drv.c report.h glk_SOURCES = lcd.h glk.c glk.h glkproto.c glkproto.h report.h hd44780_SOURCES = lcd.h hd44780.h hd44780.c hd44780-drivers.h hd44780-low.h hd44780-charmap.h report.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 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-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 port.h lpt-port.h timing.h icp_a106_SOURCES = lcd.h icp_a106.c icp_a106.h report.h IOWarrior_SOURCES = lcd.h lcd_lib.h hd44780-charmap.h IOWarrior.c IOWarrior.h report.h diff --git a/server/drivers/hd44780-drivers.h b/server/drivers/hd44780-drivers.h index cd43dce..fca4aec 100644 --- a/server/drivers/hd44780-drivers.h +++ b/server/drivers/hd44780-drivers.h @@ -22,6 +22,7 @@ #endif #include "hd44780-picanlcd.h" #include "hd44780-lcdserializer.h" +#include "hd44780-lis2.h" // add new connection type header files here static const ConnectionMapping connectionMapping[] = { @@ -37,6 +38,7 @@ static const ConnectionMapping connectionMapping[] = { #endif {"picanlcd", hd_init_picanlcd, "\tnone\n"}, {"lcdserializer", hd_init_lcdserializer, "\tnone\n"}, + {"lis2", hd_init_lis2, "\tnone\n"}, #ifdef HAVE_LIBUSB {"bwctusb", hd_init_bwct_usb, "\tnone\n"}, #endif diff --git a/server/drivers/hd44780-lis2.c b/server/drivers/hd44780-lis2.c new file mode 100644 index 0000000..e48d1db --- /dev/null +++ b/server/drivers/hd44780-lis2.c @@ -0,0 +1,228 @@ +/* + * LIS2 Serializer driver + * Modification of the code of the LCDSerializer 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 + * 2005, Laurent ARNAL + * + * This file is released under the GNU General Public License. Refer to the + * COPYING file distributed with this package. + * + * + * + * + */ + +#include "hd44780-lis2.h" +#include "hd44780-low.h" + +#include "report.h" + +#include +#include +#include + +#include +#include +#include +#include + +#include + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + + +void lis2_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch); +void lis2_HD44780_backlight (PrivateData *p, unsigned char state); +unsigned char lis2_HD44780_scankeypad (PrivateData *p); +void SetMatrice(PrivateData *p,int fd, int matriceNum, int ligne, int point); +void SetFan(int fd, int fan1, int fan2, int fan3, int fan4); +void gotoXY(int fd, int x, int y); +void test(PrivateData *p, int a); +void clear(int fd); + + +#define DEFAULT_DEVICE "/dev/ttyUSB0" + +void writeChar(int fd, int code); + +// initialise the driver +int hd_init_lis2 (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; + printf("HD44780: LCD Serializer: Using device: %s", device); + + // Set up io port correctly, and open it... + p->fd = open(device, O_RDWR | O_NOCTTY); + if (p->fd == -1) { + printf("HD44780: LCD Serializer: could not open device %s (%s)\n", device, strerror(errno)); + return -1; + } + + /* Get serial device parameters */ + tcgetattr(p->fd, &portset); + + 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 ; + portset.c_cc[VMIN] = 1; + portset.c_cc[VTIME] = 3; + + /* Set port speed to 9600 baud */ + cfsetospeed(&portset, B19200); + cfsetispeed (&portset, B0); + + /* Set TCSANOW mode of serial device */ + tcsetattr(p->fd, TCSANOW, &portset); + + + + p->hd44780_functions->senddata = lis2_HD44780_senddata; + p->hd44780_functions->backlight = lis2_HD44780_backlight; + p->hd44780_functions->scankeypad = lis2_HD44780_scankeypad; + + common_init (p, IF_8BIT); + + return 0; +} + + +void SetMatrice(PrivateData *p, int fd, int matriceNum, int ligne, int point) +{ + // char from 0 to 7 + // line from 0 to 7 from top to bottom + // pixel 0/1 is 5 bit coding from 0 to 31 from right to left (16/8/4/2/1) + writeChar(p->fd,0); + writeChar(p->fd,171); + writeChar(p->fd, matriceNum); + writeChar(fd, ligne); + writeChar(fd, point); +} + +void SetFan(int fd, int fan1, int fan2, int fan3, int fan4) +{ + writeChar(fd, 0); + writeChar(fd, 174); + writeChar(fd, 0); + writeChar(fd, 0); + writeChar(fd, fan1); + writeChar(fd, 0); + writeChar(fd, fan2); + writeChar(fd, 0); + writeChar(fd, fan3); + writeChar(fd, 0); + writeChar(fd, fan4); + writeChar(fd, 0); + writeChar(fd, 0); +} + +void gotoXY(int fd, int x, int y) +{ + writeChar(fd, 0); + writeChar(fd, 160+y); + writeChar(fd, x); + writeChar(fd, 167); +} + +void writeChar(int fd, int code) +{ + char buf = code; + + write(fd, &buf, 1); +} + +int mode = 0; +int charNum = 0; +int rowNum = 0; + +void lis2_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch) +{ + if (flags == RS_DATA) { + if (mode == SETCHAR) + { + writeChar( p->fd, 0); + writeChar( p->fd, 171); + writeChar( p->fd, charNum); + writeChar( p->fd, rowNum); + writeChar( p->fd, ch); + rowNum = rowNum + 1; + if (rowNum==p->cellheight) + { + mode = 0; + rowNum = 0; + } + } + else + { + if (ch<7) ch=ch+1; + write( p->fd, &ch, 1 ); + } + } + else { + if ((ch & POSITION)!=0) + { + int x = 0; + int y = 0; + int pos = 0; + + pos = (ch & ~POSITION); + + if (p->ext_mode) { + y = pos/0x20; + x = pos-(y*0x20); + } + else { + y = pos/0x40; + x = pos-(y*0x40); + } + + writeChar( p->fd, 0); + writeChar( p->fd, 161 + y); + writeChar( p->fd, x); + writeChar( p->fd, 167); + + } + else if ((ch & SETCHAR)!=0) + { + mode = SETCHAR; + charNum = ((ch & ~SETCHAR)/8) + 1; + if (charNum==8) charNum = 7; + } + else write( p->fd, &ch, 1 ); + } + +} + +void lis2_HD44780_backlight (PrivateData *p, unsigned char state) +{ + /* No backlight control */ +} + +unsigned char lis2_HD44780_scankeypad (PrivateData *p) +{ + return 0; +} + + + + diff --git a/server/drivers/hd44780-lis2.h b/server/drivers/hd44780-lis2.h new file mode 100644 index 0000000..7821a99 --- /dev/null +++ b/server/drivers/hd44780-lis2.h @@ -0,0 +1,9 @@ +#ifndef HD_LIS2_H +#define HD_LIS2_H + +#include "lcd.h" /* for Driver */ + +// initialise this particular driver +int hd_init_lis2 (Driver *drvthis); + +#endif