aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreinelt <>2006-01-05 18:56:57 +0000
committerreinelt <>2006-01-05 18:56:57 +0000
commita1dd0dc2cae4fd4d7cc9f760fe14fdd18a62b72e (patch)
tree09ed20cfdf721e57ca25050644eed1c717c2f2e7
parent7c20dbb68758e212366f6ce0c6af114413bc3228 (diff)
downloadlcd4linux-a1dd0dc2cae4fd4d7cc9f760fe14fdd18a62b72e.tar.gz
[lcd4linux @ 2006-01-05 18:56:57 by reinelt]
more GPO stuff
Diffstat (limited to '')
-rw-r--r--drv_Cwlinux.c26
-rw-r--r--drv_HD44780.c17
-rw-r--r--drv_LPH7508.c6
-rw-r--r--drv_M50530.c56
-rw-r--r--drv_MatrixOrbital.c34
-rw-r--r--drv_Sample.c15
-rw-r--r--drv_generic_gpio.c6
7 files changed, 100 insertions, 60 deletions
diff --git a/drv_Cwlinux.c b/drv_Cwlinux.c
index cb1fa41..9df7e72 100644
--- a/drv_Cwlinux.c
+++ b/drv_Cwlinux.c
@@ -1,4 +1,4 @@
-/* $Id: drv_Cwlinux.c,v 1.22 2005/05/08 04:32:44 reinelt Exp $
+/* $Id: drv_Cwlinux.c,v 1.23 2006/01/05 18:56:57 reinelt Exp $
*
* new style driver for Cwlinux display modules
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_Cwlinux.c,v $
+ * Revision 1.23 2006/01/05 18:56:57 reinelt
+ * more GPO stuff
+ *
* Revision 1.22 2005/05/08 04:32:44 reinelt
* CodingStyle added and applied
*
@@ -146,6 +149,7 @@
#include "widget_bar.h"
#include "drv.h"
#include "drv_generic_text.h"
+#include "drv_generic_gpio.h"
#include "drv_generic_serial.h"
@@ -154,11 +158,6 @@ static char Name[] = "Cwlinux";
static int Model;
static int Protocol;
-/* Fixme: GPO's not yet implemented */
-/* static int GPO[8]; */
-static int GPOS;
-
-
typedef struct {
int type;
char *name;
@@ -237,6 +236,14 @@ static void drv_CW12232_defchar(const int ascii, const unsigned char *buffer)
}
+static int drv_CW_GPO(const int num, const int val)
+{
+ /* Fixme: GPO's not yet implemented! */
+ error ("%s: GPO's not yet implemented!", Name);
+ return val;
+}
+
+
static void drv_CW_clear(void)
{
#if 1
@@ -382,6 +389,7 @@ static void plugin_brightness(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) */
/****************************************/
@@ -421,6 +429,7 @@ int drv_CW_init(const char *section, const int quiet)
/* real worker functions */
drv_generic_text_real_write = drv_CW_write;
+ drv_generic_gpio_real_set = drv_CW_GPO;
switch (Protocol) {
case 1:
@@ -455,6 +464,10 @@ int drv_CW_init(const char *section, const int quiet)
/* add fixed chars to the bar driver */
drv_generic_text_bar_add_segment(0, 0, 255, 32); /* ASCII 32 = blank */
+ /* 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;
@@ -483,6 +496,7 @@ int drv_CW_quit(const int quiet)
info("%s: shutting down.", Name);
drv_generic_text_quit();
+ drv_generic_gpio_quit();
/* clear display */
drv_CW_clear();
diff --git a/drv_HD44780.c b/drv_HD44780.c
index 97aae9a..63a1cc7 100644
--- a/drv_HD44780.c
+++ b/drv_HD44780.c
@@ -1,4 +1,4 @@
-/* $Id: drv_HD44780.c,v 1.59 2006/01/03 06:13:44 reinelt Exp $
+/* $Id: drv_HD44780.c,v 1.60 2006/01/05 18:56:57 reinelt Exp $
*
* new style driver for HD44780-based displays
*
@@ -32,6 +32,9 @@
*
*
* $Log: drv_HD44780.c,v $
+ * Revision 1.60 2006/01/05 18:56:57 reinelt
+ * more GPO stuff
+ *
* Revision 1.59 2006/01/03 06:13:44 reinelt
* GPIO's for MatrixOrbital
*
@@ -1324,7 +1327,7 @@ static int drv_HD_start(const char *section, const int quiet)
gpos = 0;
}
GPOS = gpos;
- if (gpos > 0) {
+ if (GPOS > 0) {
info("%s: using %d GPO's", Name, GPOS);
}
@@ -1469,12 +1472,6 @@ 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 */
@@ -1484,6 +1481,10 @@ int drv_HD_init(const char *section, const int quiet)
if (!asc255bug)
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;
diff --git a/drv_LPH7508.c b/drv_LPH7508.c
index 18b2e68..2e9b3f9 100644
--- a/drv_LPH7508.c
+++ b/drv_LPH7508.c
@@ -1,4 +1,4 @@
-/* $Id: drv_LPH7508.c,v 1.5 2006/01/03 06:13:45 reinelt Exp $
+/* $Id: drv_LPH7508.c,v 1.6 2006/01/05 18:56:57 reinelt Exp $
*
* driver for Pollin LPH7508
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_LPH7508.c,v $
+ * Revision 1.6 2006/01/05 18:56:57 reinelt
+ * more GPO stuff
+ *
* Revision 1.5 2006/01/03 06:13:45 reinelt
* GPIO's for MatrixOrbital
*
@@ -540,7 +543,6 @@ int drv_L7_quit(const int quiet)
info("%s: shutting down display.", Name);
drv_generic_graphic_clear();
- drv_generic_gpio_clear();
if (!quiet) {
drv_generic_graphic_greet("goodbye!", NULL);
diff --git a/drv_M50530.c b/drv_M50530.c
index 2a90fac..3e792c8 100644
--- a/drv_M50530.c
+++ b/drv_M50530.c
@@ -1,4 +1,4 @@
-/* $Id: drv_M50530.c,v 1.19 2005/06/09 17:41:47 reinelt Exp $
+/* $Id: drv_M50530.c,v 1.20 2006/01/05 18:56:57 reinelt Exp $
*
* new style driver for M50530-based displays
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_M50530.c,v $
+ * Revision 1.20 2006/01/05 18:56:57 reinelt
+ * more GPO stuff
+ *
* Revision 1.19 2005/06/09 17:41:47 reinelt
* M50530 fixes (many thanks to Szymon Bieganski)
*
@@ -136,6 +139,7 @@
#include "widget_bar.h"
#include "drv.h"
#include "drv_generic_text.h"
+#include "drv_generic_gpio.h"
#include "drv_generic_parport.h"
static char Name[] = "M50530";
@@ -151,9 +155,8 @@ static int FONT5X11;
static int DDRAM;
static int DUTY;
-/* 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 {
@@ -234,24 +237,32 @@ static void drv_M5_defchar(const int ascii, const unsigned char *matrix)
}
-/* Fixme: GPO's */
-#if 0
-static void drv_M5_setGPO(const int bits)
+static int drv_M5_GPO(const int num, const int val)
{
- if (Lcd.gpos > 0) {
+ int v;
- /* put data on DB1..DB8 */
- drv_generic_parport_data(bits);
+ if (val > 0) {
+ /* set bit */
+ v = 1;
+ GPO |= 1 << num;
+ } else {
+ /* clear bit */
+ v = 0;
+ GPO &= ~(1 << num);
+ }
- /* 74HCT573 set-up time */
- ndelay(20);
+ /* put data on DB1..DB8 */
+ drv_generic_parport_data(GPO);
- /* send data */
- /* 74HCT573 enable pulse width = 24ns */
- drv_generic_parport_toggle(SIGNAL_GPO, 1, 24);
- }
+ /* 74HCT573 set-up time */
+ ndelay(20);
+
+ /* send data */
+ /* 74HCT573 enable pulse width = 24ns */
+ drv_generic_parport_toggle(SIGNAL_GPO, 1, 24);
+
+ return v;
}
-#endif
static int drv_M5_start(const char *section, const int quiet)
@@ -345,7 +356,9 @@ static int drv_M5_start(const char *section, const int quiet)
if (cfg_number(section, "GPOs", 0, 0, 8, &n) < 0)
return -1;
GPOS = n;
- info("%s: controlling %d GPO's", Name, GPOS);
+ if (GPOS > 0) {
+ info("%s: controlling %d GPO's", Name, GPOS);
+ }
if (drv_generic_parport_open(section, Name) != 0) {
error("%s: could not initialize parallel port!", Name);
@@ -491,6 +504,7 @@ static int drv_M5_start(const char *section, const int quiet)
/* 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) */
/****************************************/
@@ -526,6 +540,7 @@ int drv_M5_init(const char *section, const int quiet)
/* real worker functions */
drv_generic_text_real_write = drv_M5_write;
drv_generic_text_real_defchar = drv_M5_defchar;
+ drv_generic_gpio_real_set = drv_M5_GPO;
/* start display */
@@ -547,6 +562,10 @@ int drv_M5_init(const char *section, const int quiet)
/* add fixed chars to the bar driver */
drv_generic_text_bar_add_segment(0, 0, 255, 32); /* ASCII 32 = blank */
+ /* 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;
@@ -576,6 +595,7 @@ int drv_M5_quit(const int quiet)
info("%s: shutting down.", Name);
drv_generic_text_quit();
+ drv_generic_gpio_quit();
/* clear display */
drv_M5_clear();
diff --git a/drv_MatrixOrbital.c b/drv_MatrixOrbital.c
index f60d163..0a8976c 100644
--- a/drv_MatrixOrbital.c
+++ b/drv_MatrixOrbital.c
@@ -1,4 +1,4 @@
-/* $Id: drv_MatrixOrbital.c,v 1.40 2006/01/03 06:13:45 reinelt Exp $
+/* $Id: drv_MatrixOrbital.c,v 1.41 2006/01/05 18:56:57 reinelt Exp $
*
* new style driver for Matrix Orbital serial display modules
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_MatrixOrbital.c,v $
+ * Revision 1.41 2006/01/05 18:56:57 reinelt
+ * more GPO stuff
+ *
* Revision 1.40 2006/01/03 06:13:45 reinelt
* GPIO's for MatrixOrbital
*
@@ -372,7 +375,7 @@ static int drv_MO_GPI(const int num)
if (num < 0 || num > 7) {
return 0;
}
-
+
/* read RPM every two seconds */
if (time(&now) - T[num] >= 2) {
@@ -380,19 +383,18 @@ static int drv_MO_GPI(const int num)
unsigned char ans[7];
T[num] = now;
-
+
cmd[0] = '\376';
cmd[1] = '\301';
- cmd[2] = (char) num+1;
+ cmd[2] = (char) num + 1;
drv_generic_serial_write(cmd, 3);
usleep(100000);
- if (drv_generic_serial_read((char*)ans, 7) == 7) {
- if (ans[0] == 0x23 && ans[1] == 0x2a && ans[2] == 0x03 && ans[3] == 0x52 && ans[4] == num+1) {
- GPI[num] = 18750000 / (256*ans[5]+ans[6]);
+ if (drv_generic_serial_read((char *) ans, 7) == 7) {
+ if (ans[0] == 0x23 && ans[1] == 0x2a && ans[2] == 0x03 && ans[3] == 0x52 && ans[4] == num + 1) {
+ GPI[num] = 18750000 / (256 * ans[5] + ans[6]);
} else {
- error ("%s: strange answer %02x %02x %02x %02x %02x %02x %02x",
- Name, ans[0], ans[1], ans[2], ans[3], ans[4], ans[5], ans[6]);
+ error("%s: strange answer %02x %02x %02x %02x %02x %02x %02x", Name, ans[0], ans[1], ans[2], ans[3], ans[4], ans[5], ans[6]);
}
}
}
@@ -665,10 +667,8 @@ int drv_MO_init(const char *section, const int quiet)
drv_generic_text_bar_add_segment(255, 255, 255, 255); /* ASCII 255 = block */
/* initialize generic GPIO driver */
- if (GPIS > 0 || GPOS > 0) {
- if ((ret = drv_generic_gpio_init(section, Name)) != 0)
- return ret;
- }
+ if ((ret = drv_generic_gpio_init(section, Name)) != 0)
+ return ret;
/* register text widget */
wc = Widget_Text;
@@ -688,7 +688,7 @@ int drv_MO_init(const char *section, const int quiet)
/* register plugins */
AddFunction("LCD::contrast", -1, plugin_contrast);
AddFunction("LCD::backlight", -1, plugin_backlight);
-
+
return 0;
}
@@ -700,11 +700,7 @@ int drv_MO_quit(const int quiet)
info("%s: shutting down display.", Name);
drv_generic_text_quit();
- drv_generic_gpio_clear();
-
- if (GPIS > 0 || GPOS > 0) {
- drv_generic_gpio_quit();
- }
+ drv_generic_gpio_quit();
/* clear display */
drv_MO_clear();
diff --git a/drv_Sample.c b/drv_Sample.c
index 09efd50..813ddd3 100644
--- a/drv_Sample.c
+++ b/drv_Sample.c
@@ -1,4 +1,4 @@
-/* $Id: drv_Sample.c,v 1.2 2005/12/19 05:08:31 reinelt Exp $
+/* $Id: drv_Sample.c,v 1.3 2006/01/05 18:56:57 reinelt Exp $
*
* sample lcd4linux driver
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_Sample.c,v $
+ * Revision 1.3 2006/01/05 18:56:57 reinelt
+ * more GPO stuff
+ *
* Revision 1.2 2005/12/19 05:08:31 reinelt
* GPO's added to the Sample driver
*
@@ -243,7 +246,7 @@ static void drv_Sample_blit(const int row, const int col, const int height, cons
static int drv_Sample_GPO(const int num, const int val)
{
char cmd[4];
-
+
/* assume 0x42 to be the 'GPO' command */
cmd[0] = 0x42;
cmd[1] = num;
@@ -559,12 +562,12 @@ int drv_Sample_quit(const int quiet)
drv_generic_text_quit();
+ /* remove unless you have GPO's */
+ drv_generic_gpio_quit();
+
/* clear display */
drv_Sample_clear();
- /* remove unless you have GPO's */
- drv_generic_gpio_clear();
-
/* say goodbye... */
if (!quiet) {
drv_generic_text_greet("goodbye!", NULL);
@@ -587,7 +590,7 @@ int drv_Sample_quit2(const int quiet)
drv_generic_graphic_clear();
/* remove unless you have GPO's */
- drv_generic_gpio_clear();
+ drv_generic_gpio_quit();
/* say goodbye... */
if (!quiet) {
diff --git a/drv_generic_gpio.c b/drv_generic_gpio.c
index 26eaa54..0bed2d4 100644
--- a/drv_generic_gpio.c
+++ b/drv_generic_gpio.c
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_gpio.c,v 1.3 2006/01/03 06:13:45 reinelt Exp $
+/* $Id: drv_generic_gpio.c,v 1.4 2006/01/05 18:56:57 reinelt Exp $
*
* generic driver helper for GPO's
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_generic_gpio.c,v $
+ * Revision 1.4 2006/01/05 18:56:57 reinelt
+ * more GPO stuff
+ *
* Revision 1.3 2006/01/03 06:13:45 reinelt
* GPIO's for MatrixOrbital
*
@@ -249,5 +252,6 @@ int drv_generic_gpio_draw(WIDGET * W)
int drv_generic_gpio_quit(void)
{
info("%s: shutting down GPIO driver.", Driver);
+ drv_generic_gpio_clear();
return 0;
}