aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2000-08-09 09:50:29 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2000-08-09 09:50:29 +0000
commit1645d61018c24013525f3953613aaea56714bab4 (patch)
treeddf01503c9b524efbe08b2887ab9b9f0bed1dc55
parent7ff246c0458df37567dcefebfd9a720f9b98cdb7 (diff)
downloadlcd4linux-1645d61018c24013525f3953613aaea56714bab4.tar.gz
[lcd4linux @ 2000-08-09 09:50:29 by reinelt]
opened 0.98 development removed driver-specific signal-handlers added 'quit'-function to driver structure added global signal-handler git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@61 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to '')
-rw-r--r--BeckmannEgle.c28
-rw-r--r--Crystalfontz.c38
-rw-r--r--HD44780.c32
-rw-r--r--MatrixOrbital.c36
-rw-r--r--PalmPilot.c28
-rw-r--r--README41
-rw-r--r--XWindow.c41
-rwxr-xr-xconfigure2
-rw-r--r--configure.in2
-rw-r--r--display.c22
-rw-r--r--display.h11
-rw-r--r--lcd4linux.c39
-rw-r--r--system.c11
13 files changed, 204 insertions, 127 deletions
diff --git a/BeckmannEgle.c b/BeckmannEgle.c
index 790d3b7..c660bf9 100644
--- a/BeckmannEgle.c
+++ b/BeckmannEgle.c
@@ -1,4 +1,4 @@
-/* $Id: BeckmannEgle.c,v 1.2 2000/04/30 06:40:42 reinelt Exp $
+/* $Id: BeckmannEgle.c,v 1.3 2000/08/09 09:50:29 reinelt Exp $
*
* driver for Beckmann+Egle mini terminals
*
@@ -20,6 +20,13 @@
*
*
* $Log: BeckmannEgle.c,v $
+ * Revision 1.3 2000/08/09 09:50:29 reinelt
+ *
+ * opened 0.98 development
+ * removed driver-specific signal-handlers
+ * added 'quit'-function to driver structure
+ * added global signal-handler
+ *
* Revision 1.2 2000/04/30 06:40:42 reinelt
*
* bars for Beckmann+Egle driver
@@ -43,7 +50,6 @@
#include <string.h>
#include <errno.h>
#include <unistd.h>
-#include <signal.h>
#include <termios.h>
#include <fcntl.h>
@@ -346,8 +352,6 @@ int BE_clear (void)
return 0;
}
-static void BE_quit (int signal); //forward declaration
-
int BE_init (LCD *Self)
{
int i, rows=-1, cols=-1;
@@ -403,10 +407,6 @@ int BE_init (LCD *Self)
BE_clear();
- signal(SIGINT, BE_quit);
- signal(SIGQUIT, BE_quit);
- signal(SIGTERM, BE_quit);
-
return 0;
}
@@ -528,19 +528,15 @@ int BE_flush (void)
return 0;
}
-int lcd_hello (void); // prototype from lcd4linux.c
-
-static void BE_quit (int signal)
+int BE_quit (void)
{
- debug ("got signal %d\n", signal);
- BE_clear();
- lcd_hello();
+ debug ("closing port %s\n", Port);
close (Device);
unlock_port(Port);
- exit (0);
+ return 0;
}
LCD BeckmannEgle[] = {
- { "BLC100x", 0, 0, XRES, YRES, BARS, BE_init, BE_clear, BE_put, BE_bar, BE_flush },
+ { "BLC100x", 0, 0, XRES, YRES, BARS, BE_init, BE_clear, BE_put, BE_bar, BE_flush, BE_quit },
{ NULL }
};
diff --git a/Crystalfontz.c b/Crystalfontz.c
index 09d41d1..9b3c370 100644
--- a/Crystalfontz.c
+++ b/Crystalfontz.c
@@ -1,4 +1,4 @@
-/* $Id: Crystalfontz.c,v 1.3 2000/06/04 21:43:50 herp Exp $
+/* $Id: Crystalfontz.c,v 1.4 2000/08/09 09:50:29 reinelt Exp $
*
* driver for display modules from Crystalfontz
*
@@ -19,6 +19,13 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: Crystalfontz.c,v $
+ * Revision 1.4 2000/08/09 09:50:29 reinelt
+ *
+ * opened 0.98 development
+ * removed driver-specific signal-handlers
+ * added 'quit'-function to driver structure
+ * added global signal-handler
+ *
* Revision 1.3 2000/06/04 21:43:50 herp
* minor bugfix (zero length)
*
@@ -31,9 +38,9 @@
#include <errno.h>
#include <termios.h>
#include <unistd.h>
-#include <signal.h>
#include <fcntl.h>
+#include "debug.h"
#include "cfg.h"
#include "lock.h"
#include "display.h"
@@ -56,8 +63,9 @@ static char isTxtDirty;
static char *isBarDirty;
static char isAnyBarDirty;
-static void cryfonquit() {
+int cryfonquit(void) {
+ debug ("closing port %s\n", Port);
close(Device);
unlock_port(Port);
exit(0);
@@ -94,7 +102,7 @@ struct termios portset;
return fd;
}
-static int cryfoninit(LCD *Self) {
+int cryfoninit(LCD *Self) {
char *port;
char *speed;
char *backlight;
@@ -140,6 +148,8 @@ char cmd_contrast[2]={ CRYFON_CONTRAST_CTRL, };
return -1;
}
+ debug ("using port %s at %d baud\n", Port, atoi(speed));
+
if ((Device=cryfonopen())==-1)
return -1;
@@ -185,10 +195,6 @@ char cmd_contrast[2]={ CRYFON_CONTRAST_CTRL, };
isAnyBarDirty=0;
isTxtDirty=0;
- signal(SIGINT,cryfonquit);
- signal(SIGQUIT,cryfonquit);
- signal(SIGTERM,cryfonquit);
-
usleep(350000);
write(Device, CRYFON_HIDE_CURSOR CRYFON_SCROLL_OFF CRYFON_WRAP_OFF,3);
backlight=cfg_get("Backlight")?:NULL;
@@ -206,13 +212,13 @@ char cmd_contrast[2]={ CRYFON_CONTRAST_CTRL, };
return 0;
}
-static int cryfonclear() {
+int cryfonclear() {
memset(Txtbuf,' ',tdim);
memset(Barbuf,0,bdim);
return 0;
}
-static int cryfonput(int row,int col,char *text) {
+int cryfonput(int row,int col,char *text) {
int pos;
pos=row*Lcd.cols+col;
@@ -254,7 +260,7 @@ static void whiten(int bitfrom,int len,int pos,int startbyte,int endbyte) {
}
}
-static int cryfonbar(int type,int row,int col,int max,int len1,int len2) {
+int cryfonbar(int type,int row,int col,int max,int len1,int len2) {
int endb,maxb;
int bitfrom;
int pos;
@@ -529,7 +535,7 @@ int i,j,k1,k2,ci;
flushBarCharBuf();
}
-static int cryfonflush() {
+int cryfonflush() {
if (isTxtDirty) {
writeTxtDiff();
@@ -544,9 +550,9 @@ static int cryfonflush() {
}
LCD Crystalfontz[] = {
- { "626", 2, 16, XRES, YRES, BARS, cryfoninit, cryfonclear, cryfonput, cryfonbar, cryfonflush },
- { "636", 2, 16, XRES, YRES, BARS, cryfoninit, cryfonclear, cryfonput, cryfonbar, cryfonflush },
- { "632", 2, 16, XRES, YRES, BARS, cryfoninit, cryfonclear, cryfonput, cryfonbar, cryfonflush },
- { "634", 4, 20, XRES, YRES, BARS, cryfoninit, cryfonclear, cryfonput, cryfonbar, cryfonflush },
+ { "626", 2, 16, XRES, YRES, BARS, cryfoninit, cryfonclear, cryfonput, cryfonbar, cryfonflush, cryfonquit },
+ { "636", 2, 16, XRES, YRES, BARS, cryfoninit, cryfonclear, cryfonput, cryfonbar, cryfonflush, cryfonquit },
+ { "632", 2, 16, XRES, YRES, BARS, cryfoninit, cryfonclear, cryfonput, cryfonbar, cryfonflush, cryfonquit },
+ { "634", 4, 20, XRES, YRES, BARS, cryfoninit, cryfonclear, cryfonput, cryfonbar, cryfonflush, cryfonquit },
{ NULL }
};
diff --git a/HD44780.c b/HD44780.c
index 3278ad2..a31db00 100644
--- a/HD44780.c
+++ b/HD44780.c
@@ -1,4 +1,4 @@
-/* $Id: HD44780.c,v 1.6 2000/07/31 10:43:44 reinelt Exp $
+/* $Id: HD44780.c,v 1.7 2000/08/09 09:50:29 reinelt Exp $
*
* driver for display modules based on the HD44780 chip
*
@@ -20,6 +20,13 @@
*
*
* $Log: HD44780.c,v $
+ * Revision 1.7 2000/08/09 09:50:29 reinelt
+ *
+ * opened 0.98 development
+ * removed driver-specific signal-handlers
+ * added 'quit'-function to driver structure
+ * added global signal-handler
+ *
* Revision 1.6 2000/07/31 10:43:44 reinelt
*
* some changes to support kernel-2.4 (different layout of various files in /proc)
@@ -70,7 +77,6 @@
#include <string.h>
#include <unistd.h>
#include <time.h>
-#include <signal.h>
#include <errno.h>
#ifdef HAVE_SYS_IO_H
#include <sys/io.h>
@@ -340,8 +346,6 @@ int HD_clear (void)
return 0;
}
-static void HD_quit (int signal); //forward declaration
-
int HD_init (LCD *Self)
{
int rows=-1, cols=-1;
@@ -386,10 +390,6 @@ int HD_init (LCD *Self)
HD_clear();
- signal(SIGINT, HD_quit);
- signal(SIGQUIT, HD_quit);
- signal(SIGTERM, HD_quit);
-
return 0;
}
@@ -518,17 +518,17 @@ int HD_flush (void)
return 0;
}
-int lcd_hello (void); // prototype from lcd4linux.c
-
-static void HD_quit (int signal)
+int HD_quit (void)
{
- debug ("got signal %d\n", signal);
- HD_clear();
- lcd_hello();
- exit (0);
+ debug ("closing port 0x%x\n", Port);
+ if (ioperm(Port, 3, 0)!=0) {
+ fprintf (stderr, "HD44780: ioperm(0x%x) failed: %s\n", Port, strerror(errno));
+ return -1;
+ }
+ return 0;
}
LCD HD44780[] = {
- { "HD44780", 0, 0, XRES, YRES, BARS, HD_init, HD_clear, HD_put, HD_bar, HD_flush },
+ { "HD44780", 0, 0, XRES, YRES, BARS, HD_init, HD_clear, HD_put, HD_bar, HD_flush, HD_quit },
{ NULL }
};
diff --git a/MatrixOrbital.c b/MatrixOrbital.c
index 5096ee0..a3e8077 100644
--- a/MatrixOrbital.c
+++ b/MatrixOrbital.c
@@ -1,4 +1,4 @@
-/* $Id: MatrixOrbital.c,v 1.17 2000/04/15 11:13:54 reinelt Exp $
+/* $Id: MatrixOrbital.c,v 1.18 2000/08/09 09:50:29 reinelt Exp $
*
* driver for Matrix Orbital serial display modules
*
@@ -20,6 +20,13 @@
*
*
* $Log: MatrixOrbital.c,v $
+ * Revision 1.18 2000/08/09 09:50:29 reinelt
+ *
+ * opened 0.98 development
+ * removed driver-specific signal-handlers
+ * added 'quit'-function to driver structure
+ * added global signal-handler
+ *
* Revision 1.17 2000/04/15 11:13:54 reinelt
*
* added '-d' (debugging) switch
@@ -106,7 +113,6 @@
#include <string.h>
#include <errno.h>
#include <unistd.h>
-#include <signal.h>
#include <termios.h>
#include <fcntl.h>
@@ -386,8 +392,6 @@ int MO_clear (void)
return 0;
}
-static void MO_quit (int signal); //forward declaration
-
int MO_init (LCD *Self)
{
char *port;
@@ -442,10 +446,6 @@ int MO_init (LCD *Self)
MO_write ("\376R", 2); // auto scroll off
MO_write ("\376V", 2); // GPO off
- signal(SIGINT, MO_quit);
- signal(SIGQUIT, MO_quit);
- signal(SIGTERM, MO_quit);
-
return 0;
}
@@ -567,23 +567,19 @@ int MO_flush (void)
return 0;
}
-int lcd_hello (void); // prototype from lcd4linux.c
-
-static void MO_quit (int signal)
+int MO_quit (void)
{
- debug ("got signal %d\n", signal);
- MO_clear();
- lcd_hello();
+ debug ("closing port %s\n", Port);
close (Device);
unlock_port(Port);
- exit (0);
+ return (0);
}
LCD MatrixOrbital[] = {
- { "LCD0821", 2, 8, XRES, YRES, BARS, MO_init, MO_clear, MO_put, MO_bar, MO_flush },
- { "LCD1621", 2, 16, XRES, YRES, BARS, MO_init, MO_clear, MO_put, MO_bar, MO_flush },
- { "LCD2021", 2, 20, XRES, YRES, BARS, MO_init, MO_clear, MO_put, MO_bar, MO_flush },
- { "LCD2041", 4, 20, XRES, YRES, BARS, MO_init, MO_clear, MO_put, MO_bar, MO_flush },
- { "LCD4021", 2, 40, XRES, YRES, BARS, MO_init, MO_clear, MO_put, MO_bar, MO_flush },
+ { "LCD0821", 2, 8, XRES, YRES, BARS, MO_init, MO_clear, MO_put, MO_bar, MO_flush, MO_quit },
+ { "LCD1621", 2, 16, XRES, YRES, BARS, MO_init, MO_clear, MO_put, MO_bar, MO_flush, MO_quit },
+ { "LCD2021", 2, 20, XRES, YRES, BARS, MO_init, MO_clear, MO_put, MO_bar, MO_flush, MO_quit },
+ { "LCD2041", 4, 20, XRES, YRES, BARS, MO_init, MO_clear, MO_put, MO_bar, MO_flush, MO_quit },
+ { "LCD4021", 2, 40, XRES, YRES, BARS, MO_init, MO_clear, MO_put, MO_bar, MO_flush, MO_quit },
{ NULL }
};
diff --git a/PalmPilot.c b/PalmPilot.c
index 68c35fa..b507050 100644
--- a/PalmPilot.c
+++ b/PalmPilot.c
@@ -1,4 +1,4 @@
-/* $Id: PalmPilot.c,v 1.1 2000/05/02 06:05:00 reinelt Exp $
+/* $Id: PalmPilot.c,v 1.2 2000/08/09 09:50:29 reinelt Exp $
*
* driver for 3Com Palm Pilot
*
@@ -20,6 +20,13 @@
*
*
* $Log: PalmPilot.c,v $
+ * Revision 1.2 2000/08/09 09:50:29 reinelt
+ *
+ * opened 0.98 development
+ * removed driver-specific signal-handlers
+ * added 'quit'-function to driver structure
+ * added global signal-handler
+ *
* Revision 1.1 2000/05/02 06:05:00 reinelt
*
* driver for 3Com Palm Pilot added
@@ -38,7 +45,6 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#include <signal.h>
#include <errno.h>
#include <termios.h>
#include <fcntl.h>
@@ -167,8 +173,6 @@ int Palm_clear (void)
return Palm_flush();
}
-static void Palm_quit (int signal); //forward declaration
-
int Palm_init (LCD *Self)
{
char *port, *speed, *s;
@@ -253,10 +257,6 @@ int Palm_init (LCD *Self)
pix_clear();
- signal(SIGINT, Palm_quit);
- signal(SIGQUIT, Palm_quit);
- signal(SIGTERM, Palm_quit);
-
return 0;
}
@@ -270,19 +270,15 @@ int Palm_bar (int type, int row, int col, int max, int len1, int len2)
return pix_bar (type, row, col, max, len1, len2);
}
-int lcd_hello (void); // prototype from lcd4linux.c
-
-static void Palm_quit (int signal)
+int Palm_quit (void)
{
- debug ("got signal %d\n", signal);
- Palm_clear();
- lcd_hello();
+ debug ("closing port %s\n", Port);
close (Device);
unlock_port (Port);
- exit (0);
+ return 0;
}
LCD PalmPilot[] = {
- { "PalmPilot", 0, 0, 0, 0, BARS, Palm_init, Palm_clear, Palm_put, Palm_bar, Palm_flush },
+ { "PalmPilot", 0, 0, 0, 0, BARS, Palm_init, Palm_clear, Palm_put, Palm_bar, Palm_flush, Palm_quit },
{ NULL }
};
diff --git a/README b/README
index c715eb5..7e5312a 100644
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
#
-# $Id: README,v 1.6 2000/04/15 16:56:52 reinelt Exp $
+# $Id: README,v 1.7 2000/08/09 09:50:29 reinelt Exp $
#
This is the README file for lcd4linux
@@ -33,6 +33,7 @@ write picture to 'output' (raster driver only)
overwrite entries from the config-file with '-c'
suppress startup splash screen with '-q'
+
SUPPORTED DISPLAYS
* Matrox Orbital: <http://www.matrixorbital.com>
@@ -43,16 +44,37 @@ SUPPORTED DISPLAYS
"LCD2041": 4 lines by 20 characters (tested)
"LCD4021": 2 lines by 40 characters
+
+* CrystalFontz <http://www.crystalfontz.com>
+
+ any of 626, 632, 634 and 636.
+
+
+* HD44780-based displays
+
+ This driver supports display modules based on the Hitachi HD44780 chip,
+ connected to a parallel port. These displays are made by different
+ manufactures, and come in various sizes.
+
+
+* PalmOrb
+
+ I was told that lcd4linux works fine with PalmOrb, a small program that
+ emulates a Matrox Orbital display on the Palm Pilot.
+
+
* X11
thanks to Herbert Rosmanith <herp@wildsau.idv.uni-linz.ac.at> a driver for the
X Window System is available. It supports any size at any resolution. A very
small XLCD4Linux-Window can even swallow on the KDE Panel!
+
* Raster formats:
a generic raster driver (which is used by the X11-driver, too) is availiable,
PPM (portable pixmap) is the only output format at the moment. I'm working
on PNG!
+
* other displays: lcd4linux and especially the display driver code is very modular,
so it should be quite easy to write a driver for any display. See README.driver
for details. Contributors are welcome!!!
@@ -81,7 +103,7 @@ Data-specific options:
overload: load average threshold and bar scaling. The '%L' token (see below) displays
a '!' instead of a blank if the current load average exceeds this value.
load bars are scaled by this value (load=overload gives 100%)
- fifo: path to fifo for communication with isdnlog (not implemented)
+ fifo: path to fifo for communication with isdnlog (not yet implemented)
sensor1: path to the 1st temperature file (e.g. /proc/sys/dev/sensors/w83781d-isa-0290/temp1)
it is important that you use the isa sensors, because the i2c sensors are very slow!
sensor1_min: temperature where the corresponding bar starts
@@ -148,12 +170,9 @@ Tokens:
'io', ISDN bytes sent
'it', ISDN bytes total (received+send)
'im', ISDN bytes max (received, send)
- 's1', T_SENSOR_1,
- 's2', T_SENSOR_2,
- 's3', T_SENSOR_3,
- 's4', T_SENSOR_4,
- 's5', T_SENSOR_5,
- 's6', T_SENSOR_6,
- 's7', T_SENSOR_7,
- 's8', T_SENSOR_8,
- 's9', T_SENSOR_9,
+ 'ti', PPP bytes received
+ 'to', PPP bytes sent
+ 'tt', PPP bytes total (received+send)
+ 'tm', PPP bytes max (received, send)
+ 's1', temperature of sensor 1
+ 's2', temperature of sensor 2 (up to s9)
diff --git a/XWindow.c b/XWindow.c
index 124dac2..0956138 100644
--- a/XWindow.c
+++ b/XWindow.c
@@ -1,4 +1,4 @@
-/* $Id: XWindow.c,v 1.18 2000/05/02 23:07:48 herp Exp $
+/* $Id: XWindow.c,v 1.19 2000/08/09 09:50:29 reinelt Exp $
*
* X11 Driver for LCD4Linux
*
@@ -20,6 +20,13 @@
*
*
* $Log: XWindow.c,v $
+ * Revision 1.19 2000/08/09 09:50:29 reinelt
+ *
+ * opened 0.98 development
+ * removed driver-specific signal-handlers
+ * added 'quit'-function to driver structure
+ * added global signal-handler
+ *
* Revision 1.18 2000/05/02 23:07:48 herp
* Crystalfontz initial coding
*
@@ -103,7 +110,7 @@
#include <sys/sem.h>
#include <sys/shm.h>
#include <unistd.h>
-#include <signal.h>
+#include <signal.h>
#include "cfg.h"
#include "display.h"
@@ -174,29 +181,11 @@ static void shmcleanup() {
if (shmid>-1) shmctl(shmid,IPC_RMID,NULL);
}
-static void quit(int nsig) {
- semcleanup();
- shmcleanup();
- if (ppid!=getpid())
- kill(ppid,nsig);
- exit(0);
-}
-
static void quit_updater() {
if (async_updater_pid>1)
kill(async_updater_pid,15);
}
-static void init_signals() {
-unsigned int oksig=(1<<SIGBUS)|(1<<SIGFPE)|(1<<SIGSEGV)|
- (1<<SIGTSTP)|(1<<SIGCHLD)|(1<<SIGCONT)|
- (1<<SIGTTIN)|(1<<SIGWINCH);
-int i;
- for(i=0;i<NSIG;i++)
- if (((1<<i)&oksig)==0)
- signal(i,quit);
-}
-
static int init_shm(int nbytes,unsigned char **buf) {
shmid=shmget(IPC_PRIVATE,nbytes,SHM_R|SHM_W);
@@ -345,7 +334,6 @@ char *s;
if (pix_init(rows,cols,xres,yres)==-1) return -1;
if (init_x(rows,cols,xres,yres)==-1) return -1;
- init_signals();
if (init_shm(rows*cols*xres*yres,&BackupLCDpixmap)==-1) return -1;
memset(BackupLCDpixmap,0xff,rows*yres*cols*xres);
if (init_thread(rows*cols*xres*yres)==-1) return -1;
@@ -402,6 +390,15 @@ int x,y;
return 0;
}
+int xlcdquit(void) {
+ semcleanup();
+ shmcleanup();
+ if (ppid!=getpid())
+ // FIXME: kill(ppid,nsig);
+ kill(ppid,SIGTERM);
+ return 0;
+}
+
/*
* this one should only be called from the updater-thread
* no user serviceable parts inside
@@ -499,7 +496,7 @@ XEvent ev;
}
LCD XWindow[] = {
- { "X11", 0, 0, 0, 0, BARS, xlcdinit, xlcdclear, xlcdput, xlcdbar, xlcdflush },
+ { "X11", 0, 0, 0, 0, BARS, xlcdinit, xlcdclear, xlcdput, xlcdbar, xlcdflush, xlcdquit },
{ NULL }
};
diff --git a/configure b/configure
index 62fb2a8..0c21ab8 100755
--- a/configure
+++ b/configure
@@ -693,7 +693,7 @@ fi
PACKAGE=lcd4linux
-VERSION=0.97
+VERSION=0.98
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
{ echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
diff --git a/configure.in b/configure.in
index 1cf0df5..fc6955a 100644
--- a/configure.in
+++ b/configure.in
@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(lcd4linux.c)
-AM_INIT_AUTOMAKE(lcd4linux, 0.97)
+AM_INIT_AUTOMAKE(lcd4linux, 0.98)
dnl Checks for programs.
AC_PROG_AWK
diff --git a/display.c b/display.c
index 1925d00..ca3bb0c 100644
--- a/display.c
+++ b/display.c
@@ -1,4 +1,4 @@
-/* $Id: display.c,v 1.18 2000/05/02 23:07:48 herp Exp $
+/* $Id: display.c,v 1.19 2000/08/09 09:50:29 reinelt Exp $
*
* framework for device drivers
*
@@ -20,6 +20,13 @@
*
*
* $Log: display.c,v $
+ * Revision 1.19 2000/08/09 09:50:29 reinelt
+ *
+ * opened 0.98 development
+ * removed driver-specific signal-handlers
+ * added 'quit'-function to driver structure
+ * added global signal-handler
+ *
* Revision 1.18 2000/05/02 23:07:48 herp
* Crystalfontz initial coding
*
@@ -123,6 +130,8 @@
* int lcd_flush (void)
* flushes the framebuffer to the display
*
+ * int lcd_quit (void)
+ * de-initializes the driver
*/
#include <stdlib.h>
@@ -181,6 +190,7 @@ int lcd_init (char *driver)
for (j=0; Driver[i].Model[j].name; j++) {
if (strcmp (Driver[i].Model[j].name, driver)==0) {
Lcd=&Driver[i].Model[j];
+ if (Lcd->init==NULL) return 0;
return Lcd->init(Lcd);
}
}
@@ -205,6 +215,7 @@ int lcd_query (int *rows, int *cols, int *xres, int *yres, int *bars)
int lcd_clear (void)
{
+ if (Lcd->clear==NULL) return 0;
return Lcd->clear();
}
@@ -212,6 +223,7 @@ int lcd_put (int row, int col, char *text)
{
if (row<1 || row>Lcd->rows) return -1;
if (col<1 || col>Lcd->cols) return -1;
+ if (Lcd->put==NULL) return 0;
return Lcd->put(row-1, col-1, text);
}
@@ -224,10 +236,18 @@ int lcd_bar (int type, int row, int col, int max, int len1, int len2)
len1=(double)max*log(len1+1)/log(max);
len2=(double)max*log(len2+1)/log(max);
}
+ if (Lcd->put==NULL) return 0;
return Lcd->bar (type & BAR_HV, row-1, col-1, max, len1, len2);
}
int lcd_flush (void)
{
+ if (Lcd->flush==NULL) return 0;
return Lcd->flush();
}
+
+int lcd_quit (void)
+{
+ if (Lcd->quit==NULL) return 0;
+ return Lcd->quit();
+}
diff --git a/display.h b/display.h
index 24184f9..990ed7c 100644
--- a/display.h
+++ b/display.h
@@ -1,4 +1,4 @@
-/* $Id: display.h,v 1.10 2000/03/26 18:46:28 reinelt Exp $
+/* $Id: display.h,v 1.11 2000/08/09 09:50:29 reinelt Exp $
*
* framework for device drivers
*
@@ -20,6 +20,13 @@
*
*
* $Log: display.h,v $
+ * Revision 1.11 2000/08/09 09:50:29 reinelt
+ *
+ * opened 0.98 development
+ * removed driver-specific signal-handlers
+ * added 'quit'-function to driver structure
+ * added global signal-handler
+ *
* Revision 1.10 2000/03/26 18:46:28 reinelt
*
* bug in pixmap.c that leaded to empty bars fixed
@@ -90,6 +97,7 @@ typedef struct LCD {
int (*put) (int x, int y, char *text);
int (*bar) (int type, int x, int y, int max, int len1, int len2);
int (*flush) (void);
+ int (*quit) (void);
} LCD;
typedef struct {
@@ -104,5 +112,6 @@ int lcd_clear (void);
int lcd_put (int row, int col, char *text);
int lcd_bar (int type, int row, int col, int max, int len1, int len2);
int lcd_flush (void);
+int lcd_quit (void);
#endif
diff --git a/lcd4linux.c b/lcd4linux.c
index 0e82382..0d49202 100644
--- a/lcd4linux.c
+++ b/lcd4linux.c
@@ -1,4 +1,4 @@
-/* $Id: lcd4linux.c,v 1.23 2000/04/17 05:14:27 reinelt Exp $
+/* $Id: lcd4linux.c,v 1.24 2000/08/09 09:50:29 reinelt Exp $
*
* LCD4Linux
*
@@ -20,6 +20,13 @@
*
*
* $Log: lcd4linux.c,v $
+ * Revision 1.24 2000/08/09 09:50:29 reinelt
+ *
+ * opened 0.98 development
+ * removed driver-specific signal-handlers
+ * added 'quit'-function to driver structure
+ * added global signal-handler
+ *
* Revision 1.23 2000/04/17 05:14:27 reinelt
*
* added README.44780
@@ -136,6 +143,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
+#include <signal.h>
#include "cfg.h"
#include "debug.h"
@@ -145,6 +153,7 @@
char *release="LCD4Linux " VERSION " (c) 2000 Michael Reinelt <reinelt@eunet.at>";
char *output=NULL;
+int got_signal=0;
int debugging=0;
int tick, tack;
@@ -157,7 +166,7 @@ static void usage(void)
printf (" lcd4linux [-c key=value] [-f config-file] [-o output-file] [-q] [-v]\n");
}
-int lcd_hello (void)
+int hello (void)
{
int i, x, y, flag;
char *line1[] = { "* LCD4Linux V" VERSION " *",
@@ -209,6 +218,12 @@ void calibrate (void)
printf (" Delay=%ld\n", max);
}
+void handler (int signal)
+{
+ debug ("got signal %d\n", signal);
+ got_signal=signal;
+}
+
int main (int argc, char *argv[])
{
char *cfg="/etc/lcd4linux.conf";
@@ -279,13 +294,18 @@ int main (int argc, char *argv[])
exit (1);
}
+ signal(SIGHUP, handler);
+ signal(SIGINT, handler);
+ signal(SIGQUIT, handler);
+ signal(SIGTERM, handler);
+
tick=atoi(cfg_get("tick")?:"100");
tack=atoi(cfg_get("tack")?:"500");
process_init();
lcd_clear();
- if (!quiet && lcd_hello()) {
+ if (!quiet && hello()) {
sleep (3);
lcd_clear();
}
@@ -293,10 +313,21 @@ int main (int argc, char *argv[])
debug ("starting main loop\n");
smooth=0;
- while (1) {
+ while (got_signal==0) {
process (smooth);
smooth+=tick;
if (smooth>tack) smooth=0;
usleep(tick*1000);
}
+
+ debug ("leaving main loop\n");
+
+ lcd_clear();
+ if (!quiet) hello();
+ lcd_quit();
+
+ if (got_signal==SIGHUP) {
+ debug ("restarting\n");
+ }
+ exit (0);
}
diff --git a/system.c b/system.c
index 246b634..97ea6ec 100644
--- a/system.c
+++ b/system.c
@@ -1,4 +1,4 @@
-/* $Id: system.c,v 1.13 2000/07/31 10:43:44 reinelt Exp $
+/* $Id: system.c,v 1.14 2000/08/09 09:50:29 reinelt Exp $
*
* system status retreivement
*
@@ -20,6 +20,13 @@
*
*
* $Log: system.c,v $
+ * Revision 1.14 2000/08/09 09:50:29 reinelt
+ *
+ * opened 0.98 development
+ * removed driver-specific signal-handlers
+ * added 'quit'-function to driver structure
+ * added global signal-handler
+ *
* Revision 1.13 2000/07/31 10:43:44 reinelt
*
* some changes to support kernel-2.4 (different layout of various files in /proc)
@@ -511,7 +518,7 @@ int Disk (int *r, int *w)
unsigned long w1, w2, w3, w4;
p=strstr(buffer, "disk_rblk");
if (p==NULL) {
- fprintf (stderr, "parse(/proc/stat) failed: no 'disk_rblk' line\n");
+ fprintf (stderr, "parse(/proc/stat) failed: neither 'disk_io' nor 'disk_rblk' found\n");
fd=-1;
return -1;
}