From 6d265a408c14f68886dba867bd9bdb973266f3b3 Mon Sep 17 00:00:00 2001 From: reinelt Date: Wed, 26 May 2004 05:03:27 +0000 Subject: [lcd4linux @ 2004-05-26 05:03:24 by reinelt] MilfordInstruments driver ported git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@435 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- Makefile.am | 4 +- Makefile.in | 10 +- MilfordInstruments.c | 400 ----------------------------------------------- Status | 2 +- configure | 52 +++--- drivers.m4 | 36 ++--- drv.c | 20 +-- drv_MilfordInstruments.c | 259 ++++++++++++++++++++++++++++++ lcd4linux.conf.sample | 13 +- 9 files changed, 333 insertions(+), 463 deletions(-) delete mode 100644 MilfordInstruments.c create mode 100644 drv_MilfordInstruments.c diff --git a/Makefile.am b/Makefile.am index 6825419..fc01a64 100644 --- a/Makefile.am +++ b/Makefile.am @@ -63,10 +63,10 @@ drv_Cwlinux.c \ drv_HD44780.c \ drv_Image.c \ drv_M50530.c \ +drv_MatrixOrbital.c \ +drv_MilfordInstruments.c \ drv_T6963.c \ drv_USBLCD.c \ -drv_MatrixOrbital.c \ -MilfordInstruments.c \ drv_X11.c \ Text.c \ font_6x8.h \ diff --git a/Makefile.in b/Makefile.in index 84b1a20..897aa59 100644 --- a/Makefile.in +++ b/Makefile.in @@ -101,7 +101,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 BeckmannEgle.c drv_Crystalfontz.c drv_Cwlinux.c drv_HD44780.c drv_Image.c drv_M50530.c drv_T6963.c drv_USBLCD.c drv_MatrixOrbital.c MilfordInstruments.c drv_X11.c Text.c font_6x8.h plugin_apm.c plugin_cpuinfo.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 BeckmannEgle.c drv_Crystalfontz.c drv_Cwlinux.c drv_HD44780.c drv_Image.c drv_M50530.c drv_MatrixOrbital.c drv_MilfordInstruments.c drv_T6963.c drv_USBLCD.c drv_X11.c Text.c font_6x8.h plugin_apm.c plugin_cpuinfo.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 @@ -139,10 +139,10 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best -DEP_FILES = .deps/BeckmannEgle.P .deps/MilfordInstruments.P \ -.deps/Text.P .deps/cfg.P .deps/debug.P .deps/drv.P \ -.deps/drv_Crystalfontz.P .deps/drv_Cwlinux.P .deps/drv_HD44780.P \ -.deps/drv_Image.P .deps/drv_M50530.P .deps/drv_MatrixOrbital.P \ +DEP_FILES = .deps/BeckmannEgle.P .deps/Text.P .deps/cfg.P .deps/debug.P \ +.deps/drv.P .deps/drv_Crystalfontz.P .deps/drv_Cwlinux.P \ +.deps/drv_HD44780.P .deps/drv_Image.P .deps/drv_M50530.P \ +.deps/drv_MatrixOrbital.P .deps/drv_MilfordInstruments.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 \ diff --git a/MilfordInstruments.c b/MilfordInstruments.c deleted file mode 100644 index e2fa294..0000000 --- a/MilfordInstruments.c +++ /dev/null @@ -1,400 +0,0 @@ -/* $Id: MilfordInstruments.c,v 1.7 2004/01/30 20:57:55 reinelt Exp $ - * - * driver for Milford Instruments 'BPK' piggy-back serial interface board - * for standard Hitachi 44780 compatible lcd modules. - * - * Copyright 2003 Andy Baxter - * - * based on the MatrixOrbital driver which is - * Copyright 1999, 2000 Michael Reinelt - * - * This program 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. - * - * This program 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: MilfordInstruments.c,v $ - * Revision 1.7 2004/01/30 20:57:55 reinelt - * HD44780 patch from Martin Hejl - * dmalloc integrated - * - * Revision 1.6 2004/01/29 04:40:02 reinelt - * every .c file includes "config.h" now - * - * Revision 1.5 2004/01/09 04:16:06 reinelt - * added 'section' argument to cfg_get(), but NULLed it on all calls by now. - * - * Revision 1.4 2004/01/06 22:33:13 reinelt - * Copyright statements cleaned up - * - * Revision 1.3 2003/10/08 13:39:53 andy-b - * Cleaned up code in MilfordInstruments.c, and added descriptions for other display sizes (untested) - * - * Revision 1.1 2003/09/29 06:58:36 reinelt - * new driver for Milford Instruments MI420 by Andy Baxter - * - */ - -/* - * - * exported fuctions: - * - * struct LCD MilfordInstruments[] - * - */ - -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "debug.h" -#include "cfg.h" -#include "lock.h" -#include "display.h" -#include "bar.h" -#include "icon.h" - -#ifdef WITH_DMALLOC -#include -#endif - -#define XRES 5 -#define YRES 8 -#define CHARS 8 - -static LCD Lcd; -static char *Port=NULL; -static speed_t Speed; -static int Device=-1; -static int Icons; - -static char *FrameBuffer1=NULL; -static char *FrameBuffer2=NULL; - - -static int MI_open (void) -{ - int fd; - pid_t pid; - struct termios portset; - - if ((pid=lock_port(Port))!=0) { - if (pid==-1) - error ("MilfordInstruments: port %s could not be locked", Port); - else - error ("MilfordInstruments: port %s is locked by process %d", Port, pid); - return -1; - } - fd = open(Port, O_RDWR | O_NOCTTY | O_NDELAY); - if (fd==-1) { - error ("MilfordInstruments: open(%s) failed: %s", Port, strerror(errno)); - unlock_port(Port); - return -1; - } - if (tcgetattr(fd, &portset)==-1) { - error ("MilfordInstruments: tcgetattr(%s) failed: %s", Port, strerror(errno)); - unlock_port(Port); - return -1; - } - cfmakeraw(&portset); - cfsetospeed(&portset, Speed); - if (tcsetattr(fd, TCSANOW, &portset)==-1) { - error ("MilfordInstruments: tcsetattr(%s) failed: %s", Port, strerror(errno)); - unlock_port(Port); - return -1; - } - return fd; -} - - -static void MI_write (char *string, int len) -{ - if (Device==-1) return; - if (write (Device, string, len)==-1) { - if (errno==EAGAIN) { - usleep(1000); - if (write (Device, string, len)>=0) return; - } - error ("MilfordInstruments: write(%s) failed: %s", Port, strerror(errno)); - } -} - - -static void MI_define_char (int ascii, char *buffer) -{ - char cmd[2]="\376x"; - if (ascii<8) { - cmd[1]=(char)(64+ascii*8); - MI_write (cmd, 2); - MI_write (buffer, 8); - } -} - - -static int MI_clear (int full) -{ - memset (FrameBuffer1, ' ', Lcd.rows*Lcd.cols*sizeof(char)); - - icon_clear(); - bar_clear(); - - if (full) { - memset (FrameBuffer2, ' ', Lcd.rows*Lcd.cols*sizeof(char)); - MI_write ("\376\001", 2); // clear screen - } - return 0; -} - - -static int MI_init (LCD *Self) -{ - char *port; - int speed; - - Lcd=*Self; - - // Init the framebuffers - FrameBuffer1 = (char*)malloc(Lcd.cols*Lcd.rows*sizeof(char)); - FrameBuffer2 = (char*)malloc(Lcd.cols*Lcd.rows*sizeof(char)); - if (FrameBuffer1==NULL || FrameBuffer2==NULL) { - error ("MilfordInstruments: framebuffer could not be allocated: malloc() failed"); - return -1; - } - - if (Port) { - free (Port); - Port=NULL; - } - - port=cfg_get (NULL, "Port", NULL); - if (port==NULL || *port=='\0') { - error ("MilfordInstruments: no 'Port' entry in %s", cfg_source()); - return -1; - } - Port=strdup(port); - - if (cfg_number(NULL, "Speed", 19200, 1200,19200, &speed)<0) return -1; - switch (speed) { - case 2400: - Speed=B2400; - break; - case 9600: - Speed=B9600; - break; - default: - error ("MilfordInstruments: unsupported speed '%d' in %s", speed, cfg_source()); - return -1; - } - - debug ("using port %s at %d baud", Port, speed); - - Device=MI_open(); - if (Device==-1) return -1; - - if (cfg_number(NULL, "Icons", 0, 0, CHARS, &Icons)<0) return -1; - if (Icons>0) { - debug ("reserving %d of %d user-defined characters for icons", Icons, CHARS); - icon_init(Lcd.rows, Lcd.cols, XRES, YRES, CHARS, Icons, MI_define_char); - Self->icons=Icons; - Lcd.icons=Icons; - } - - bar_init(Lcd.rows, Lcd.cols, XRES, YRES, CHARS-Icons); - bar_add_segment( 0, 0,255, 32); // ASCII 32 = blank - bar_add_segment(255,255,255,255); // ASCII 255 = block - - MI_clear(1); - - MI_write ("\376\014", 2); // cursor off - - return 0; -} - - -void MI_goto (int row, int col) -{ - char cmd[2]="\376x"; - char ddbase=128; - if (row & 1) { // i.e. if row is 1 or 3 - ddbase += 64; - }; - if (row & 2) { // i.e. if row is 0 or 2. - ddbase += 20; - }; - cmd[1]=(char)(ddbase+col); - MI_write(cmd,2); -} - - -int MI_put (int row, int col, char *text) -{ - char *p=FrameBuffer1+row*Lcd.cols+col; - char *t=text; - - while (*t && col++<=Lcd.cols) { - *p++=*t++; - } - return 0; -} - - -int MI_bar (int type, int row, int col, int max, int len1, int len2) -{ - return bar_draw (type, row, col, max, len1, len2); -} - - -int MI_icon (int num, int seq, int row, int col) -{ - return icon_draw (num, seq, row, col); -} - - -static int MI_flush (void) -{ - int row, col, pos1, pos2; - int c, equal; - - bar_process(MI_define_char); - - for (row=0; row5) break; - } else { - pos2=col; - equal=0; - } - } - MI_write (FrameBuffer1+row*Lcd.cols+pos1, pos2-pos1+1); - } - } - - memcpy (FrameBuffer2, FrameBuffer1, Lcd.rows*Lcd.cols*sizeof(char)); - - return 0; -} - - -int MI_quit (void) -{ - info("MilfordInstruments: shutting down."); - - debug ("closing port %s", Port); - close (Device); - unlock_port(Port); - - if (FrameBuffer1) { - free(FrameBuffer1); - FrameBuffer1=NULL; - } - - if (FrameBuffer2) { - free(FrameBuffer2); - FrameBuffer2=NULL; - } - - return (0); -} - - -LCD MilfordInstruments[] = { - { name: "MI216", - rows: 2, - cols: 16, - xres: XRES, - yres: YRES, - bars: BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2, - icons: 0, - gpos: 0, - init: MI_init, - clear: MI_clear, - put: MI_put, - bar: MI_bar, - icon: MI_icon, - gpo: NULL, - flush: MI_flush, - quit: MI_quit - }, - { name: "MI220", - rows: 2, - cols: 20, - xres: XRES, - yres: YRES, - bars: BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2, - icons: 0, - gpos: 0, - init: MI_init, - clear: MI_clear, - put: MI_put, - bar: MI_bar, - icon: MI_icon, - gpo: NULL, - flush: MI_flush, - quit: MI_quit - }, - { name: "MI240", - rows: 2, - cols: 40, - xres: XRES, - yres: YRES, - bars: BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2, - icons: 0, - gpos: 0, - init: MI_init, - clear: MI_clear, - put: MI_put, - bar: MI_bar, - icon: MI_icon, - gpo: NULL, - flush: MI_flush, - quit: MI_quit - }, - { name: "MI420", - rows: 4, - cols: 20, - xres: XRES, - yres: YRES, - bars: BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2, - icons: 0, - gpos: 0, - init: MI_init, - clear: MI_clear, - put: MI_put, - bar: MI_bar, - icon: MI_icon, - gpo: NULL, - flush: MI_flush, - quit: MI_quit - }, - - { NULL } -}; diff --git a/Status b/Status index a177724..502ead3 100644 --- a/Status +++ b/Status @@ -7,6 +7,7 @@ Lcd4Linux NextGeneration porting status HD44780 -> Ported (Text,Bar,Icon) + soft brightness,'busy flag',gpo [soft contrast] M50530 -> Ported (Text,Bar,Icon) + gpo MatrixOrbital -> Ported (Text,Bar,Icon) + blacklight,contrast,gpo,pwm,rpm + MilfordInstruments -> Ported (Text,Bar,Icon) T6963* -> Ported (Text,Bar,Icon) USBLCD -> Ported (Text,Bar,Icon) XWindow* -> Ported (Text,Bar,Icon) [gnome applet ?] @@ -14,7 +15,6 @@ Lcd4Linux NextGeneration porting status BeckmannEgle -> Curses -> - MilfordInstruments -> PalmPilot -> Obsolete SIN -> Obsolete diff --git a/configure b/configure index 05ef2d0..a48f43c 100755 --- a/configure +++ b/configure @@ -5556,30 +5556,6 @@ _ACEOF fi -if test "$T6963" = "yes"; then - GRAPHIC="yes" - PARPORT="yes" -# DRIVERS="$DRIVERS drv_T6963.lo" - DRIVERS="$DRIVERS drv_T6963.o" - -cat >>confdefs.h <<\_ACEOF -#define WITH_T6963 1 -_ACEOF - -fi - -if test "$USBLCD" = "yes"; then - TEXT="yes" - SERIAL="yes" -# DRIVERS="$DRIVERS drv_USBLCD.lo" - DRIVERS="$DRIVERS drv_USBLCD.o" - -cat >>confdefs.h <<\_ACEOF -#define WITH_USBLCD 1 -_ACEOF - -fi - if test "$MATRIXORBITAL" = "yes"; then SERIAL="yes" # DRIVERS="$DRIVERS drv_MatrixOrbital.lo" @@ -5592,8 +5568,8 @@ _ACEOF fi if test "$MILINST" = "yes"; then -# DRIVERS="$DRIVERS MilfordInstruments.lo" -# DRIVERS="$DRIVERS MilfordInstruments.o" +# DRIVERS="$DRIVERS drv_MilfordInstruments.lo" + DRIVERS="$DRIVERS drv_MilfordInstruments.o" cat >>confdefs.h <<\_ACEOF #define WITH_MILINST 1 @@ -5632,6 +5608,30 @@ if test "$IMAGE" = "yes"; then DRIVERS="$DRIVERS drv_Image.o" fi +if test "$T6963" = "yes"; then + GRAPHIC="yes" + PARPORT="yes" +# DRIVERS="$DRIVERS drv_T6963.lo" + DRIVERS="$DRIVERS drv_T6963.o" + +cat >>confdefs.h <<\_ACEOF +#define WITH_T6963 1 +_ACEOF + +fi + +if test "$USBLCD" = "yes"; then + TEXT="yes" + SERIAL="yes" +# DRIVERS="$DRIVERS drv_USBLCD.lo" + DRIVERS="$DRIVERS drv_USBLCD.o" + +cat >>confdefs.h <<\_ACEOF +#define WITH_USBLCD 1 +_ACEOF + +fi + if test "$X11" = "yes"; then if test "$no_x" = "yes"; then { echo "$as_me:$LINENO: WARNING: X11 headers or libraries not available: X11 driver disabled" >&5 diff --git a/drivers.m4 b/drivers.m4 index e1c84f7..ce09a67 100644 --- a/drivers.m4 +++ b/drivers.m4 @@ -150,22 +150,6 @@ if test "$M50530" = "yes"; then AC_DEFINE(WITH_M50530,1,[M50530 driver]) fi -if test "$T6963" = "yes"; then - GRAPHIC="yes" - PARPORT="yes" -# DRIVERS="$DRIVERS drv_T6963.lo" - DRIVERS="$DRIVERS drv_T6963.o" - AC_DEFINE(WITH_T6963,1,[T6963 driver]) -fi - -if test "$USBLCD" = "yes"; then - TEXT="yes" - SERIAL="yes" -# DRIVERS="$DRIVERS drv_USBLCD.lo" - DRIVERS="$DRIVERS drv_USBLCD.o" - AC_DEFINE(WITH_USBLCD,1,[USBLCD driver]) -fi - if test "$MATRIXORBITAL" = "yes"; then SERIAL="yes" # DRIVERS="$DRIVERS drv_MatrixOrbital.lo" @@ -174,8 +158,8 @@ if test "$MATRIXORBITAL" = "yes"; then fi if test "$MILINST" = "yes"; then -# DRIVERS="$DRIVERS MilfordInstruments.lo" -# DRIVERS="$DRIVERS MilfordInstruments.o" +# DRIVERS="$DRIVERS drv_MilfordInstruments.lo" + DRIVERS="$DRIVERS drv_MilfordInstruments.o" AC_DEFINE(WITH_MILINST,1,[Milford Instruments driver]) fi @@ -201,6 +185,22 @@ if test "$IMAGE" = "yes"; then DRIVERS="$DRIVERS drv_Image.o" fi +if test "$T6963" = "yes"; then + GRAPHIC="yes" + PARPORT="yes" +# DRIVERS="$DRIVERS drv_T6963.lo" + DRIVERS="$DRIVERS drv_T6963.o" + AC_DEFINE(WITH_T6963,1,[T6963 driver]) +fi + +if test "$USBLCD" = "yes"; then + TEXT="yes" + SERIAL="yes" +# DRIVERS="$DRIVERS drv_USBLCD.lo" + DRIVERS="$DRIVERS drv_USBLCD.o" + AC_DEFINE(WITH_USBLCD,1,[USBLCD driver]) +fi + if test "$X11" = "yes"; then if test "$no_x" = "yes"; then AC_MSG_WARN(X11 headers or libraries not available: X11 driver disabled) diff --git a/drv.c b/drv.c index 39928f9..f5d10ad 100644 --- a/drv.c +++ b/drv.c @@ -1,4 +1,4 @@ -/* $Id: drv.c,v 1.11 2004/05/25 19:54:15 reinelt Exp $ +/* $Id: drv.c,v 1.12 2004/05/26 05:03:27 reinelt Exp $ * * new framework for display drivers * @@ -23,6 +23,10 @@ * * * $Log: drv.c,v $ + * Revision 1.12 2004/05/26 05:03:27 reinelt + * + * MilfordInstruments driver ported + * * Revision 1.11 2004/05/25 19:54:15 reinelt * * 'make distcheck' bugs fixed @@ -137,9 +141,6 @@ extern DRIVER drv_Text; char *output=NULL; DRIVER *Driver[] = { -#ifdef WITH_MATRIXORBITAL - &drv_MatrixOrbital, -#endif /* Fixme #ifdef WITH_BECKMANNEGLE &BeckmannEgle, @@ -160,17 +161,18 @@ DRIVER *Driver[] = { #ifdef WITH_M50530 &drv_M50530, #endif +#ifdef WITH_MATRIXORBITAL + &drv_MatrixOrbital, +#endif +#ifdef WITH_MILINST + &drv_MilfordInstruments, +#endif #ifdef WITH_T6963 &drv_T6963, #endif #ifdef WITH_USBLCD &drv_USBLCD, #endif - /* Fixme - #ifdef WITH_MILINST - &MilfordInstruments, - #endif - */ #ifdef WITH_X11 &drv_X11, #endif diff --git a/drv_MilfordInstruments.c b/drv_MilfordInstruments.c new file mode 100644 index 0000000..534fbde --- /dev/null +++ b/drv_MilfordInstruments.c @@ -0,0 +1,259 @@ +/* $Id: drv_MilfordInstruments.c,v 1.1 2004/05/26 05:03:27 reinelt Exp $ + * + * driver for Milford Instruments 'BPK' piggy-back serial interface board + * for standard Hitachi 44780 compatible lcd modules. + * + * Copyright 2003,2004 Andy Baxter + * Copyright 2004 The LCD4Linux Team + * + * based on the MatrixOrbital driver which is + * Copyright 1999, 2000 Michael Reinelt + * + * 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_MilfordInstruments.c,v $ + * Revision 1.1 2004/05/26 05:03:27 reinelt + * + * MilfordInstruments driver ported + * + */ + +/* + * + * exported fuctions: + * + * struct DRIVER drv_MilfordInstruments + * + */ + +#include "config.h" + +#include +#include +#include +#include + +#include "debug.h" +#include "cfg.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" +#include "drv_generic_serial.h" + + +static char Name[]="MilfordInstruments"; + +typedef struct { + int type; + char *name; + int rows; + int cols; +} MODEL; + +static MODEL Models[] = { + { 216, "MI216", 2, 16 }, + { 220, "MI220", 2, 20 }, + { 240, "MI240", 2, 40 }, + { 420, "MI420", 4, 20 }, + { -1, "unknown", -1, -1 }, +}; + +static int Model; + + +// **************************************** +// *** hardware dependant functions *** +// **************************************** + +static void drv_MI_write (int row, int col, unsigned char *data, int len) +{ + char cmd[2] = "\376x"; + char ddbase = 128; + if (row & 1) { // i.e. if row is 1 or 3 + ddbase += 64; + } + if (row & 2) { // i.e. if row is 0 or 2. + ddbase += 20; + } + cmd[1] = (char)(ddbase+col); + drv_generic_serial_write(cmd,2); + + drv_generic_serial_write (data, len); +} + + +static void drv_MI_defchar (int ascii, unsigned char *buffer) +{ + char cmd[2]="\376x"; + if (ascii<8) { + cmd[1]=(char)(64+ascii*8); + drv_generic_serial_write (cmd, 2); + drv_generic_serial_write (buffer, 8); + } +} + + +static int drv_MI_start (char *section) +{ + int i; + char *model; + + model = cfg_get(section, "Model", NULL); + if (model == NULL && *model == '\0') { + error ("%s: no '%s.Model' entry from %s", Name, section, cfg_source()); + return -1; + } + + for (i=0; Models[i].type!=0xff; i++) { + if (strcasecmp(Models[i].name, model)==0) break; + } + if (Models[i].type==0xff) { + error ("%s: %s.Model '%s' is unknown from %s", Name, section, model, cfg_source()); + return -1; + } + Model=i; + info ("%s: using model '%s'", Name, Models[Model].name); + + if (drv_generic_serial_open(section, Name)<0) return -1; + + // initialize global variables + DROWS = Models[Model].rows; + DCOLS = Models[Model].cols; + + drv_generic_serial_write ("\376\001", 2); // clear screen + drv_generic_serial_write ("\376\014", 2); // cursor off + + return 0; +} + + +// **************************************** +// *** plugins *** +// **************************************** + +// none at the moment... + + +// **************************************** +// *** 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_MI_list (void) +{ + int i; + + for (i = 0; Models[i].type > 0; i++) { + printf ("%s ", Models[i].name); + } + return 0; +} + + +// initialize driver & display +int drv_MI_init (char *section) +{ + WIDGET_CLASS wc; + 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 + GOTO_COST = 4; // number of bytes a goto command requires + + // real worker functions + drv_generic_text_real_write = drv_MI_write; + drv_generic_text_real_defchar = drv_MI_defchar; + + + // start display + if ((ret=drv_MI_start (section))!=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) + return ret; + + // add fixed chars to the bar driver + drv_generic_text_bar_add_segment ( 0, 0,255, 32); // ASCII 32 = blank + 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 at the moment... + + return 0; +} + + +// close driver & display +int drv_MI_quit (void) { + + info("%s: shutting down.", Name); + drv_generic_serial_close(); + drv_generic_text_quit(); + + return (0); +} + + +DRIVER drv_MilfordInstruments = { + name: Name, + list: drv_MI_list, + init: drv_MI_init, + quit: drv_MI_quit, +}; + diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample index 3b67884..a54a1c1 100644 --- a/lcd4linux.conf.sample +++ b/lcd4linux.conf.sample @@ -8,6 +8,14 @@ Display LK204 { } +Display MI240 { + Driver 'MilfordInstruments' + Model 'MI240' + Port '/dev/tts/0' + Speed 19200 +} + + Display CF631 { Driver 'Crystalfontz' Model '631' @@ -482,6 +490,7 @@ Layout testMySQL { #Display 'LK204' +Display 'MI240' #Display 'HD44780-20x4' #Display 'M50530-24x8' #Display 'CF631' @@ -490,10 +499,10 @@ Layout testMySQL { #Display 'USBLCD' #Display 'T6963-240x64' #Display 'XWindow' -Display 'Image' +#Display 'Image' Layout 'Default' -#ayout 'L16x2' +#Layout 'L16x2' #Layout 'Test' -- cgit v1.2.3