From 4e1eaa7205d8b7fbc64dc685d864b385a25602be Mon Sep 17 00:00:00 2001 From: reinelt Date: Mon, 31 May 2004 16:39:06 +0000 Subject: [lcd4linux @ 2004-05-31 16:39:05 by reinelt] added NULL display driver (for debugging/profiling purposes) added backlight/contrast initialisation for matrixOrbital added Backlight initialisation for Cwlinux git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@452 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- Makefile.am | 1 + Makefile.in | 32 +++--- aclocal.m4 | 2 +- config.h.in | 3 + configure | 31 +++-- drivers.m4 | 27 ++--- drv.c | 16 ++- drv_Cwlinux.c | 73 +++++++++--- drv_MatrixOrbital.c | 325 +++++++++++++++++++++++++++++++++++----------------- drv_NULL.c | 192 +++++++++++++++++++++++++++++++ hash.c | 13 ++- 11 files changed, 535 insertions(+), 180 deletions(-) create mode 100644 drv_NULL.c diff --git a/Makefile.am b/Makefile.am index aac5da6..508e7cc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -65,6 +65,7 @@ drv_Image.c \ drv_M50530.c \ drv_MatrixOrbital.c \ drv_MilfordInstruments.c \ +drv_NULL.c \ drv_T6963.c \ drv_USBLCD.c \ drv_X11.c \ diff --git a/Makefile.in b/Makefile.in index 2ae01c5..851526a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -101,7 +101,7 @@ lcd4linux_SOURCES = lcd4linux.c cfg.c cfg.h deb #liblcd4linux_la_SOURCES = -EXTRA_lcd4linux_SOURCES = drv_generic_text.c drv_generic_text.h drv_generic_graphic.c drv_generic_graphic.h drv_generic_serial.c drv_generic_serial.h drv_generic_parport.c drv_generic_parport.h drv_BeckmannEgle.c drv_Crystalfontz.c drv_Curses.c drv_Cwlinux.c drv_HD44780.c drv_Image.c drv_M50530.c drv_MatrixOrbital.c drv_MilfordInstruments.c drv_T6963.c drv_USBLCD.c drv_X11.c font_6x8.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_seti.c plugin_uname.c plugin_uptime.c plugin_wireless.c plugin_xmms.c +EXTRA_lcd4linux_SOURCES = drv_generic_text.c drv_generic_text.h drv_generic_graphic.c drv_generic_graphic.h drv_generic_serial.c drv_generic_serial.h drv_generic_parport.c drv_generic_parport.h drv_BeckmannEgle.c drv_Crystalfontz.c drv_Curses.c drv_Cwlinux.c drv_HD44780.c drv_Image.c drv_M50530.c drv_MatrixOrbital.c drv_MilfordInstruments.c drv_NULL.c drv_T6963.c drv_USBLCD.c drv_X11.c font_6x8.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_seti.c plugin_uname.c plugin_uptime.c plugin_wireless.c plugin_xmms.c EXTRA_DIST = lcd4linux.conf.sample lcd4kde.conf lcd4linux.kdelnk lcd4linux.xpm lcd4linux.lsm curses.m4 AUTHORS CREDITS FAQ NEWS TODO README README.Drivers README.Plugins README.KDE plugin_sample.c @@ -143,21 +143,21 @@ DEP_FILES = .deps/cfg.P .deps/debug.P .deps/drv.P \ .deps/drv_BeckmannEgle.P .deps/drv_Crystalfontz.P .deps/drv_Curses.P \ .deps/drv_Cwlinux.P .deps/drv_HD44780.P .deps/drv_Image.P \ .deps/drv_M50530.P .deps/drv_MatrixOrbital.P \ -.deps/drv_MilfordInstruments.P .deps/drv_T6963.P .deps/drv_USBLCD.P \ -.deps/drv_X11.P .deps/drv_generic_graphic.P .deps/drv_generic_parport.P \ -.deps/drv_generic_serial.P .deps/drv_generic_text.P .deps/evaluator.P \ -.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_seti.P .deps/plugin_string.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_MilfordInstruments.P .deps/drv_NULL.P .deps/drv_T6963.P \ +.deps/drv_USBLCD.P .deps/drv_X11.P .deps/drv_generic_graphic.P \ +.deps/drv_generic_parport.P .deps/drv_generic_serial.P \ +.deps/drv_generic_text.P .deps/evaluator.P .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_seti.P .deps/plugin_string.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/aclocal.m4 b/aclocal.m4 index c1b37d3..a6d638c 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,4 +1,4 @@ -dnl aclocal.m4 generated automatically by aclocal 1.4-p6 +dnl aclocal.m4t generated automatically by aclocal 1.4-p6 dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation diff --git a/config.h.in b/config.h.in index d8b4fdb..9dac2e4 100644 --- a/config.h.in +++ b/config.h.in @@ -350,6 +350,9 @@ /* Milford Instruments driver */ #undef WITH_MILINST +/* NULL driver */ +#undef WITH_NULL + /* driver */ #undef WITH_PNG diff --git a/configure b/configure index 2f9a299..f8604f0 100755 --- a/configure +++ b/configure @@ -869,7 +869,7 @@ Optional Packages: possible drivers are: BeckmannEgle, CrystalFontz, Curses, Cwlinux, HD44780, M50530, T6963, USBLCD, MatrixOrbital, - MilfordInstruments, PNG, PPM, X11 + MilfordInstruments, NULL, PNG, PPM, X11 --with-plugins= choose which plugins to compile. type --with-plugins=list for a list of avaible plugins @@ -5420,6 +5420,7 @@ for driver in $drivers; do USBLCD="yes" MATRIXORBITAL="yes" MILINST="yes" + NULL="yes" PALMPILOT="yes" PNG="yes" PPM="yes" @@ -5443,6 +5444,9 @@ for driver in $drivers; do M50530) M50530=$val ;; + NULL) + NULL=$val; + ;; T6963) T6963=$val ;; @@ -5482,7 +5486,6 @@ GRAPHIC="no" IMAGE="no" if test "$BECKMANNEGLE" = "yes"; then -# DRIVERS="$DRIVERS drv_BeckmannEgle.lo" DRIVERS="$DRIVERS drv_BeckmannEgle.o" cat >>confdefs.h <<\_ACEOF @@ -5494,7 +5497,6 @@ fi if test "$CRYSTALFONTZ" = "yes"; then TEXT="yes" SERIAL="yes" -# DRIVERS="$DRIVERS drv_Crystalfontz.lo" DRIVERS="$DRIVERS drv_Crystalfontz.o" cat >>confdefs.h <<\_ACEOF @@ -5505,7 +5507,6 @@ fi if test "$CURSES" = "yes"; then if test "$has_curses" = true; then -# DRIVERS="$DRIVERS drv_Curses.lo" DRIVERS="$DRIVERS drv_Curses.o" DRVLIBS="$DRVLIBS $CURSES_LIBS" CPPFLAGS="$CPPFLAGS $CURSES_INCLUDES" @@ -5523,7 +5524,6 @@ fi if test "$CWLINUX" = "yes"; then TEXT="yes" SERIAL="yes" -# DRIVERS="$DRIVERS drv_Cwlinux.lo" DRIVERS="$DRIVERS drv_Cwlinux.o" cat >>confdefs.h <<\_ACEOF @@ -5535,7 +5535,6 @@ fi if test "$HD44780" = "yes"; then TEXT="yes" PARPORT="yes" -# DRIVERS="$DRIVERS drv_HD44780.lo" DRIVERS="$DRIVERS drv_HD44780.o" cat >>confdefs.h <<\_ACEOF @@ -5547,7 +5546,6 @@ fi if test "$M50530" = "yes"; then TEXT="yes" PARPORT="yes" -# DRIVERS="$DRIVERS drv_M50530.lo" DRIVERS="$DRIVERS drv_M50530.o" cat >>confdefs.h <<\_ACEOF @@ -5558,7 +5556,6 @@ fi if test "$MATRIXORBITAL" = "yes"; then SERIAL="yes" -# DRIVERS="$DRIVERS drv_MatrixOrbital.lo" DRIVERS="$DRIVERS drv_MatrixOrbital.o" cat >>confdefs.h <<\_ACEOF @@ -5568,7 +5565,6 @@ _ACEOF fi if test "$MILINST" = "yes"; then -# DRIVERS="$DRIVERS drv_MilfordInstruments.lo" DRIVERS="$DRIVERS drv_MilfordInstruments.o" cat >>confdefs.h <<\_ACEOF @@ -5577,6 +5573,15 @@ _ACEOF fi +if test "$NULL" = "yes"; then + DRIVERS="$DRIVERS drv_NULL.o" + +cat >>confdefs.h <<\_ACEOF +#define WITH_NULL 1 +_ACEOF + +fi + if test "$PNG" = "yes"; then if test "$has_gd" = "true"; then GRAPHIC="yes" @@ -5604,14 +5609,12 @@ _ACEOF fi if test "$IMAGE" = "yes"; then -# DRIVERS="$DRIVERS drv_Image.lo" DRIVERS="$DRIVERS drv_Image.o" fi if test "$T6963" = "yes"; then GRAPHIC="yes" PARPORT="yes" -# DRIVERS="$DRIVERS drv_T6963.lo" DRIVERS="$DRIVERS drv_T6963.o" cat >>confdefs.h <<\_ACEOF @@ -5623,7 +5626,6 @@ fi if test "$USBLCD" = "yes"; then TEXT="yes" SERIAL="yes" -# DRIVERS="$DRIVERS drv_USBLCD.lo" DRIVERS="$DRIVERS drv_USBLCD.o" cat >>confdefs.h <<\_ACEOF @@ -5638,7 +5640,6 @@ if test "$X11" = "yes"; then echo "$as_me: WARNING: X11 headers or libraries not available: X11 driver disabled" >&2;} else GRAPHIC="yes" -# DRIVERS="$DRIVERS drv_X11.lo" DRIVERS="$DRIVERS drv_X11.o" DRVLIBS="$DRVLIBS -L$ac_x_libraries -lX11" @@ -5657,26 +5658,22 @@ fi # generic text driver if test "$TEXT" = "yes"; then -# DRIVERS="$DRIVERS drv_generic_text.lo" DRIVERS="$DRIVERS drv_generic_text.o" fi # generic graphic driver if test "$GRAPHIC" = "yes"; then : -# DRIVERS="$DRIVERS drv_generic_graphic.lo" DRIVERS="$DRIVERS drv_generic_graphic.o" fi # generic parport driver if test "$PARPORT" = "yes"; then -# DRIVERS="$DRIVERS drv_generic_parport.lo" DRIVERS="$DRIVERS drv_generic_parport.o" fi # generic serial driver if test "$SERIAL" = "yes"; then -# DRIVERS="$DRIVERS drv_generic_serial.lo" DRIVERS="$DRIVERS drv_generic_serial.o" fi diff --git a/drivers.m4 b/drivers.m4 index eee2c90..145710a 100644 --- a/drivers.m4 +++ b/drivers.m4 @@ -11,7 +11,7 @@ AC_ARG_WITH( [ possible drivers are:] [ BeckmannEgle, CrystalFontz, Curses, Cwlinux,] [ HD44780, M50530, T6963, USBLCD, MatrixOrbital,] - [ MilfordInstruments, PNG, PPM, X11], + [ MilfordInstruments, NULL, PNG, PPM, X11], drivers=$withval, drivers=all ) @@ -42,6 +42,7 @@ for driver in $drivers; do USBLCD="yes" MATRIXORBITAL="yes" MILINST="yes" + NULL="yes" PALMPILOT="yes" PNG="yes" PPM="yes" @@ -65,6 +66,9 @@ for driver in $drivers; do M50530) M50530=$val ;; + NULL) + NULL=$val; + ;; T6963) T6963=$val ;; @@ -101,7 +105,6 @@ GRAPHIC="no" IMAGE="no" if test "$BECKMANNEGLE" = "yes"; then -# DRIVERS="$DRIVERS drv_BeckmannEgle.lo" DRIVERS="$DRIVERS drv_BeckmannEgle.o" AC_DEFINE(WITH_BECKMANNEGLE,1,[Beckmann&Egle driver]) fi @@ -109,14 +112,12 @@ fi if test "$CRYSTALFONTZ" = "yes"; then TEXT="yes" SERIAL="yes" -# DRIVERS="$DRIVERS drv_Crystalfontz.lo" DRIVERS="$DRIVERS drv_Crystalfontz.o" AC_DEFINE(WITH_CRYSTALFONTZ,1,[Crystalfontz driver]) fi if test "$CURSES" = "yes"; then if test "$has_curses" = true; then -# DRIVERS="$DRIVERS drv_Curses.lo" DRIVERS="$DRIVERS drv_Curses.o" DRVLIBS="$DRVLIBS $CURSES_LIBS" CPPFLAGS="$CPPFLAGS $CURSES_INCLUDES" @@ -129,7 +130,6 @@ fi if test "$CWLINUX" = "yes"; then TEXT="yes" SERIAL="yes" -# DRIVERS="$DRIVERS drv_Cwlinux.lo" DRIVERS="$DRIVERS drv_Cwlinux.o" AC_DEFINE(WITH_CWLINUX,1,[CwLinux driver]) fi @@ -137,7 +137,6 @@ fi if test "$HD44780" = "yes"; then TEXT="yes" PARPORT="yes" -# DRIVERS="$DRIVERS drv_HD44780.lo" DRIVERS="$DRIVERS drv_HD44780.o" AC_DEFINE(WITH_HD44780,1,[HD44780 driver]) fi @@ -145,24 +144,26 @@ fi if test "$M50530" = "yes"; then TEXT="yes" PARPORT="yes" -# DRIVERS="$DRIVERS drv_M50530.lo" DRIVERS="$DRIVERS drv_M50530.o" AC_DEFINE(WITH_M50530,1,[M50530 driver]) fi if test "$MATRIXORBITAL" = "yes"; then SERIAL="yes" -# DRIVERS="$DRIVERS drv_MatrixOrbital.lo" DRIVERS="$DRIVERS drv_MatrixOrbital.o" AC_DEFINE(WITH_MATRIXORBITAL,1,[MatrixOrbital driver]) fi if test "$MILINST" = "yes"; then -# DRIVERS="$DRIVERS drv_MilfordInstruments.lo" DRIVERS="$DRIVERS drv_MilfordInstruments.o" AC_DEFINE(WITH_MILINST,1,[Milford Instruments driver]) fi +if test "$NULL" = "yes"; then + DRIVERS="$DRIVERS drv_NULL.o" + AC_DEFINE(WITH_NULL,1,[NULL driver]) +fi + if test "$PNG" = "yes"; then if test "$has_gd" = "true"; then GRAPHIC="yes" @@ -181,14 +182,12 @@ if test "$PPM" = "yes"; then fi if test "$IMAGE" = "yes"; then -# DRIVERS="$DRIVERS drv_Image.lo" DRIVERS="$DRIVERS drv_Image.o" fi if test "$T6963" = "yes"; then GRAPHIC="yes" PARPORT="yes" -# DRIVERS="$DRIVERS drv_T6963.lo" DRIVERS="$DRIVERS drv_T6963.o" AC_DEFINE(WITH_T6963,1,[T6963 driver]) fi @@ -196,7 +195,6 @@ fi if test "$USBLCD" = "yes"; then TEXT="yes" SERIAL="yes" -# DRIVERS="$DRIVERS drv_USBLCD.lo" DRIVERS="$DRIVERS drv_USBLCD.o" AC_DEFINE(WITH_USBLCD,1,[USBLCD driver]) fi @@ -206,7 +204,6 @@ if test "$X11" = "yes"; then AC_MSG_WARN(X11 headers or libraries not available: X11 driver disabled) else GRAPHIC="yes" -# DRIVERS="$DRIVERS drv_X11.lo" DRIVERS="$DRIVERS drv_X11.o" DRVLIBS="$DRVLIBS -L$ac_x_libraries -lX11" AC_DEFINE(WITH_X11,1,[X11 driver]) @@ -219,26 +216,22 @@ fi # generic text driver if test "$TEXT" = "yes"; then -# DRIVERS="$DRIVERS drv_generic_text.lo" DRIVERS="$DRIVERS drv_generic_text.o" fi # generic graphic driver if test "$GRAPHIC" = "yes"; then : -# DRIVERS="$DRIVERS drv_generic_graphic.lo" DRIVERS="$DRIVERS drv_generic_graphic.o" fi # generic parport driver if test "$PARPORT" = "yes"; then -# DRIVERS="$DRIVERS drv_generic_parport.lo" DRIVERS="$DRIVERS drv_generic_parport.o" fi # generic serial driver if test "$SERIAL" = "yes"; then -# DRIVERS="$DRIVERS drv_generic_serial.lo" DRIVERS="$DRIVERS drv_generic_serial.o" fi diff --git a/drv.c b/drv.c index a0cfa18..7077497 100644 --- a/drv.c +++ b/drv.c @@ -1,4 +1,4 @@ -/* $Id: drv.c,v 1.14 2004/05/28 13:51:42 reinelt Exp $ +/* $Id: drv.c,v 1.15 2004/05/31 16:39:06 reinelt Exp $ * * new framework for display drivers * @@ -23,6 +23,12 @@ * * * $Log: drv.c,v $ + * Revision 1.15 2004/05/31 16:39:06 reinelt + * + * added NULL display driver (for debugging/profiling purposes) + * added backlight/contrast initialisation for matrixOrbital + * added Backlight initialisation for Cwlinux + * * Revision 1.14 2004/05/28 13:51:42 reinelt * * ported driver for Beckmann+Egle Mini-Terminals @@ -138,10 +144,11 @@ extern DRIVER drv_Cwlinux; extern DRIVER drv_HD44780; extern DRIVER drv_Image; extern DRIVER drv_M50530; -extern DRIVER drv_T6963; -extern DRIVER drv_USBLCD; extern DRIVER drv_MatrixOrbital; extern DRIVER drv_MilfordInstruments; +extern DRIVER drv_NULL; +extern DRIVER drv_T6963; +extern DRIVER drv_USBLCD; extern DRIVER drv_X11; // output file for Image driver @@ -177,6 +184,9 @@ DRIVER *Driver[] = { #ifdef WITH_MILINST &drv_MilfordInstruments, #endif +#ifdef WITH_NULL + &drv_NULL, +#endif #ifdef WITH_T6963 &drv_T6963, #endif diff --git a/drv_Cwlinux.c b/drv_Cwlinux.c index 8d7d096..dac2f61 100644 --- a/drv_Cwlinux.c +++ b/drv_Cwlinux.c @@ -1,4 +1,4 @@ -/* $Id: drv_Cwlinux.c,v 1.8 2004/05/31 05:38:02 reinelt Exp $ +/* $Id: drv_Cwlinux.c,v 1.9 2004/05/31 16:39:06 reinelt Exp $ * * new style driver for Cwlinux display modules * @@ -23,6 +23,12 @@ * * * $Log: drv_Cwlinux.c,v $ + * Revision 1.9 2004/05/31 16:39:06 reinelt + * + * added NULL display driver (for debugging/profiling purposes) + * added backlight/contrast initialisation for matrixOrbital + * added Backlight initialisation for Cwlinux + * * Revision 1.8 2004/05/31 05:38:02 reinelt * * fixed possible bugs with user-defined chars (clear high bits) @@ -167,6 +173,38 @@ static void drv_CW12232_defchar (int ascii, unsigned char *buffer) } +static int drv_CW_brightness (int brightness) +{ + static unsigned char Brightness = 0; + char cmd[5] = "\376A_\375"; + + // -1 is used to query the current brightness + if (brightness == -1) return Brightness; + + if (brightness < 0 ) brightness = 0; + if (brightness > 255) brightness = 255; + Brightness = brightness; + + switch (Brightness) { + case 0: + // backlight off + drv_generic_serial_write ("\376F\375", 3); + break; + case 8: + // backlight on + drv_generic_serial_write ("\376B\375", 3); + break; + default: + // backlight level + cmd[2] = (char)Brightness; + drv_generic_serial_write (cmd, 4); + break; + } + + return Brightness; +} + + static int drv_CW_start (char *section) { int i; @@ -230,6 +268,11 @@ static int drv_CW_start (char *section) drv_generic_serial_write ("\376K\375", 3); // underline cursor off drv_generic_serial_write ("\376B\375", 3); // backlight on + // set brightness + if (cfg_number(section, "Brightness", 0, 0, 8, &i) > 0) { + drv_CW_brightness(i); + } + return 0; } @@ -239,29 +282,23 @@ static int drv_CW_start (char *section) // **************************************** -static void plugin_backlight (RESULT *result, RESULT *arg1) +static void plugin_brightness (RESULT *result, int argc, RESULT *argv[]) { - char cmd[5]="\376A_\375"; - double backlight; + double brightness; - backlight=R2N(arg1); - if (backlight<0) backlight=0; - if (backlight>8) backlight=8; - - switch ((int)backlight) { + switch (argc) { case 0: - drv_generic_serial_write ("\376F\375", 3); // backlight off + brightness = drv_CW_brightness(-1); + SetResult(&result, R_NUMBER, &brightness); break; - case 8: - drv_generic_serial_write ("\376B\375", 3); // backlight on + case 1: + brightness = drv_CW_brightness(R2N(argv[0])); + SetResult(&result, R_NUMBER, &brightness); break; default: - cmd[2]=(char)backlight; - drv_generic_serial_write (cmd, 4); // backlight level - break; + error ("%s.brightness(): wrong number of parameters", Name); + SetResult(&result, R_STRING, ""); } - - SetResult(&result, R_NUMBER, &backlight); } @@ -351,7 +388,7 @@ int drv_CW_init (char *section) widget_register(&wc); // register plugins - AddFunction ("LCD::backlight", 1, plugin_backlight); + AddFunction ("LCD::brightness", -1, plugin_brightness); return 0; } diff --git a/drv_MatrixOrbital.c b/drv_MatrixOrbital.c index 5a65c54..ec1f949 100644 --- a/drv_MatrixOrbital.c +++ b/drv_MatrixOrbital.c @@ -1,4 +1,4 @@ -/* $Id: drv_MatrixOrbital.c,v 1.25 2004/05/31 05:38:02 reinelt Exp $ +/* $Id: drv_MatrixOrbital.c,v 1.26 2004/05/31 16:39:06 reinelt Exp $ * * new style driver for Matrix Orbital serial display modules * @@ -23,6 +23,12 @@ * * * $Log: drv_MatrixOrbital.c,v $ + * Revision 1.26 2004/05/31 16:39:06 reinelt + * + * added NULL display driver (for debugging/profiling purposes) + * added backlight/contrast initialisation for matrixOrbital + * added Backlight initialisation for Cwlinux + * * Revision 1.25 2004/05/31 05:38:02 reinelt * * fixed possible bugs with user-defined chars (clear high bits) @@ -235,6 +241,147 @@ static void drv_MO_defchar (int ascii, unsigned char *matrix) } +static int drv_MO_contrast (int contrast) +{ + static unsigned char Contrast=0; + char buffer[4]; + + // -1 is used to query the current contrast + if (contrast == -1) return Contrast; + + if (contrast < 0 ) contrast = 0; + if (contrast > 255) contrast = 255; + Contrast = contrast; + + snprintf (buffer, 4, "\376P%c", Contrast); + drv_generic_serial_write (buffer, 3); + + return Contrast; +} + + +static int drv_MO_backlight (int backlight) +{ + static unsigned char Backlight=0; + char buffer[4]; + + // -1 is used to query the current backlight + if (backlight == -1) return Backlight; + + if (backlight < 0 ) backlight = 0; + if (backlight > 255) backlight = 255; + Backlight = backlight; + + if (backlight<0) { + // backlight off + snprintf (buffer, 3, "\376F"); + drv_generic_serial_write (buffer, 2); + } else { + // backlight on for n minutes + snprintf (buffer, 4, "\376B%c", (int)backlight); + drv_generic_serial_write (buffer, 3); + } + + return Backlight; +} + + +static int drv_MO_gpo (int num, int val) +{ + static int GPO[6] = { -1, -1, -1, -1, -1, -1 }; + char cmd[3]="\376"; + + if (num < 1) num = 1; + if (num > 6) num = 6; + + // -1 is used to query the current PWM + if (val == -1) return GPO[num-1]; + + if (val < 0) val = 0; + if (val > 1) val = 1; + GPO[num-1] = val; + + switch (Protocol) { + case 1: + if (num == 1) { + if (val > 0) { + drv_generic_serial_write ("\376W", 2); // GPO on + } else { + drv_generic_serial_write ("\376V", 2); // GPO off + } + } else { + GPO[num-1] = -1; + } + break; + + case 2: + if (val > 0) { + cmd[1] = 'W'; // GPO on + } else { + cmd[1] = 'V'; // GPO off + } + cmd[2] = (char)num; + drv_generic_serial_write (cmd, 3); + break; + } + + return GPO[num-1]; +} + + +static int drv_MO_pwm (int num, int val) +{ + static int PWM[6] = { -1, -1, -1, -1, -1, -1 }; + char cmd[4]="\376\300"; + + if (num < 1) num = 1; + if (num > 6) num = 6; + + // -1 is used to query the current PWM + if (val == -1) return PWM[num-1]; + + if (val < 0) val = 0; + if (val > 255) val = 255; + PWM[num-1] = val; + + cmd[2] = (char)num; + cmd[3] = (char)val; + drv_generic_serial_write (cmd, 4); + + return val; +} + + +static int drv_MO_rpm (int num) +{ + static int RPM[6] = { -1, -1, -1, -1, -1, -1 }; + char cmd[3] = "\376\301"; + char buffer[7]; + + if (num < 1) num = 1; + if (num > 6) num = 6; + + cmd[2] = (char)num; + drv_generic_serial_write (cmd, 3); + + usleep(100000); + drv_generic_serial_read (buffer, 7); + + debug ("rpm: buffer[0]=0x%01x", buffer[0]); + debug ("rpm: buffer[1]=0x%01x", buffer[1]); + debug ("rpm: buffer[2]=0x%01x", buffer[2]); + debug ("rpm: buffer[3]=0x%01x", buffer[3]); + debug ("rpm: buffer[4]=0x%01x", buffer[4]); + debug ("rpm: buffer[5]=0x%01x", buffer[5]); + debug ("rpm: buffer[6]=0x%01x", buffer[6]); + + // Fixme: + RPM[num-1] = 42; + + return RPM[num-1]; +} + + static int drv_MO_start (char *section) { int i; @@ -315,6 +462,16 @@ static int drv_MO_start (char *section) drv_generic_serial_write ("\376D", 2); // line wrapping off drv_generic_serial_write ("\376R", 2); // auto scroll off + // set contrast + if (cfg_number(section, "Contrast", 0, 0, 255, &i)>0) { + drv_MO_contrast(i); + } + + // set backlight + if (cfg_number(section, "Backlight", 0, 0, 255, &i)>0) { + drv_MO_backlight(i); + } + return 0; } @@ -324,136 +481,92 @@ static int drv_MO_start (char *section) // **************************************** -static void plugin_contrast (RESULT *result, RESULT *arg1) +static void plugin_contrast (RESULT *result, int argc, RESULT *argv[]) { - char buffer[4]; double contrast; - contrast=R2N(arg1); - if (contrast<0 ) contrast=0; - if (contrast>255) contrast=255; - snprintf (buffer, 4, "\376P%c", (int)contrast); - drv_generic_serial_write (buffer, 3); - - SetResult(&result, R_NUMBER, &contrast); + switch (argc) { + case 0: + contrast = drv_MO_contrast(-1); + SetResult(&result, R_NUMBER, &contrast); + break; + case 1: + contrast = drv_MO_contrast(R2N(argv[0])); + SetResult(&result, R_NUMBER, &contrast); + break; + default: + error ("%s::contrast(): wrong number of parameters", Name); + SetResult(&result, R_STRING, ""); + } } -static void plugin_backlight (RESULT *result, RESULT *arg1) +static void plugin_backlight (RESULT *result, int argc, RESULT *argv[]) { - char buffer[4]; double backlight; - - backlight=R2N(arg1); - if (backlight<-1 ) backlight=-1; - if (backlight>255) backlight=255; - if (backlight<0) { - // backlight off - snprintf (buffer, 3, "\376F"); - drv_generic_serial_write (buffer, 2); - } else { - // backlight on for n minutes - snprintf (buffer, 4, "\376B%c", (int)backlight); - drv_generic_serial_write (buffer, 3); + + switch (argc) { + case 0: + backlight = drv_MO_backlight(-1); + SetResult(&result, R_NUMBER, &backlight); + break; + case 1: + backlight = drv_MO_backlight(R2N(argv[0])); + SetResult(&result, R_NUMBER, &backlight); + break; + default: + error ("%s::backlight(): wrong number of parameters"); + SetResult(&result, R_STRING, ""); } - SetResult(&result, R_NUMBER, &backlight); } -static void plugin_gpo (RESULT *result, RESULT *arg1, RESULT *arg2) +static void plugin_gpo (RESULT *result, int argc, RESULT *argv[]) { - int num; - double val; - char cmd[3]="\376"; - - num=R2N(arg1); - val=R2N(arg2); + double gpo; - if (num<1) num=1; - if (num>6) num=6; - - if (val>=1.0) { - val=1.0; - } else { - val=0.0; - } - - switch (Protocol) { + switch (argc) { case 1: - if (num==0) { - if (val>=1.0) { - drv_generic_serial_write ("\376W", 2); // GPO on - } else { - drv_generic_serial_write ("\376V", 2); // GPO off - } - } else { - error("Fixme"); - val=-1.0; - } + gpo = drv_MO_gpo(R2N(argv[0]), -1); + SetResult(&result, R_NUMBER, &gpo); break; - case 2: - if (val>=1.0) { - cmd[1]='W'; // GPO on - } else { - cmd[1]='V'; // GPO off - } - cmd[2]=(char)num; - drv_generic_serial_write (cmd, 3); + gpo = drv_MO_gpo(R2N(argv[0]), R2N(argv[1])); + SetResult(&result, R_NUMBER, &gpo); break; + default: + error ("%s:gpo(): wrong number of parameters"); + SetResult(&result, R_STRING, ""); } - - SetResult(&result, R_NUMBER, &val); } -static void plugin_pwm (RESULT *result, RESULT *arg1, RESULT *arg2) +static void plugin_pwm (RESULT *result, int argc, RESULT *argv[]) { - int num; - double val; - char cmd[4]="\376\300"; + double pwm; - num=R2N(arg1); - if (num<1) num=1; - if (num>6) num=6; - cmd[2]=(char)num; - - val=R2N(arg2); - if (val< 0.0) val= 0.0; - if (val>255.0) val=255.0; - cmd[3]=(char)val; - - drv_generic_serial_write (cmd, 4); - - SetResult(&result, R_NUMBER, &val); + switch (argc) { + case 1: + pwm = drv_MO_pwm(R2N(argv[0]), -1); + SetResult(&result, R_NUMBER, &pwm); + break; + case 2: + pwm = drv_MO_pwm(R2N(argv[0]), R2N(argv[1])); + SetResult(&result, R_NUMBER, &pwm); + break; + default: + error ("%s:pwm(): wrong number of parameters"); + SetResult(&result, R_STRING, ""); + } } static void plugin_rpm (RESULT *result, RESULT *arg1) { - int num; - double val; - char cmd[3]="\376\301"; - char buffer[7]; - - num=R2N(arg1); - if (num<1) num=1; - if (num>6) num=6; - cmd[2]=(char)num; - - drv_generic_serial_write (cmd, 3); - usleep(100000); - drv_generic_serial_read (buffer, 7); - - debug ("rpm: buffer[0]=0x%01x", buffer[0]); - debug ("rpm: buffer[1]=0x%01x", buffer[1]); - debug ("rpm: buffer[2]=0x%01x", buffer[2]); - debug ("rpm: buffer[3]=0x%01x", buffer[3]); - debug ("rpm: buffer[4]=0x%01x", buffer[4]); - debug ("rpm: buffer[5]=0x%01x", buffer[5]); - debug ("rpm: buffer[6]=0x%01x", buffer[6]); + double rpm; - SetResult(&result, R_NUMBER, &val); + rpm = drv_MO_rpm(R2N(arg1)); + SetResult(&result, R_NUMBER, &rpm); } @@ -537,11 +650,11 @@ int drv_MO_init (char *section) widget_register(&wc); // register plugins - AddFunction ("LCD::contrast", 1, plugin_contrast); - AddFunction ("LCD::backlight", 1, plugin_backlight); - AddFunction ("LCD::gpo", 2, plugin_gpo); - AddFunction ("LCD::pwm", 2, plugin_pwm); - AddFunction ("LCD::rpm", 1, plugin_rpm); + AddFunction ("LCD::contrast", -1, plugin_contrast); + AddFunction ("LCD::backlight", -1, plugin_backlight); + AddFunction ("LCD::gpo", -1, plugin_gpo); + AddFunction ("LCD::pwm", -1, plugin_pwm); + AddFunction ("LCD::rpm", 1, plugin_rpm); return 0; } diff --git a/drv_NULL.c b/drv_NULL.c new file mode 100644 index 0000000..4db7bb0 --- /dev/null +++ b/drv_NULL.c @@ -0,0 +1,192 @@ +/* $Id: drv_NULL.c,v 1.1 2004/05/31 16:39:06 reinelt Exp $ + * + * NULL driver (for testing) + * + * Copyright 2004 Michael Reinelt + * Copyright 2004 The LCD4Linux Team + * + * 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_NULL.c,v $ + * Revision 1.1 2004/05/31 16:39:06 reinelt + * + * added NULL display driver (for debugging/profiling purposes) + * added backlight/contrast initialisation for matrixOrbital + * added Backlight initialisation for Cwlinux + * + */ + +/* + * + * exported fuctions: + * + * struct DRIVER drv_NULL + * + */ + +#include "config.h" + +#include +#include +#include + +#include "debug.h" +#include "cfg.h" +#include "plugin.h" +#include "widget.h" +#include "widget_text.h" +#include "widget_bar.h" +#include "drv.h" +#include "drv_generic_text.h" + + +static char Name[]="NULL"; + + +// **************************************** +// *** hardware dependant functions *** +// **************************************** + +static void drv_NULL_write (int row, int col, unsigned char *data, int len) +{ + // empty +} + + +static void drv_NULL_defchar (int ascii, unsigned char *matrix) +{ + // empty +} + + +static int drv_NULL_start (char *section) +{ + char *s; + + s = cfg_get(section, "Size", "20x4"); + if (s == NULL || *s == '\0') { + error ("%s: no '%s.Size' entry from %s", Name, section, cfg_source()); + free(s); + return -1; + } + if (sscanf(s, "%dx%d", &DCOLS, &DROWS) != 2 || DROWS < 1 || DCOLS < 1) { + error ("%s: bad %s.Size '%s' from %s", Name, section, s, cfg_source); + free(s); + return -1; + } + free (s); + + return 0; +} + + +// **************************************** +// *** plugins *** +// **************************************** + +// none at the moment... + + +// **************************************** +// *** widget callbacks *** +// **************************************** + +// using drv_generic_text_draw(W) +// using drv_generic_text_bar_draw(W) + + +// **************************************** +// *** exported functions *** +// **************************************** + + +// list models +int drv_NULL_list (void) +{ + printf ("generic"); + return 0; +} + + +// initialize driver & display +int drv_NULL_init (char *section) +{ + WIDGET_CLASS wc; + int ret; + + // display preferences + XRES = 6; // 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_NULL_write; + drv_generic_text_real_defchar = drv_NULL_defchar; + + // start display + if ((ret = drv_NULL_start (section)) != 0) + return ret; + + // initialize generic text driver + if ((ret = drv_generic_text_init(section, Name)) != 0) + return ret; + + // initialize generic bar driver + if ((ret = drv_generic_text_bar_init(1)) != 0) + return ret; + + // add fixed chars to the bar driver + drv_generic_text_bar_add_segment ( 0, 0,255, 32); // ASCII 32 = blank + drv_generic_text_bar_add_segment (255,255,255,'*'); // asterisk + + // register text widget + wc = Widget_Text; + wc.draw = drv_generic_text_draw; + widget_register(&wc); + + // register bar widget + wc = Widget_Bar; + wc.draw = drv_generic_text_bar_draw; + widget_register(&wc); + + // register plugins + // none at the moment... + + return 0; +} + + +// close driver & display +int drv_NULL_quit (void) { + + info("%s: shutting down.", Name); + drv_generic_text_quit(); + + return (0); +} + + +DRIVER drv_NULL = { + name: Name, + list: drv_NULL_list, + init: drv_NULL_init, + quit: drv_NULL_quit, +}; + diff --git a/hash.c b/hash.c index b73313a..57dbe06 100644 --- a/hash.c +++ b/hash.c @@ -1,4 +1,4 @@ -/* $Id: hash.c,v 1.17 2004/03/11 06:39:59 reinelt Exp $ +/* $Id: hash.c,v 1.18 2004/05/31 16:39:06 reinelt Exp $ * * hashes (associative arrays) * @@ -23,6 +23,12 @@ * * * $Log: hash.c,v $ + * Revision 1.18 2004/05/31 16:39:06 reinelt + * + * added NULL display driver (for debugging/profiling purposes) + * added backlight/contrast initialisation for matrixOrbital + * added Backlight initialisation for Cwlinux + * * Revision 1.17 2004/03/11 06:39:59 reinelt * big patch from Martin: * - reuse filehandles @@ -162,6 +168,9 @@ static HASH_ITEM* hash_lookup (HASH *Hash, char *key, int sortit) Hash->sorted=1; } + // no key was passed + if (key==NULL) return NULL; + // lookup using bsearch if (Hash->sorted) { Item=bsearch(key, Hash->Items, Hash->nItems, sizeof(HASH_ITEM), hash_lookup_f); @@ -378,7 +387,7 @@ double hash_get_regex (HASH *Hash, char *key, int delay) } // force the table to be sorted by requesting anything - hash_lookup(Hash, "", 1); + hash_lookup(Hash, NULL, 1); for (i=0;inItems; i++) { if (regexec(&preg, Hash->Items[i].key, 0, NULL, 0)==0) { -- cgit v1.2.3