aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreinelt <>2005-12-20 07:07:44 +0000
committerreinelt <>2005-12-20 07:07:44 +0000
commit3971f3c7af7397861c0db8fa72ba75a2b5d76ce1 (patch)
treeab40f6618a5cf52ca1a5d95a2d985ac4194334eb
parent7dfeea43c5cbd5bd160fc8ab85872cdbeb225e09 (diff)
downloadlcd4linux-3971f3c7af7397861c0db8fa72ba75a2b5d76ce1.tar.gz
[lcd4linux @ 2005-12-20 07:07:43 by reinelt]
further work on GPO's, HD44780 GPO support
Diffstat (limited to '')
-rwxr-xr-xconfigure5
-rw-r--r--drivers.m45
-rw-r--r--drv_HD44780.c59
-rw-r--r--drv_LPH7508.c67
-rw-r--r--drv_generic_gpio.c53
-rw-r--r--lcd4linux.conf.sample5
6 files changed, 134 insertions, 60 deletions
diff --git a/configure b/configure
index 896b484..22afbd3 100755
--- a/configure
+++ b/configure
@@ -6226,6 +6226,7 @@ if test "$HD44780" = "yes"; then
TEXT="yes"
PARPORT="yes"
I2C="yes"
+ GPIO="yes"
DRIVERS="$DRIVERS drv_HD44780.o"
cat >>confdefs.h <<\_ACEOF
@@ -6370,8 +6371,8 @@ if test "$SAMPLE" = "yes"; then
# select either text or graphics mode
TEXT="yes"
GRAPHIC="yes"
- # support for GPO's
- GPO="yes"
+ # support for GPIO's
+ GPIO="yes"
# select bus: serial (including USB), parallel or i2c
SERIAL="yes"
PARPORT="yes"
diff --git a/drivers.m4 b/drivers.m4
index c100f45..cdab746 100644
--- a/drivers.m4
+++ b/drivers.m4
@@ -223,6 +223,7 @@ if test "$HD44780" = "yes"; then
TEXT="yes"
PARPORT="yes"
I2C="yes"
+ GPIO="yes"
DRIVERS="$DRIVERS drv_HD44780.o"
AC_DEFINE(WITH_HD44780,1,[HD44780 driver])
fi
@@ -317,8 +318,8 @@ if test "$SAMPLE" = "yes"; then
# select either text or graphics mode
TEXT="yes"
GRAPHIC="yes"
- # support for GPO's
- GPO="yes"
+ # support for GPIO's
+ GPIO="yes"
# select bus: serial (including USB), parallel or i2c
SERIAL="yes"
PARPORT="yes"
diff --git a/drv_HD44780.c b/drv_HD44780.c
index 6d66903..4ad177d 100644
--- a/drv_HD44780.c
+++ b/drv_HD44780.c
@@ -1,4 +1,4 @@
-/* $Id: drv_HD44780.c,v 1.57 2005/12/12 09:08:08 reinelt Exp $
+/* $Id: drv_HD44780.c,v 1.58 2005/12/20 07:07:44 reinelt Exp $
*
* new style driver for HD44780-based displays
*
@@ -32,6 +32,9 @@
*
*
* $Log: drv_HD44780.c,v $
+ * Revision 1.58 2005/12/20 07:07:44 reinelt
+ * further work on GPO's, HD44780 GPO support
+ *
* Revision 1.57 2005/12/12 09:08:08 reinelt
* finally removed old udelay code path; read timing values from config
*
@@ -288,6 +291,7 @@
#include "widget_bar.h"
#include "drv.h"
#include "drv_generic_text.h"
+#include "drv_generic_gpio.h"
#include "drv_generic_parport.h"
#ifdef WITH_I2C
@@ -333,10 +337,8 @@ static unsigned char SIGNAL_GPO;
/* flag for busy-waiting vs. busy flag checking */
static int UseBusy = 0;
-
-/* Fixme: GPO's not yet implemented */
-static int GPOS;
-/* static int GPO=0; */
+/* buffer holding the GPO state */
+static unsigned char GPO = 0;
typedef struct {
@@ -1115,24 +1117,32 @@ static int drv_HD_brightness(int brightness)
}
-/* Fixme: GPO's */
-#if 0
-static void drv_HD_setGPO(const int bits)
+static int drv_HD_GPO(const int num, const int val)
{
- if (Lcd.gpos > 0) {
-
- /* put data on DB1..DB8 */
- drv_generic_parport_data(bits);
-
- /* 74HCT573 set-up time */
- ndelay(20);
-
- /* send data */
- /* 74HCT573 enable pulse width = 24ns */
- drv_generic_parport_toggle(SIGNAL_GPO, 1, 230);
+ int v;
+
+ if (val > 0) {
+ /* set bit */
+ v = 1;
+ GPO |= 1 << num;
+ } else {
+ /* clear bit */
+ v = 0;
+ GPO &= ~(1 << num);
}
+
+ /* put data on DB1..DB8 */
+ drv_generic_parport_data(GPO);
+
+ /* 74HCT573 set-up time */
+ ndelay(20);
+
+ /* send data */
+ /* 74HCT573 enable pulse width = 24ns */
+ drv_generic_parport_toggle(SIGNAL_GPO, 1, 230);
+
+ return v;
}
-#endif
static void drv_HD_LCM162_timer(void __attribute__ ((unused)) * notused)
@@ -1400,6 +1410,7 @@ static void plugin_brightness(RESULT * result, RESULT * arg1)
/* 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) */
/****************************************/
@@ -1436,6 +1447,7 @@ int drv_HD_init(const char *section, const int quiet)
/* real worker functions */
drv_generic_text_real_write = drv_HD_write;
drv_generic_text_real_defchar = drv_HD_defchar;
+ drv_generic_gpio_real_set = drv_HD_GPO;
/* start display */
@@ -1454,6 +1466,12 @@ int drv_HD_init(const char *section, const int quiet)
if ((ret = drv_generic_text_bar_init(0)) != 0)
return ret;
+ /* initialize generic GPIO driver */
+ if (GPOS > 0) {
+ if ((ret = drv_generic_gpio_init(section, Name)) != 0)
+ return ret;
+ }
+
/* add fixed chars to the bar driver */
/* most displays have a full block on ascii 255, but some have kind of */
/* an 'inverted P'. If you specify 'asc255bug 1 in the config, this */
@@ -1497,6 +1515,7 @@ int drv_HD_quit(const int quiet)
info("%s: shutting down.", Name);
drv_generic_text_quit();
+ drv_generic_gpio_quit();
/* clear display */
drv_HD_clear();
diff --git a/drv_LPH7508.c b/drv_LPH7508.c
index cf731d0..b57cdb8 100644
--- a/drv_LPH7508.c
+++ b/drv_LPH7508.c
@@ -1,4 +1,4 @@
-/* $Id: drv_LPH7508.c,v 1.3 2005/12/18 16:18:36 reinelt Exp $
+/* $Id: drv_LPH7508.c,v 1.4 2005/12/20 07:07:44 reinelt Exp $
*
* driver for Pollin LPH7508
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_LPH7508.c,v $
+ * Revision 1.4 2005/12/20 07:07:44 reinelt
+ * further work on GPO's, HD44780 GPO support
+ *
* Revision 1.3 2005/12/18 16:18:36 reinelt
* GPO's added again
*
@@ -243,66 +246,78 @@ static void drv_L7_blit(const int row, const int col, const int height, const in
static int drv_L7_GPO(const int num, const int val)
{
+ int v = 0;
+
switch (num) {
case 0:
/* battery symbol */
- drv_L7_put(32, (val > 0) ? 1 : 0);
+ v = (val > 0) ? 1 : 0;
+ drv_L7_put(32, v);
break;
case 1:
/* battery level */
if (val < 0) {
- drv_L7_put(46, 0);
- drv_L7_put(47, 0);
- drv_L7_put(48, 0);
- drv_L7_put(49, 0);
+ v = 0;
+ drv_L7_put(46, v);
+ drv_L7_put(47, v);
+ drv_L7_put(48, v);
+ drv_L7_put(49, v);
} else {
- drv_L7_put(46, (val & 1) ? 1 : 0);
- drv_L7_put(47, (val & 2) ? 1 : 0);
- drv_L7_put(48, (val & 4) ? 1 : 0);
- drv_L7_put(49, (val & 8) ? 1 : 0);
+ v = val & 0x0f;
+ drv_L7_put(46, (v & 1) ? 1 : 0);
+ drv_L7_put(47, (v & 2) ? 1 : 0);
+ drv_L7_put(48, (v & 4) ? 1 : 0);
+ drv_L7_put(49, (v & 8) ? 1 : 0);
}
break;
case 2:
/* earpiece */
- drv_L7_put(59, (val > 0) ? 1 : 0);
+ v = (val > 0) ? 1 : 0;
+ drv_L7_put(59, v);
break;
case 3:
/* triangle */
- drv_L7_put(69, (val > 0) ? 1 : 0);
+ v = (val > 0) ? 1 : 0;
+ drv_L7_put(69, v);
Buffer1[8 * SCOLS + 69 - 32] = (val > 0);
break;
case 4:
/* head */
- drv_L7_put(83, (val > 0) ? 1 : 0);
+ v = (val > 0) ? 1 : 0;
+ drv_L7_put(83, v);
Buffer1[8 * SCOLS + 83 - 32] = (val > 0);
break;
case 5:
/* message */
- drv_L7_put(98, (val > 0) ? 1 : 0);
+ v = (val > 0) ? 1 : 0;
+ drv_L7_put(98, v);
Buffer1[8 * SCOLS + 98 - 32] = (val > 0);
break;
case 6:
/* antenna */
- drv_L7_put(117, (val > 0) ? 1 : 0);
+ v = (val > 0) ? 1 : 0;
+ drv_L7_put(117, v);
Buffer1[8 * SCOLS + 117 - 32] = (val > 0);
break;
case 7:
/* signal level */
if (val < 0) {
- drv_L7_put(112, 0);
- drv_L7_put(113, 0);
- drv_L7_put(114, 0);
- drv_L7_put(115, 0);
+ v = 0;
+ drv_L7_put(112, v);
+ drv_L7_put(113, v);
+ drv_L7_put(114, v);
+ drv_L7_put(115, v);
} else {
- drv_L7_put(112, (val & 1) ? 1 : 0);
- drv_L7_put(113, (val & 2) ? 1 : 0);
- drv_L7_put(114, (val & 4) ? 1 : 0);
- drv_L7_put(115, (val & 8) ? 1 : 0);
+ v = val & 0x0f;
+ drv_L7_put(112, (v & 1) ? 1 : 0);
+ drv_L7_put(113, (v & 2) ? 1 : 0);
+ drv_L7_put(114, (v & 4) ? 1 : 0);
+ drv_L7_put(115, (v & 8) ? 1 : 0);
}
break;
}
- return 0;
+ return v;
}
@@ -432,9 +447,7 @@ static int drv_L7_start(const char *section)
static void plugin_contrast(RESULT * result, RESULT * arg1)
{
- double contrast;
-
- contrast = drv_L7_contrast(R2N(arg1));
+ double contrast = drv_L7_contrast(R2N(arg1));
SetResult(&result, R_NUMBER, &contrast);
}
diff --git a/drv_generic_gpio.c b/drv_generic_gpio.c
index 4e3a811..c4bf69b 100644
--- a/drv_generic_gpio.c
+++ b/drv_generic_gpio.c
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_gpio.c,v 1.1 2005/12/18 16:18:36 reinelt Exp $
+/* $Id: drv_generic_gpio.c,v 1.2 2005/12/20 07:07:44 reinelt Exp $
*
* generic driver helper for GPO's
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_generic_gpio.c,v $
+ * Revision 1.2 2005/12/20 07:07:44 reinelt
+ * further work on GPO's, HD44780 GPO support
+ *
* Revision 1.1 2005/12/18 16:18:36 reinelt
* GPO's added again
*
@@ -37,8 +40,8 @@
*
* these functions must be implemented by the real driver:
*
- * void (*drv_generic_gpio_real_set) (const int num, const int val);
- * sets GPO num to val
+ * int (*drv_generic_gpio_real_set) (const int num, const int val);
+ * sets GPO num to val, returns the actal value
*
* int (*drv_generic_gpio_real_get) (const int num);
* reads GPI num
@@ -88,6 +91,43 @@ int GPOS = 0;
int GPIS = 0;
+static void drv_generic_gpio_plugin_gpo(RESULT * result, const int argc, RESULT * argv[])
+{
+ int num, val;
+ double gpo;
+
+ switch (argc) {
+ case 1:
+ num = R2N(argv[0]);
+ if (num <= 0 || num > GPOS) {
+ error("%s::GPO(%d): GPO out of range (1..%d)", Driver, num, GPOS);
+ SetResult(&result, R_STRING, "");
+ return;
+ }
+ gpo = GPO[num-1];
+ SetResult(&result, R_NUMBER, &gpo);
+ break;
+ case 2:
+ num = R2N(argv[0]);
+ val = R2N(argv[1]);
+ if (num <= 0 || num > GPOS) {
+ error("%s::GPO(%d): GPO out of range (1..%d)", Driver, num, GPOS);
+ SetResult(&result, R_STRING, "");
+ return;
+ }
+ if (GPO[num-1] != val) {
+ GPO[num-1] = drv_generic_gpio_real_set(num-1, val);
+ }
+ gpo = GPO[num-1];
+ SetResult(&result, R_NUMBER, &gpo);
+ break;
+ default:
+ error("%s::GPO(): wrong number of parameters", Driver);
+ SetResult(&result, R_STRING, "");
+ }
+}
+
+
int drv_generic_gpio_init(const char *section, const char *driver)
{
WIDGET_CLASS wc;
@@ -109,7 +149,7 @@ int drv_generic_gpio_init(const char *section, const char *driver)
/* register plugins */
- /* Fixme */
+ AddFunction("LCD::GPO", -1, drv_generic_gpio_plugin_gpo);
return 0;
}
@@ -126,7 +166,7 @@ int drv_generic_gpio_clear(void)
/* really clear GPO's */
for (i = 0; i < GPOS; i++) {
- drv_generic_gpio_real_set(i, 0);
+ GPO[i] = drv_generic_gpio_real_set(i, 0);
}
return 0;
@@ -145,8 +185,7 @@ int drv_generic_gpio_draw(WIDGET * W)
}
if (GPO[num] != val) {
- drv_generic_gpio_real_set(num, val);
- GPO[num] = val;
+ GPO[num] = drv_generic_gpio_real_set(num, val);
}
return 0;
diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample
index 2b45f1c..c3a508c 100644
--- a/lcd4linux.conf.sample
+++ b/lcd4linux.conf.sample
@@ -95,6 +95,7 @@ Display HD44780-generic {
Port '/dev/parports/0'
Size '8x2'
asc255bug 0
+ GPOs 8
Wire {
RW 'GND'
RS 'AUTOFD'
@@ -863,7 +864,7 @@ Layout testMySQL {
#Display 'LK204'
#Display 'MI240'
#Display 'CW12232'
-#Display 'HD44780-generic'
+Display 'HD44780-generic'
#Display 'HD44780-WinAmp'
#Display 'WDC2704M'
#Display 'SC1602D'
@@ -884,7 +885,7 @@ Layout testMySQL {
#Display 'Image'
#Display 'Trefon'
#Display 'LPH7508-serdisplib'
-Display 'LPH7508'
+#Display 'LPH7508'
#Layout 'Default'
#Layout 'L8x2'