From b285743489e7d237cb32fc3aaae0ffdad6c264a4 Mon Sep 17 00:00:00 2001 From: reinelt <> Date: Sat, 22 Jan 2005 22:57:57 +0000 Subject: [lcd4linux @ 2005-01-22 22:57:57 by reinelt] LCD-Linux driver added --- Makefile.am | 1 + Makefile.in | 37 ++++--- config.h.in | 3 + configure | 27 ++++- drivers.m4 | 21 +++- drv.c | 9 +- drv_LCDLinux.c | 301 ++++++++++++++++++++++++++++++++++++++++++++++++++ drv_LCDTerm.c | 12 +- lcd4linux.conf.sample | 18 +-- 9 files changed, 382 insertions(+), 47 deletions(-) create mode 100644 drv_LCDLinux.c diff --git a/Makefile.am b/Makefile.am index 779b40b..cf89cd2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -64,6 +64,7 @@ drv_Curses.c \ drv_Cwlinux.c \ drv_HD44780.c \ drv_Image.c \ +drv_LCDLinux.c \ drv_LCDTerm.c \ drv_M50530.c \ drv_MatrixOrbital.c \ diff --git a/Makefile.in b/Makefile.in index eda52b5..b64f8c6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -99,7 +99,7 @@ lcd4linux_SOURCES = lcd4linux.c cfg.c cfg.h deb #liblcd4linux_la_SOURCES = -EXTRA_lcd4linux_SOURCES = drv_generic_text.c drv_generic_text.h drv_generic_graphic.c drv_generic_graphic.h drv_generic_serial.c drv_generic_serial.h drv_generic_parport.c drv_generic_parport.h drv_BeckmannEgle.c drv_BWCT.c drv_Crystalfontz.c drv_Curses.c drv_Cwlinux.c drv_HD44780.c drv_Image.c drv_LCDTerm.c drv_M50530.c drv_MatrixOrbital.c drv_MilfordInstruments.c drv_NULL.c drv_RouterBoard.c drv_T6963.c drv_USBLCD.c drv_X11.c font_6x8.h plugin_apm.c plugin_cpuinfo.c plugin_diskstats.c plugin_dvb.c plugin_exec.c plugin_i2c_sensors.c plugin_imon.c plugin_isdn.c plugin_loadavg.c plugin_meminfo.c plugin_mysql.c plugin_netdev.c plugin_pop3.c plugin_ppp.c plugin_proc_stat.c plugin_seti.c plugin_uname.c plugin_uptime.c plugin_wireless.c plugin_xmms.c +EXTRA_lcd4linux_SOURCES = drv_generic_text.c drv_generic_text.h drv_generic_graphic.c drv_generic_graphic.h drv_generic_serial.c drv_generic_serial.h drv_generic_parport.c drv_generic_parport.h drv_BeckmannEgle.c drv_BWCT.c drv_Crystalfontz.c drv_Curses.c drv_Cwlinux.c drv_HD44780.c drv_Image.c drv_LCDLinux.c drv_LCDTerm.c drv_M50530.c drv_MatrixOrbital.c drv_MilfordInstruments.c drv_NULL.c drv_RouterBoard.c drv_T6963.c drv_USBLCD.c drv_X11.c font_6x8.h plugin_apm.c plugin_cpuinfo.c plugin_diskstats.c plugin_dvb.c plugin_exec.c plugin_i2c_sensors.c plugin_imon.c plugin_isdn.c plugin_loadavg.c plugin_meminfo.c plugin_mysql.c plugin_netdev.c plugin_pop3.c plugin_ppp.c plugin_proc_stat.c plugin_seti.c plugin_uname.c plugin_uptime.c plugin_wireless.c plugin_xmms.c EXTRA_DIST = lcd4linux.conf.sample lcd4kde.conf lcd4linux.kdelnk lcd4linux.xpm lcd4linux.lsm curses.m4 AUTHORS CREDITS FAQ NEWS TODO README README.Drivers README.Plugins README.KDE plugin_sample.c @@ -140,23 +140,24 @@ GZIP_ENV = --best DEP_FILES = .deps/cfg.P .deps/debug.P .deps/drv.P .deps/drv_BWCT.P \ .deps/drv_BeckmannEgle.P .deps/drv_Crystalfontz.P .deps/drv_Curses.P \ .deps/drv_Cwlinux.P .deps/drv_HD44780.P .deps/drv_Image.P \ -.deps/drv_LCDTerm.P .deps/drv_M50530.P .deps/drv_MatrixOrbital.P \ -.deps/drv_MilfordInstruments.P .deps/drv_NULL.P .deps/drv_RouterBoard.P \ -.deps/drv_T6963.P .deps/drv_USBLCD.P .deps/drv_X11.P \ -.deps/drv_generic_graphic.P .deps/drv_generic_parport.P \ -.deps/drv_generic_serial.P .deps/drv_generic_text.P .deps/evaluator.P \ -.deps/hash.P .deps/layout.P .deps/lcd4linux.P .deps/pid.P \ -.deps/plugin.P .deps/plugin_apm.P .deps/plugin_cfg.P \ -.deps/plugin_cpuinfo.P .deps/plugin_diskstats.P .deps/plugin_dvb.P \ -.deps/plugin_exec.P .deps/plugin_i2c_sensors.P .deps/plugin_imon.P \ -.deps/plugin_isdn.P .deps/plugin_loadavg.P .deps/plugin_math.P \ -.deps/plugin_meminfo.P .deps/plugin_mysql.P .deps/plugin_netdev.P \ -.deps/plugin_pop3.P .deps/plugin_ppp.P .deps/plugin_proc_stat.P \ -.deps/plugin_seti.P .deps/plugin_string.P .deps/plugin_test.P \ -.deps/plugin_time.P .deps/plugin_uname.P .deps/plugin_uptime.P \ -.deps/plugin_wireless.P .deps/plugin_xmms.P .deps/qprintf.P \ -.deps/thread.P .deps/timer.P .deps/udelay.P .deps/widget.P \ -.deps/widget_bar.P .deps/widget_icon.P .deps/widget_text.P +.deps/drv_LCDLinux.P .deps/drv_LCDTerm.P .deps/drv_M50530.P \ +.deps/drv_MatrixOrbital.P .deps/drv_MilfordInstruments.P \ +.deps/drv_NULL.P .deps/drv_RouterBoard.P .deps/drv_T6963.P \ +.deps/drv_USBLCD.P .deps/drv_X11.P .deps/drv_generic_graphic.P \ +.deps/drv_generic_parport.P .deps/drv_generic_serial.P \ +.deps/drv_generic_text.P .deps/evaluator.P .deps/hash.P .deps/layout.P \ +.deps/lcd4linux.P .deps/pid.P .deps/plugin.P .deps/plugin_apm.P \ +.deps/plugin_cfg.P .deps/plugin_cpuinfo.P .deps/plugin_diskstats.P \ +.deps/plugin_dvb.P .deps/plugin_exec.P .deps/plugin_i2c_sensors.P \ +.deps/plugin_imon.P .deps/plugin_isdn.P .deps/plugin_loadavg.P \ +.deps/plugin_math.P .deps/plugin_meminfo.P .deps/plugin_mysql.P \ +.deps/plugin_netdev.P .deps/plugin_pop3.P .deps/plugin_ppp.P \ +.deps/plugin_proc_stat.P .deps/plugin_seti.P .deps/plugin_string.P \ +.deps/plugin_test.P .deps/plugin_time.P .deps/plugin_uname.P \ +.deps/plugin_uptime.P .deps/plugin_wireless.P .deps/plugin_xmms.P \ +.deps/qprintf.P .deps/thread.P .deps/timer.P .deps/udelay.P \ +.deps/widget.P .deps/widget_bar.P .deps/widget_icon.P \ +.deps/widget_text.P SOURCES = $(lcd4linux_SOURCES) $(EXTRA_lcd4linux_SOURCES) OBJECTS = $(lcd4linux_OBJECTS) diff --git a/config.h.in b/config.h.in index a05eb4b..2ed609e 100644 --- a/config.h.in +++ b/config.h.in @@ -332,6 +332,9 @@ /* HD44780 driver */ #undef WITH_HD44780 +/* LCD-Linux driver */ +#undef WITH_LCDLINUX + /* LCDTerm driver */ #undef WITH_LCDTERM diff --git a/configure b/configure index a4e4564..e084bf6 100755 --- a/configure +++ b/configure @@ -868,8 +868,9 @@ Optional Packages: (try 'all,\!' if your shell complains...) possible drivers are: BeckmannEgle, BWCT, CrystalFontz, Curses, Cwlinux, - HD44780, LCDTerm, M50530, MatrixOrbital, MilfordInstruments, - NULL, PNG, PPM, RouterBoard, T6963, USBLCD, X11 + HD44780, LCDLinux, LCDTerm, M50530, MatrixOrbital, + MilfordInstruments, NULL, PNG, PPM, RouterBoard, + T6963, USBLCD, X11 --with-plugins= choose which plugins to compile. type --with-plugins=list for a list of avaible plugins @@ -3398,7 +3399,7 @@ echo "${ECHO_T}Please note that some screen refreshs may fail" >&6 echo $ECHO_N "checking for ncurses version... $ECHO_C" >&6 ncurses_version=unknown cat > conftest.$ac_ext < @@ -5406,7 +5407,8 @@ for driver in $drivers; do CURSES="yes" CWLINUX="yes" HD44780="yes" - LCDTerm="yes" + LCDLINUX="yes" + LCDTERM="yes" M50530="yes" MATRIXORBITAL="yes" MILINST="yes" @@ -5436,8 +5438,11 @@ for driver in $drivers; do HD44780) HD44780=$val ;; + LCDLINUX) + LCDLINUX=$val + ;; LCDTerm) - LCDTerm=$val + LCDTERM=$val ;; M50530) M50530=$val @@ -5562,7 +5567,17 @@ _ACEOF fi -if test "$LCDTerm" = "yes"; then +if test "$LCDLINUX" = "yes"; then + TEXT="yes" + DRIVERS="$DRIVERS drv_LCDLinux.o" + +cat >>confdefs.h <<\_ACEOF +#define WITH_LCDLINUX 1 +_ACEOF + +fi + +if test "$LCDTERM" = "yes"; then TEXT="yes" SERIAL="yes" DRIVERS="$DRIVERS drv_LCDTerm.o" diff --git a/drivers.m4 b/drivers.m4 index cdc8848..f98ac22 100644 --- a/drivers.m4 +++ b/drivers.m4 @@ -29,8 +29,9 @@ AC_ARG_WITH( [ (try 'all,\!' if your shell complains...)] [ possible drivers are:] [ BeckmannEgle, BWCT, CrystalFontz, Curses, Cwlinux,] - [ HD44780, LCDTerm, M50530, MatrixOrbital, MilfordInstruments,] - [ NULL, PNG, PPM, RouterBoard, T6963, USBLCD, X11], + [ HD44780, LCDLinux, LCDTerm, M50530, MatrixOrbital,] + [ MilfordInstruments, NULL, PNG, PPM, RouterBoard,] + [ T6963, USBLCD, X11], drivers=$withval, drivers=all ) @@ -57,7 +58,8 @@ for driver in $drivers; do CURSES="yes" CWLINUX="yes" HD44780="yes" - LCDTerm="yes" + LCDLINUX="yes" + LCDTERM="yes" M50530="yes" MATRIXORBITAL="yes" MILINST="yes" @@ -87,8 +89,11 @@ for driver in $drivers; do HD44780) HD44780=$val ;; + LCDLINUX) + LCDLINUX=$val + ;; LCDTerm) - LCDTerm=$val + LCDTERM=$val ;; M50530) M50530=$val @@ -184,7 +189,13 @@ if test "$HD44780" = "yes"; then AC_DEFINE(WITH_HD44780,1,[HD44780 driver]) fi -if test "$LCDTerm" = "yes"; then +if test "$LCDLINUX" = "yes"; then + TEXT="yes" + DRIVERS="$DRIVERS drv_LCDLinux.o" + AC_DEFINE(WITH_LCDLINUX,1,[LCD-Linux driver]) +fi + +if test "$LCDTERM" = "yes"; then TEXT="yes" SERIAL="yes" DRIVERS="$DRIVERS drv_LCDTerm.o" diff --git a/drv.c b/drv.c index 5de94fd..af4b975 100644 --- a/drv.c +++ b/drv.c @@ -1,4 +1,4 @@ -/* $Id: drv.c,v 1.25 2005/01/18 06:30:22 reinelt Exp $ +/* $Id: drv.c,v 1.26 2005/01/22 22:57:57 reinelt Exp $ * * new framework for display drivers * @@ -23,6 +23,9 @@ * * * $Log: drv.c,v $ + * Revision 1.26 2005/01/22 22:57:57 reinelt + * LCD-Linux driver added + * * Revision 1.25 2005/01/18 06:30:22 reinelt * added (C) to all copyright statements * @@ -183,6 +186,7 @@ extern DRIVER drv_Curses; extern DRIVER drv_Cwlinux; extern DRIVER drv_HD44780; extern DRIVER drv_Image; +extern DRIVER drv_LCDLinux; extern DRIVER drv_LCDTerm; extern DRIVER drv_M50530; extern DRIVER drv_MatrixOrbital; @@ -221,6 +225,9 @@ DRIVER *Driver[] = { #if defined (WITH_PNG) || defined(WITH_PPM) &drv_Image, #endif +#ifdef WITH_LCDLinux + &drv_LCDLinux, +#endif #ifdef WITH_LCDTERM &drv_LCDTerm, #endif diff --git a/drv_LCDLinux.c b/drv_LCDLinux.c new file mode 100644 index 0000000..1acde9b --- /dev/null +++ b/drv_LCDLinux.c @@ -0,0 +1,301 @@ +/* $Id: drv_LCDLinux.c,v 1.1 2005/01/22 22:57:57 reinelt Exp $ + * + * driver for the LCD-Linux HD44780 kernel driver + * http://lcd-linux.sourceforge.net + * + * Copyright (C) 2005 Michael Reinelt + * Copyright (C) 2005 The LCD4Linux Team + * + * This file is part of LCD4Linux. + * + * LCD4Linux is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * LCD4Linux is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * $Log: drv_LCDLinux.c,v $ + * Revision 1.1 2005/01/22 22:57:57 reinelt + * LCD-Linux driver added + * + */ + +/* + * + * exported fuctions: + * + * struct DRIVER drv_LCDLinux + * + */ + +#include "config.h" + +#include +#include +#include +#include +#include + +#include "debug.h" +#include "cfg.h" +#include "qprintf.h" +#include "plugin.h" +#include "widget.h" +#include "widget_text.h" +#include "widget_icon.h" +#include "widget_bar.h" +#include "drv.h" +#include "drv_generic_text.h" + +static char Name[]="LCD-Linux"; + + +/****************************************/ +/*** hardware dependant functions ***/ +/****************************************/ + +static void drv_LL_clear (void) +{ + char cmd[1]; + + /* Fixme */ +#if 0 + cmd[0] = LCD_CLEAR; /* clear display */ + drv_generic_serial_write (cmd, 1); /* clear screen */ +#endif + +} + + +static int drv_LL_send (const char request, const char value) +{ + char buf[2]; + + buf[0] = request; + buf[1] = value; + + // Fixme + // drv_generic_serial_write (buf, 2); + + return 0; +} + + +static void drv_LL_command (const char cmd) +{ + // Fixme + // drv_LL_send (LCD_CMD, cmd); +} + + +static void drv_LL_write (const int row, const int col, const char *data, int len) +{ + int pos; + + /* 16x4 Displays use a slightly different layout */ + if (DCOLS==16 && DROWS==4) { + pos = (row%2)*64+(row/2)*16+col; + } else { + pos = (row%2)*64+(row/2)*20+col; + } + + drv_LL_command (0x80|pos); + + while (len--) { + // Fixme + // drv_LL_send (LCD_DATA, *data++); + } +} + +static void drv_LL_defchar (const int ascii, const unsigned char *matrix) +{ + int i; + + drv_LL_command (0x40|8*ascii); + + for (i = 0; i < 8; i++) { + // Fixme + // drv_LL_send (LCD_DATA, *matrix++ & 0x1f); + } +} + + +static int drv_LL_start (const char *section, const int quiet) +{ + int rows=-1, cols=-1; + char *s; + + /* Fixme: open device */ + + s=cfg_get(section, "Size", NULL); + if (s==NULL || *s=='\0') { + error ("%s: no '%s.Size' entry from %s", Name, section, cfg_source()); + return -1; + } + if (sscanf(s,"%dx%d",&cols,&rows)!=2 || rows<1 || cols<1) { + error ("%s: bad %s.Size '%s' from %s", Name, section, s, cfg_source()); + free (s); + return -1; + } + + DROWS = rows; + DCOLS = cols; + + /* initialize display */ + drv_LL_command (0x29); /* 8 Bit mode, 1/16 duty cycle, 5x8 font */ + drv_LL_command (0x08); /* Display off, cursor off, blink off */ + drv_LL_command (0x0c); /* Display on, cursor off, blink off */ + drv_LL_command (0x06); /* curser moves to right, no shift */ + + drv_LL_clear(); /* clear display */ + + if (!quiet) { + char buffer[40]; + qprintf(buffer, sizeof(buffer), "%s %dx%d", Name, DCOLS, DROWS); + if (drv_generic_text_greet (buffer, "www.bwct.de")) { + sleep (3); + drv_LL_clear(); + } + } + + return 0; +} + + +/****************************************/ +/*** plugins ***/ +/****************************************/ + +/* none */ + + +/****************************************/ +/*** widget callbacks ***/ +/****************************************/ + + +/* using drv_generic_text_draw(W) */ +/* using drv_generic_text_icon_draw(W) */ +/* using drv_generic_text_bar_draw(W) */ + + +/****************************************/ +/*** exported functions ***/ +/****************************************/ + + +/* list models */ +int drv_LL_list (void) +{ + printf ("generic"); + return 0; +} + + +/* initialize driver & display */ +int drv_LL_init (const char *section, const int quiet) +{ + WIDGET_CLASS wc; + int asc255bug; + int ret; + + /* display preferences */ + XRES = 5; /* pixel width of one char */ + YRES = 8; /* pixel height of one char */ + CHARS = 8; /* number of user-defineable characters */ + CHAR0 = 0; /* ASCII of first user-defineable char */ + + /* Fixme: */ + GOTO_COST = 2; /* number of bytes a goto command requires */ + + /* real worker functions */ + drv_generic_text_real_write = drv_LL_write; + drv_generic_text_real_defchar = drv_LL_defchar; + + + /* start display */ + if ((ret=drv_LL_start (section, quiet))!=0) + return ret; + + /* initialize generic text driver */ + if ((ret=drv_generic_text_init(section, Name))!=0) + return ret; + + /* initialize generic icon driver */ + if ((ret=drv_generic_text_icon_init())!=0) + return ret; + + /* initialize generic bar driver */ + if ((ret=drv_generic_text_bar_init(0))!=0) + return ret; + + /* add fixed chars to the bar driver */ + /* most displays have a full block on ascii 255, but some have kind of */ + /* an 'inverted P'. If you specify 'asc255bug 1 in the config, this */ + /* char will not be used, but rendered by the bar driver */ + cfg_number(section, "asc255bug", 0, 0, 1, &asc255bug); + drv_generic_text_bar_add_segment ( 0, 0,255, 32); /* ASCII 32 = blank */ + if (!asc255bug) + drv_generic_text_bar_add_segment (255,255,255,255); /* ASCII 255 = block */ + + /* register text widget */ + wc=Widget_Text; + wc.draw=drv_generic_text_draw; + widget_register(&wc); + + /* register icon widget */ + wc=Widget_Icon; + wc.draw=drv_generic_text_icon_draw; + widget_register(&wc); + + /* register bar widget */ + wc=Widget_Bar; + wc.draw=drv_generic_text_bar_draw; + widget_register(&wc); + + /* register plugins */ + /* none */ + + return 0; +} + + +/* close driver & display */ +int drv_LL_quit (const int quiet) +{ + + info("%s: shutting down.", Name); + + drv_generic_text_quit(); + + /* clear display */ + drv_LL_clear(); + + /* say goodbye... */ + if (!quiet) { + drv_generic_text_greet ("goodbye!", NULL); + } + + // Fixme: close device + + return (0); +} + + +DRIVER drv_LCDLinux = { + name: Name, + list: drv_LL_list, + init: drv_LL_init, + quit: drv_LL_quit, +}; + + diff --git a/drv_LCDTerm.c b/drv_LCDTerm.c index 3f524d4..51c7ff1 100644 --- a/drv_LCDTerm.c +++ b/drv_LCDTerm.c @@ -1,4 +1,4 @@ -/* $Id: drv_LCDTerm.c,v 1.2 2005/01/18 06:30:23 reinelt Exp $ +/* $Id: drv_LCDTerm.c,v 1.3 2005/01/22 22:57:57 reinelt Exp $ * * driver for the LCDTerm serial-to-HD44780 adapter boards * http://www.bobblick.com/techref/projects/lcdterm/lcdterm.html @@ -24,6 +24,9 @@ * * * $Log: drv_LCDTerm.c,v $ + * Revision 1.3 2005/01/22 22:57:57 reinelt + * LCD-Linux driver added + * * Revision 1.2 2005/01/18 06:30:23 reinelt * added (C) to all copyright statements * @@ -43,14 +46,7 @@ #include "config.h" #include -#include -#include -#include #include -#include -#include -#include -#include #include "debug.h" #include "cfg.h" diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample index 4faff44..8cfcaef 100644 --- a/lcd4linux.conf.sample +++ b/lcd4linux.conf.sample @@ -63,14 +63,14 @@ Display Curses { Display HD44780-generic { Driver 'HD44780' Model 'generic' - Port '/dev/parports/0' + Port '/dev/parport0' Size '20x4' Wire { RW 'GND' RS 'AUTOFD' ENABLE 'STROBE' ENABLE2 'GND' - GPO 'GND' + GPO 'INIT' } } @@ -79,7 +79,7 @@ Display HD44780-winamp { Driver 'HD44780' Model 'generic' UseBusy 1 - Port '/dev/parports/0' + Port '/dev/parport0' Size '20x4' Wire { RW 'AUTOFD' @@ -95,7 +95,7 @@ Display HD44780-kernelconcepts { Driver 'HD44780' Model 'HD66712' UseBusy 1 - Port '/dev/parports/0' + Port '/dev/parport0' Size '20x4' Wire { RW 'AUTOFD' @@ -108,7 +108,7 @@ Display HD44780-kernelconcepts { Display SC1602D { Driver 'HD44780' - Port '/dev/parports/0' + Port '/dev/parport0' Bits '8' Size '16x2' asc255bug 0 @@ -126,7 +126,7 @@ Display LCM-162 { Driver 'HD44780' Model 'LCM-162' # Bus 'parport' - Port '/dev/parports/0' + Port '/dev/parport0' Size '16x2' UseBusy 1 asc255bug 0 @@ -206,7 +206,7 @@ Display BWCT { Display T6963-240x64 { Driver 'T6963' - Port '/dev/parports/0' + Port '/dev/parport0' Size '240x64' Wire.CE 'STROBE' Wire.CD 'SELECT' @@ -721,14 +721,14 @@ Layout testMySQL { #Display 'LK204' #Display 'MI240' #Display 'CW12232' -#Display 'HD44780-20x4' +Display 'HD44780-generic' #Display 'SC1602D' #Display 'LCM-162' #Display 'CF631' #Display 'CF632' #Display 'CF633' #Display 'Curses' -Display 'M50530-24x8' +#Display 'M50530-24x8' #Display 'LCDTerm' #Display 'CT20x4' #Display 'T6963-240x64' -- cgit v1.2.3