aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drv_Crystalfontz.c98
-rw-r--r--lcd4linux.conf.sample6
2 files changed, 47 insertions, 57 deletions
diff --git a/drv_Crystalfontz.c b/drv_Crystalfontz.c
index 82f3cb4..31688cd 100644
--- a/drv_Crystalfontz.c
+++ b/drv_Crystalfontz.c
@@ -1,4 +1,4 @@
-/* $Id: drv_Crystalfontz.c,v 1.36 2005/09/07 06:51:44 reinelt Exp $
+/* $Id: drv_Crystalfontz.c,v 1.37 2006/01/06 08:12:19 reinelt Exp $
*
* new style driver for Crystalfontz display modules
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_Crystalfontz.c,v $
+ * Revision 1.37 2006/01/06 08:12:19 reinelt
+ * GPO's for Crystalfontz
+ *
* Revision 1.36 2005/09/07 06:51:44 reinelt
* Support for CF635 added
*
@@ -193,6 +196,7 @@
#include "widget_bar.h"
#include "drv.h"
#include "drv_generic_text.h"
+#include "drv_generic_gpio.h"
#include "drv_generic_serial.h"
@@ -225,33 +229,29 @@ static double Fan_RPM[4] = { 0.0, };
static double Temperature[32] = { 0.0, };
-/* Fixme: GPO's not yet implemented */
-/* static int GPO[8]; */
-static int GPOS;
-
-
typedef struct {
int type;
char *name;
int rows;
int cols;
+ int gpis;
int gpos;
int protocol;
int payload;
} MODEL;
-/* Fixme #1: number of gpo's should be verified */
+/* Fixme #1: number of GPI's & GPO's should be verified */
/* Fixme #2: protocol should be verified */
static MODEL Models[] = {
- {626, "626", 2, 16, 0, 1, 0},
- {631, "631", 2, 20, 0, 3, 22},
- {632, "632", 2, 16, 0, 1, 0},
- {633, "633", 2, 16, 0, 2, 18},
- {634, "634", 4, 20, 0, 1, 0},
- {635, "635", 4, 20, 0, 3, 22},
- {636, "636", 2, 16, 0, 1, 0},
- {-1, "Unknown", -1, -1, 0, 0, 0}
+ {626, "626", 2, 16, 0, 0, 1, 0},
+ {631, "631", 2, 20, 0, 0, 3, 22},
+ {632, "632", 2, 16, 0, 0, 1, 0},
+ {633, "633", 2, 16, 4, 4, 2, 18},
+ {634, "634", 4, 20, 0, 0, 1, 0},
+ {635, "635", 4, 20, 0, 0, 3, 22},
+ {636, "636", 2, 16, 0, 0, 1, 0},
+ {-1, "Unknown", -1, -1, 0, 0, 0, 0}
};
@@ -658,26 +658,27 @@ static int drv_CF_backlight(int backlight)
}
-static int drv_CF_fan_pwm(int fan, int power)
+static int drv_CF_GPI(const int num)
{
- static unsigned char PWM[4] = { 100, };
+ if (num < 0 || num > 3) {
+ return 0;
+ }
+ return Fan_RPM[num];
+}
- /* sanity check */
- if (fan < 1 || fan > 4)
- return -1;
- /* fan ranges from 1 to 4 */
- fan--;
+static int drv_CF_GPO(const int num, const int val)
+{
+ static unsigned char PWM[4] = { 0, };
+
+ int v = val;
- /* -1 is used to query the current power */
- if (power == -1)
- return PWM[fan];
+ if (v < 0)
+ v = 0;
+ if (v > 100)
+ v = 100;
- if (power < 0)
- power = 0;
- if (power > 100)
- power = 100;
- PWM[fan] = power;
+ PWM[num] = v;
switch (Protocol) {
case 2:
@@ -685,7 +686,7 @@ static int drv_CF_fan_pwm(int fan, int power)
break;
}
- return PWM[fan];
+ return v;
}
@@ -909,6 +910,7 @@ static int drv_CF_start(const char *section)
/* initialize global variables */
DROWS = Models[Model].rows;
DCOLS = Models[Model].cols;
+ GPIS = Models[Model].gpis;
GPOS = Models[Model].gpos;
Protocol = Models[Model].protocol;
Payload = Models[Model].payload;
@@ -996,25 +998,6 @@ static void plugin_backlight(RESULT * result, const int argc, RESULT * argv[])
}
-static void plugin_fan_pwm(RESULT * result, const int argc, RESULT * argv[])
-{
- double pwm;
-
- switch (argc) {
- case 1:
- pwm = drv_CF_fan_pwm(R2N(argv[0]), -1);
- SetResult(&result, R_NUMBER, &pwm);
- break;
- case 2:
- pwm = drv_CF_fan_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, "");
- }
-}
-
/* Fixme: other plugins for Fans, Temperature sensors, ... */
@@ -1026,6 +1009,7 @@ static void plugin_fan_pwm(RESULT * result, const int argc, RESULT * argv[])
/* using drv_generic_text_draw(W) */
/* using drv_generic_text_icon_draw(W) */
/* using drv_generic_text_bar_draw(W) */
+/* using drv_generic_gpio_draw(W) */
/****************************************/
@@ -1074,12 +1058,16 @@ int drv_CF_init(const char *section, const int quiet)
GOTO_COST = -1; /* there is no goto on 633 */
drv_generic_text_real_write = drv_CF_write2;
drv_generic_text_real_defchar = drv_CF_defchar23;
+ drv_generic_gpio_real_get = drv_CF_GPI;
+ drv_generic_gpio_real_set = drv_CF_GPO;
break;
case 3:
CHAR0 = 0; /* ASCII of first user-defineable char */
GOTO_COST = 3; /* number of bytes a goto command requires */
drv_generic_text_real_write = drv_CF_write3;
drv_generic_text_real_defchar = drv_CF_defchar23;
+ drv_generic_gpio_real_get = drv_CF_GPI;
+ drv_generic_gpio_real_set = drv_CF_GPO;
break;
}
@@ -1109,6 +1097,10 @@ int drv_CF_init(const char *section, const int quiet)
if (Protocol == 2)
drv_generic_text_bar_add_segment(255, 255, 255, 255); /* ASCII 255 = block */
+ /* initialize generic GPIO driver */
+ if ((ret = drv_generic_gpio_init(section, Name)) != 0)
+ return ret;
+
/* register text widget */
wc = Widget_Text;
wc.draw = drv_generic_text_draw;
@@ -1127,9 +1119,6 @@ int drv_CF_init(const char *section, const int quiet)
/* register plugins */
AddFunction("LCD::contrast", -1, plugin_contrast);
AddFunction("LCD::backlight", -1, plugin_backlight);
- if (Protocol == 2) {
- AddFunction("LCD::fan_pwm", -1, plugin_fan_pwm);
- }
return 0;
}
@@ -1139,9 +1128,10 @@ int drv_CF_init(const char *section, const int quiet)
int drv_CF_quit(const int quiet)
{
- info("%s: shutting down.", Name);
+ info("%s: shutting down display.", Name);
drv_generic_text_quit();
+ drv_generic_gpio_quit();
/* clear display */
drv_CF_clear();
diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample
index 355830b..06c423e 100644
--- a/lcd4linux.conf.sample
+++ b/lcd4linux.conf.sample
@@ -90,7 +90,7 @@ Display CF632 {
}
Display CF633 {
- Icons 4
+ Icons 1
Driver 'Crystalfontz'
Model '633'
Port '/dev/tts/0'
@@ -923,13 +923,13 @@ Layout testMySQL {
#Display 'MI240'
#Display 'CW12232'
#Display 'HD44780-generic'
-Display 'HD44780-WinAmp'
+#Display 'HD44780-WinAmp'
#Display 'WDC2704M'
#Display 'SC1602D'
#Display 'LCM-162'
#Display 'CF631'
#Display 'CF632'
-#Display 'CF633'
+Display 'CF633'
#Display 'Curses'
#Display 'M50530-24x8'
#Display 'LCDTerm'
n prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0