mirror of
https://github.com/netfun2000/lcd4linux.git
synced 2026-02-27 09:44:34 +08:00
[lcd4linux @ 2000-04-15 11:13:54 by reinelt]
added '-d' (debugging) switch added several debugging messages removed config entry 'Delay' for HD44780 driver delay loop for HD44780 will be calibrated automatically git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@45 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $Id: HD44780.c,v 1.2 2000/04/13 06:09:52 reinelt Exp $
|
||||
/* $Id: HD44780.c,v 1.3 2000/04/15 11:13:54 reinelt Exp $
|
||||
*
|
||||
* driver for display modules based on the HD44780 chip
|
||||
*
|
||||
@@ -20,6 +20,13 @@
|
||||
*
|
||||
*
|
||||
* $Log: HD44780.c,v $
|
||||
* Revision 1.3 2000/04/15 11:13:54 reinelt
|
||||
*
|
||||
* added '-d' (debugging) switch
|
||||
* added several debugging messages
|
||||
* removed config entry 'Delay' for HD44780 driver
|
||||
* delay loop for HD44780 will be calibrated automatically
|
||||
*
|
||||
* Revision 1.2 2000/04/13 06:09:52 reinelt
|
||||
*
|
||||
* added BogoMips() to system.c (not used by now, maybe sometimes we can
|
||||
@@ -45,10 +52,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "cfg.h"
|
||||
#include "display.h"
|
||||
|
||||
@@ -74,7 +83,7 @@ typedef struct {
|
||||
|
||||
static LCD Lcd;
|
||||
static unsigned short Port=0;
|
||||
static unsigned long Delay;
|
||||
static unsigned long loops_per_usec;
|
||||
|
||||
static char Txt[4][40];
|
||||
static BAR Bar[4][40];
|
||||
@@ -85,10 +94,40 @@ static SEGMENT Segment[128] = {{ len1:0, len2:0, type:255, used:0, ascii:32
|
||||
|
||||
static void HD_delay (unsigned long usec)
|
||||
{
|
||||
unsigned long i=usec*Delay/2;
|
||||
unsigned long i=usec*loops_per_usec;
|
||||
while (i--);
|
||||
}
|
||||
|
||||
static void HD_calibrate_delay (void)
|
||||
{
|
||||
clock_t tick;
|
||||
unsigned long bit;
|
||||
|
||||
loops_per_usec=1;
|
||||
while (loops_per_usec<<=1) {
|
||||
tick=clock();
|
||||
while (clock()==tick);
|
||||
tick=clock();
|
||||
HD_delay(1000000/CLOCKS_PER_SEC);
|
||||
if (clock()>tick)
|
||||
break;
|
||||
}
|
||||
|
||||
loops_per_usec>>=1;
|
||||
bit=loops_per_usec;
|
||||
while (bit>>=1) {
|
||||
loops_per_usec|=bit;
|
||||
tick=clock();
|
||||
while (clock()==tick);
|
||||
tick=clock();
|
||||
HD_delay(1000000/CLOCKS_PER_SEC);
|
||||
if (clock()>tick)
|
||||
loops_per_usec&=~bit;
|
||||
}
|
||||
|
||||
debug ("calibrating delay: %ld loops/usec\n", loops_per_usec);
|
||||
}
|
||||
|
||||
static void HD_command (unsigned char cmd, int delay)
|
||||
{
|
||||
outb (cmd, Port); // put data on DB1..DB8
|
||||
@@ -111,8 +150,9 @@ static void HD_write (char *string, int len, int delay)
|
||||
|
||||
static int HD_open (void)
|
||||
{
|
||||
debug ("using port 0x%x\n", Port);
|
||||
if (ioperm(Port, 3, 1)!=0) {
|
||||
fprintf (stderr, "HD44780: ioperm() failed: %s\n", strerror(errno));
|
||||
fprintf (stderr, "HD44780: ioperm(0x%x) failed: %s\n", Port, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -338,20 +378,12 @@ int HD_init (LCD *Self)
|
||||
return -1;
|
||||
}
|
||||
|
||||
s=cfg_get ("Delay");
|
||||
if (s==NULL || *s=='\0') {
|
||||
fprintf (stderr, "HD44780: no 'Delay' entry in %s\n", cfg_file());
|
||||
return -1;
|
||||
}
|
||||
if ((Delay=strtol(s, &e, 0))==0 || *e!='\0' || Delay<1) {
|
||||
fprintf (stderr, "HD44780: bad delay '%s' in %s\n", s, cfg_file());
|
||||
return -1;
|
||||
}
|
||||
|
||||
Self->rows=rows;
|
||||
Self->cols=cols;
|
||||
Lcd=*Self;
|
||||
|
||||
HD_calibrate_delay();
|
||||
|
||||
if (HD_open()!=0)
|
||||
return -1;
|
||||
|
||||
@@ -493,9 +525,9 @@ int lcd_hello (void); // prototype from lcd4linux.c
|
||||
|
||||
static void HD_quit (int signal)
|
||||
{
|
||||
debug ("got signal %d\n", signal);
|
||||
HD_clear();
|
||||
lcd_hello();
|
||||
// Fixme: ioperm rückgängig machen?
|
||||
exit (0);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ endif
|
||||
|
||||
lcd4linux_SOURCES = \
|
||||
lcd4linux.c \
|
||||
debug.h \
|
||||
cfg.c cfg.h \
|
||||
lock.c lock.h \
|
||||
parser.c parser.h \
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ AM_CFLAGS = $(X_CFLAGS) -Wall
|
||||
lcd4linux_LDFLAGS = $(X_LIBS)
|
||||
@WITH_X_TRUE@lcd4linux_LDADD = -lX11
|
||||
|
||||
lcd4linux_SOURCES = lcd4linux.c cfg.c cfg.h lock.c lock.h parser.c parser.h processor.c processor.h system.c system.h isdn.c isdn.h filter.c filter.h display.c display.h pixmap.c pixmap.h fontmap.c fontmap.h Skeleton.c MatrixOrbital.c HD44780.c Raster.c XWindow.c
|
||||
lcd4linux_SOURCES = lcd4linux.c debug.h cfg.c cfg.h lock.c lock.h parser.c parser.h processor.c processor.h system.c system.h isdn.c isdn.h filter.c filter.h display.c display.h pixmap.c pixmap.h fontmap.c fontmap.h Skeleton.c MatrixOrbital.c HD44780.c Raster.c XWindow.c
|
||||
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
|
||||
+12
-1
@@ -1,4 +1,4 @@
|
||||
/* $Id: MatrixOrbital.c,v 1.16 2000/04/13 06:09:52 reinelt Exp $
|
||||
/* $Id: MatrixOrbital.c,v 1.17 2000/04/15 11:13:54 reinelt Exp $
|
||||
*
|
||||
* driver for Matrix Orbital serial display modules
|
||||
*
|
||||
@@ -20,6 +20,13 @@
|
||||
*
|
||||
*
|
||||
* $Log: MatrixOrbital.c,v $
|
||||
* Revision 1.17 2000/04/15 11:13:54 reinelt
|
||||
*
|
||||
* added '-d' (debugging) switch
|
||||
* added several debugging messages
|
||||
* removed config entry 'Delay' for HD44780 driver
|
||||
* delay loop for HD44780 will be calibrated automatically
|
||||
*
|
||||
* Revision 1.16 2000/04/13 06:09:52 reinelt
|
||||
*
|
||||
* added BogoMips() to system.c (not used by now, maybe sometimes we can
|
||||
@@ -103,6 +110,7 @@
|
||||
#include <termios.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "cfg.h"
|
||||
#include "lock.h"
|
||||
#include "display.h"
|
||||
@@ -419,6 +427,8 @@ int MO_init (LCD *Self)
|
||||
return -1;
|
||||
}
|
||||
|
||||
debug ("using port %s at %d baud\n", Port, atoi(speed));
|
||||
|
||||
Device=MO_open();
|
||||
if (Device==-1) return -1;
|
||||
|
||||
@@ -561,6 +571,7 @@ int lcd_hello (void); // prototype from lcd4linux.c
|
||||
|
||||
static void MO_quit (int signal)
|
||||
{
|
||||
debug ("got signal %d\n", signal);
|
||||
MO_clear();
|
||||
lcd_hello();
|
||||
close (Device);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: README,v 1.4 2000/04/10 04:40:53 reinelt Exp $
|
||||
# $Id: README,v 1.5 2000/04/15 11:13:54 reinelt Exp $
|
||||
#
|
||||
|
||||
This is the README file for lcd4linux
|
||||
@@ -22,12 +22,13 @@ print version number and a small help text, then exit
|
||||
lcd4linux -l
|
||||
list available drivers
|
||||
|
||||
lcd4linux [-c key=val] [-f config-file] [-o output] [-q]
|
||||
lcd4linux [-c key=val] [-d] [-f config-file] [-o output] [-q]
|
||||
run lcd4linux
|
||||
generate debugging messages with '-d'
|
||||
use configuration from 'config-file' instead of /etc/lcd4linux.conf
|
||||
write picture to 'output' (raster driver only)
|
||||
overwrite entries from the config-file with '-c'
|
||||
supress startup splash screen with '-q_
|
||||
suppress startup splash screen with '-q'
|
||||
|
||||
SUPPORTED DISPLAYS
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Id: cfg.c,v 1.6 2000/04/03 04:46:38 reinelt Exp $
|
||||
/* $Id: cfg.c,v 1.7 2000/04/15 11:13:54 reinelt Exp $
|
||||
*
|
||||
* config file stuff
|
||||
*
|
||||
@@ -20,6 +20,13 @@
|
||||
*
|
||||
*
|
||||
* $Log: cfg.c,v $
|
||||
* Revision 1.7 2000/04/15 11:13:54 reinelt
|
||||
*
|
||||
* added '-d' (debugging) switch
|
||||
* added several debugging messages
|
||||
* removed config entry 'Delay' for HD44780 driver
|
||||
* delay loop for HD44780 will be calibrated automatically
|
||||
*
|
||||
* Revision 1.6 2000/04/03 04:46:38 reinelt
|
||||
*
|
||||
* added '-c key=val' option
|
||||
@@ -140,7 +147,7 @@ static char *dequote (char *string)
|
||||
static void cfg_add (char *key, char *val, int lock)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i=0; i<nConfig; i++) {
|
||||
if (strcasecmp(Config[i].key, key)==0) {
|
||||
if (Config[i].lock>lock) return;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/* $Id: debug.h,v 1.1 2000/04/15 11:13:54 reinelt Exp $
|
||||
*
|
||||
* debug messages
|
||||
*
|
||||
* Copyright 1999, 2000 by Michael Reinelt (reinelt@eunet.at)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*
|
||||
* $Log: debug.h,v $
|
||||
* Revision 1.1 2000/04/15 11:13:54 reinelt
|
||||
*
|
||||
* added '-d' (debugging) switch
|
||||
* added several debugging messages
|
||||
* removed config entry 'Delay' for HD44780 driver
|
||||
* delay loop for HD44780 will be calibrated automatically
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _DEBUG_H_
|
||||
#define _DEBUG_H_
|
||||
|
||||
extern int debugging;
|
||||
#define debug(args...) do { if (debugging) printf(__FILE__ ": " args); } while(0)
|
||||
|
||||
#endif
|
||||
+1
-1
@@ -3,7 +3,7 @@ size 6x5
|
||||
font 6x8
|
||||
pixel 1+0
|
||||
gap 1x0
|
||||
border 2
|
||||
border 3
|
||||
foreground \#102000
|
||||
halfground \#90c000
|
||||
background \#a0d000
|
||||
|
||||
+21
-3
@@ -1,4 +1,4 @@
|
||||
/* $Id: lcd4linux.c,v 1.19 2000/04/10 04:40:53 reinelt Exp $
|
||||
/* $Id: lcd4linux.c,v 1.20 2000/04/15 11:13:54 reinelt Exp $
|
||||
*
|
||||
* LCD4Linux
|
||||
*
|
||||
@@ -20,6 +20,13 @@
|
||||
*
|
||||
*
|
||||
* $Log: lcd4linux.c,v $
|
||||
* Revision 1.20 2000/04/15 11:13:54 reinelt
|
||||
*
|
||||
* added '-d' (debugging) switch
|
||||
* added several debugging messages
|
||||
* removed config entry 'Delay' for HD44780 driver
|
||||
* delay loop for HD44780 will be calibrated automatically
|
||||
*
|
||||
* Revision 1.19 2000/04/10 04:40:53 reinelt
|
||||
*
|
||||
* minor changes and cleanups
|
||||
@@ -114,18 +121,22 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "cfg.h"
|
||||
#include "display.h"
|
||||
#include "processor.h"
|
||||
|
||||
char *release="LCD4Linux V" VERSION " (c) 2000 Michael Reinelt <reinelt@eunet.at>";
|
||||
char *output=NULL;
|
||||
int debugging=0;
|
||||
int tick, tack;
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
printf ("%s\n", release);
|
||||
printf ("usage: lcd4linux [-h] [-l] [-c key=value] [-f config-file] [-o output-file] [-q]\n");
|
||||
printf ("usage: lcd4linux [-h]\n");
|
||||
printf (" lcd4linux [-l]\n");
|
||||
printf (" lcd4linux [-c key=value] [-d] [-f config-file] [-o output-file] [-q]\n");
|
||||
}
|
||||
|
||||
int lcd_hello (void)
|
||||
@@ -171,7 +182,7 @@ int main (int argc, char *argv[])
|
||||
int c, smooth;
|
||||
int quiet=0;
|
||||
|
||||
while ((c=getopt (argc, argv, "c:f:hlo:q"))!=EOF) {
|
||||
while ((c=getopt (argc, argv, "c:df:hlo:q"))!=EOF) {
|
||||
switch (c) {
|
||||
case 'c':
|
||||
if (cfg_cmd (optarg)<0) {
|
||||
@@ -179,6 +190,9 @@ int main (int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
debugging++;
|
||||
break;
|
||||
case 'h':
|
||||
usage();
|
||||
exit(0);
|
||||
@@ -205,6 +219,8 @@ int main (int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
|
||||
debug ("LCD4Linux " VERSION "\n");
|
||||
|
||||
// set default values
|
||||
|
||||
cfg_set ("row1", "*** %o %v ***");
|
||||
@@ -220,6 +236,8 @@ int main (int argc, char *argv[])
|
||||
fprintf (stderr, "%s: missing 'display' entry!\n", cfg_file());
|
||||
exit (1);
|
||||
}
|
||||
|
||||
debug ("initializing driver %s\n", driver);
|
||||
if (lcd_init(driver)==-1) {
|
||||
exit (1);
|
||||
}
|
||||
|
||||
+10
-2
@@ -1,4 +1,4 @@
|
||||
/* $Id: processor.c,v 1.3 2000/04/01 16:22:38 reinelt Exp $
|
||||
/* $Id: processor.c,v 1.4 2000/04/15 11:13:54 reinelt Exp $
|
||||
*
|
||||
* main data processing
|
||||
*
|
||||
@@ -20,6 +20,13 @@
|
||||
*
|
||||
*
|
||||
* $Log: processor.c,v $
|
||||
* Revision 1.4 2000/04/15 11:13:54 reinelt
|
||||
*
|
||||
* added '-d' (debugging) switch
|
||||
* added several debugging messages
|
||||
* removed config entry 'Delay' for HD44780 driver
|
||||
* delay loop for HD44780 will be calibrated automatically
|
||||
*
|
||||
* Revision 1.3 2000/04/01 16:22:38 reinelt
|
||||
*
|
||||
* bug that caused a segfault in processor.c fixed (thanks to herp)
|
||||
@@ -52,6 +59,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "cfg.h"
|
||||
#include "system.h"
|
||||
#include "isdn.h"
|
||||
@@ -379,7 +387,7 @@ void process_init (void)
|
||||
|
||||
load.overload=atof(cfg_get("overload")?:"2.0");
|
||||
lcd_query (&rows, &cols, &xres, &yres, &supported_bars);
|
||||
|
||||
debug ("%d rows, %d columns, %dx%d pixels\n", rows, cols, xres, yres);
|
||||
for (i=1; i<=rows; i++) {
|
||||
snprintf (buffer, sizeof(buffer), "row%d", i);
|
||||
row[i]=strdup(parse(cfg_get(buffer)?:"", supported_bars, token_usage));
|
||||
|
||||
Reference in New Issue
Block a user