aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drv_HD44780.c15
-rw-r--r--drv_LPH7508.c9
-rw-r--r--drv_MatrixOrbital.c279
-rw-r--r--drv_generic_gpio.c85
-rw-r--r--drv_generic_gpio.h10
-rw-r--r--drv_generic_graphic.c21
-rw-r--r--drv_generic_graphic.h7
-rw-r--r--drv_generic_text.c37
-rw-r--r--drv_generic_text.h9
-rw-r--r--lcd4linux.conf.sample70
10 files changed, 314 insertions, 228 deletions
diff --git a/drv_HD44780.c b/drv_HD44780.c
index 4ad177d..97aae9a 100644
--- a/drv_HD44780.c
+++ b/drv_HD44780.c
@@ -1,4 +1,4 @@
-/* $Id: drv_HD44780.c,v 1.58 2005/12/20 07:07:44 reinelt Exp $
+/* $Id: drv_HD44780.c,v 1.59 2006/01/03 06:13:44 reinelt Exp $
*
* new style driver for HD44780-based displays
*
@@ -32,6 +32,9 @@
*
*
* $Log: drv_HD44780.c,v $
+ * Revision 1.59 2006/01/03 06:13:44 reinelt
+ * GPIO's for MatrixOrbital
+ *
* Revision 1.58 2005/12/20 07:07:44 reinelt
* further work on GPO's, HD44780 GPO support
*
@@ -1120,7 +1123,7 @@ static int drv_HD_brightness(int brightness)
static int drv_HD_GPO(const int num, const int val)
{
int v;
-
+
if (val > 0) {
/* set bit */
v = 1;
@@ -1133,10 +1136,10 @@ static int drv_HD_GPO(const int num, const int val)
/* 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);
@@ -1471,7 +1474,7 @@ int drv_HD_init(const char *section, const int quiet)
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 */
@@ -1512,7 +1515,7 @@ int drv_HD_init(const char *section, const int quiet)
int drv_HD_quit(const int quiet)
{
- info("%s: shutting down.", Name);
+ info("%s: shutting down display.", Name);
drv_generic_text_quit();
drv_generic_gpio_quit();
diff --git a/drv_LPH7508.c b/drv_LPH7508.c
index b57cdb8..18b2e68 100644
--- a/drv_LPH7508.c
+++ b/drv_LPH7508.c
@@ -1,4 +1,4 @@
-/* $Id: drv_LPH7508.c,v 1.4 2005/12/20 07:07:44 reinelt Exp $
+/* $Id: drv_LPH7508.c,v 1.5 2006/01/03 06:13:45 reinelt Exp $
*
* driver for Pollin LPH7508
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_LPH7508.c,v $
+ * Revision 1.5 2006/01/03 06:13:45 reinelt
+ * GPIO's for MatrixOrbital
+ *
* Revision 1.4 2005/12/20 07:07:44 reinelt
* further work on GPO's, HD44780 GPO support
*
@@ -247,7 +250,7 @@ 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 */
@@ -534,7 +537,7 @@ int drv_L7_init(const char *section, const int quiet)
int drv_L7_quit(const int quiet)
{
- info("%s: shutting down.", Name);
+ info("%s: shutting down display.", Name);
drv_generic_graphic_clear();
drv_generic_gpio_clear();
diff --git a/drv_MatrixOrbital.c b/drv_MatrixOrbital.c
index 8ea5b24..f60d163 100644
--- a/drv_MatrixOrbital.c
+++ b/drv_MatrixOrbital.c
@@ -1,4 +1,4 @@
-/* $Id: drv_MatrixOrbital.c,v 1.39 2005/05/08 04:32:44 reinelt Exp $
+/* $Id: drv_MatrixOrbital.c,v 1.40 2006/01/03 06:13:45 reinelt Exp $
*
* new style driver for Matrix Orbital serial display modules
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_MatrixOrbital.c,v $
+ * Revision 1.40 2006/01/03 06:13:45 reinelt
+ * GPIO's for MatrixOrbital
+ *
* Revision 1.39 2005/05/08 04:32:44 reinelt
* CodingStyle added and applied
*
@@ -203,6 +206,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include <time.h>
#include "debug.h"
#include "cfg.h"
@@ -213,6 +217,7 @@
#include "widget_bar.h"
#include "drv.h"
#include "drv_generic_text.h"
+#include "drv_generic_gpio.h"
#include "drv_generic_serial.h"
@@ -221,16 +226,12 @@ static char Name[] = "MatrixOrbital";
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;
int rows;
int cols;
+ int gpis;
int gpos;
int protocol;
} MODEL;
@@ -239,32 +240,33 @@ typedef struct {
/* Fixme #2: protocol should be verified */
static MODEL Models[] = {
- {0x01, "LCD0821", 2, 8, 0, 1},
- {0x03, "LCD2021", 2, 20, 0, 1},
- {0x04, "LCD1641", 4, 16, 0, 1},
- {0x05, "LCD2041", 4, 20, 0, 1},
- {0x06, "LCD4021", 2, 40, 0, 1},
- {0x07, "LCD4041", 4, 40, 0, 1},
- {0x08, "LK202-25", 2, 20, 0, 2},
- {0x09, "LK204-25", 4, 20, 0, 2},
- {0x0a, "LK404-55", 4, 40, 0, 2},
- {0x0b, "VFD2021", 2, 20, 0, 1},
- {0x0c, "VFD2041", 4, 20, 0, 1},
- {0x0d, "VFD4021", 2, 40, 0, 1},
- {0x0e, "VK202-25", 2, 20, 0, 1},
- {0x0f, "VK204-25", 4, 20, 0, 1},
- {0x10, "GLC12232", -1, -1, 0, 1},
- {0x13, "GLC24064", -1, -1, 0, 1},
- {0x15, "GLK24064-25", -1, -1, 0, 1},
- {0x22, "GLK12232-25", -1, -1, 0, 1},
- {0x31, "LK404-AT", 4, 40, 0, 2},
- {0x32, "VFD1621", 2, 16, 0, 1},
- {0x33, "LK402-12", 2, 40, 0, 2},
- {0x34, "LK162-12", 2, 16, 0, 2},
- {0x35, "LK204-25PC", 4, 20, 0, 2},
- {0x36, "LK202-24-USB", 2, 20, 0, 2},
- {0x38, "LK204-24-USB", 4, 20, 0, 2},
- {0xff, "Unknown", -1, -1, 0, 0}
+ {0x01, "LCD0821", 2, 8, 0, 1, 1},
+ {0x03, "LCD2021", 2, 20, 0, 1, 1},
+ {0x04, "LCD1641", 4, 16, 0, 1, 1},
+ {0x05, "LCD2041", 4, 20, 0, 1, 1},
+ {0x06, "LCD4021", 2, 40, 0, 1, 1},
+ {0x07, "LCD4041", 4, 40, 0, 1, 1},
+ {0x08, "LK202-25", 2, 20, 8, 8, 2},
+ {0x09, "LK204-25", 4, 20, 8, 8, 2},
+ {0x0a, "LK404-55", 4, 40, 8, 8, 2},
+ {0x0b, "VFD2021", 2, 20, 0, 1, 1},
+ {0x0c, "VFD2041", 4, 20, 0, 1, 1},
+ {0x0d, "VFD4021", 2, 40, 0, 1, 1},
+ {0x0e, "VK202-25", 2, 20, 0, 1, 1},
+ {0x0f, "VK204-25", 4, 20, 0, 1, 1},
+ {0x10, "GLC12232", -1, -1, 0, 1, 1},
+ {0x13, "GLC24064", -1, -1, 0, 1, 1},
+ {0x15, "GLK24064-25", -1, -1, 0, 1, 1},
+ {0x22, "GLK12232-25", -1, -1, 0, 1, 1},
+ {0x31, "LK404-AT", 4, 40, 8, 8, 2},
+ {0x32, "VFD1621", 2, 16, 0, 1, 1},
+ {0x33, "LK402-12", 2, 40, 8, 8, 2},
+ {0x34, "LK162-12", 2, 16, 8, 8, 2},
+ {0x35, "LK204-25PC", 4, 20, 8, 8, 2},
+ {0x36, "LK202-24-USB", 2, 20, 8, 8, 2},
+ {0x38, "LK204-24-USB", 4, 20, 8, 8, 2},
+ {0x39, "VK204-24-USB", 4, 20, 8, 8, 2},
+ {0xff, "Unknown", -1, -1, 0, 0, 0}
};
@@ -361,111 +363,87 @@ static int drv_MO_backlight(int backlight)
}
-static int drv_MO_gpo(int num, int val)
+static int drv_MO_GPI(const int num)
{
- static int GPO[6] = { -1, -1, -1, -1, -1, -1 };
- char cmd[3] = "\376";
+ static int GPI[8] = { -1, -1, -1, -1, -1, -1, -1, -1 };
+ static time_t T[8], now;
+
+
+ if (num < 0 || num > 7) {
+ return 0;
+ }
+
+ /* read RPM every two seconds */
+ if (time(&now) - T[num] >= 2) {
+
+ char cmd[3];
+ unsigned char ans[7];
+
+ T[num] = now;
+
+ cmd[0] = '\376';
+ cmd[1] = '\301';
+ 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]);
+ } 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]);
+ }
+ }
+ }
- if (num < 1)
- num = 1;
- if (num > 6)
- num = 6;
+ return GPI[num];
+}
- /* -1 is used to query the current GPO */
- if (val == -1)
- return GPO[num - 1];
- if (val < 0)
- val = 0;
- if (val > 1)
- val = 1;
- GPO[num - 1] = val;
+static int drv_MO_GPO(const int num, const int val)
+{
+ int v = 0;
+ char cmd[4];
switch (Protocol) {
case 1:
- if (num == 1) {
+ if (num == 0) {
if (val > 0) {
+ v = 1;
drv_generic_serial_write("\376W", 2); /* GPO on */
} else {
+ v = 0;
drv_generic_serial_write("\376V", 2); /* GPO off */
}
- } else {
- GPO[num - 1] = -1;
}
break;
case 2:
- if (val > 0) {
+ if (val <= 0) {
+ v = 0;
+ cmd[0] = '\376';
+ cmd[1] = 'V'; /* GPO off */
+ cmd[2] = (char) num + 1;
+ drv_generic_serial_write(cmd, 3);
+ } else if (val >= 255) {
+ v = 255;
+ cmd[0] = '\376';
cmd[1] = 'W'; /* GPO on */
+ cmd[2] = (char) num + 1;
+ drv_generic_serial_write(cmd, 3);
} else {
- cmd[1] = 'V'; /* GPO off */
+ v = val;
+ cmd[0] = '\376';
+ cmd[1] = '\300'; /* PWM control */
+ cmd[2] = (char) num + 1;
+ cmd[3] = (char) v;
+ drv_generic_serial_write(cmd, 4);
}
- cmd[2] = (char) num;
- drv_generic_serial_write(cmd, 3);
break;
}
- return GPO[num - 1];
-}
-
-
-static int drv_MO_pwm(int num, int val)
-{
- static int PWM[6] = { -1, -1, -1, -1, -1, -1 };
- char cmd[4] = "\376\300";
-
- if (num < 1)
- num = 1;
- if (num > 6)
- num = 6;
-
- /* -1 is used to query the current PWM */
- if (val == -1)
- return PWM[num - 1];
-
- if (val < 0)
- val = 0;
- if (val > 255)
- val = 255;
- PWM[num - 1] = val;
-
- cmd[2] = (char) num;
- cmd[3] = (char) val;
- drv_generic_serial_write(cmd, 4);
-
- return val;
-}
-
-
-static int drv_MO_rpm(int num)
-{
- static int RPM[6] = { -1, -1, -1, -1, -1, -1 };
- char cmd[3] = "\376\301";
- char buffer[7];
-
- if (num < 1)
- num = 1;
- if (num > 6)
- num = 6;
-
- cmd[2] = (char) num;
- drv_generic_serial_write(cmd, 3);
-
- usleep(100000);
- drv_generic_serial_read(buffer, 7);
-
- debug("rpm: buffer[0]=0x%01x", buffer[0]);
- debug("rpm: buffer[1]=0x%01x", buffer[1]);
- debug("rpm: buffer[2]=0x%01x", buffer[2]);
- debug("rpm: buffer[3]=0x%01x", buffer[3]);
- debug("rpm: buffer[4]=0x%01x", buffer[4]);
- debug("rpm: buffer[5]=0x%01x", buffer[5]);
- debug("rpm: buffer[6]=0x%01x", buffer[6]);
-
- /* Fixme: RPM calculations??? */
- RPM[num - 1] = 42;
-
- return RPM[num - 1];
+ return v;
}
@@ -525,6 +503,7 @@ static int drv_MO_start(const char *section, const int quiet)
/* initialize global variables */
DROWS = Models[Model].rows;
DCOLS = Models[Model].cols;
+ GPIS = Models[Model].gpis;
GPOS = Models[Model].gpos;
Protocol = Models[Model].protocol;
@@ -618,55 +597,6 @@ static void plugin_backlight(RESULT * result, const int argc, RESULT * argv[])
}
-static void plugin_gpo(RESULT * result, const int argc, RESULT * argv[])
-{
- double gpo;
-
- switch (argc) {
- case 1:
- gpo = drv_MO_gpo(R2N(argv[0]), -1);
- SetResult(&result, R_NUMBER, &gpo);
- break;
- case 2:
- gpo = drv_MO_gpo(R2N(argv[0]), R2N(argv[1]));
- SetResult(&result, R_NUMBER, &gpo);
- break;
- default:
- error("%s:gpo(): wrong number of parameters", Name);
- SetResult(&result, R_STRING, "");
- }
-}
-
-
-static void plugin_pwm(RESULT * result, const int argc, RESULT * argv[])
-{
- double pwm;
-
- switch (argc) {
- case 1:
- pwm = drv_MO_pwm(R2N(argv[0]), -1);
- SetResult(&result, R_NUMBER, &pwm);
- break;
- case 2:
- pwm = drv_MO_pwm(R2N(argv[0]), R2N(argv[1]));
- SetResult(&result, R_NUMBER, &pwm);
- break;
- default:
- error("%s:pwm(): wrong number of parameters", Name);
- SetResult(&result, R_STRING, "");
- }
-}
-
-
-static void plugin_rpm(RESULT * result, RESULT * arg1)
-{
- double rpm;
-
- rpm = drv_MO_rpm(R2N(arg1));
- SetResult(&result, R_NUMBER, &rpm);
-}
-
-
/****************************************/
/*** widget callbacks ***/
/****************************************/
@@ -674,6 +604,7 @@ static void plugin_rpm(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) */
/****************************************/
@@ -709,6 +640,8 @@ int drv_MO_init(const char *section, const int quiet)
/* real worker functions */
drv_generic_text_real_write = drv_MO_write;
drv_generic_text_real_defchar = drv_MO_defchar;
+ drv_generic_gpio_real_get = drv_MO_GPI;
+ drv_generic_gpio_real_set = drv_MO_GPO;
/* start display */
@@ -731,6 +664,12 @@ int drv_MO_init(const char *section, const int quiet)
drv_generic_text_bar_add_segment(0, 0, 255, 32); /* ASCII 32 = blank */
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;
+ }
+
/* register text widget */
wc = Widget_Text;
wc.draw = drv_generic_text_draw;
@@ -749,10 +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);
- AddFunction("LCD::gpo", -1, plugin_gpo);
- AddFunction("LCD::pwm", -1, plugin_pwm);
- AddFunction("LCD::rpm", 1, plugin_rpm);
-
+
return 0;
}
@@ -761,9 +697,14 @@ int drv_MO_init(const char *section, const int quiet)
int drv_MO_quit(const int quiet)
{
- info("%s: shutting down.", Name);
+ info("%s: shutting down display.", Name);
drv_generic_text_quit();
+ drv_generic_gpio_clear();
+
+ if (GPIS > 0 || GPOS > 0) {
+ drv_generic_gpio_quit();
+ }
/* clear display */
drv_MO_clear();
diff --git a/drv_generic_gpio.c b/drv_generic_gpio.c
index c4bf69b..26eaa54 100644
--- a/drv_generic_gpio.c
+++ b/drv_generic_gpio.c
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_gpio.c,v 1.2 2005/12/20 07:07:44 reinelt Exp $
+/* $Id: drv_generic_gpio.c,v 1.3 2006/01/03 06:13:45 reinelt Exp $
*
* generic driver helper for GPO's
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_generic_gpio.c,v $
+ * Revision 1.3 2006/01/03 06:13:45 reinelt
+ * GPIO's for MatrixOrbital
+ *
* Revision 1.2 2005/12/20 07:07:44 reinelt
* further work on GPO's, HD44780 GPO support
*
@@ -49,17 +52,20 @@
*
* exported fuctions:
*
- * int drv_generic_gpio_init(const char *section, const char *driver);
+ * int drv_generic_gpio_init(const char *section, const char *driver)
* initializes the generic GPIO driver
*
* int drv_generic_gpio_clear(void);
* resets all GPO's
*
- * int drv_generic_gpio_draw(WIDGET * W);
+ * int drv_generic_gpio_get (const int num)
+ * returns value og GPI #num
+ *
+ * int drv_generic_gpio_draw(WIDGET * W)
* 'draws' GPO widget
* calls drv_generic_gpio_real_set()
*
- * int drv_generic_gpio_quit(void);
+ * int drv_generic_gpio_quit(void)
* closes the generic GPIO driver
*
*/
@@ -79,17 +85,40 @@
#include <dmalloc.h>
#endif
+#define MAX_GPIS 32
#define MAX_GPOS 32
static char *Section = NULL;
static char *Driver = NULL;
+static int GPI[MAX_GPIS];
static int GPO[MAX_GPOS];
int GPOS = 0;
int GPIS = 0;
+int (*drv_generic_gpio_real_set) () = NULL;
+int (*drv_generic_gpio_real_get) () = NULL;
+
+
+static void drv_generic_gpio_plugin_gpi(RESULT * result, RESULT * arg1)
+{
+ int num;
+ double val;
+
+ num = R2N(arg1);
+
+ if (num <= 0 || num > GPIS) {
+ error("%s::GPI(%d): GPI out of range (1..%d)", Driver, num, GPIS);
+ SetResult(&result, R_STRING, "");
+ return;
+ }
+
+ val = drv_generic_gpio_get(num - 1);
+ SetResult(&result, R_NUMBER, &val);
+}
+
static void drv_generic_gpio_plugin_gpo(RESULT * result, const int argc, RESULT * argv[])
{
@@ -104,7 +133,7 @@ static void drv_generic_gpio_plugin_gpo(RESULT * result, const int argc, RESULT
SetResult(&result, R_STRING, "");
return;
}
- gpo = GPO[num-1];
+ gpo = GPO[num - 1];
SetResult(&result, R_NUMBER, &gpo);
break;
case 2:
@@ -115,10 +144,11 @@ static void drv_generic_gpio_plugin_gpo(RESULT * result, const int argc, RESULT
SetResult(&result, R_STRING, "");
return;
}
- if (GPO[num-1] != val) {
- GPO[num-1] = drv_generic_gpio_real_set(num-1, val);
+ if (GPO[num - 1] != val) {
+ if (drv_generic_gpio_real_set)
+ GPO[num - 1] = drv_generic_gpio_real_set(num - 1, val);
}
- gpo = GPO[num-1];
+ gpo = GPO[num - 1];
SetResult(&result, R_NUMBER, &gpo);
break;
default:
@@ -135,9 +165,7 @@ int drv_generic_gpio_init(const char *section, const char *driver)
Section = (char *) section;
Driver = (char *) driver;
- if (GPIS <= 0 && GPOS <= 0) {
- error("%s: Huh? gpio_init(GPIS=%d, GPOS=%d)", Driver, GPIS, GPOS);
- }
+ info("%s: using %d GPI's and %d GPO's", Driver, GPIS, GPOS);
/* reset all GPO's */
drv_generic_gpio_clear();
@@ -147,8 +175,8 @@ int drv_generic_gpio_init(const char *section, const char *driver)
wc.draw = drv_generic_gpio_draw;
widget_register(&wc);
-
/* register plugins */
+ AddFunction("LCD::GPI", 1, drv_generic_gpio_plugin_gpi);
AddFunction("LCD::GPO", -1, drv_generic_gpio_plugin_gpo);
return 0;
@@ -159,20 +187,45 @@ int drv_generic_gpio_clear(void)
{
int i;
- /* init GPO bufferr */
+ /* clear GPI buffer */
+ for (i = 0; i < MAX_GPIS; i++) {
+ GPI[i] = 0;
+ }
+
+ /* clear GPO buffer */
for (i = 0; i < MAX_GPOS; i++) {
GPO[i] = 0;
}
/* really clear GPO's */
for (i = 0; i < GPOS; i++) {
- GPO[i] = drv_generic_gpio_real_set(i, 0);
+ if (drv_generic_gpio_real_set)
+ GPO[i] = drv_generic_gpio_real_set(i, 0);
+
}
return 0;
}
+int drv_generic_gpio_get(const int num)
+{
+ int val = 0;
+
+ if (num < 0 || num >= GPIS) {
+ error("%s: gpio_get(%d): GPI out of range (0..%d)", Driver, num + 1, GPIS);
+ return -1;
+ }
+
+ if (drv_generic_gpio_real_get)
+ val = drv_generic_gpio_real_get(num);
+
+ GPI[num] = val;
+
+ return val;
+}
+
+
int drv_generic_gpio_draw(WIDGET * W)
{
WIDGET_GPO *gpo = W->data;
@@ -185,7 +238,8 @@ int drv_generic_gpio_draw(WIDGET * W)
}
if (GPO[num] != val) {
- GPO[num] = drv_generic_gpio_real_set(num, val);
+ if (drv_generic_gpio_real_set)
+ GPO[num] = drv_generic_gpio_real_set(num, val);
}
return 0;
@@ -194,5 +248,6 @@ int drv_generic_gpio_draw(WIDGET * W)
int drv_generic_gpio_quit(void)
{
+ info("%s: shutting down GPIO driver.", Driver);
return 0;
}
diff --git a/drv_generic_gpio.h b/drv_generic_gpio.h
index 114e049..35457db 100644
--- a/drv_generic_gpio.h
+++ b/drv_generic_gpio.h
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_gpio.h,v 1.1 2005/12/18 16:18:36 reinelt Exp $
+/* $Id: drv_generic_gpio.h,v 1.2 2006/01/03 06:13:45 reinelt Exp $
*
* generic driver helper for GPIO's
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_generic_gpio.h,v $
+ * Revision 1.2 2006/01/03 06:13:45 reinelt
+ * GPIO's for MatrixOrbital
+ *
* Revision 1.1 2005/12/18 16:18:36 reinelt
* GPO's added again
*
@@ -38,12 +41,13 @@ extern int GPIS; /* number of GPO's */
extern int GPOS; /* number of GPO's */
/* these function must be implemented by the real driver */
-int (*drv_generic_gpio_real_set) (const int num, const int val);
-int (*drv_generic_gpio_real_get) (const int num);
+extern int (*drv_generic_gpio_real_set) (const int num, const int val);
+extern int (*drv_generic_gpio_real_get) (const int num);
/* generic functions and widget callbacks */
int drv_generic_gpio_init(const char *section, const char *driver);
int drv_generic_gpio_clear(void);
+int drv_generic_gpio_get(const int num);
int drv_generic_gpio_draw(WIDGET * W);
int drv_generic_gpio_quit(void);
diff --git a/drv_generic_graphic.c b/drv_generic_graphic.c
index cd38435..e88da34 100644
--- a/drv_generic_graphic.c
+++ b/drv_generic_graphic.c
@@ -23,6 +23,9 @@
*
*
* $Log: drv_generic_graphic.c,v $
+ * Revision 1.17 2006/01/03 06:13:46 reinelt
+ * GPIO's for MatrixOrbital
+ *
* Revision 1.16 2005/12/13 14:07:28 reinelt
* LPH7508 driver finished
*
@@ -152,6 +155,7 @@ int XRES, YRES; /* pixels of one char cell */
unsigned char *drv_generic_graphic_FB = NULL;
+void (*drv_generic_graphic_real_blit) () = NULL;
/****************************************/
/*** generic Framebuffer stuff ***/
@@ -195,7 +199,9 @@ static void drv_generic_graphic_resizeFB(int rows, int cols)
int drv_generic_graphic_clear(void)
{
memset(drv_generic_graphic_FB, 0, LCOLS * LROWS * sizeof(*drv_generic_graphic_FB));
- drv_generic_graphic_real_blit(0, 0, LROWS, LCOLS);
+ if (drv_generic_graphic_real_blit)
+ drv_generic_graphic_real_blit(0, 0, LROWS, LCOLS);
+
return 0;
}
@@ -229,7 +235,8 @@ static void drv_generic_graphic_render(const int row, const int col, const char
}
/* flush area */
- drv_generic_graphic_real_blit(row, col, YRES, XRES * len);
+ if (drv_generic_graphic_real_blit)
+ drv_generic_graphic_real_blit(row, col, YRES, XRES * len);
}
@@ -334,7 +341,9 @@ int drv_generic_graphic_icon_draw(WIDGET * W)
}
/* flush area */
- drv_generic_graphic_real_blit(row, col, YRES, XRES);
+ if (drv_generic_graphic_real_blit)
+ drv_generic_graphic_real_blit(row, col, YRES, XRES);
+
return 0;
@@ -413,9 +422,11 @@ int drv_generic_graphic_bar_draw(WIDGET * W)
/* flush area */
if (dir & (DIR_EAST | DIR_WEST)) {
- drv_generic_graphic_real_blit(row, col, YRES, XRES * len);
+ if (drv_generic_graphic_real_blit)
+ drv_generic_graphic_real_blit(row, col, YRES, XRES * len);
} else {
- drv_generic_graphic_real_blit(row, col, YRES * len, XRES);
+ if (drv_generic_graphic_real_blit)
+ drv_generic_graphic_real_blit(row, col, YRES * len, XRES);
}
return 0;
diff --git a/drv_generic_graphic.h b/drv_generic_graphic.h
index 9eb8180..a66999d 100644
--- a/drv_generic_graphic.h
+++ b/drv_generic_graphic.h
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_graphic.h,v 1.9 2005/05/08 04:32:44 reinelt Exp $
+/* $Id: drv_generic_graphic.h,v 1.10 2006/01/03 06:13:46 reinelt Exp $
*
* generic driver helper for graphic displays
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_generic_graphic.h,v $
+ * Revision 1.10 2006/01/03 06:13:46 reinelt
+ * GPIO's for MatrixOrbital
+ *
* Revision 1.9 2005/05/08 04:32:44 reinelt
* CodingStyle added and applied
*
@@ -80,7 +83,7 @@ extern int XRES, YRES; /* pixel width/height of one char */
extern unsigned char *drv_generic_graphic_FB;
/* these functions must be implemented by the real driver */
-void (*drv_generic_graphic_real_blit) (const int row, const int col, const int height, const int width);
+extern void (*drv_generic_graphic_real_blit) (const int row, const int col, const int height, const int width);
/* generic functions and widget callbacks */
int drv_generic_graphic_init(const char *section, const char *driver);
diff --git a/drv_generic_text.c b/drv_generic_text.c
index bc18d74..5ab6126 100644
--- a/drv_generic_text.c
+++ b/drv_generic_text.c
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_text.c,v 1.29 2005/11/06 09:54:43 reinelt Exp $
+/* $Id: drv_generic_text.c,v 1.30 2006/01/03 06:13:46 reinelt Exp $
*
* generic driver helper for text-based displays
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_generic_text.c,v $
+ * Revision 1.30 2006/01/03 06:13:46 reinelt
+ * GPIO's for MatrixOrbital
+ *
* Revision 1.29 2005/11/06 09:54:43 reinelt
* fixed icon size removed, uses XRES & YRES (I hope this doesn't lead to problemes...)
*
@@ -258,6 +261,9 @@ int GOTO_COST = 0; /* number of bytes a goto command requires */
int INVALIDATE = 0; /* re-send a modified userdefined char? */
+void (*drv_generic_text_real_write) () = NULL;
+void (*drv_generic_text_real_defchar) () = NULL;
+
static char *LayoutFB = NULL;
static char *DisplayFB = NULL;
@@ -387,7 +393,8 @@ int drv_generic_text_greet(const char *msg1, const char *msg2)
for (i = 0; line1[i]; i++) {
if (strlen(line1[i]) <= (unsigned) DCOLS) {
- drv_generic_text_real_write(0, (DCOLS - strlen(line1[i])) / 2, line1[i], strlen(line1[i]));
+ if (drv_generic_text_real_write)
+ drv_generic_text_real_write(0, (DCOLS - strlen(line1[i])) / 2, line1[i], strlen(line1[i]));
flag = 1;
break;
}
@@ -396,7 +403,8 @@ int drv_generic_text_greet(const char *msg1, const char *msg2)
if (DROWS >= 2) {
for (i = 0; line2[i]; i++) {
if (strlen(line2[i]) <= (unsigned) DCOLS) {
- drv_generic_text_real_write(1, (DCOLS - strlen(line2[i])) / 2, line2[i], strlen(line2[i]));
+ if (drv_generic_text_real_write)
+ drv_generic_text_real_write(1, (DCOLS - strlen(line2[i])) / 2, line2[i], strlen(line2[i]));
flag = 1;
break;
}
@@ -406,7 +414,8 @@ int drv_generic_text_greet(const char *msg1, const char *msg2)
if (msg1 && DROWS >= 3) {
int len = strlen(msg1);
if (len <= DCOLS) {
- drv_generic_text_real_write(2, (DCOLS - len) / 2, msg1, len);
+ if (drv_generic_text_real_write)
+ drv_generic_text_real_write(2, (DCOLS - len) / 2, msg1, len);
flag = 1;
}
}
@@ -414,7 +423,8 @@ int drv_generic_text_greet(const char *msg1, const char *msg2)
if (msg2 && DROWS >= 4) {
int len = strlen(msg2);
if (len <= DCOLS) {
- drv_generic_text_real_write(3, (DCOLS - len) / 2, msg2, len);
+ if (drv_generic_text_real_write)
+ drv_generic_text_real_write(3, (DCOLS - len) / 2, msg2, len);
flag = 1;
}
}
@@ -462,7 +472,8 @@ int drv_generic_text_draw(WIDGET * W)
}
}
memcpy(fb2 + pos1, fb1 + pos1, pos2 - pos1 + 1);
- drv_generic_text_real_write(row, col0, fb2 + pos1, pos2 - pos1 + 1);
+ if (drv_generic_text_real_write)
+ drv_generic_text_real_write(row, col0, fb2 + pos1, pos2 - pos1 + 1);
}
}
@@ -541,7 +552,8 @@ int drv_generic_text_icon_draw(WIDGET * W)
/* maybe redefine icon */
if (Icon->curmap != Icon->prvmap && Icon->visible) {
Icon->prvmap = Icon->curmap;
- drv_generic_text_real_defchar(Icon->ascii, Icon->bitmap + YRES * Icon->curmap);
+ if (drv_generic_text_real_defchar)
+ drv_generic_text_real_defchar(Icon->ascii, Icon->bitmap + YRES * Icon->curmap);
invalidate = INVALIDATE;
}
@@ -558,7 +570,8 @@ int drv_generic_text_icon_draw(WIDGET * W)
/* maybe send icon to the display */
if (row < DROWS && col < DCOLS && (DisplayFB[d_idx] != ascii || invalidate)) {
DisplayFB[d_idx] = ascii;
- drv_generic_text_real_write(row, col, DisplayFB + d_idx, 1);
+ if (drv_generic_text_real_write)
+ drv_generic_text_real_write(row, col, DisplayFB + d_idx, 1);
}
return 0;
@@ -746,7 +759,7 @@ static void drv_generic_text_bar_create_segments(void)
break;
/* hollow style, val(1,2) == 1, like '[' */
/* if (l1 == 1 && l2 == 1 && Segment[i].style == STYLE_FIRST && BarFB[n].style == STYLE_HOLLOW)
- break;
+ break;
*//* hollow style, val(1,2) == 1, like ']' */
/* if (l1 == 1 && l2 == 1 && Segment[i].style == STYLE_LAST && BarFB[n].style == STYLE_HOLLOW)
break;
@@ -954,7 +967,8 @@ static void drv_generic_text_bar_define_chars(void)
}
break;
}
- drv_generic_text_real_defchar(CHAR0 + c, buffer);
+ if (drv_generic_text_real_defchar)
+ drv_generic_text_real_defchar(CHAR0 + c, buffer);
/* maybe invalidate framebuffer */
if (INVALIDATE) {
@@ -1067,7 +1081,8 @@ int drv_generic_text_bar_draw(WIDGET * W)
}
}
memcpy(DisplayFB + row * DCOLS + pos1, LayoutFB + row * LCOLS + pos1, pos2 - pos1 + 1);
- drv_generic_text_real_write(row, col0, DisplayFB + row * DCOLS + pos1, pos2 - pos1 + 1);
+ if (drv_generic_text_real_write)
+ drv_generic_text_real_write(row, col0, DisplayFB + row * DCOLS + pos1, pos2 - pos1 + 1);
}
}
diff --git a/drv_generic_text.h b/drv_generic_text.h
index 18b01db..a9eb7eb 100644
--- a/drv_generic_text.h
+++ b/drv_generic_text.h
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_text.h,v 1.18 2005/05/08 04:32:44 reinelt Exp $
+/* $Id: drv_generic_text.h,v 1.19 2006/01/03 06:13:46 reinelt Exp $
*
* generic driver helper for text-based displays
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_generic_text.h,v $
+ * Revision 1.19 2006/01/03 06:13:46 reinelt
+ * GPIO's for MatrixOrbital
+ *
* Revision 1.18 2005/05/08 04:32:44 reinelt
* CodingStyle added and applied
*
@@ -115,8 +118,8 @@ extern int GOTO_COST; /* number of bytes a goto command requires */
extern int INVALIDATE; /* re-send a modified userdefined char? */
/* these functions must be implemented by the real driver */
-void (*drv_generic_text_real_write) (const int row, const int col, const char *data, const int len);
-void (*drv_generic_text_real_defchar) (const int ascii, const unsigned char *matrix);
+extern void (*drv_generic_text_real_write) (const int row, const int col, const char *data, const int len);
+extern void (*drv_generic_text_real_defchar) (const int ascii, const unsigned char *matrix);
/* generic functions and widget callbacks */
int drv_generic_text_init(const char *section, const char *driver);
diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample
index c3a508c..5d33622 100644
--- a/lcd4linux.conf.sample
+++ b/lcd4linux.conf.sample
@@ -27,6 +27,22 @@ Display LCD-Linux {
UseBusy 0
}
+Display LCD2041 {
+ Driver 'MatrixOrbital'
+ Model 'LCD2041'
+ Port '/dev/tts/0'
+ Speed 19200
+ Contrast 160
+}
+
+Display LK202 {
+ Driver 'MatrixOrbital'
+ Model 'LK202-24-USB'
+ Port '/dev/tts/USB0'
+ Speed 19200
+ Contrast 256/2
+}
+
Display LK204 {
Driver 'MatrixOrbital'
Model 'LK204-24-USB'
@@ -730,16 +746,46 @@ Widget Test2 {
speed 150
}
-Widget GPO_Test {
+Widget GPO_Val1 {
+ class 'Text'
+ expression LCD::GPO(1)
+ prefix 'GPO#1'
+ width 10
+ precision 0
+ align 'R'
+ update tick
+}
+
+Widget GPI_Val1 {
+ class 'Text'
+ expression LCD::GPI(1)
+ prefix 'GPI#1'
+ width 10
+ precision 0
+ align 'R'
+ update tick
+}
+
+Widget GPO_Val4 {
+ class 'Text'
+ expression LCD::GPO(4)
+ prefix 'GPO#4'
+ width 10
+ precision 0
+ align 'R'
+ update tick
+}
+
+Widget GPO_Test1 {
class 'GPO'
- expression test::onoff(1)
+ expression 255*test::onoff(1)
update 300
}
-Widget GPO_Test2 {
+Widget GPO_Test255 {
class 'GPO'
- expression test::bar(0,15, 0, 1)
- update 300
+ expression test::bar(0,255, 0, 1)
+ update 100
}
Layout Default {
@@ -842,11 +888,11 @@ Layout Test2 {
}
Layout TestGPO {
- Row1.Col1 'Test1'
-# GPO7 'GPO_Test'
- GPO2 'GPO_Test2'
- GPO1 'GPO_Test'
-
+ Row1.Col1 'GPO_Val1'
+ Row1.Col10 'GPI_Val1'
+ Row2.Col1 'GPO_Val4'
+ GPO1 'GPO_Test255'
+ GPO4 'GPO_Test1'
}
Layout testMySQL {
@@ -861,10 +907,12 @@ Layout testMySQL {
#Display 'SerDispLib'
#Display 'LCD-Linux'
+#Display 'LCD2041'
+Display 'LK202'
#Display 'LK204'
#Display 'MI240'
#Display 'CW12232'
-Display 'HD44780-generic'
+#Display 'HD44780-generic'
#Display 'HD44780-WinAmp'
#Display 'WDC2704M'
#Display 'SC1602D'