aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2005-11-04 14:10:38 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2005-11-04 14:10:38 +0000
commit9d0ba6ed3850aaf6f6d9ac60a040253f0b8e8371 (patch)
tree9969d78f72c393e17fd73079f374c4df478d6d22
parent922673cb27839663c80da0d7ef65266d67bf7794 (diff)
downloadlcd4linux-9d0ba6ed3850aaf6f6d9ac60a040253f0b8e8371.tar.gz
[lcd4linux @ 2005-11-04 14:10:38 by reinelt]
drv_Sample and drv_LPH7508 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@593 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
-rw-r--r--Makefile.am1
-rw-r--r--Makefile.in39
-rw-r--r--config.h.in3
-rwxr-xr-xconfigure24
-rw-r--r--drivers.m420
-rw-r--r--drv.c9
-rw-r--r--drv_LPH7508.c362
-rw-r--r--drv_Sample.c578
8 files changed, 1012 insertions, 24 deletions
diff --git a/Makefile.am b/Makefile.am
index 32aea13..ac2917d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -67,6 +67,7 @@ drv_MilfordInstruments.c \
drv_Noritake.c \
drv_NULL.c \
drv_RouterBoard.c \
+drv_Sample.c \
drv_serdisplib.c \
drv_SimpleLCD.c \
drv_T6963.c \
diff --git a/Makefile.in b/Makefile.in
index 1a09f2c..96b5e63 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -104,7 +104,7 @@ lcd4linux_DEPENDENCIES = @DRIVERS@ @PLUGINS@
lcd4linux_SOURCES = lcd4linux.c cfg.c cfg.h debug.c debug.h drv.c drv.h evaluator.c evaluator.h hash.c hash.h layout.c layout.h pid.c pid.h timer.c timer.h thread.c thread.h udelay.c udelay.h qprintf.c qprintf.h widget.c widget.h widget_text.c widget_text.h widget_bar.c widget_bar.h widget_icon.c widget_icon.h plugin.c plugin.h plugin_cfg.c plugin_math.c plugin_string.c plugin_test.c plugin_time.c
-EXTRA_lcd4linux_SOURCES = drv_generic_text.c drv_generic_text.h drv_generic_graphic.c drv_generic_graphic.h drv_generic_serial.c drv_generic_serial.h drv_generic_parport.c drv_generic_parport.h drv_generic_i2c.c drv_generic_i2c.h drv_BeckmannEgle.c drv_BWCT.c drv_Crystalfontz.c drv_Curses.c drv_Cwlinux.c drv_HD44780.c drv_Image.c drv_LCDLinux.c drv_LCDLinux.h drv_LCDTerm.c drv_LPH7508.c drv_M50530.c drv_MatrixOrbital.c drv_MilfordInstruments.c drv_Noritake.c drv_NULL.c drv_RouterBoard.c drv_serdisplib.c drv_SimpleLCD.c drv_T6963.c drv_Trefon.c drv_USBLCD.c drv_WincorNixdorf.c drv_X11.c font_6x8.h lcd4linux_i2c.h plugin_apm.c plugin_cpuinfo.c plugin_diskstats.c plugin_dvb.c plugin_exec.c plugin_i2c_sensors.c plugin_imon.c plugin_isdn.c plugin_loadavg.c plugin_meminfo.c plugin_mysql.c plugin_netdev.c plugin_pop3.c plugin_ppp.c plugin_proc_stat.c plugin_python.c plugin_sample.c plugin_seti.c plugin_statfs.c plugin_uname.c plugin_uptime.c plugin_wireless.c plugin_xmms.c
+EXTRA_lcd4linux_SOURCES = drv_generic_text.c drv_generic_text.h drv_generic_graphic.c drv_generic_graphic.h drv_generic_serial.c drv_generic_serial.h drv_generic_parport.c drv_generic_parport.h drv_generic_i2c.c drv_generic_i2c.h drv_BeckmannEgle.c drv_BWCT.c drv_Crystalfontz.c drv_Curses.c drv_Cwlinux.c drv_HD44780.c drv_Image.c drv_LCDLinux.c drv_LCDLinux.h drv_LCDTerm.c drv_LPH7508.c drv_M50530.c drv_MatrixOrbital.c drv_MilfordInstruments.c drv_Noritake.c drv_NULL.c drv_RouterBoard.c drv_Sample.c drv_serdisplib.c drv_SimpleLCD.c drv_T6963.c drv_Trefon.c drv_USBLCD.c drv_WincorNixdorf.c drv_X11.c font_6x8.h lcd4linux_i2c.h plugin_apm.c plugin_cpuinfo.c plugin_diskstats.c plugin_dvb.c plugin_exec.c plugin_i2c_sensors.c plugin_imon.c plugin_isdn.c plugin_loadavg.c plugin_meminfo.c plugin_mysql.c plugin_netdev.c plugin_pop3.c plugin_ppp.c plugin_proc_stat.c plugin_python.c plugin_sample.c plugin_seti.c plugin_statfs.c plugin_uname.c plugin_uptime.c plugin_wireless.c plugin_xmms.c
EXTRA_DIST = lcd4linux.conf.sample lcd4kde.conf lcd4linux.kdelnk lcd4linux.xpm lcd4linux.lsm curses.m4 AUTHORS CREDITS FAQ NEWS TODO README README.Drivers README.Plugins README.KDE plugin_sample.c
@@ -147,24 +147,25 @@ DEP_FILES = .deps/cfg.P .deps/debug.P .deps/drv.P .deps/drv_BWCT.P \
.deps/drv_LCDLinux.P .deps/drv_LCDTerm.P .deps/drv_LPH7508.P \
.deps/drv_M50530.P .deps/drv_MatrixOrbital.P \
.deps/drv_MilfordInstruments.P .deps/drv_NULL.P .deps/drv_Noritake.P \
-.deps/drv_RouterBoard.P .deps/drv_SimpleLCD.P .deps/drv_T6963.P \
-.deps/drv_Trefon.P .deps/drv_USBLCD.P .deps/drv_WincorNixdorf.P \
-.deps/drv_X11.P .deps/drv_generic_graphic.P .deps/drv_generic_i2c.P \
-.deps/drv_generic_parport.P .deps/drv_generic_serial.P \
-.deps/drv_generic_text.P .deps/drv_serdisplib.P .deps/evaluator.P \
-.deps/hash.P .deps/layout.P .deps/lcd4linux.P .deps/pid.P \
-.deps/plugin.P .deps/plugin_apm.P .deps/plugin_cfg.P \
-.deps/plugin_cpuinfo.P .deps/plugin_diskstats.P .deps/plugin_dvb.P \
-.deps/plugin_exec.P .deps/plugin_i2c_sensors.P .deps/plugin_imon.P \
-.deps/plugin_isdn.P .deps/plugin_loadavg.P .deps/plugin_math.P \
-.deps/plugin_meminfo.P .deps/plugin_mysql.P .deps/plugin_netdev.P \
-.deps/plugin_pop3.P .deps/plugin_ppp.P .deps/plugin_proc_stat.P \
-.deps/plugin_python.P .deps/plugin_sample.P .deps/plugin_seti.P \
-.deps/plugin_statfs.P .deps/plugin_string.P .deps/plugin_test.P \
-.deps/plugin_time.P .deps/plugin_uname.P .deps/plugin_uptime.P \
-.deps/plugin_wireless.P .deps/plugin_xmms.P .deps/qprintf.P \
-.deps/thread.P .deps/timer.P .deps/udelay.P .deps/widget.P \
-.deps/widget_bar.P .deps/widget_icon.P .deps/widget_text.P
+.deps/drv_RouterBoard.P .deps/drv_Sample.P .deps/drv_SimpleLCD.P \
+.deps/drv_T6963.P .deps/drv_Trefon.P .deps/drv_USBLCD.P \
+.deps/drv_WincorNixdorf.P .deps/drv_X11.P .deps/drv_generic_graphic.P \
+.deps/drv_generic_i2c.P .deps/drv_generic_parport.P \
+.deps/drv_generic_serial.P .deps/drv_generic_text.P \
+.deps/drv_serdisplib.P .deps/evaluator.P .deps/hash.P .deps/layout.P \
+.deps/lcd4linux.P .deps/pid.P .deps/plugin.P .deps/plugin_apm.P \
+.deps/plugin_cfg.P .deps/plugin_cpuinfo.P .deps/plugin_diskstats.P \
+.deps/plugin_dvb.P .deps/plugin_exec.P .deps/plugin_i2c_sensors.P \
+.deps/plugin_imon.P .deps/plugin_isdn.P .deps/plugin_loadavg.P \
+.deps/plugin_math.P .deps/plugin_meminfo.P .deps/plugin_mysql.P \
+.deps/plugin_netdev.P .deps/plugin_pop3.P .deps/plugin_ppp.P \
+.deps/plugin_proc_stat.P .deps/plugin_python.P .deps/plugin_sample.P \
+.deps/plugin_seti.P .deps/plugin_statfs.P .deps/plugin_string.P \
+.deps/plugin_test.P .deps/plugin_time.P .deps/plugin_uname.P \
+.deps/plugin_uptime.P .deps/plugin_wireless.P .deps/plugin_xmms.P \
+.deps/qprintf.P .deps/thread.P .deps/timer.P .deps/udelay.P \
+.deps/widget.P .deps/widget_bar.P .deps/widget_icon.P \
+.deps/widget_text.P
SOURCES = $(lcd4linux_SOURCES) $(EXTRA_lcd4linux_SOURCES)
OBJECTS = $(lcd4linux_OBJECTS)
diff --git a/config.h.in b/config.h.in
index c268294..01204dc 100644
--- a/config.h.in
+++ b/config.h.in
@@ -395,6 +395,9 @@
/* RouterBoard driver */
#undef WITH_ROUTERBOARD
+/* Sample driver */
+#undef WITH_SAMPLE
+
/* serdisplib driver */
#undef WITH_SERDISPLIB
diff --git a/configure b/configure
index eca8f7a..af5c1ff 100755
--- a/configure
+++ b/configure
@@ -871,8 +871,8 @@ Optional Packages:
BeckmannEgle, BWCT, CrystalFontz, Curses, Cwlinux,
HD44780, LCDLinux, LCDTerm, LPH7508, M50530,
MatrixOrbital, MilfordInstruments, Noritake, NULL,
- PNG, PPM, RouterBoard, serdisplib, SimpleLCD, T6963,
- Trefon, USBLCD, WincorNixdorf, X11
+ PNG, PPM, RouterBoard, Sample, serdisplib, SimpleLCD,
+ T6963, Trefon, USBLCD, WincorNixdorf, X11
--with-plugins=<list> choose which plugins to compile.
type --with-plugins=list for a list
of avaible plugins
@@ -6048,6 +6048,7 @@ for driver in $drivers; do
PNG="yes"
PPM="yes"
ROUTERBOARD="yes"
+ SAMPLE="yes"
SERDISPLIB="yes"
SIMPLELCD="yes"
T6963="yes"
@@ -6107,6 +6108,9 @@ for driver in $drivers; do
RouterBoard)
ROUTERBOARD=$val
;;
+ Sample)
+ SAMPLE=$val
+ ;;
serdisplib)
SERDISPLIB=$val;
;;
@@ -6360,6 +6364,22 @@ _ACEOF
fi
+if test "$SAMPLE" = "yes"; then
+ # select either text or graphics mode
+ TEXT="yes"
+ GRAPHIC="yes"
+ # select bus: serial (including USB), parallel or i2c
+ SERIAL="yes"
+ PARPORT="yes"
+ #I2C="yes"
+ DRIVERS="$DRIVERS drv_Sample.o"
+
+cat >>confdefs.h <<\_ACEOF
+#define WITH_SAMPLE 1
+_ACEOF
+
+fi
+
if test "$SERDISPLIB" = "yes"; then
if test "$has_serdisplib" = "true"; then
GRAPHIC="yes"
diff --git a/drivers.m4 b/drivers.m4
index a5ec90e..4b7ed5b 100644
--- a/drivers.m4
+++ b/drivers.m4
@@ -31,8 +31,8 @@ AC_ARG_WITH(
[ BeckmannEgle, BWCT, CrystalFontz, Curses, Cwlinux,]
[ HD44780, LCDLinux, LCDTerm, LPH7508, M50530,]
[ MatrixOrbital, MilfordInstruments, Noritake, NULL,]
- [ PNG, PPM, RouterBoard, serdisplib, SimpleLCD, T6963,]
- [ Trefon, USBLCD, WincorNixdorf, X11],
+ [ PNG, PPM, RouterBoard, Sample, serdisplib, SimpleLCD,]
+ [ T6963, Trefon, USBLCD, WincorNixdorf, X11],
drivers=$withval,
drivers=all
)
@@ -70,6 +70,7 @@ for driver in $drivers; do
PNG="yes"
PPM="yes"
ROUTERBOARD="yes"
+ SAMPLE="yes"
SERDISPLIB="yes"
SIMPLELCD="yes"
T6963="yes"
@@ -129,6 +130,9 @@ for driver in $drivers; do
RouterBoard)
ROUTERBOARD=$val
;;
+ Sample)
+ SAMPLE=$val
+ ;;
serdisplib)
SERDISPLIB=$val;
;;
@@ -307,6 +311,18 @@ if test "$ROUTERBOARD" = "yes"; then
AC_DEFINE(WITH_ROUTERBOARD,1,[RouterBoard driver])
fi
+if test "$SAMPLE" = "yes"; then
+ # select either text or graphics mode
+ TEXT="yes"
+ GRAPHIC="yes"
+ # select bus: serial (including USB), parallel or i2c
+ SERIAL="yes"
+ PARPORT="yes"
+ #I2C="yes"
+ DRIVERS="$DRIVERS drv_Sample.o"
+ AC_DEFINE(WITH_SAMPLE,1,[Sample driver])
+fi
+
if test "$SERDISPLIB" = "yes"; then
if test "$has_serdisplib" = "true"; then
GRAPHIC="yes"
diff --git a/drv.c b/drv.c
index b461f9e..3e78131 100644
--- a/drv.c
+++ b/drv.c
@@ -1,4 +1,4 @@
-/* $Id: drv.c,v 1.34 2005/11/04 04:44:52 reinelt Exp $
+/* $Id: drv.c,v 1.35 2005/11/04 14:10:38 reinelt Exp $
*
* new framework for display drivers
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv.c,v $
+ * Revision 1.35 2005/11/04 14:10:38 reinelt
+ * drv_Sample and drv_LPH7508
+ *
* Revision 1.34 2005/11/04 04:44:52 reinelt
* LPH7508 driver (not yet finished)
*
@@ -220,6 +223,7 @@ extern DRIVER drv_MilfordInstruments;
extern DRIVER drv_Noritake;
extern DRIVER drv_NULL;
extern DRIVER drv_RouterBoard;
+extern DRIVER drv_Sample;
extern DRIVER drv_serdisplib;
extern DRIVER drv_SimpleLCD;
extern DRIVER drv_T6963;
@@ -283,6 +287,9 @@ DRIVER *Driver[] = {
#ifdef WITH_ROUTERBOARD
&drv_RouterBoard,
#endif
+#ifdef WITH_Sample
+ &drv_Sample,
+#endif
#ifdef WITH_SERDISPLIB
&drv_serdisplib,
#endif
diff --git a/drv_LPH7508.c b/drv_LPH7508.c
new file mode 100644
index 0000000..3e7aec2
--- /dev/null
+++ b/drv_LPH7508.c
@@ -0,0 +1,362 @@
+/* $Id: drv_LPH7508.c,v 1.1 2005/11/04 14:10:38 reinelt Exp $
+ *
+ * driver for Pollin LPH7508
+ *
+ * Copyright (C) 2005 Michael Reinelt <reinelt@eunet.at>
+ * Copyright (C) 2005 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_LPH7508.c,v $
+ * Revision 1.1 2005/11/04 14:10:38 reinelt
+ * drv_Sample and drv_LPH7508
+ *
+ */
+
+/*
+ *
+ * exported fuctions:
+ *
+ * struct DRIVER drv_LPH7508
+ *
+ */
+
+#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 "qprintf.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"
+
+#ifdef WITH_DMALLOC
+#include <dmalloc.h>
+#endif
+
+static char Name[] = "LPH7508";
+
+
+static unsigned char SIGNAL_RES;
+static unsigned char SIGNAL_CS1;
+static unsigned char SIGNAL_RW;
+static unsigned char SIGNAL_A0;
+
+static int PAGES, SROWS, SCOLS;
+
+unsigned char *Buffer1, *Buffer2;
+
+
+/****************************************/
+/*** hardware dependant functions ***/
+/****************************************/
+
+static void drv_L7_write_ctrl(const unsigned char data)
+{
+ /* Fixme: busy-check??? */
+
+ /* put data on DB1..DB8 */
+ drv_generic_parport_data(data);
+
+ /* CS1 = high, RW = low, A0 = low */
+ drv_generic_parport_control(SIGNAL_CS1 | SIGNAL_RW | SIGNAL_A0, SIGNAL_CS1);
+
+ /* Fixme: setup time? */
+ ndelay(100);
+
+ /* Fixme: toggle time? */
+ drv_generic_parport_toggle(SIGNAL_CS1, 0, 100);
+
+ ndelay(100); // Fixme
+}
+
+
+static void drv_L7_write_data(const unsigned char data)
+{
+ /* Fixme: busy-check??? */
+
+ /* put data on DB1..DB8 */
+ drv_generic_parport_data(data);
+
+ /* CS1 = high, RW = low, A0 = high */
+ drv_generic_parport_control(SIGNAL_CS1 | SIGNAL_RW | SIGNAL_A0, SIGNAL_CS1 | SIGNAL_A0);
+
+ /* Fixme: setup time? */
+ ndelay(100);
+
+ /* Fixme: toggle time? */
+ drv_generic_parport_toggle(SIGNAL_CS1, 0, 100);
+
+ ndelay(100); // Fixme
+}
+
+
+static void drv_L7_blit(const int row, const int col, const int height, const int width)
+{
+ int r, c;
+
+ /* transfer layout to display framebuffer */
+ for (r = row; r < row + height; r++) {
+ if (r >= SROWS)
+ break;
+ int p = r / 8; /* page */
+ for (c = col; c < col + width; c++) {
+ if (c >= SCOLS)
+ break;
+ int a = p * SCOLS + c; /* RAM address */
+ unsigned char m = 1 << (r % 8); /* bit mask */
+ if (drv_generic_graphic_FB[r * LCOLS + c]) {
+ /* set bit */
+ Buffer1[a] |= m;
+ } else {
+ /* clear bit */
+ Buffer1[a] &= ~m;
+ }
+ }
+ }
+
+ /* process display framebuffer */
+
+}
+
+
+static int drv_L7_start(const char *section)
+{
+ char *s;
+
+ /* fixed size */
+ DROWS = 64;
+ DCOLS = 100;
+
+ /* SED1560 display RAM layout */
+ PAGES = 8;
+ SROWS = PAGES * 8;
+ SCOLS = 166;
+
+ 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;
+ }
+
+ /* Fixme: provider other fonts someday... */
+ if (XRES != 6 && YRES != 8) {
+ error("%s: bad Font '%s' from %s (only 6x8 at the moment)", Name, s, cfg_source());
+ return -1;
+ }
+
+ /* provide room for page 8 (symbols) */
+ Buffer1 = malloc((PAGES + 1) * SCOLS);
+ if (Buffer1 == NULL) {
+ error("%s: framebuffer #1 could not be allocated: malloc() failed", Name);
+ return -1;
+ }
+
+ Buffer2 = malloc((PAGES + 1) * SCOLS);
+ if (Buffer2 == NULL) {
+ error("%s: framebuffer #2 could not be allocated: malloc() failed", Name);
+ return -1;
+ }
+
+ memset(Buffer1, 0, (PAGES + 1) * SCOLS * sizeof(*Buffer1));
+ memset(Buffer2, 0, (PAGES + 1) * SCOLS * sizeof(*Buffer2));
+
+ if (drv_generic_parport_open(section, Name) != 0) {
+ error("%s: could not initialize parallel port!", Name);
+ return -1;
+ }
+
+ if ((SIGNAL_RES = drv_generic_parport_hardwire_ctrl("RES", "INIT")) == 0xff)
+ return -1;
+ if ((SIGNAL_CS1 = drv_generic_parport_hardwire_ctrl("CS1", "STROBE")) == 0xff)
+ return -1;
+ if ((SIGNAL_RW = drv_generic_parport_hardwire_ctrl("RW", "SLCTIN")) == 0xff)
+ return -1;
+ if ((SIGNAL_A0 = drv_generic_parport_hardwire_ctrl("A0", "AUTOFD")) == 0xff)
+ return -1;
+
+ /* rise RES, CS1, RW and A0 */
+ drv_generic_parport_control(SIGNAL_RES | SIGNAL_CS1 | SIGNAL_RW | SIGNAL_A0, SIGNAL_RES | SIGNAL_CS1 | SIGNAL_RW | SIGNAL_A0);
+
+ /* set direction: write */
+ drv_generic_parport_direction(0);
+
+
+ /* reset display: lower RESET for 1 usec */
+ drv_generic_parport_control(SIGNAL_RES, 0);
+ udelay(1);
+ drv_generic_parport_control(SIGNAL_RES, SIGNAL_RES);
+ udelay(1);
+
+ /* just to make sure: send a software reset */
+ drv_L7_write_ctrl(0xe2);
+
+ /* initialize display */
+ drv_L7_write_ctrl(0x40); /* Start Display Line = 0 */
+ drv_L7_write_ctrl(0x20); /* reverse line driving release */
+ drv_L7_write_ctrl(0xCC); /* OutputStatus = $0C, 102x64 */
+ drv_L7_write_ctrl(0xA0); /* ADC = normal */
+ drv_L7_write_ctrl(0xA9); /* LCD-Duty = 1/64 */
+ drv_L7_write_ctrl(0xAB); /* LCD-Duty +1 (1/65, symbols) */
+ drv_L7_write_ctrl(0x25); /* power supply on */
+ udelay(100);
+ drv_L7_write_ctrl(0xED); /* power supply on completion */
+
+ /* clear display */
+ /* Fixme drv_L7_clear(); */
+
+ 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_L7_list(void)
+{
+ printf("LPH7508");
+ return 0;
+}
+
+
+/* initialize driver & display */
+int drv_L7_init(const char *section, const int quiet)
+{
+ WIDGET_CLASS wc;
+ int ret;
+
+ /* real worker functions */
+ drv_generic_graphic_real_blit = drv_L7_blit;
+
+ /* start display */
+ if ((ret = drv_L7_start(section)) != 0)
+ return ret;
+
+ /* initialize generic graphic driver */
+ if ((ret = drv_generic_graphic_init(section, Name)) != 0)
+ return ret;
+
+ if (!quiet) {
+ char buffer[40];
+ qprintf(buffer, sizeof(buffer), "%s %dx%d", Name, DCOLS, DROWS);
+ if (drv_generic_graphic_greet(buffer, NULL)) {
+ sleep(3);
+ drv_generic_graphic_clear();
+ }
+ }
+
+ /* 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_L7_quit(const int quiet)
+{
+
+ info("%s: shutting down.", Name);
+
+ drv_generic_graphic_clear();
+
+ if (!quiet) {
+ drv_generic_graphic_greet("goodbye!", NULL);
+ }
+
+ drv_generic_graphic_quit();
+ drv_generic_parport_close();
+
+ if (Buffer1) {
+ free(Buffer1);
+ Buffer1 = NULL;
+ }
+
+ if (Buffer2) {
+ free(Buffer2);
+ Buffer2 = NULL;
+ }
+
+ return (0);
+}
+
+
+DRIVER drv_LPH7508 = {
+ name:Name,
+ list:drv_L7_list,
+ init:drv_L7_init,
+ quit:drv_L7_quit,
+};
diff --git a/drv_Sample.c b/drv_Sample.c
new file mode 100644
index 0000000..6ed5490
--- /dev/null
+++ b/drv_Sample.c
@@ -0,0 +1,578 @@
+/* $Id: drv_Sample.c,v 1.1 2005/11/04 14:10:38 reinelt Exp $
+ *
+ * sample lcd4linux driver
+ *
+ * Copyright (C) 2005 Michael Reinelt <reinelt@eunet.at>
+ * Copyright (C) 2005 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_Sample.c,v $
+ * Revision 1.1 2005/11/04 14:10:38 reinelt
+ * drv_Sample and drv_LPH7508
+ *
+ */
+
+/*
+ *
+ * exported fuctions:
+ *
+ * struct DRIVER drv_Sample
+ *
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include <usb.h>
+
+#include "debug.h"
+#include "cfg.h"
+#include "qprintf.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"
+
+/* text mode display? */
+#include "drv_generic_text.h"
+
+/* graphic display? */
+#include "drv_generic_graphic.h"
+
+/* serial port? */
+#include "drv_generic_serial.h"
+
+/* parallel port? */
+#include "drv_generic_parport.h"
+
+/* i2c bus? */
+#ifdef WITH_I2C
+#include "drv_generic_i2c.h"
+#endif
+
+
+static char Name[] = "Sample";
+
+
+/* for parallel port displays only */
+/* use whatever lines you need */
+static unsigned char SIGNAL_RS;
+static unsigned char SIGNAL_EX;
+
+
+
+/****************************************/
+/*** hardware dependant functions ***/
+/****************************************/
+
+/* low-level parallel port stuff */
+/* example for sending one byte over the wire */
+static void drv_Sample_bang(const unsigned int data)
+{
+ /* put data on DB1..DB8 */
+ drv_generic_parport_data(data & 0xff);
+
+ /* set/clear some signals */
+ drv_generic_parport_control(SIGNAL_RS, SIGNAL_RS);
+
+ /* data setup time (e.g. 200 ns) */
+ ndelay(200);
+
+ /* send byte */
+ /* signal pulse width 500ns */
+ drv_generic_parport_toggle(SIGNAL_EX, 1, 500);
+
+ /* wait for command completion (e.g. 100 us) */
+ udelay(100);
+}
+
+
+static int drv_Sample_open(const char *section)
+{
+ /* open serial port */
+ /* don't mind about device, speed and stuff, this function will take care of */
+
+ if (drv_generic_serial_open(section, Name, 0) < 0)
+ return -1;
+
+
+ /* opening the parallel port is a bit more tricky: */
+ /* you have to do all the bit-banging yourself... */
+
+ if (drv_generic_parport_open(section, Name) != 0) {
+ error("%s: could not initialize parallel port!", Name);
+ return -1;
+ }
+
+ /* read the wiring from config */
+ if ((SIGNAL_EX = drv_generic_parport_wire_ctrl("EX", "STROBE")) == 0xff)
+ return -1;
+ if ((SIGNAL_RS = drv_generic_parport_wire_ctrl("RS", "INIT")) == 0xff)
+ return -1;
+
+ /* clear all signals */
+ drv_generic_parport_control(SIGNAL_EX | SIGNAL_RS, 0);
+
+ /* set direction: write */
+ drv_generic_parport_direction(0);
+
+ return 0;
+}
+
+
+static int drv_Sample_close(void)
+{
+ /* close whatever port you've opened */
+ drv_generic_parport_close();
+ drv_generic_serial_close();
+
+ return 0;
+}
+
+
+/* dummy function that sends something to the display */
+static void drv_Sample_send(const char *data, const unsigned int len)
+{
+ unsigned int i;
+
+ /* send data to the serial port is easy... */
+ drv_generic_serial_write(data, len);
+
+ /* sending data to the parallel port is a bit more tricky... */
+ for (i = 0; i < len; i++) {
+ drv_Sample_bang (*data++);
+ }
+}
+
+
+/* text mode displays only */
+static void drv_Sample_clear(void)
+{
+ char cmd[1];
+
+ /* do whatever is necessary to clear the display */
+ /* assume 0x01 to be a 'clear display' command */
+ cmd[0] = 0x01;
+ drv_Sample_send(cmd, 1);
+}
+
+
+/* text mode displays only */
+static void drv_Sample_write(const int row, const int col, const char *data, int len)
+{
+ char cmd[3];
+
+ /* do the cursor positioning here */
+ /* assume 0x02 to be a 'Goto' command */
+ cmd[0] = 0x02;
+ cmd[1] = row;
+ cmd[2] = col;
+ drv_Sample_send(cmd, 3);
+
+ /* send string to the display */
+ drv_Sample_send(data, len);
+
+}
+
+/* text mode displays only */
+static void drv_Sample_defchar(const int ascii, const unsigned char *matrix)
+{
+ char cmd[10];
+ int i;
+
+ /* call the 'define character' function */
+ /* assume 0x03 to be the 'defchar' command */
+ cmd[0] = 0x03;
+ cmd[1] = ascii;
+
+ /* send bitmap to the display */
+ for (i = 0; i < 8; i++) {
+ cmd[i + 2] = *matrix++;
+ }
+ drv_Sample_send(cmd, 10);
+}
+
+
+/* for graphic displays only */
+static void drv_Sample_blit(const int row, const int col, const int height, const int width)
+{
+ int r, c;
+
+ for (r = row; r < row + height; r++) {
+ for (c = col; c < col + width; c++) {
+ if (drv_generic_graphic_FB[r * LCOLS + c]) {
+ /* set bit */
+ } else {
+ /* clear bit */
+ }
+ }
+ }
+}
+
+
+/* example function used in a plugin */
+static int drv_Sample_contrast(int contrast)
+{
+ char cmd[2];
+
+ /* adjust limits according to the display */
+ if (contrast < 0)
+ contrast = 0;
+ if (contrast > 255)
+ contrast = 255;
+
+ /* call a 'contrast' function */
+ /* assume 0x04 to be the 'set contrast' command */
+ cmd[0] = 0x04;
+ cmd[1] = contrast;
+ drv_Sample_send(cmd, 2);
+
+ return contrast;
+}
+
+
+/* start text mode display */
+static int drv_Sample_start(const char *section)
+{
+ int contrast;
+ int rows = -1, cols = -1;
+ char *s;
+ char cmd[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;
+ }
+ if (sscanf(s, "%dx%d", &cols, &rows) != 2 || rows < 1 || cols < 1) {
+ error("%s: bad %s.Size '%s' from %s", Name, section, s, cfg_source());
+ free(s);
+ return -1;
+ }
+
+ DROWS = rows;
+ DCOLS = cols;
+
+ /* open communication with the display */
+ if (drv_Sample_open(section) < 0) {
+ return -1;
+ }
+
+ /* reset & initialize display */
+ /* assume 0x00 to be a 'reset' command */
+ cmd[0] = 0x00;
+ drv_Sample_send(cmd, 0);
+
+ if (cfg_number(section, "Contrast", 0, 0, 255, &contrast) > 0) {
+ drv_Sample_contrast(contrast);
+ }
+
+ drv_Sample_clear(); /* clear display */
+
+ return 0;
+}
+
+
+/* start graphic display */
+static int drv_Sample_start2(const char *section)
+{
+ char *s;
+ char cmd[1];
+ int contrast;
+
+ /* read display size from config */
+ 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;
+ }
+
+ /* Fixme: provider other fonts someday... */
+ if (XRES != 6 && YRES != 8) {
+ error("%s: bad Font '%s' from %s (only 6x8 at the moment)", Name, s, cfg_source());
+ return -1;
+ }
+
+ /* you surely want to allocate a framebuffer or something... */
+
+ /* open communication with the display */
+ if (drv_Sample_open(section) < 0) {
+ return -1;
+ }
+
+ /* reset & initialize display */
+ /* assume 0x00 to be a 'reset' command */
+ cmd[0] = 0x00;
+ drv_Sample_send(cmd, 1);
+
+ if (cfg_number(section, "Contrast", 0, 0, 255, &contrast) > 0) {
+ drv_Sample_contrast(contrast);
+ }
+
+ return 0;
+}
+
+
+/****************************************/
+/*** plugins ***/
+/****************************************/
+
+static void plugin_contrast(RESULT * result, RESULT * arg1)
+{
+ double contrast;
+
+ contrast = drv_Sample_contrast(R2N(arg1));
+ SetResult(&result, R_NUMBER, &contrast);
+}
+
+
+/****************************************/
+/*** widget callbacks ***/
+/****************************************/
+
+
+/* using drv_generic_text_draw(W) */
+/* using drv_generic_text_icon_draw(W) */
+/* using drv_generic_text_bar_draw(W) */
+
+
+/****************************************/
+/*** exported functions ***/
+/****************************************/
+
+
+/* list models */
+int drv_Sample_list(void)
+{
+ printf("generic");
+ return 0;
+}
+
+
+/* initialize driver & display */
+/* use this function for a text display */
+int drv_Sample_init(const char *section, const int quiet)
+{
+ WIDGET_CLASS wc;
+ int ret;
+
+ /* display preferences */
+ XRES = 5; /* pixel width of one char */
+ YRES = 8; /* pixel height of one char */
+ CHARS = 8; /* number of user-defineable characters */
+ CHAR0 = 0; /* ASCII of first user-defineable char */
+ GOTO_COST = 2; /* number of bytes a goto command requires */
+
+ /* real worker functions */
+ drv_generic_text_real_write = drv_Sample_write;
+ drv_generic_text_real_defchar = drv_Sample_defchar;
+
+
+ /* start display */
+ if ((ret = drv_Sample_start(section)) != 0)
+ return ret;
+
+ if (!quiet) {
+ char buffer[40];
+ qprintf(buffer, sizeof(buffer), "%s %dx%d", Name, DCOLS, DROWS);
+ if (drv_generic_text_greet(buffer, "www.bwct.de")) {
+ sleep(3);
+ drv_Sample_clear();
+ }
+ }
+
+ /* initialize generic text driver */
+ if ((ret = drv_generic_text_init(section, Name)) != 0)
+ return ret;
+
+ /* initialize generic icon driver */
+ if ((ret = drv_generic_text_icon_init()) != 0)
+ return ret;
+
+ /* initialize generic bar driver */
+ if ((ret = drv_generic_text_bar_init(0)) != 0)
+ return ret;
+
+ /* add fixed chars to the bar driver */
+ drv_generic_text_bar_add_segment(0, 0, 255, 32); /* ASCII 32 = blank */
+
+
+ /* register text widget */
+ wc = Widget_Text;
+ wc.draw = drv_generic_text_draw;
+ widget_register(&wc);
+
+ /* register icon widget */
+ wc = Widget_Icon;
+ wc.draw = drv_generic_text_icon_draw;
+ widget_register(&wc);
+
+ /* register bar widget */
+ wc = Widget_Bar;
+ wc.draw = drv_generic_text_bar_draw;
+ widget_register(&wc);
+
+ /* register plugins */
+ AddFunction("LCD::contrast", 1, plugin_contrast);
+
+ return 0;
+}
+
+
+/* initialize driver & display */
+/* use this function for a graphic display */
+int drv_Sample_init2(const char *section, const int quiet)
+{
+ WIDGET_CLASS wc;
+ int ret;
+
+ /* real worker functions */
+ drv_generic_graphic_real_blit = drv_Sample_blit;
+
+ /* start display */
+ if ((ret = drv_Sample_start2(section)) != 0)
+ return ret;
+
+ /* initialize generic graphic driver */
+ if ((ret = drv_generic_graphic_init(section, Name)) != 0)
+ return ret;
+
+ if (!quiet) {
+ char buffer[40];
+ qprintf(buffer, sizeof(buffer), "%s %dx%d", Name, DCOLS, DROWS);
+ if (drv_generic_graphic_greet(buffer, NULL)) {
+ sleep(3);
+ drv_generic_graphic_clear();
+ }
+ }
+
+ /* 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 */
+ AddFunction("LCD::contrast", 1, plugin_contrast);
+
+
+ return 0;
+}
+
+
+
+/* close driver & display */
+/* use this function for a text display */
+int drv_Sample_quit(const int quiet)
+{
+
+ info("%s: shutting down.", Name);
+
+ drv_generic_text_quit();
+
+ /* clear display */
+ drv_Sample_clear();
+
+ /* say goodbye... */
+ if (!quiet) {
+ drv_generic_text_greet("goodbye!", NULL);
+ }
+
+ debug("closing connection");
+ drv_Sample_close();
+
+ return (0);
+}
+
+/* close driver & display */
+/* use this function for a graphic display */
+int drv_Sample_quit2(const int quiet)
+{
+
+ info("%s: shutting down.", Name);
+
+ /* clear display */
+ drv_generic_graphic_clear();
+
+ /* say goodbye... */
+ if (!quiet) {
+ drv_generic_graphic_greet("goodbye!", NULL);
+ }
+
+ drv_generic_graphic_quit();
+
+ debug("closing connection");
+ drv_Sample_close();
+
+ return (0);
+}
+
+
+/* use this one for a text display */
+DRIVER drv_Sample = {
+ name:Name,
+ list:drv_Sample_list,
+ init:drv_Sample_init,
+ quit:drv_Sample_quit,
+};
+
+
+/* use this one for a graphic display */
+DRIVER drv_Sample2 = {
+ name:Name,
+ list:drv_Sample_list,
+ init:drv_Sample_init2,
+ quit:drv_Sample_quit2,
+};