diff options
-rw-r--r-- | Makefile.am | 18 | ||||
-rw-r--r-- | Makefile.in | 19 | ||||
-rw-r--r-- | T6963.c | 511 | ||||
-rwxr-xr-x | configure | 22 | ||||
-rw-r--r-- | configure.in | 22 | ||||
-rw-r--r-- | drv.c | 16 | ||||
-rw-r--r-- | drv_HD44780.c | 10 | ||||
-rw-r--r-- | drv_M50530.c | 15 | ||||
-rw-r--r-- | drv_T6963.c | 498 | ||||
-rw-r--r-- | drv_generic_graphic.c | 313 | ||||
-rw-r--r-- | drv_generic_graphic.h | 66 | ||||
-rw-r--r-- | drv_generic_text.c | 14 | ||||
-rw-r--r-- | drv_generic_text.h | 9 | ||||
-rw-r--r-- | font_6x8.h (renamed from fontmap.c) | 48 | ||||
-rw-r--r-- | fontmap.h | 39 | ||||
-rw-r--r-- | lcd4linux.conf.sample | 14 | ||||
-rwxr-xr-x | libtool | 92 | ||||
-rw-r--r-- | pixmap.c | 330 | ||||
-rw-r--r-- | pixmap.h | 61 | ||||
-rw-r--r-- | plugin_i2c_sensors.c | 172 | ||||
-rw-r--r-- | widget_icon.c | 10 | ||||
-rw-r--r-- | widget_icon.h | 26 |
22 files changed, 1165 insertions, 1160 deletions
diff --git a/Makefile.am b/Makefile.am index e06282f..b76b57f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,20 +52,11 @@ plugin_xmms.c #liblcd4linux_la_LDFLAGS = -version-info 9:12:9 #liblcd4linux_la_LIBADD = @DRIVERS@ -#liblcd4linux_la_SOURCES = \ -#display.c display.h \ -#drv.c drv.h \ -#debug.c debug.h \ -#cfg.c cfg.h \ -#lock.c lock.h \ -#pixmap.c pixmap.h \ -#bar.c bar.h \ -#icon.c icon.h \ -#fontmap.c fontmap.h \ -#udelay.c udelay.h +#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 \ @@ -73,7 +64,7 @@ drv_Crystalfontz.c \ drv_Cwlinux.c \ drv_HD44780.c \ drv_M50530.c \ -T6963.c \ +drv_T6963.c \ drv_USBLCD.c \ drv_MatrixOrbital.c \ MilfordInstruments.c \ @@ -81,7 +72,8 @@ PalmPilot.c \ Raster.c \ SIN.c \ XWindow.c \ -Text.c +Text.c \ +font_6x8.h EXTRA_DIST = \ lcd4linux.conf.sample \ diff --git a/Makefile.in b/Makefile.in index 3ebd0c3..549e534 100644 --- a/Makefile.in +++ b/Makefile.in @@ -113,19 +113,9 @@ lcd4linux_SOURCES = lcd4linux.c cfg.c cfg.h deb #liblcd4linux_la_LDFLAGS = -version-info 9:12:9 #liblcd4linux_la_LIBADD = @DRIVERS@ -#liblcd4linux_la_SOURCES = \ -#display.c display.h \ -#drv.c drv.h \ -#debug.c debug.h \ -#cfg.c cfg.h \ -#lock.c lock.h \ -#pixmap.c pixmap.h \ -#bar.c bar.h \ -#icon.c icon.h \ -#fontmap.c fontmap.h \ -#udelay.c udelay.h +#liblcd4linux_la_SOURCES = -EXTRA_lcd4linux_SOURCES = drv_generic_text.c drv_generic_text.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_M50530.c T6963.c drv_USBLCD.c drv_MatrixOrbital.c MilfordInstruments.c PalmPilot.c Raster.c SIN.c XWindow.c Text.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_M50530.c drv_T6963.c drv_USBLCD.c drv_MatrixOrbital.c MilfordInstruments.c PalmPilot.c Raster.c SIN.c XWindow.c Text.c font_6x8.h EXTRA_DIST = lcd4linux.conf.sample lcd4kde.conf lcd4linux.kdelnk lcd4linux.xpm lcd4linux.lsm curses.m4 AUTHORS CREDITS FAQ NEWS TODO README README.Rows README.Tokens README.Drivers README.Plugins README.KDE plugin_sample.c @@ -172,10 +162,11 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best DEP_FILES = .deps/BeckmannEgle.P .deps/MilfordInstruments.P \ -.deps/PalmPilot.P .deps/Raster.P .deps/SIN.P .deps/T6963.P .deps/Text.P \ +.deps/PalmPilot.P .deps/Raster.P .deps/SIN.P .deps/Text.P \ .deps/XWindow.P .deps/cfg.P .deps/debug.P .deps/drv.P \ .deps/drv_Crystalfontz.P .deps/drv_Cwlinux.P .deps/drv_HD44780.P \ -.deps/drv_M50530.P .deps/drv_MatrixOrbital.P .deps/drv_USBLCD.P \ +.deps/drv_M50530.P .deps/drv_MatrixOrbital.P .deps/drv_T6963.P \ +.deps/drv_USBLCD.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/lock.P .deps/pid.P .deps/plugin.P \ diff --git a/T6963.c b/T6963.c deleted file mode 100644 index a8f98d0..0000000 --- a/T6963.c +++ /dev/null @@ -1,511 +0,0 @@ -/* $Id: T6963.c,v 1.15 2004/01/30 20:57:55 reinelt Exp $ - * - * driver for display modules based on the Toshiba T6963 chip - * - * Copyright 1999, 2000 Michael Reinelt <reinelt@eunet.at> - * - * 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: T6963.c,v $ - * Revision 1.15 2004/01/30 20:57:55 reinelt - * HD44780 patch from Martin Hejl - * dmalloc integrated - * - * Revision 1.14 2004/01/09 04:16:06 reinelt - * added 'section' argument to cfg_get(), but NULLed it on all calls by now. - * - * Revision 1.13 2003/10/05 17:58:50 reinelt - * libtool junk; copyright messages cleaned up - * - * Revision 1.12 2003/09/29 06:12:56 reinelt - * changed default HD44780 wiring: unused signals are GND - * - * Revision 1.11 2003/09/13 06:45:43 reinelt - * icons for all remaining drivers - * - * Revision 1.10 2003/08/16 07:31:35 reinelt - * double buffering in all drivers - * - * Revision 1.9 2003/08/15 07:54:07 reinelt - * HD44780 4 bit mode implemented - * - * Revision 1.8 2003/08/01 05:15:42 reinelt - * last cleanups for 0.9.9 - * - * Revision 1.7 2003/07/24 04:48:09 reinelt - * 'soft clear' needed for virtual rows - * - * Revision 1.6 2003/04/07 06:03:00 reinelt - * further parallel port abstraction - * - * Revision 1.5 2003/02/22 07:53:10 reinelt - * cfg_get(key,defval) - * - * Revision 1.4 2002/08/21 06:09:53 reinelt - * some T6963 fixes, ndelay wrap - * - * Revision 1.3 2002/08/19 04:41:20 reinelt - * introduced bar.c, moved bar stuff from display.h to bar.h - * - * Revision 1.2 2002/08/17 12:54:08 reinelt - * minor T6963 changes - * - * Revision 1.1 2002/04/29 11:00:26 reinelt - * - * added Toshiba T6963 driver - * added ndelay() with nanosecond resolution - * - * - */ - -/* - * - * exported fuctions: - * - * struct LCD T6963[] - * - */ - -#include "config.h" - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <errno.h> - -#include "debug.h" -#include "cfg.h" -#include "display.h" -#include "bar.h" -#include "icon.h" -#include "parport.h" -#include "udelay.h" -#include "pixmap.h" - -#ifdef WITH_DMALLOC -#include <dmalloc.h> -#endif - - -#define XRES 6 -#define YRES 8 - -static LCD Lcd; -static int Icons; - -unsigned char *Buffer1, *Buffer2; - -static unsigned char SIGNAL_CE; -static unsigned char SIGNAL_CD; -static unsigned char SIGNAL_RD; -static unsigned char SIGNAL_WR; - - -// Fixme: -static int bug=0; - -// perform normal status check -void T6_status1 (void) -{ - int n; - - // turn off data line drivers - parport_direction (1); - - // lower CE and RD - parport_control (SIGNAL_CE | SIGNAL_RD, 0); - - // Access Time: 150 ns - ndelay(150); - - // wait for STA0=1 and STA1=1 - n=0; - do { - rep_nop(); - if (++n>1000) { - debug("hang in status1"); - bug=1; - break; - } - } while ((parport_read() & 0x03) != 0x03); - - // rise RD and CE - parport_control (SIGNAL_RD | SIGNAL_CE, SIGNAL_RD | SIGNAL_CE); - - // Output Hold Time: 50 ns - ndelay(50); - - // turn on data line drivers - parport_direction (0); -} - - -// perform status check in "auto mode" -void T6_status2 (void) -{ - int n; - - // turn off data line drivers - parport_direction (1); - - // lower RD and CE - parport_control (SIGNAL_RD | SIGNAL_CE, 0); - - // Access Time: 150 ns - ndelay(150); - - // wait for STA3=1 - n=0; - do { - rep_nop(); - if (++n>1000) { - debug("hang in status2"); - bug=1; - break; - } - } while ((parport_read() & 0x08) != 0x08); - - // rise RD and CE - parport_control (SIGNAL_RD | SIGNAL_CE, SIGNAL_RD | SIGNAL_CE); - - // Output Hold Time: 50 ns - ndelay(50); - - // turn on data line drivers - parport_direction (0); -} - - -static void T6_write_cmd (unsigned char cmd) -{ - // wait until the T6963 is idle - T6_status1(); - - // put data on DB1..DB8 - parport_data (cmd); - - // lower WR and CE - parport_control (SIGNAL_WR | SIGNAL_CE, 0); - - // Pulse width - ndelay(80); - - // rise WR and CE - parport_control (SIGNAL_WR | SIGNAL_CE, SIGNAL_WR | SIGNAL_CE); - - // Data Hold Time - ndelay(40); -} - - -static void T6_write_data (unsigned char data) -{ - // wait until the T6963 is idle - T6_status1(); - - // put data on DB1..DB8 - parport_data (data); - - // lower C/D - parport_control (SIGNAL_CD, 0); - - // C/D Setup Time - ndelay(20); - - // lower WR and CE - parport_control (SIGNAL_WR | SIGNAL_CE, 0); - - // Pulse Width - ndelay(80); - - // rise WR and CE - parport_control (SIGNAL_WR | SIGNAL_CE, SIGNAL_WR | SIGNAL_CE); - - // Data Hold Time - ndelay(40); - - // rise CD - parport_control (SIGNAL_CD, SIGNAL_CD); -} - - -static void T6_write_auto (unsigned char data) -{ - // wait until the T6963 is idle - T6_status2(); - - // put data on DB1..DB8 - parport_data (data); - - // lower C/D - parport_control (SIGNAL_CD, 0); - - // C/D Setup Time - ndelay(20); - - // lower WR and CE - parport_control (SIGNAL_WR | SIGNAL_CE, 0); - - // Pulse Width - ndelay(80); - - // rise WR and CE - parport_control (SIGNAL_WR | SIGNAL_CE, SIGNAL_WR | SIGNAL_CE); - - // Data Hold Time - ndelay(40); - - // rise CD - parport_control (SIGNAL_CD, SIGNAL_CD); -} - - -#if 0 // not used -static void T6_send_byte (unsigned char cmd, unsigned char data) -{ - T6_write_data(data); - T6_write_cmd(cmd); -} -#endif - -static void T6_send_word (unsigned char cmd, unsigned short data) -{ - T6_write_data(data&0xff); - T6_write_data(data>>8); - T6_write_cmd(cmd); -} - - -static void T6_memset(unsigned short addr, unsigned char data, int len) -{ - int i; - - T6_send_word (0x24, addr); // Set Adress Pointer - T6_write_cmd(0xb0); // Set Data Auto Write - for (i=0; i<len; i++) { - T6_write_auto(data); - if (bug) { - debug("bug occured at byte %d of %d", i, len); - bug=0; - } - } - T6_status2(); - T6_write_cmd(0xb2); // Auto Reset -} - - -static void T6_memcpy(unsigned short addr, unsigned char *data, int len) -{ - int i; - - T6_send_word (0x24, 0x0200+addr); // Set Adress Pointer - T6_write_cmd(0xb0); // Set Data Auto Write - for (i=0; i<len; i++) { - T6_write_auto(*(data++)); - if (bug) { - debug("bug occured at byte %d of %d, addr=%d", i, len, addr); - bug=0; - } - } - T6_status2(); - T6_write_cmd(0xb2); // Auto Reset -} - - -int T6_clear (int full) -{ - int rows; - - if (full) { - - rows=(Lcd.rows>8 ? 8 : Lcd.rows); - - T6_memset(0x0000, 0, Lcd.cols*rows); // clear text area - T6_memset(0x0200, 0, Lcd.cols*rows*8); // clear graphic area - - if (Lcd.rows>8) { - T6_memset(0x8000, 0, Lcd.cols*(Lcd.rows-rows)); // clear text area #2 - T6_memset(0x8200, 0, Lcd.cols*(Lcd.rows-rows)*8); // clear graphic area #2 - } - - memset(Buffer1,0,Lcd.cols*Lcd.rows*Lcd.yres*sizeof(*Buffer1)); - memset(Buffer2,0,Lcd.cols*Lcd.rows*Lcd.yres*sizeof(*Buffer2)); - } - - return pix_clear(); -} - - -int T6_init (LCD *Self) -{ - Lcd=*Self; - - if (pix_init (Lcd.rows, Lcd.cols, Lcd.xres, Lcd.yres)!=0) { - error ("T6963: pix_init(%d, %d, %d, %d) failed", Lcd.rows, Lcd.cols, Lcd.xres, Lcd.yres); - return -1; - } - - if (cfg_number(NULL, "Icons", 0, 0, 8, &Icons) < 0) return -1; - if (Icons>0) { - info ("allocating %d icons", Icons); - icon_init(Lcd.rows, Lcd.cols, Lcd.xres, Lcd.yres, 8, Icons, pix_icon); - Self->icons=Icons; - Lcd.icons=Icons; - } - - Buffer1=malloc(Lcd.cols*Lcd.rows*Lcd.yres); - if (Buffer1==NULL) { - error ("T6963: malloc(%d) failed: %s", Lcd.cols*Lcd.rows*Lcd.yres, strerror(errno)); - return -1; - } - - Buffer2=malloc(Lcd.cols*Lcd.rows*Lcd.yres); - if (Buffer2==NULL) { - error ("T6963: malloc(%d) failed: %s", Lcd.cols*Lcd.rows*Lcd.yres, strerror(errno)); - return -1; - } - - if ((SIGNAL_CE=parport_wire_ctrl ("CE", "STROBE"))==0xff) return -1; - if ((SIGNAL_CD=parport_wire_ctrl ("CD", "SELECT"))==0xff) return -1; - if ((SIGNAL_RD=parport_wire_ctrl ("RD", "AUTOFD"))==0xff) return -1; - if ((SIGNAL_WR=parport_wire_ctrl ("WR", "INIT") )==0xff) return -1; - - if (parport_open() != 0) { - error ("T6963: could not initialize parallel port!"); - return -1; - } - - // rise CE, CD, RD and WR - parport_control (SIGNAL_CE | SIGNAL_CD | SIGNAL_RD | SIGNAL_WR, - SIGNAL_CE | SIGNAL_CD | SIGNAL_RD | SIGNAL_WR); - - // set direction: write - parport_direction (0); - - debug ("setting %d columns", Lcd.cols); - - T6_send_word (0x40, 0x0000); // Set Text Home Address - T6_send_word (0x41, Lcd.cols); // Set Text Area - - T6_send_word (0x42, 0x0200); // Set Graphic Home Address - T6_send_word (0x43, Lcd.cols); // Set Graphic Area - - T6_write_cmd (0x80); // Mode Set: OR mode, Internal CG RAM mode - T6_send_word (0x22, 0x0002); // Set Offset Register - T6_write_cmd (0x98); // Set Display Mode: Curser off, Text off, Graphics on - T6_write_cmd (0xa0); // Set Cursor Pattern: 1 line cursor - T6_send_word (0x21, 0x0000); // Set Cursor Pointer to (0,0) - - T6_clear(1); - - return 0; -} - - -int T6_put (int row, int col, char *text) -{ - return pix_put(row,col,text); -} - - -int T6_bar (int type, int row, int col, int max, int len1, int len2) -{ - return pix_bar(type,row,col,max,len1,len2); -} - - -int T6_icon (int num, int seq, int row, int col) -{ - return icon_draw (num, seq, row, col); -} - - -int T6_flush (void) -{ - int i, j, e; - - memset(Buffer1,0,Lcd.cols*Lcd.rows*Lcd.yres*sizeof(*Buffer1)); - - for (i=0; i<Lcd.cols*Lcd.rows*Lcd.yres; i++) { - for (j=0; j<Lcd.xres; j++) { - Buffer1[i]<<=1; - if (LCDpixmap[i*Lcd.xres+j]) Buffer1[i]|=1; - } - } - - for (i=0; i<Lcd.cols*Lcd.rows*Lcd.yres; i++) { - if (Buffer1[i]==Buffer2[i]) continue; - for (j=i, e=0; i<Lcd.cols*Lcd.rows*Lcd.yres; i++) { - if (Buffer1[i]==Buffer2[i]) { - if (++e>4) break; - } else { - e=0; - } - } - T6_memcpy (j, Buffer1+j, i-j-e+1); - } - - memcpy(Buffer2,Buffer1,Lcd.cols*Lcd.rows*Lcd.yres*sizeof(*Buffer1)); - - return 0; -} - - -int T6_quit (void) -{ - return parport_close(); -} - - -LCD T6963[] = { - { name: "TLC1091", - rows: 16, - cols: 40, - xres: 6, - yres: 8, - bars: BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2 | BAR_V2 | BAR_T, - icons: 0, - gpos: 0, - init: T6_init, - clear: T6_clear, - put: T6_put, - bar: T6_bar, - icon: T6_icon, - gpo: NULL, - flush: T6_flush, - quit: T6_quit - }, - { name: "DMF5002N", - rows: 14, - cols: 16, - xres: 8, - yres: 8, - bars: BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2 | BAR_V2 | BAR_T, - icons: 0, - gpos: 0, - init: T6_init, - clear: T6_clear, - put: T6_put, - bar: T6_bar, - icon: T6_icon, - gpo: NULL, - flush: T6_flush, - quit: T6_quit - }, - { NULL } -}; @@ -20935,7 +20935,7 @@ echo "${ECHO_T}done" >&6 PARPORT="no" SERIAL="no" TEXT="no" -RASTER="no" +GRAPHIC="no" if test "$BECKMANNEGLE" = "yes"; then # DRIVERS="$DRIVERS BeckmannEgle.lo" @@ -20984,6 +20984,7 @@ _ACEOF fi if test "$M50530" = "yes"; then + TEXT="yes" PARPORT="yes" # DRIVERS="$DRIVERS drv_M50530.lo" DRIVERS="$DRIVERS drv_M50530.o" @@ -20995,9 +20996,10 @@ _ACEOF fi if test "$T6963" = "yes"; then + GRAPHIC="yes" PARPORT="yes" -# DRIVERS="$DRIVERS T6963.lo" -# DRIVERS="$DRIVERS T6963.o" +# DRIVERS="$DRIVERS drv_T6963.lo" + DRIVERS="$DRIVERS drv_T6963.o" cat >>confdefs.h <<\_ACEOF #define WITH_T6963 1 @@ -21006,6 +21008,8 @@ _ACEOF fi if test "$USBLCD" = "yes"; then + TEXT="yes" + SERIAL="yes" # DRIVERS="$DRIVERS drv_USBLCD.lo" DRIVERS="$DRIVERS drv_USBLCD.o" @@ -21048,7 +21052,7 @@ fi if test "$PNG" = "yes"; then if test "$has_gd" = "true"; then - RASTER="yes" + GRAPHIC="yes" cat >>confdefs.h <<\_ACEOF #define WITH_PNG 1 @@ -21063,7 +21067,7 @@ fi if test "$PPM" = "yes"; then if test "$has_gd" = "true"; then - RASTER="yes" + GRAPHIC="yes" cat >>confdefs.h <<\_ACEOF #define WITH_PPM 1 @@ -21121,11 +21125,11 @@ if test "$TEXT" = "yes"; then DRIVERS="$DRIVERS drv_generic_text.o" fi -# Raster.lo depends on PPM or PNG -if test "$RASTER" = "yes"; then +# generic graphic driver +if test "$GRAPHIC" = "yes"; then : -# DRIVERS="$DRIVERS Raster.lo" -# DRIVERS="$DRIVERS Raster.o" +# DRIVERS="$DRIVERS + DRIVERS="$DRIVERS drv_generic_graphic.o" fi # generic parport driver diff --git a/configure.in b/configure.in index 731a3d5..cd157bc 100644 --- a/configure.in +++ b/configure.in @@ -142,7 +142,7 @@ AC_MSG_RESULT([done]) PARPORT="no" SERIAL="no" TEXT="no" -RASTER="no" +GRAPHIC="no" if test "$BECKMANNEGLE" = "yes"; then # DRIVERS="$DRIVERS BeckmannEgle.lo" @@ -175,6 +175,7 @@ if test "$HD44780" = "yes"; then fi if test "$M50530" = "yes"; then + TEXT="yes" PARPORT="yes" # DRIVERS="$DRIVERS drv_M50530.lo" DRIVERS="$DRIVERS drv_M50530.o" @@ -182,13 +183,16 @@ if test "$M50530" = "yes"; then fi if test "$T6963" = "yes"; then + GRAPHIC="yes" PARPORT="yes" -# DRIVERS="$DRIVERS T6963.lo" -# DRIVERS="$DRIVERS T6963.o" +# 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]) @@ -215,7 +219,7 @@ fi if test "$PNG" = "yes"; then if test "$has_gd" = "true"; then - RASTER="yes" + GRAPHIC="yes" AC_DEFINE(WITH_PNG,1,[ driver]) DRVLIBS="$DRVLIBS -lgd" else @@ -225,7 +229,7 @@ fi if test "$PPM" = "yes"; then if test "$has_gd" = "true"; then - RASTER="yes" + GRAPHIC="yes" AC_DEFINE(WITH_PPM,1,[ driver]) else AC_MSG_WARN(gd.h not found: PNG driver disabled) @@ -265,11 +269,11 @@ if test "$TEXT" = "yes"; then DRIVERS="$DRIVERS drv_generic_text.o" fi -# Raster.lo depends on PPM or PNG -if test "$RASTER" = "yes"; then +# generic graphic driver +if test "$GRAPHIC" = "yes"; then : -# DRIVERS="$DRIVERS Raster.lo" -# DRIVERS="$DRIVERS Raster.o" +# DRIVERS="$DRIVERS + DRIVERS="$DRIVERS drv_generic_graphic.o" fi # generic parport driver @@ -1,4 +1,4 @@ -/* $Id: drv.c,v 1.7 2004/02/15 08:22:47 reinelt Exp $ +/* $Id: drv.c,v 1.8 2004/02/15 21:43:43 reinelt Exp $ * * new framework for display drivers * @@ -23,6 +23,12 @@ * * * $Log: drv.c,v $ + * Revision 1.8 2004/02/15 21:43:43 reinelt + * T6963 driver nearly finished + * framework for graphic displays done + * i2c_sensors patch from Xavier + * some more old generation files removed + * * Revision 1.7 2004/02/15 08:22:47 reinelt * ported USBLCD driver to NextGeneration * added drv_M50530.c (I forgot yesterday, sorry) @@ -138,11 +144,9 @@ DRIVER *Driver[] = { #ifdef WITH_M50530 &drv_M50530, #endif - /* Fixme - #ifdef WITH_T6963 - &T6963, - #endif - */ +#ifdef WITH_T6963 + &drv_T6963, +#endif #ifdef WITH_USBLCD &drv_USBLCD, #endif diff --git a/drv_HD44780.c b/drv_HD44780.c index ece00c9..a942de7 100644 --- a/drv_HD44780.c +++ b/drv_HD44780.c @@ -1,4 +1,4 @@ -/* $Id: drv_HD44780.c,v 1.12 2004/02/14 11:56:17 reinelt Exp $ +/* $Id: drv_HD44780.c,v 1.13 2004/02/15 21:43:43 reinelt Exp $ * * new style driver for HD44780-based displays * @@ -29,6 +29,12 @@ * * * $Log: drv_HD44780.c,v $ + * Revision 1.13 2004/02/15 21:43:43 reinelt + * T6963 driver nearly finished + * framework for graphic displays done + * i2c_sensors patch from Xavier + * some more old generation files removed + * * Revision 1.12 2004/02/14 11:56:17 reinelt * M50530 driver ported * changed lots of 'char' to 'unsigned char' @@ -249,7 +255,7 @@ static void wait_for_busy_flag(int controller) // get the current time gettimeofday(&now, NULL); if (now.tv_sec==end.tv_sec?now.tv_usec>=end.tv_usec:now.tv_sec>=end.tv_sec) { - error ("HD44780: timeout waiting for busy flag on controller %x (%x)", controller, data); + error ("%s: timeout waiting for busy flag on controller %x (%x)", Name, controller, data); break; } diff --git a/drv_M50530.c b/drv_M50530.c index b33630e..7361855 100644 --- a/drv_M50530.c +++ b/drv_M50530.c @@ -1,4 +1,4 @@ -/* $Id: drv_M50530.c,v 1.1 2004/02/15 08:22:47 reinelt Exp $ +/* $Id: drv_M50530.c,v 1.2 2004/02/15 21:43:43 reinelt Exp $ * * new style driver for M50530-based displays * @@ -23,6 +23,12 @@ * * * $Log: drv_M50530.c,v $ + * Revision 1.2 2004/02/15 21:43:43 reinelt + * T6963 driver nearly finished + * framework for graphic displays done + * i2c_sensors patch from Xavier + * some more old generation files removed + * * Revision 1.1 2004/02/15 08:22:47 reinelt * ported USBLCD driver to NextGeneration * added drv_M50530.c (I forgot yesterday, sorry) @@ -64,7 +70,6 @@ static char Name[]="M50530"; static int Model; -static int Capabilities; static unsigned char SIGNAL_EX; static unsigned char SIGNAL_IOC1; @@ -79,12 +84,11 @@ static int GPOS; typedef struct { int type; char *name; - int capabilities; } MODEL; static MODEL Models[] = { - { 0x01, "generic", 0 }, - { 0xff, "Unknown", 0 } + { 0x01, "generic" }, + { 0xff, "Unknown" } }; @@ -182,7 +186,6 @@ static int drv_M5_start (char *section) return -1; } Model=i; - Capabilities=Models[Model].capabilities; info ("%s: using model '%s'", Name, Models[Model].name); } else { error ("%s: empty '%s.Model' entry from %s", Name, section, cfg_source()); diff --git a/drv_T6963.c b/drv_T6963.c new file mode 100644 index 0000000..2706805 --- /dev/null +++ b/drv_T6963.c @@ -0,0 +1,498 @@ +/* $Id: drv_T6963.c,v 1.1 2004/02/15 21:43:43 reinelt Exp $ + * + * new style driver for T6963-based displays + * + * Copyright 1999-2004 Michael Reinelt <reinelt@eunet.at> + * Copyright 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net> + * + * 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_T6963.c,v $ + * Revision 1.1 2004/02/15 21:43:43 reinelt + * T6963 driver nearly finished + * framework for graphic displays done + * i2c_sensors patch from Xavier + * some more old generation files removed + * + */ + +/* + * + * exported fuctions: + * + * struct DRIVER drv_T6963 + * + */ + +#include "config.h" + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <unistd.h> +#include <termios.h> +#include <fcntl.h> +#include <sys/time.h> + +#include "debug.h" +#include "cfg.h" +#include "udelay.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_graphic.h" +#include "drv_generic_parport.h" + +static char Name[]="T6963"; +static int Model; + +typedef struct { + int type; + char *name; +} MODEL; + +static MODEL Models[] = { + { 0x01, "generic" }, + { 0xff, "Unknown" } +}; + + +static unsigned char SIGNAL_CE; +static unsigned char SIGNAL_CD; +static unsigned char SIGNAL_RD; +static unsigned char SIGNAL_WR; + +// Fixme: +static int bug=0; + + +// **************************************** +// *** hardware dependant functions *** +// **************************************** + +// perform normal status check +static void drv_T6_status1 (void) +{ + int n; + + // turn off data line drivers + drv_generic_parport_direction (1); + + // lower CE and RD + drv_generic_parport_control (SIGNAL_CE | SIGNAL_RD, 0); + + // Access Time: 150 ns + ndelay(150); + + // wait for STA0=1 and STA1=1 + n=0; + do { + rep_nop(); + if (++n>1000) { + debug("hang in status1"); + bug=1; + break; + } + } while ((drv_generic_parport_read() & 0x03) != 0x03); + + // rise RD and CE + drv_generic_parport_control (SIGNAL_RD | SIGNAL_CE, SIGNAL_RD | SIGNAL_CE); + + // Output Hold Time: 50 ns + ndelay(50); + + // turn on data line drivers + drv_generic_parport_direction (0); +} + + +// perform status check in "auto mode" +static void drv_T6_status2 (void) +{ + int n; + + // turn off data line drivers + drv_generic_parport_direction (1); + + // lower RD and CE + drv_generic_parport_control (SIGNAL_RD | SIGNAL_CE, 0); + + // Access Time: 150 ns + ndelay(150); + + // wait for STA3=1 + n=0; + do { + rep_nop(); + if (++n>1000) { + debug("hang in status2"); + bug=1; + break; + } + } while ((drv_generic_parport_read() & 0x08) != 0x08); + + // rise RD and CE + drv_generic_parport_control (SIGNAL_RD | SIGNAL_CE, SIGNAL_RD | SIGNAL_CE); + + // Output Hold Time: 50 ns + ndelay(50); + + // turn on data line drivers + drv_generic_parport_direction (0); +} + + +static void drv_T6_write_cmd (unsigned char cmd) +{ + // wait until the T6963 is idle + drv_T6_status1(); + + // put data on DB1..DB8 + drv_generic_parport_data (cmd); + + // lower WR and CE + drv_generic_parport_control (SIGNAL_WR | SIGNAL_CE, 0); + + // Pulse width + ndelay(80); + + // rise WR and CE + drv_generic_parport_control (SIGNAL_WR | SIGNAL_CE, SIGNAL_WR | SIGNAL_CE); + + // Data Hold Time + ndelay(40); +} + + +static void drv_T6_write_data (unsigned char data) +{ + // wait until the T6963 is idle + drv_T6_status1(); + + // put data on DB1..DB8 + drv_generic_parport_data (data); + + // lower C/D + drv_generic_parport_control (SIGNAL_CD, 0); + + // C/D Setup Time + ndelay(20); + + // lower WR and CE + drv_generic_parport_control (SIGNAL_WR | SIGNAL_CE, 0); + + // Pulse Width + ndelay(80); + + // rise WR and CE + drv_generic_parport_control (SIGNAL_WR | SIGNAL_CE, SIGNAL_WR | SIGNAL_CE); + + // Data Hold Time + ndelay(40); + + // rise CD + drv_generic_parport_control (SIGNAL_CD, SIGNAL_CD); +} + + +static void drv_T6_write_auto (unsigned char data) +{ + // wait until the T6963 is idle + drv_T6_status2(); + + // put data on DB1..DB8 + drv_generic_parport_data (data); + + // lower C/D + drv_generic_parport_control (SIGNAL_CD, 0); + + // C/D Setup Time + ndelay(20); + + // lower WR and CE + drv_generic_parport_control (SIGNAL_WR | SIGNAL_CE, 0); + + // Pulse Width + ndelay(80); + + // rise WR and CE + drv_generic_parport_control (SIGNAL_WR | SIGNAL_CE, SIGNAL_WR | SIGNAL_CE); + + // Data Hold Time + ndelay(40); + + // rise CD + drv_generic_parport_control (SIGNAL_CD, SIGNAL_CD); +} + + +#if 0 // not used +static void drv_T6_send_byte (unsigned char cmd, unsigned char data) +{ + drv_T6_write_data(data); + drv_T6_write_cmd(cmd); +} +#endif + +static void drv_T6_send_word (unsigned char cmd, unsigned short data) +{ + drv_T6_write_data(data&0xff); + drv_T6_write_data(data>>8); + drv_T6_write_cmd(cmd); +} + + +static void drv_T6_memset(unsigned short addr, unsigned char data, int len) +{ + int i; + + drv_T6_send_word (0x24, addr); // Set Adress Pointer + drv_T6_write_cmd(0xb0); // Set Data Auto Write + for (i=0; i<len; i++) { + drv_T6_write_auto(data); + if (bug) { + bug=0; + debug("bug occured at byte %d of %d", i, len); + } + } + drv_T6_status2(); + drv_T6_write_cmd(0xb2); // Auto Reset +} + + +static void drv_T6_memcpy(unsigned short addr, unsigned char *data, int len) +{ + int i; + + drv_T6_send_word (0x24, 0x0200+addr); // Set Adress Pointer + drv_T6_write_cmd(0xb0); // Set Data Auto Write + for (i=0; i<len; i++) { + drv_T6_write_auto(*(data++)); + if (bug) { + bug=0; + debug("bug occured at byte %d of %d, addr=%d", i, len, addr); + } + } + drv_T6_status2(); + drv_T6_write_cmd(0xb2); // Auto Reset +} + + +static int drv_T6_start (char *section) +{ + char *model, *s; + int rows, cols; + + model=cfg_get(section, "Model", "generic"); + if (model!=NULL && *model!='\0') { + int i; + 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); + } else { + error ("%s: empty '%s.Model' entry from %s", Name, section, cfg_source()); + return -1; + } + + 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; + } + + DROWS = -1; + DCOLS = -1; + if (sscanf(s, "%dx%d", &DCOLS, &DROWS)!=2 || DCOLS<1 || DROWS<1) { + error ("%s: bad Size '%s' from %s", Name, s, cfg_source()); + return -1; + } + + s=cfg_get(section, "Font", "6x8"); + if (s==NULL || *s=='\0') { + error ("%s: no '%s.Font' entry from %s", Name, section, cfg_source()); + return -1; + } + + XRES = -1; + YRES = -1; + if (sscanf(s, "%dx%d", &XRES, &YRES)!=2 || XRES<1 || YRES<1) { + error ("%s: bad Font '%s' from %s", Name, s, cfg_source()); + return -1; + } + + if (drv_generic_parport_open(section, Name) != 0) { + error ("%s: could not initialize parallel port!", Name); + return -1; + } + + if ((SIGNAL_CE=drv_generic_parport_wire_ctrl ("CE", "STROBE"))==0xff) return -1; + if ((SIGNAL_CD=drv_generic_parport_wire_ctrl ("CD", "SELECT"))==0xff) return -1; + if ((SIGNAL_RD=drv_generic_parport_wire_ctrl ("RD", "AUTOFD"))==0xff) return -1; + if ((SIGNAL_WR=drv_generic_parport_wire_ctrl ("WR", "INIT") )==0xff) return -1; + + // rise CE, CD, RD and WR + drv_generic_parport_control (SIGNAL_CE | SIGNAL_CD | SIGNAL_RD | SIGNAL_WR, + SIGNAL_CE | SIGNAL_CD | SIGNAL_RD | SIGNAL_WR); + // set direction: write + drv_generic_parport_direction (0); + + // initialize display + + rows=DROWS/8; // text rows, assume 6x8 font + cols=DCOLS/6; // text cols, assume 6x8 font + + drv_T6_send_word (0x40, 0x0000); // Set Text Home Address + drv_T6_send_word (0x41, cols); // Set Text Area + + drv_T6_send_word (0x42, 0x0200); // Set Graphic Home Address + drv_T6_send_word (0x43, cols); // Set Graphic Area + + drv_T6_write_cmd (0x80); // Mode Set: OR mode, Internal CG RAM mode + drv_T6_send_word (0x22, 0x0002); // Set Offset Register + drv_T6_write_cmd (0x98); // Set Display Mode: Curser off, Text off, Graphics on + drv_T6_write_cmd (0xa0); // Set Cursor Pattern: 1 line cursor + drv_T6_send_word (0x21, 0x0000); // Set Cursor Pointer to (0,0) + + + // clear display + + // upper half + if (rows>8) rows=8; + drv_T6_memset(0x0000, 0, cols*rows); // clear text area + drv_T6_memset(0x0200, 0, cols*rows*8); // clear graphic area + + // lower half + if (DROWS>8*8) { + rows=DROWS/8-8; + drv_T6_memset(0x8000, 0, cols*rows); // clear text area #2 + drv_T6_memset(0x8200, 0, cols*rows*8); // clear graphic area #2 + } + + return 0; +} + + +// **************************************** +// *** plugins *** +// **************************************** + +// none at the moment... + + +// **************************************** +// *** widget callbacks *** +// **************************************** + + +// using drv_generic_graphic_draw(W) +// using drv_generic_graphic_icon_draw(W) +// using drv_generic_graphic_bar_draw(W) + + +// **************************************** +// *** exported functions *** +// **************************************** + + +// list models +int drv_T6_list (void) +{ + int i; + + for (i=0; Models[i].type!=0xff; i++) { + printf ("%s ", Models[i].name); + } + return 0; +} + + +// initialize driver & display +int drv_T6_init (char *section) +{ + WIDGET_CLASS wc; + int ret; + + // display preferences + GOTO_COST = 2; // number of bytes a goto command requires + + // real worker functions + // Fixme: which one? + // drv_generic_text_real_write = drv_T6_write; + // drv_generic_text_real_goto = drv_T6_goto; + // drv_generic_text_real_defchar = drv_T6_defchar; + + // start display + if ((ret=drv_T6_start (section))!=0) + return ret; + + // initialize generic graphic driver + if ((ret=drv_generic_graphic_init(section, Name))!=0) + return ret; + + // register text widget + wc=Widget_Text; + wc.draw=drv_generic_graphic_draw; + widget_register(&wc); + + // register icon widget + wc=Widget_Icon; + wc.draw=drv_generic_graphic_icon_draw; + widget_register(&wc); + + // register bar widget + wc=Widget_Bar; + wc.draw=drv_generic_graphic_bar_draw; + widget_register(&wc); + + // register plugins + // none at the moment... + + + return 0; +} + + +// close driver & display +int drv_T6_quit (void) { + + info("%s: shutting down.", Name); + drv_generic_parport_close(); + drv_generic_graphic_quit(); + + return (0); +} + + +DRIVER drv_T6963 = { + name: Name, + list: drv_T6_list, + init: drv_T6_init, + quit: drv_T6_quit, +}; + + diff --git a/drv_generic_graphic.c b/drv_generic_graphic.c new file mode 100644 index 0000000..058b83c --- /dev/null +++ b/drv_generic_graphic.c @@ -0,0 +1,313 @@ +/* $Id + * + * generic driver helper for graphic displays + * + * Copyright 1999, 2000 Michael Reinelt <reinelt@eunet.at> + * Copyright 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net> + * + * 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_generic_graphic.c,v $ + * Revision 1.1 2004/02/15 21:43:43 reinelt + * T6963 driver nearly finished + * framework for graphic displays done + * i2c_sensors patch from Xavier + * some more old generation files removed + * + */ + +/* + * + * exported fuctions: + * + * Fixme: document me! + * + */ + +#include "config.h" + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <unistd.h> +#include <termios.h> +#include <fcntl.h> + +#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_graphic.h" +#include "font_6x8.h" + +#ifdef WITH_DMALLOC +#include <dmalloc.h> +#endif + + +static char *Section=NULL; +static char *Driver=NULL; + +int DROWS, DCOLS; // display size (pixels!) +int LROWS, LCOLS; // layout size (pixels!) +int XRES, YRES; // pixels of one char cell +int GOTO_COST; // number of bytes a goto command requires + +static unsigned char *LayoutFB = NULL; +static unsigned char *DisplayFB = NULL; + + +// **************************************** +// *** generic Framebuffer stuff *** +// **************************************** + +static void drv_generic_graphic_resizeFB (int rows, int cols) +{ + char *newFB; + int row, col; + + // Layout FB is large enough + if (rows<=LROWS && cols<=LCOLS) + return; + + // get maximum values + if (rows<LROWS) rows=LROWS; + if (cols<LCOLS) cols=LCOLS; + + // allocate new Layout FB + newFB=malloc(cols*rows*sizeof(char)); + memset (newFB, 0, rows*cols*sizeof(char)); + + // transfer contents + if (LayoutFB!=NULL) { + for (row=0; row<LROWS; row++) { + for (col=0; col<LCOLS; col++) { + newFB[row*cols+col]=LayoutFB[row*LCOLS+col]; + } + } + free (LayoutFB); + } + LayoutFB = newFB; + + LCOLS = cols; + LROWS = rows; +} + + +static void drv_generic_graphic_flush (int row0, int col0, int rows, int cols) +{ + debug ("flushing from (%d, %d) size (%d, %d)", row0, col0, rows, cols); +} + + +int drv_generic_graphic_draw (WIDGET *W) +{ + WIDGET_TEXT *Text=W->data; + unsigned char *txt; + int row, col, len; + int x, y; + + row=YRES*W->row; + col=XRES*W->col; + txt=Text->buffer; + len=strlen(txt); + + // maybe grow layout framebuffer + drv_generic_graphic_resizeFB (row+YRES, col+XRES*len); + + // render text into layout FB + while (*txt!='\0') { + int c=*txt; + for (y=0; y<YRES; y++) { + int mask=1<<XRES; + for (x=0; x<XRES; x++) { + mask>>=1; + LayoutFB[(row+y)*LCOLS+col+x] = Font_6x8[c][y]&mask ? 1:0; + } + } + col+=XRES; + txt++; + } + + // flush area + drv_generic_graphic_flush (row, col, YRES, XRES*len); + + return 0; +} + + +// **************************************** +// *** generic icon handling *** +// **************************************** + +int drv_generic_graphic_icon_draw (WIDGET *W) +{ + WIDGET_ICON *Icon = W->data; + unsigned char *bitmap = Icon->bitmap+YRES*Icon->curmap; + int row, col; + int x, y; + + row = YRES*W->row; + col = XRES*W->col; + + // maybe grow layout framebuffer + drv_generic_graphic_resizeFB (row+YRES, col+XRES); + + // render icon + for (y=0; y<YRES; y++) { + int mask=1<<XRES; + for (x=0; x<XRES; x++) { + mask>>=1; + DisplayFB[(row+y)*LCOLS+col+x] = Icon->visible ? 0 : bitmap[y]&mask ? 1 : 0; + } + } + + // flush area + drv_generic_graphic_flush (row, col, YRES, XRES); + + return 0; + +} + + +// **************************************** +// *** generic bar handling *** +// **************************************** + +int drv_generic_graphic_bar_draw (WIDGET *W) +{ + WIDGET_BAR *Bar = W->data; + int row, col, len, res, rev, max, val1, val2; + int x, y; + DIRECTION dir; + + row = YRES*W->row; + col = XRES*W->col; + dir = Bar->direction; + len = Bar->length; + + // maybe grow layout framebuffer + if (dir & (DIR_EAST|DIR_WEST)) { + drv_generic_graphic_resizeFB (row+YRES, col+XRES*len); + } else { + drv_generic_graphic_resizeFB (row+YRES*len, col+XRES); + } + + res = dir & (DIR_EAST|DIR_WEST)?XRES:YRES; + max = len * res; + val1 = Bar->val1 * (double)(max); + val2 = Bar->val2 * (double)(max); + + if (val1<1) val1=1; + else if (val1>max) val1=max; + + if (val2<1) val2=1; + else if (val2>max) val2=max; + + rev=0; + + switch (dir) { + case DIR_WEST: + val1=max-val1; + val2=max-val2; + rev=1; + + case DIR_EAST: + for (y=0; y<YRES; y++) { + len=y<YRES/2 ? val1 : val2; + for (x=0; x<max; x++) { + LayoutFB[(row+y)*LCOLS+col+x] = x<len ? !rev : rev; + } + } + break; + + case DIR_SOUTH: + val1=max-val1; + val2=max-val2; + rev=1; + + case DIR_NORTH: + for (y=0; y<max; y++) { + for (x=0; x<XRES; x++) { + len=x<XRES/2 ? val1 : val2; + LayoutFB[(row+y)*LCOLS+col+x] = y<len ? !rev : rev; + } + } + break; + } + + // flush area + if (dir & (DIR_EAST|DIR_WEST)) { + drv_generic_graphic_flush (row, col, YRES, XRES*len); + } else { + drv_generic_graphic_flush (row, col, YRES*len, XRES); + } + + return 0; +} + + +// **************************************** +// *** generic init/quit *** +// **************************************** + +int drv_generic_graphic_init (char *section, char *driver) +{ + Section=section; + Driver=driver; + + // init display framebuffer + DisplayFB = malloc(DCOLS*DROWS*sizeof(char)); + memset (DisplayFB, 0, DROWS*DCOLS*sizeof(char)); + + // init layout framebuffer + LROWS = 0; + LCOLS = 0; + LayoutFB=NULL; + drv_generic_graphic_resizeFB (DROWS, DCOLS); + + // sanity check + if (LayoutFB==NULL || DisplayFB==NULL) { + error ("%s: framebuffer could not be allocated: malloc() failed", Driver); + return -1; + } + + return 0; +} + + +int drv_generic_graphic_quit (void) +{ + + if (LayoutFB) { + free(LayoutFB); + LayoutFB=NULL; + } + + if (DisplayFB) { + free(DisplayFB); + DisplayFB=NULL; + } + + return (0); +} diff --git a/drv_generic_graphic.h b/drv_generic_graphic.h new file mode 100644 index 0000000..3850b7f --- /dev/null +++ b/drv_generic_graphic.h @@ -0,0 +1,66 @@ +/* $Id: drv_generic_graphic.h,v 1.1 2004/02/15 21:43:43 reinelt Exp $ + * + * generic driver helper for graphic displays + * + * Copyright 1999, 2000 Michael Reinelt <reinelt@eunet.at> + * Copyright 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net> + * + * 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_generic_graphic.h,v $ + * Revision 1.1 2004/02/15 21:43:43 reinelt + * T6963 driver nearly finished + * framework for graphic displays done + * i2c_sensors patch from Xavier + * some more old generation files removed + * + */ + +/* + * + * exported fuctions: + * + * Fixme: document me! + * + */ + +#ifndef _DRV_GENERIC_GRAPHIC_H_ +#define _DRV_GENERIC_GRAPHIC_H_ + + +#include <termios.h> +#include "widget.h" + + +extern int DROWS, DCOLS; // display size +extern int LROWS, LCOLS; // layout size +extern int XRES, YRES; // pixel width/height of one char +extern int GOTO_COST; // number of bytes a goto command requires + +// these functions must be implemented by the real driver +// Fixme: +void (*drv_generic_graphic_real_memcpy)(void); + + +int drv_generic_graphic_init (char *section, char *driver); +int drv_generic_graphic_draw (WIDGET *W); +int drv_generic_graphic_icon_draw (WIDGET *W); +int drv_generic_graphic_bar_draw (WIDGET *W); +int drv_generic_graphic_quit (void); + +#endif diff --git a/drv_generic_text.c b/drv_generic_text.c index e450ec6..60b7875 100644 --- a/drv_generic_text.c +++ b/drv_generic_text.c @@ -1,4 +1,4 @@ -/* $Id: drv_generic_text.c,v 1.10 2004/02/14 11:56:17 reinelt Exp $ +/* $Id: drv_generic_text.c,v 1.11 2004/02/15 21:43:43 reinelt Exp $ * * generic driver helper for text-based displays * @@ -23,6 +23,12 @@ * * * $Log: drv_generic_text.c,v $ + * Revision 1.11 2004/02/15 21:43:43 reinelt + * T6963 driver nearly finished + * framework for graphic displays done + * i2c_sensors patch from Xavier + * some more old generation files removed + * * Revision 1.10 2004/02/14 11:56:17 reinelt * M50530 driver ported * changed lots of 'char' to 'unsigned char' @@ -121,8 +127,8 @@ int CHARS, CHAR0; // number of user-defineable characters, ASCII of first char int ICONS; // number of user-defineable characters reserved for icons -static char *LayoutFB = NULL; -static char *DisplayFB = NULL; +static unsigned char *LayoutFB = NULL; +static unsigned char *DisplayFB = NULL; static int nSegment=0; static int fSegment=0; @@ -135,7 +141,7 @@ static BAR *BarFB = NULL; // *** generic Framebuffer stuff *** // **************************************** -void drv_generic_text_resizeFB (int rows, int cols) +static void drv_generic_text_resizeFB (int rows, int cols) { char *newFB; BAR *newBar; diff --git a/drv_generic_text.h b/drv_generic_text.h index ef8680c..f6c8099 100644 --- a/drv_generic_text.h +++ b/drv_generic_text.h @@ -1,4 +1,4 @@ -/* $Id: drv_generic_text.h,v 1.5 2004/02/14 11:56:17 reinelt Exp $ +/* $Id: drv_generic_text.h,v 1.6 2004/02/15 21:43:43 reinelt Exp $ * * generic driver helper for text-based displays * @@ -23,6 +23,12 @@ * * * $Log: drv_generic_text.h,v $ + * Revision 1.6 2004/02/15 21:43:43 reinelt + * T6963 driver nearly finished + * framework for graphic displays done + * i2c_sensors patch from Xavier + * some more old generation files removed + * * Revision 1.5 2004/02/14 11:56:17 reinelt * M50530 driver ported * changed lots of 'char' to 'unsigned char' @@ -73,7 +79,6 @@ void (*drv_generic_text_real_defchar)(int ascii, unsigned char *buffer); int drv_generic_text_init (char *section, char *driver); -void drv_generic_text_resizeFB (int rows, int cols); int drv_generic_text_draw (WIDGET *W); int drv_generic_text_icon_init (void); int drv_generic_text_icon_draw (WIDGET *W); @@ -1,8 +1,9 @@ -/* $Id: fontmap.c,v 1.6 2004/01/29 04:40:02 reinelt Exp $ +/* $Id: font_6x8.h,v 1.1 2004/02/15 21:43:43 reinelt Exp $ * - * 5x8 font + * 6x8 font * - * Copyright 1999, 2000 Michael Reinelt <reinelt@eunet.at> + * Copyright 1999, 2000, 2004 Michael Reinelt <reinelt@eunet.at> + * Copyright 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net> * * This file is part of LCD4Linux. * @@ -21,42 +22,15 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * - * $Log: fontmap.c,v $ - * Revision 1.6 2004/01/29 04:40:02 reinelt - * every .c file includes "config.h" now - * - * Revision 1.5 2003/10/05 17:58:50 reinelt - * libtool junk; copyright messages cleaned up - * - * Revision 1.4 2000/08/10 09:44:09 reinelt - * - * new debugging scheme: error(), info(), debug() - * uses syslog if in daemon mode - * - * Revision 1.3 2000/03/25 05:50:43 reinelt - * - * memory leak in Raster_flush closed - * driver family logic changed - * - * Revision 1.2 2000/03/24 11:36:56 reinelt - * - * new syntax for raster configuration - * changed XRES and YRES to be configurable - * PPM driver works nice - * - * Revision 1.1 2000/03/22 15:36:21 reinelt - * - * added '-l' switch (list drivers) - * generic pixmap driver added - * X11 Framework done + * $Log: font_6x8.h,v $ + * Revision 1.1 2004/02/15 21:43:43 reinelt + * T6963 driver nearly finished + * framework for graphic displays done + * i2c_sensors patch from Xavier + * some more old generation files removed * */ -#include "config.h" - -#include "pixmap.h" -#include "fontmap.h" - #define ______ 0x00 #define _____O 0x01 #define ____O_ 0x02 @@ -90,7 +64,7 @@ #define _OOOO_ 0x1e #define _OOOOO 0x1f -unsigned char Fontmap[256][8]={ +unsigned char Font_6x8[256][8]={ [0x20] { ______, ______, ______, diff --git a/fontmap.h b/fontmap.h deleted file mode 100644 index 7708832..0000000 --- a/fontmap.h +++ /dev/null @@ -1,39 +0,0 @@ -/* $Id: fontmap.h,v 1.2 2003/10/05 17:58:50 reinelt Exp $ - * - * 5x8 font - * - * Copyright 1999, 2000 Michael Reinelt <reinelt@eunet.at> - * - * 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: fontmap.h,v $ - * Revision 1.2 2003/10/05 17:58:50 reinelt - * libtool junk; copyright messages cleaned up - * - * Revision 1.1 2000/03/24 11:37:43 reinelt - * - * fontmap.h added - * - */ - -#ifndef _FONTMAP_H_ -#define _FONTMAP_H_ - -extern unsigned char Fontmap[256][8]; - -#endif diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample index 164fff9..73cf1fc 100644 --- a/lcd4linux.conf.sample +++ b/lcd4linux.conf.sample @@ -71,6 +71,17 @@ Display USBLCD { } +Display T6963-240x64 { + Driver 'T6963' + Port '/dev/parports/0' + Size '240x64' + Wire.CE 'STROBE' + Wire.CD 'SELECT' + Wire.RD 'AUTOFD' + Wire.WR 'INIT' +} + + Widget OS { class 'Text' expression '*** '.uname('sysname').' '.uname('release').' ***' @@ -291,7 +302,8 @@ Layout L16x2 { #Display 'CF631' #Display 'CF632' #Display 'CF633' -Display 'USBLCD' +#Display 'USBLCD' +Display 'T6963-240x64' Layout 'Default' #Layout 'L16x2' @@ -399,8 +399,8 @@ modename="$progname" # Constants. PROGRAM=ltmain.sh PACKAGE=libtool -VERSION=1.5.0a -TIMESTAMP=" (1.1220.2.35 2003/11/12 18:51:58) Debian$Rev: 179 $" +VERSION=1.5.2 +TIMESTAMP=" (1.1220.2.60 2004/01/25 12:25:08) Debian$Rev: 192 $" default_mode= help="Try \`$progname --help' for more information." @@ -1234,6 +1234,7 @@ EOF no_install=no objs= non_pic_objects= + precious_files_regex= prefer_static_libs=no preload=no prev= @@ -1397,6 +1398,11 @@ EOF prev= continue ;; + precious_regex) + precious_files_regex="$arg" + prev= + continue + ;; release) release="-$arg" prev= @@ -1763,6 +1769,11 @@ EOF -o) prev=output ;; + -precious-files-regex) + prev=precious_regex + continue + ;; + -release) prev=release continue @@ -2665,9 +2676,10 @@ EOF else $show "extracting exported symbol list from \`$soname'" save_ifs="$IFS"; IFS='~' - eval cmds=\"$extract_expsyms_cmds\" + cmds=$extract_expsyms_cmds for cmd in $cmds; do IFS="$save_ifs" + eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done @@ -2678,9 +2690,10 @@ EOF if test -f "$output_objdir/$newlib"; then :; else $show "generating import library for \`$soname'" save_ifs="$IFS"; IFS='~' - eval cmds=\"$old_archive_from_expsyms_cmds\" + cmds=$old_archive_from_expsyms_cmds for cmd in $cmds; do IFS="$save_ifs" + eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done @@ -2959,8 +2972,8 @@ EOF *" $path "*) ;; *) newlib_search_path="$newlib_search_path $path";; esac - path="" fi + path="" ;; *) path="-L$path" @@ -3428,6 +3441,10 @@ EOF *.$objext) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) + if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 + then + continue + fi removelist="$removelist $p" ;; *) ;; @@ -3937,10 +3954,11 @@ EOF $show "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $run $rm $export_symbols - eval cmds=\"$export_symbols_cmds\" + cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" + eval cmd=\"$cmd\" if len=`expr "X$cmd" : ".*"` && test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then $show "$cmd" @@ -4057,19 +4075,23 @@ EOF # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then - eval cmds=\"$module_expsym_cmds\" + eval test_cmds=\"$module_expsym_cmds\" + cmds=$module_expsym_cmds else - eval cmds=\"$module_cmds\" + eval test_cmds=\"$module_cmds\" + cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - eval cmds=\"$archive_expsym_cmds\" + eval test_cmds=\"$archive_expsym_cmds\" + cmds=$archive_expsym_cmds else - eval cmds=\"$archive_cmds\" + eval test_cmds=\"$archive_cmds\" + cmds=$archive_cmds fi fi - if test "X$skipped_export" != "X:" && len=`expr "X$cmds" : ".*"` && + if test "X$skipped_export" != "X:" && len=`expr "X$test_cmds" : ".*"` && test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else @@ -4154,6 +4176,7 @@ EOF save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" + eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done @@ -4170,19 +4193,28 @@ EOF # value of $libobjs for piecewise linking. # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + cmds=$module_expsym_cmds + else + cmds=$module_cmds + fi + else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - eval cmds=\"$archive_expsym_cmds\" + cmds=$archive_expsym_cmds else - eval cmds=\"$archive_cmds\" + cmds=$archive_cmds + fi fi # Append the command to remove the reloadable object files # to the just-reset $cmds. - eval cmds=\"\$cmds~$rm $delfiles\" + eval cmds=\"\$cmds~\$rm $delfiles\" fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" + eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done @@ -4333,10 +4365,11 @@ EOF reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" - eval cmds=\"$reload_cmds\" + cmds=$reload_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" + eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done @@ -4369,10 +4402,11 @@ EOF # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" - eval cmds=\"$reload_cmds\" + cmds=$reload_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" + eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done @@ -5344,13 +5378,13 @@ fi\ # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then - eval cmds=\"$old_archive_from_new_cmds\" + cmds=$old_archive_from_new_cmds else eval cmds=\"$old_archive_cmds\" if len=`expr "X$cmds" : ".*"` && test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then - : + cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts $echo "using piecewise archive linking..." @@ -5402,12 +5436,13 @@ fi\ if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else - eval cmds=\"\$concat_cmds~$old_archive_cmds\" + eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do + eval cmd=\"$cmd\" IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? @@ -5825,10 +5860,11 @@ relink_command=\"$relink_command\"" # Do each command in the postinstall commands. lib="$destdir/$realname" - eval cmds=\"$postinstall_cmds\" + cmds=$postinstall_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" + eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done @@ -6041,16 +6077,17 @@ relink_command=\"$relink_command\"" $show "$install_prog $file $oldlib" $run eval "$install_prog \$file \$oldlib" || exit $? - if test -n "$stripme" && test -n "$striplib"; then + if test -n "$stripme" && test -n "$old_striplib"; then $show "$old_striplib $oldlib" $run eval "$old_striplib $oldlib" || exit $? fi # Do each command in the postinstall commands. - eval cmds=\"$old_postinstall_cmds\" + cmds=$old_postinstall_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" + eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done @@ -6085,10 +6122,11 @@ relink_command=\"$relink_command\"" for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. - eval cmds=\"$finish_cmds\" + cmds=$finish_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" + eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || admincmds="$admincmds $cmd" @@ -6362,10 +6400,11 @@ relink_command=\"$relink_command\"" if test "$mode" = uninstall; then if test -n "$library_names"; then # Do each command in the postuninstall commands. - eval cmds=\"$postuninstall_cmds\" + cmds=$postuninstall_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" + eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" if test "$?" -ne 0 && test "$rmforce" != yes; then @@ -6377,10 +6416,11 @@ relink_command=\"$relink_command\"" if test -n "$old_library"; then # Do each command in the old_postuninstall commands. - eval cmds=\"$old_postuninstall_cmds\" + cmds=$old_postuninstall_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" + eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" if test "$?" -ne 0 && test "$rmforce" != yes; then @@ -6625,6 +6665,8 @@ The following components of LINK-COMMAND are treated specially: -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects + -precious-files-regex REGEX + don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries diff --git a/pixmap.c b/pixmap.c deleted file mode 100644 index d219a6d..0000000 --- a/pixmap.c +++ /dev/null @@ -1,330 +0,0 @@ -/* $Id: pixmap.c,v 1.14 2004/01/30 20:57:56 reinelt Exp $ - * - * generic pixmap driver - * - * Copyright 1999, 2000 Michael Reinelt <reinelt@eunet.at> - * - * 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: pixmap.c,v $ - * Revision 1.14 2004/01/30 20:57:56 reinelt - * HD44780 patch from Martin Hejl - * dmalloc integrated - * - * Revision 1.13 2004/01/29 04:40:02 reinelt - * every .c file includes "config.h" now - * - * Revision 1.12 2003/10/05 17:58:50 reinelt - * libtool junk; copyright messages cleaned up - * - * Revision 1.11 2003/09/10 14:01:53 reinelt - * icons nearly finished\! - * - * Revision 1.10 2002/08/19 04:41:20 reinelt - * introduced bar.c, moved bar stuff from display.h to bar.h - * - * Revision 1.9 2001/05/27 07:19:28 reinelt - * - * fixed a warning in pixmap.c - * temporarily fixed a bug in isdn.c (ISDN_MAX_CHANNELS is no longer defined?) - * fixed a bug in configure.in (--with-drivers=xyz did not work) - * - * Revision 1.8 2001/04/27 05:04:57 reinelt - * - * replaced OPEN_MAX with sysconf() - * replaced mktemp() with mkstemp() - * unlock serial port if open() fails - * - * Revision 1.7 2001/03/17 11:44:10 ltoetsch - * allow more than 1 BAR_T - * - * Revision 1.6 2001/03/16 16:40:17 ltoetsch - * implemented time bar - * - * Revision 1.5 2000/03/26 18:46:28 reinelt - * - * bug in pixmap.c that leaded to empty bars fixed - * name conflicts with X11 resolved - * - * Revision 1.4 2000/03/25 05:50:43 reinelt - * - * memory leak in Raster_flush closed - * driver family logic changed - * - * Revision 1.3 2000/03/24 11:36:56 reinelt - * - * new syntax for raster configuration - * changed XRES and YRES to be configurable - * PPM driver works nice - * - * Revision 1.2 2000/03/23 07:24:48 reinelt - * - * PPM driver up and running (but slow!) - * - * Revision 1.1 2000/03/22 15:36:21 reinelt - * - * added '-l' switch (list drivers) - * generic pixmap driver added - * X11 Framework done - * - */ - -/* - * exported functions: - * - * int pix_clear(void); - * clears the pixmap - * - * int pix_init (int rows, int cols, int XRES, int YRES); - * allocates & clears pixmap - * - * int pix_put (int row, int col, char *text); - * draws text into the pixmap - * - * int pix_bar (int type, int row, int col, int max, int len1, int len2); - * draws a bar into the pixmap - * - * void pix_icon (int ascii, char *buffer) - * used as the "define char" function for icons - * - */ - - -#include "config.h" - -#include <stdlib.h> -#include <stdio.h> -#include <time.h> - -#include "display.h" -#include "bar.h" -#include "icon.h" -#include "pixmap.h" -#include "fontmap.h" -#include "debug.h" - -#ifdef WITH_DMALLOC -#include <dmalloc.h> -#endif - -static int ROWS=0; -static int COLS=0; -static int XRES=0; -static int YRES=0; - -unsigned char *LCDpixmap=NULL; - - -int pix_clear(void) -{ - int i; - - for (i=0; i<ROWS*COLS; i++) { - LCDpixmap[i]=0; - } - - return 0; -} - - -int pix_init (int rows, int cols, int xres, int yres) -{ - if (rows<1 || cols<1 || xres<1 || yres<1) - return -1; - - if (LCDpixmap) - free (LCDpixmap); - - XRES=xres; - YRES=yres; - ROWS=rows*yres; - COLS=cols*xres; - - if ((LCDpixmap=malloc (ROWS*COLS*sizeof(unsigned char)))==NULL) - return -1; - - return pix_clear(); -} - - -int pix_put (int row, int col, char *text) -{ - int c, x, y, mask; - - row*=YRES; - col*=XRES; - - while (*text && col<COLS) { - c=*(unsigned char*)text; - if (c!='\t') { - for (y=0; y<YRES; y++) { - mask=1<<XRES; - for (x=0; x<XRES; x++) { - mask>>=1; - LCDpixmap[(row+y)*COLS+col+x]=Fontmap[c][y]&mask?1:0; - } - } - } - col+=XRES; - text++; - } - return 0; -} - - -#define N_BAR_T 10 - -int pix_bar (int type, int row, int col, int max, int len1, int len2) -{ - int x, y, len, rev; - static struct { - int row, col, len; - int *buf; - int init; - time_t old; - } vals[N_BAR_T]; - time_t now; - int i=0; - - row*=YRES; - col*=XRES; - - if (type & BAR_H) { - if (max>COLS-col) - max=COLS-col; - } else { - if (max>ROWS-row) - max=ROWS-row; - } - - if (len1<1) len1=1; - else if (len1>max) len1=max; - - if (type == BAR_T) { - for (i=0; i < N_BAR_T; i++) { - if (vals[i].init == 0 && vals[i].buf == 0) { - vals[i].buf = calloc(len2, sizeof(int)); - if (vals[i].buf == NULL) { - error("Couldn't allocte valbuf"); - vals[i].init = -1; - return -1; - } - vals[i].init = 1; - vals[i].len = len2; - vals[i].col = col; - vals[i].row = row; - time(&vals[i].old); - break; - } - else if (vals[i].init==1 && col==vals[i].col && row==vals[i].row) - break; - } - if (i == N_BAR_T) { - error("Too many $t, %d supported", N_BAR_T); - return -1; - } - } - else { - if (len2<1) len2=1; - else if (len2>max) len2=max; - } - - rev=0; - - switch (type) { - case BAR_L: - len1=max-len1; - len2=max-len2; - rev=1; - - case BAR_R: - for (y=0; y<YRES; y++) { - len=y<YRES/2?len1:len2; - for (x=0; x<max; x++) { - LCDpixmap[(row+y)*COLS+col+x]=x<len?!rev:rev; - } - } - break; - - case BAR_U: - len1=max-len1; - len2=max-len2; - rev=1; - - case BAR_D: - for (y=0; y<max; y++) { - for (x=0; x<XRES; x++) { - len=x<XRES/2?len1:len2; - LCDpixmap[(row+y)*COLS+col+x]=y<len?!rev:rev; - } - } - break; - - case BAR_T: - len1=max-len1; - len2=vals[i].len; - rev=1; - time(&now); - if (now == vals[i].old) { - vals[i].buf[len2-1] += len1; - vals[i].buf[len2-1] /= 2; - } - else { - for (; vals[i].old < now; vals[i].old++) - for (x=1; x<len2; x++) - vals[i].buf[x-1]=vals[i].buf[x]; - vals[i].buf[len2-1] = len1; - } - for (x=0; x<len2; x++) { - len = vals[i].buf[x]; - for (y=0; y<max; y++) { - // TODO: allow for drawing lines? - LCDpixmap[(row+y)*COLS+col+x]=y<len?!rev:rev; - } - } - break; - - } - return 0; -} - - -void pix_icon (int ascii, char *buffer) -{ - // we have to peek the whole screen for this particular icon, - // and render it again - - int row, col; - int x, y, mask; - int c; - - for (row=0; row<ROWS/YRES; row++) { - for (col=0; col<COLS/XRES; col++) { - c=icon_peek(row, col); - if (c!=ascii) continue; - for (y=0; y<YRES; y++) { - mask=1<<XRES; - for (x=0; x<XRES; x++) { - mask>>=1; - LCDpixmap[(row*YRES+y)*COLS+col*XRES+x]=buffer[y]&mask?1:0; - } - } - } - } - -} diff --git a/pixmap.h b/pixmap.h deleted file mode 100644 index 694b68e..0000000 --- a/pixmap.h +++ /dev/null @@ -1,61 +0,0 @@ -/* $Id: pixmap.h,v 1.5 2003/10/05 17:58:50 reinelt Exp $ - * - * generic pixmap driver - * - * Copyright 1999, 2000 Michael Reinelt <reinelt@eunet.at> - * - * 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: pixmap.h,v $ - * Revision 1.5 2003/10/05 17:58:50 reinelt - * libtool junk; copyright messages cleaned up - * - * Revision 1.4 2003/09/10 14:01:53 reinelt - * icons nearly finished\! - * - * Revision 1.3 2000/03/26 19:03:52 reinelt - * - * more Pixmap renaming - * quoting of '#' in config file - * - * Revision 1.2 2000/03/24 11:36:56 reinelt - * - * new syntax for raster configuration - * changed XRES and YRES to be configurable - * PPM driver works nice - * - * Revision 1.1 2000/03/22 15:36:21 reinelt - * - * added '-l' switch (list drivers) - * generic pixmap driver added - * X11 Framework done - * - */ - -#ifndef _PIXMAP_H_ -#define _PIXMAP_H_ - -extern unsigned char *LCDpixmap; - -int pix_clear (void); -int pix_init (int rows, int cols, int xres, int yres); -int pix_put (int row, int col, char *text); -int pix_bar (int type, int row, int col, int max, int len1, int len2); -void pix_icon (int ascii, char *buffer); - -#endif diff --git a/plugin_i2c_sensors.c b/plugin_i2c_sensors.c index 0c08b81..662f6c2 100644 --- a/plugin_i2c_sensors.c +++ b/plugin_i2c_sensors.c @@ -1,8 +1,9 @@ -/* $Id: plugin_i2c_sensors.c,v 1.10 2004/02/14 12:07:27 nicowallmeier Exp $ +/* $Id: plugin_i2c_sensors.c,v 1.11 2004/02/15 21:43:43 reinelt Exp $ * * I2C sensors plugin * * Copyright 2003,2004 Xavier Vello <xavier66@free.fr> + * Copyright 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net> * * This file is part of LCD4Linux. * @@ -22,6 +23,12 @@ * * * $Log: plugin_i2c_sensors.c,v $ + * Revision 1.11 2004/02/15 21:43:43 reinelt + * T6963 driver nearly finished + * framework for graphic displays done + * i2c_sensors patch from Xavier + * some more old generation files removed + * * Revision 1.10 2004/02/14 12:07:27 nicowallmeier * minor bugfix * @@ -41,7 +48,6 @@ * loadavg() uClibc replacement from Martin Heyl * round() uClibc replacement from Martin Hejl * warning in i2c_sensors fixed - * [ * * Revision 1.5 2004/01/29 05:55:30 reinelt * check for /sys mounted @@ -59,7 +65,6 @@ * * I2C Sensors plugin from Xavier added * - * */ /* @@ -67,22 +72,34 @@ * * int plugin_init_i2c_sensors (void) * adds function i2c_sensors() to retrieve informations from - * the i2c sensors via the sysfs interface of 2.6.x kernels + * the i2c sensors via sysfs or procfs interface * * -- WARNING -- - * This plugin is only for kernel series 2.5/2.6 and higher ! - * It uses the new sysfs pseudo-filesystem that you can mount with: - * mount -t sysfs none /sys - * - * -- WARNING #2 -- * This plugin should detect where your sensors are at startup. * If you can't get any token to work, ensure you don't get * an error message with "lcd4linux -Fvvv". * * If so, try to force the path to your sensors in the conf like this : - * i2c_sensors-path '/sys/bus/i2c/devices/0-6000/' - * (replace 0-6000 with the appropriate dir) - * + * for sysfs: i2c_sensors-path '/sys/bus/i2c/devices/0-6000/' + * for procfs: i2c_sensors-path '/proc/sys/dev/sensors/via686a-isa-6000' + * /!\ these path are for my system, change the last dir according to yours + */ + +/* + * Available tokens : # represents an int from 1 to 3 (or more) + * temp_input# -> temperature of sensor # (in °C) + * temp_max# and temp_hyst# -> max and min of sensor # + * in_input#, in_min# and in_max# -> voltages + * fan_input# -> speed (in RPM) of fan # + * fan_min# and fan_div# + * + * Tokens avaible only via sysfs if suported by your sensors: + * curr_input#, curr_min# and curr_max# -> value of current (in amps) + * pwm# + * temp_crit# -> critical value of sensor # + * vid -> cpu core voltage + * and maybe others + * (see /usr/src/linux/Documentation/i2c/sysfs-interface on linux 2.6) */ #include "config.h" @@ -104,25 +121,31 @@ #endif static char *path=NULL; +static int use_sysfs=0; static HASH I2Csensors = { 0, }; +static const char *procfs_tokens[4][3] = { + {"temp_hyst", "temp_max", "temp_input"}, // for temp# + {"in_min", "in_max", "in_input"}, // for in# + {"fan_div1", "fan_div2", "fan_div3"}, // for fan_div + {"fan_min", "fan_input", ""} // for fan# +}; + /***********************************************\ * Parsing for new 2.6 kernels 'sysfs' interface * \***********************************************/ -static int parse_i2c_sensors_sysfs(RESULT *arg) + +static int parse_i2c_sensors_sysfs(char *key) { double value; char val[32]; char buffer[32]; - char *key=R2S(arg); char file[64]; FILE *stream; - // construct absolute path to the file to read strcpy(file, path); strcat(file, key); - // read of file to buffer stream=fopen(file, "r"); if (stream==NULL) { error ("fopen(%s) failed",file); @@ -153,51 +176,52 @@ static int parse_i2c_sensors_sysfs(RESULT *arg) // we supress this nasty \n at the end val[strlen(val)-1]='\0'; } - + hash_set (&I2Csensors, key, val); - return 0; -} + return 0; -void my_i2c_sensors_sysfs(RESULT *result, RESULT *arg) -{ - int age; - char *val; - char *key=R2S(arg); - - age=hash_age(&I2Csensors, key, &val); - // refresh every 100msec - if (age<0 || age>100) { - parse_i2c_sensors_sysfs(arg); - val=hash_get(&I2Csensors, key); - } - if (val) { - SetResult(&result, R_STRING, val); - } else { - SetResult(&result, R_STRING, "??"); - } } - /************************************************\ * Parsing for old 2.4 kernels 'procfs' interface * \************************************************/ -static int parse_i2c_sensors_procfs(RESULT *arg) +static int parse_i2c_sensors_procfs(char *key) { - char *key=R2S(arg); - char file[64]; + char file[64]; FILE *stream; char buffer[32]; char *value; char *running; int pos=0; - const char delim[3]= " \n"; + const char delim[3]=" \n"; char final_key[32]; - + char *number = &key[strlen(key)-1]; + int tokens_index; + //debug("%s -> %s", key, number); strcpy(file, path); - strcat(file, key); + + if (!strncmp(key, "temp_", 5)) { + tokens_index=0; + strcat(file, "temp"); + strcat(file, number); + } else if (!strncmp(key, "in_", 3)) { + tokens_index=1; + strcat(file, "in"); + strcat(file, number); + } else if (!strncmp(key, "fan_div", 7)) { + tokens_index=2; + strcat(file, "fan_div"); + number = ""; + } else if (!strncmp(key, "fan_", 4)) { + tokens_index=3; + strcat(file, "fan"); + strcat(file, number); + } else { + return -1; + } stream=fopen(file, "r"); if (stream==NULL) { @@ -211,15 +235,17 @@ static int parse_i2c_sensors_procfs(RESULT *arg) error ("%s empty ?!",file); return -1; } - + running=strdupa(buffer); while(1) { value = strsep (&running, delim); - // debug("%s pos %i -> %s", key, pos , value); - if (!value) { + debug("%s pos %i -> %s", file, pos , value); + if (!value || !strcmp(value, "")) { + debug("%s pos %i -> BREAK", file, pos); break; } else { - sprintf (final_key, "%s.%i", key, pos); + sprintf (final_key, "%s%s", procfs_tokens[tokens_index][pos], number); + debug ("%s -> %s", final_key, value); hash_set (&I2Csensors, final_key, value); pos++; } @@ -227,29 +253,23 @@ static int parse_i2c_sensors_procfs(RESULT *arg) return 0; } -void my_i2c_sensors_procfs(RESULT *result, int argc, RESULT *argv[]) + /*****************************************\ + * Common functions (path search and init) * + \*****************************************/ + +void my_i2c_sensors(RESULT *result, RESULT *arg) { int age; char *val; - char *key; + char *key=R2S(arg); - switch (argc) { - case 1: - sprintf(key, "%s.0", R2S(argv[0])); - break; - case 2: - sprintf(key, "%s.%s", R2S(argv[0]), R2S(argv[1])); - break; - default: - return; - break; - } - age=hash_age(&I2Csensors, key, &val); - - // refresh every 100msec - if (age<0 || age>100) { - parse_i2c_sensors_procfs(argv[0]); + if (age<0 || age>250) { + if (use_sysfs) { + parse_i2c_sensors_sysfs(key); + } else { + parse_i2c_sensors_procfs(key); + } val=hash_get(&I2Csensors, key); } if (val) { @@ -259,10 +279,6 @@ void my_i2c_sensors_procfs(RESULT *result, int argc, RESULT *argv[]) } } - /*****************************************\ - * Common functions (path search and init) * - \*****************************************/ - void my_i2c_sensors_path(char *method) { struct dirent *dir; @@ -277,11 +293,10 @@ void my_i2c_sensors_path(char *method) base="/sys/bus/i2c/devices/"; } else if (!strcmp(method, "procfs")) { base="/proc/sys/dev/sensors/"; - //base="/sensors_2.4/"; // fake dir to test without rebooting 2.4 ;) + //base="/sensors_2.4/"; // fake dir to test without rebooting 2.4 ;) } else { return; } - fd1 = opendir(base); if (!fd1) { @@ -295,9 +310,9 @@ void my_i2c_sensors_path(char *method) while((dir = readdir(fd1))) { // Skip non-directories and '.' and '..' - if (dir->d_type!=DT_DIR || - strcmp(dir->d_name, "." )==0 || - strcmp(dir->d_name, "..")==0) { + if (dir->d_type!=DT_DIR || + strcmp(dir->d_name, "." )==0 || + strcmp(dir->d_name, "..")==0) { continue; } @@ -327,7 +342,7 @@ int plugin_init_i2c_sensors (void) char *path_cfg=cfg_get(NULL, "i2c_sensors-path", ""); if (strncmp(path_cfg, "/", 1)) { - debug("No path to i2c sensors found in the conf, calling my_i2c_sensors_path()"); + //debug("No path to i2c sensors found in the conf, calling my_i2c_sensors_path()"); my_i2c_sensors_path("sysfs"); if (!path) my_i2c_sensors_path("procfs"); @@ -358,11 +373,10 @@ int plugin_init_i2c_sensors (void) if (!path) { free(path); } else { - if (!strncmp(path, "/sys", 4)) { - AddFunction ("i2c_sensors", 1, my_i2c_sensors_sysfs); - } else if (!strncmp(path, "/proc", 5)) { - AddFunction ("i2c_sensors", -1, my_i2c_sensors_procfs); + if (strncmp(path, "/sys", 4)==0) { + use_sysfs=1; } + AddFunction ("i2c_sensors", 1, my_i2c_sensors); } return 0; diff --git a/widget_icon.c b/widget_icon.c index 3c631d9..a8d9738 100644 --- a/widget_icon.c +++ b/widget_icon.c @@ -1,4 +1,4 @@ -/* $Id: widget_icon.c,v 1.6 2004/02/07 13:45:23 reinelt Exp $ +/* $Id: widget_icon.c,v 1.7 2004/02/15 21:43:43 reinelt Exp $ * * icon widget handling * @@ -21,6 +21,12 @@ * * * $Log: widget_icon.c,v $ + * Revision 1.7 2004/02/15 21:43:43 reinelt + * T6963 driver nearly finished + * framework for graphic displays done + * i2c_sensors patch from Xavier + * some more old generation files removed + * * Revision 1.6 2004/02/07 13:45:23 reinelt * icon visibility patch #2 from Xavier * @@ -77,7 +83,7 @@ static void widget_icon_read_bitmap (char *section, WIDGET_ICON *Icon) int row, n; char key[15]; char *val, *v; - char *map; + unsigned char *map; for (row=0; row<YRES; row++) { snprintf (key, sizeof(key), "Bitmap.Row%d", row+1); diff --git a/widget_icon.h b/widget_icon.h index 9259836..ede84ea 100644 --- a/widget_icon.h +++ b/widget_icon.h @@ -1,4 +1,4 @@ -/* $Id: widget_icon.h,v 1.3 2004/02/04 19:11:44 reinelt Exp $ +/* $Id: widget_icon.h,v 1.4 2004/02/15 21:43:43 reinelt Exp $ * * icon widget handling * @@ -23,6 +23,12 @@ * * * $Log: widget_icon.h,v $ + * Revision 1.4 2004/02/15 21:43:43 reinelt + * T6963 driver nearly finished + * framework for graphic displays done + * i2c_sensors patch from Xavier + * some more old generation files removed + * * Revision 1.3 2004/02/04 19:11:44 reinelt * icon visibility patch from Xavier * @@ -39,15 +45,15 @@ #define _WIDGET_ICON_H_ typedef struct WIDGET_ICON { - char *speed_expr; // expression for update interval - int speed; // update interval (msec) - int ascii; // ascii code of icon (depends on the driver) - int curmap; // current bitmap sequence - int prvmap; // previous bitmap sequence - int maxmap; // number of bitmap sequences - char *bitmap; // bitmaps of (animated) icon - int visible; - char *visible_expr; + char *speed_expr; // expression for update interval + int speed; // update interval (msec) + int ascii; // ascii code of icon (depends on the driver) + int curmap; // current bitmap sequence + int prvmap; // previous bitmap sequence + int maxmap; // number of bitmap sequences + unsigned char *bitmap; // bitmaps of (animated) icon + int visible; // icon visible? + char *visible_expr; // expression for visibility } WIDGET_ICON; extern WIDGET_CLASS Widget_Icon; |