diff options
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | Makefile.in | 4 | ||||
-rw-r--r-- | config.h.in | 6 | ||||
-rwxr-xr-x | configure | 175 | ||||
-rw-r--r-- | configure.in | 3 | ||||
-rw-r--r-- | drivers.m4 | 17 | ||||
-rw-r--r-- | drv.c | 9 | ||||
-rw-r--r-- | drv_LUIse.c | 367 |
8 files changed, 577 insertions, 5 deletions
diff --git a/Makefile.am b/Makefile.am index 75ffe02..47bfe79 100644 --- a/Makefile.am +++ b/Makefile.am @@ -64,6 +64,7 @@ drv_LCDLinux.c \ drv_LCDLinux.h \ drv_LCDTerm.c \ drv_LPH7508.c \ +drv_LUIse.c \ drv_M50530.c \ drv_MatrixOrbital.c \ drv_MilfordInstruments.c \ diff --git a/Makefile.in b/Makefile.in index 80aa295..fac2395 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 widget_gpo.c widget_gpo.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_gpio.c drv_generic_gpio.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_lcd4linux_SOURCES = drv_generic_text.c drv_generic_text.h drv_generic_graphic.c drv_generic_graphic.h drv_generic_gpio.c drv_generic_gpio.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_LUIse.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 @@ -145,7 +145,7 @@ DEP_FILES = .deps/cfg.P .deps/debug.P .deps/drv.P .deps/drv_BWCT.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_LCDLinux.P .deps/drv_LCDTerm.P .deps/drv_LPH7508.P \ -.deps/drv_M50530.P .deps/drv_MatrixOrbital.P \ +.deps/drv_LUIse.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_Sample.P .deps/drv_SimpleLCD.P \ .deps/drv_T6963.P .deps/drv_Trefon.P .deps/drv_USBLCD.P \ diff --git a/config.h.in b/config.h.in index 01204dc..cc914f8 100644 --- a/config.h.in +++ b/config.h.in @@ -64,6 +64,9 @@ /* Define to 1 if you have the <linux/ppdev.h> header file. */ #undef HAVE_LINUX_PPDEV_H +/* Define to 1 if you have the <luise.h> header file. */ +#undef HAVE_LUISE_H + /* Define to 1 if you have the <memory.h> header file. */ #undef HAVE_MEMORY_H @@ -371,6 +374,9 @@ /* LPH7508 driver */ #undef WITH_LPH7508 +/* LUIse driver */ +#undef WITH_LUISE + /* M50530 driver */ #undef WITH_M50530 @@ -869,7 +869,7 @@ Optional Packages: (try 'all,\!<driver>' if your shell complains...) possible drivers are: BeckmannEgle, BWCT, CrystalFontz, Curses, Cwlinux, - HD44780, LCDLinux, LCDTerm, LPH7508, M50530, + HD44780, LCDLinux, LCDTerm, LPH7508, LUIse, M50530, MatrixOrbital, MilfordInstruments, Noritake, NULL, PNG, PPM, RouterBoard, Sample, serdisplib, SimpleLCD, T6963, Trefon, USBLCD, WincorNixdorf, X11 @@ -5613,6 +5613,159 @@ fi done +# check for luise.h + +for ac_header in luise.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ---------------------------------------------------- ## +## Report this to lcd4linux-users@lists.sourceforge.net ## +## ---------------------------------------------------- ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + has_luise="true" +else + has_luise="false" +fi + +done + + # check for serdisplib for ac_header in serdisplib/serdisp.h @@ -6040,6 +6193,7 @@ for driver in $drivers; do LCDLINUX="yes" LCDTERM="yes" LPH7508="yes" + LUISE="yes" M50530="yes" MATRIXORBITAL="yes" MILINST="yes" @@ -6084,6 +6238,9 @@ for driver in $drivers; do LPH7508) LPH7508=$val ;; + LUIse) + LUISE=$val + ;; M50530) M50530=$val ;; @@ -6273,6 +6430,22 @@ _ACEOF fi +if test "$LUISE" = "yes"; then + if test "$has_luise" = "true"; then + GRAPHIC="yes" + DRIVERS="$DRIVERS drv_LUIse.o" + DRVLIBS="$DRVLIBS -L/usr/local/lib -lluise" + +cat >>confdefs.h <<\_ACEOF +#define WITH_LUISE 1 +_ACEOF + + else + { echo "$as_me:$LINENO: WARNING: luise.h not found: LUIse driver disabled" >&5 +echo "$as_me: WARNING: luise.h not found: LUIse driver disabled" >&2;} + fi +fi + if test "$M50530" = "yes"; then TEXT="yes" PARPORT="yes" diff --git a/configure.in b/configure.in index 87a0981..8bbebb7 100644 --- a/configure.in +++ b/configure.in @@ -62,6 +62,9 @@ AC_CHECK_HEADERS(gd/gd.h gd.h, [has_gd="true"; break], [has_gd="false"]) # check for usb.h AC_CHECK_HEADERS(usb.h, [has_usb="true"], [has_usb="false"]) +# check for luise.h +AC_CHECK_HEADERS(luise.h, [has_luise="true"], [has_luise="false"]) + # check for serdisplib AC_CHECK_HEADERS(serdisplib/serdisp.h, [has_serdisplib="true"], [has_serdisplib="false"]) @@ -29,7 +29,7 @@ AC_ARG_WITH( [ (try 'all,\!<driver>' if your shell complains...)] [ possible drivers are:] [ BeckmannEgle, BWCT, CrystalFontz, Curses, Cwlinux,] - [ HD44780, LCDLinux, LCDTerm, LPH7508, M50530,] + [ HD44780, LCDLinux, LCDTerm, LPH7508, LUIse, M50530,] [ MatrixOrbital, MilfordInstruments, Noritake, NULL,] [ PNG, PPM, RouterBoard, Sample, serdisplib, SimpleLCD,] [ T6963, Trefon, USBLCD, WincorNixdorf, X11], @@ -62,6 +62,7 @@ for driver in $drivers; do LCDLINUX="yes" LCDTERM="yes" LPH7508="yes" + LUISE="yes" M50530="yes" MATRIXORBITAL="yes" MILINST="yes" @@ -106,6 +107,9 @@ for driver in $drivers; do LPH7508) LPH7508=$val ;; + LUIse) + LUISE=$val + ;; M50530) M50530=$val ;; @@ -253,6 +257,17 @@ if test "$LPH7508" = "yes"; then AC_DEFINE(WITH_LPH7508,1,[LPH7508 driver]) fi +if test "$LUISE" = "yes"; then + if test "$has_luise" = "true"; then + GRAPHIC="yes" + DRIVERS="$DRIVERS drv_LUIse.o" + DRVLIBS="$DRVLIBS -L/usr/local/lib -lluise" + AC_DEFINE(WITH_LUISE,1,[LUIse driver]) + else + AC_MSG_WARN(luise.h not found: LUIse driver disabled) + fi +fi + if test "$M50530" = "yes"; then TEXT="yes" PARPORT="yes" @@ -1,4 +1,4 @@ -/* $Id: drv.c,v 1.36 2005/11/05 06:26:51 reinelt Exp $ +/* $Id: drv.c,v 1.37 2006/01/03 13:20:06 reinelt Exp $ * * new framework for display drivers * @@ -23,6 +23,9 @@ * * * $Log: drv.c,v $ + * Revision 1.37 2006/01/03 13:20:06 reinelt + * LUIse driver added + * * Revision 1.36 2005/11/05 06:26:51 reinelt * littly typo corrected * @@ -220,6 +223,7 @@ extern DRIVER drv_Image; extern DRIVER drv_LCDLinux; extern DRIVER drv_LCDTerm; extern DRIVER drv_LPH7508; +extern DRIVER drv_LUIse; extern DRIVER drv_M50530; extern DRIVER drv_MatrixOrbital; extern DRIVER drv_MilfordInstruments; @@ -272,6 +276,9 @@ DRIVER *Driver[] = { #ifdef WITH_LPH7508 &drv_LPH7508, #endif +#ifdef WITH_LUISE + &drv_LUIse, +#endif #ifdef WITH_M50530 &drv_M50530, #endif diff --git a/drv_LUIse.c b/drv_LUIse.c new file mode 100644 index 0000000..e88baca --- /dev/null +++ b/drv_LUIse.c @@ -0,0 +1,367 @@ +/* $Id: drv_LUIse.c,v 1.1 2006/01/03 13:20:06 reinelt Exp $ + * + * LUIse lcd4linux driver + * + * Copyright (C) 2005 Theo Schneider <theo@schneider-berlin.net> + * 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_LUIse.c,v $ + * Revision 1.1 2006/01/03 13:20:06 reinelt + * LUIse driver added + * + */ + +/* + * + * exported fuctions: + * + * struct DRIVER drv_LUIse + * + */ + +#include "config.h" + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <errno.h> + +#include <usb.h> +#include <luise.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" + +static char Name[] = "LUIse"; + +/* default Wert */ +static int devNum = 0; + + + +/****************************************/ +/*** hardware dependant functions ***/ +/****************************************/ +static void drv_LUIse_clear(void) +{ + unsigned char buf[9600]; + int x; + + // clear text + LUI_Text(devNum, 0, 0, 320, 240, 0, 0, 1, 1, ""); + + // clear picture + for (x = 0; x < 9600; x++) + buf[x] = 0x00; + LUI_Bitmap(devNum, 0, 0, 0, 0, 0, 320, 240, 320, 240, buf); + LUI_Bitmap(devNum, 1, 0, 0, 0, 0, 320, 240, 320, 240, buf); +} + + +static void drv_LUIse_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]) { + LUI_SetPixel(devNum, 0, c, r, 1); + } else { + LUI_SetPixel(devNum, 0, c, r, 0); + } + } + } +} + +static int drv_LUIse_contrast(int contrast) +{ + /* adjust limits according to the display */ + if (contrast < 0) + contrast = 0; + if (contrast > 255) + contrast = 255; + + LUI_SetContrast(devNum, contrast); + + return contrast; +} + +static int drv_LUIse_backlight(int backlight) +{ + if (backlight < 0) + backlight = 0; + if (backlight > 1) + backlight = 1; + + LUI_CCFL(devNum, backlight); + + return backlight; +} + + +/* start graphic display */ +static int drv_LUIse_start(const char *section) +{ + char *s; + int gfxmode, gfxinvert, ScreenRotation, IOrefresh; + int contrast, backlight; + + /* read devNum from config */ + s = cfg_get(section, "DeviceNum", 0); + if (s == NULL || *s == '\0') { + error("%s: no '%s.DeviceNum' entry from %s", Name, section, cfg_source()); + return -1; + } + if (sscanf(s, "%d", &devNum) < 0 || devNum > 4) { + error("s: bad DeviceNum '%s' from %s", Name, s, cfg_source()); + return -1; + } + info("%s: using DeviceNum '%d'", Name, devNum); + + /* open communication with the display */ + if (LUI_OpenDevice(devNum) > 0) { + error("unable to open DeviceNum: %d", devNum); + return -1; + } + + /* + * 0 : gfxmode 0 = or, 1 = and, 2 = xor + * 0 : gfxinvert 0 = normal, 1 = invert + * 0 : ScreenRotation 0 =, 1 =, 2 =, 3 =, + * 2 : IOrefresh 0 = 25ms...255=256*25ms + */ + + s = cfg_get(section, "Mode", "0.0.0.2"); + if (s == NULL || *s == '\0') { + error("%s: no '%s.Mode' entry from %s", Name, section, cfg_source()); + return -1; + } + + if (sscanf(s, "%d.%d.%d.%d", &gfxmode, &gfxinvert, &ScreenRotation, &IOrefresh) != 4 || + gfxmode < 0 || gfxmode > 2 || gfxinvert < 0 || gfxinvert > 1 || + ScreenRotation < 0 || ScreenRotation > 255 || IOrefresh < 0 || IOrefresh > 255) { + error("%s: bad Mode '%s' from %s", Name, s, cfg_source()); + return -1; + } + + if (LUI_LCDmode(devNum, gfxmode, gfxinvert, ScreenRotation, IOrefresh) > 0) { + error("Error LUI_LCDmode"); + return -1; + } + + switch (ScreenRotation) { + case 0:{ + DROWS = 240; + DCOLS = 320; + break; + } + case 1:{ + DROWS = 320; + DCOLS = 240; + break; + } + case 2:{ + DROWS = 240; + DCOLS = 320; + break; + } + case 3:{ + DROWS = 320; + DCOLS = 240; + break; + } + } + + 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; + } + + if (cfg_number(section, "Contrast", 128, 0, 255, &contrast) > 0) { + drv_LUIse_contrast(contrast); + } + + if (cfg_number(section, "Backlight", 0, 0, 1, &backlight) > 0) { + drv_LUIse_backlight(backlight); + } + + s = cfg_get(section, "Backpicture", NULL); + if (s == NULL || *s == '\0') { + error("%s: no '%s.Backpicture' entry from %s", Name, section, cfg_source()); + } else { + drv_LUIse_clear(); + if (LUI_BMPfile(devNum, 1, 0, 0, 0, 0, XRES, YRES, s)) { + error("%s: Sorry unable to load: %s", Name, s); + return -1; + } + } + + return 0; +} + + +/****************************************/ +/*** plugins ***/ +/****************************************/ + +static void plugin_contrast(RESULT * result, RESULT * arg1) +{ + double contrast; + + contrast = drv_LUIse_contrast(R2N(arg1)); + SetResult(&result, R_NUMBER, &contrast); +} + +static void plugin_backlight(RESULT * result, RESULT * arg1) +{ + double backlight; + + backlight = drv_LUIse_backlight(R2N(arg1)); + SetResult(&result, R_NUMBER, &backlight); +} + +/****************************************/ +/*** 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_LUIse_list(void) +{ + printf("generic"); + return 0; +} + +/* initialize driver & display */ +int drv_LUIse_init(const char *section, const int quiet) +{ + WIDGET_CLASS wc; + int ret; + + /* real worker functions */ + drv_generic_graphic_real_blit = drv_LUIse_blit; + + /* start display */ + if ((ret = drv_LUIse_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 */ + AddFunction("LCD::contrast", 1, plugin_contrast); + AddFunction("LCD::backlight", 1, plugin_backlight); + + return 0; +} + +/* close driver & display */ +/* use this function for a graphic display */ +int drv_LUIse_quit(const int quiet) +{ + + info("%s: shutting down.", Name); + + /* clear display */ + drv_LUIse_clear(); + + /* set default for Contrast, ScreenRotation, gfxmode, gfxinvert, IOrefresh */ + LUI_SetContrast(devNum, 128); + LUI_LCDmode(devNum, 0, 0, 0, 2); + + + /* say goodbye... */ + if (!quiet) { + drv_generic_graphic_greet("goodbye!", NULL); + } + + drv_generic_graphic_quit(); + + debug("closing connection"); + LUI_CloseDevice(devNum); + + return (0); +} + +/* use this one for a graphic display */ +DRIVER drv_LUIse = { + name:Name, + list:drv_LUIse_list, + init:drv_LUIse_init, + quit:drv_LUIse_quit, +}; |