]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2006-01-05 18:56:57 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Thu, 5 Jan 2006 18:56:57 +0000 (18:56 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Thu, 5 Jan 2006 18:56:57 +0000 (18:56 +0000)
more GPO stuff

git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@608 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

drv_Cwlinux.c
drv_HD44780.c
drv_LPH7508.c
drv_M50530.c
drv_MatrixOrbital.c
drv_Sample.c
drv_generic_gpio.c

index cb1fa41b8e298944788e7a5805e0ddf6cf51638d..9df7e727131fefca1dac642931c46b41476e69d2 100644 (file)
@@ -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
  *
 #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();
index 97aae9ad71fddd0523872f7c816ab637c1eaf227..63a1cc7144e95ad43c17a5af776c0bf6408f54b0 100644 (file)
@@ -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;
index 18b2e684c2b2ffb2517e08947ffd62bda8705287..2e9b3f94e367a8445fde9a9d2ad7a02f3eeab1ec 100644 (file)
@@ -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);
index 2a90fac3dfa6aa81e9700fc66d7b7acc34a9299d..3e792c858a11612a28db00cdea00a57e380bdc05 100644 (file)
@@ -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)
  *
 #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();
index f60d163078218ad33da0c11125b3a74be4a9ec80..0a8976cb7642bfe06a97e3933ed5c82c44761eed 100644 (file)
@@ -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();
index 09efd506b1cf4d16de2e6c6d06d65b9b46b2ac5c..813ddd3b64e8246557be34acd375216f6d662ab1 100644 (file)
@@ -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) {
index 26eaa54ad677f9c0437e4f3464565ea124c2f0bc..0bed2d4b059f326a40d05b0d9b1f402e614ea6ca 100644 (file)
@@ -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;
 }