aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.in2
-rw-r--r--drv_BeckmannEgle.c549
-rw-r--r--drv_MatrixOrbital.c38
-rw-r--r--drv_USBLCD.c22
-rw-r--r--drv_generic_serial.c28
-rw-r--r--drv_generic_text.c14
-rw-r--r--lcd4linux.conf.sample20
7 files changed, 562 insertions, 111 deletions
diff --git a/Makefile.in b/Makefile.in
index 8021108..bfa654f 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -82,7 +82,7 @@ PLUGINS = @PLUGINS@
bin_PROGRAMS = lcd4linux
#lib_LTLIBRARIES = liblcd4linux.la
-AM_CFLAGS = $(X_CFLAGS) -D_GNU_SOURCE -Wall
+AM_CFLAGS = $(X_CFLAGS) -D_GNU_SOURCE -Wall -ansi
lcd4linux_LDFLAGS = $(X_LIBS)
lcd4linux_LDADD = @DRIVERS@ @PLUGINS@ @DRVLIBS@ @PLUGINLIBS@
diff --git a/drv_BeckmannEgle.c b/drv_BeckmannEgle.c
index 9cbe418..6b45191 100644
--- a/drv_BeckmannEgle.c
+++ b/drv_BeckmannEgle.c
@@ -1,6 +1,6 @@
-/* $Id: drv_BeckmannEgle.c,v 1.8 2004/06/20 10:09:54 reinelt Exp $
+/* $Id: drv_BeckmannEgle.c,v 1.9 2004/06/26 06:12:15 reinelt Exp $
*
- * driver for Beckmann+Egle mini terminals
+ * driver for Beckmann+Egle "Mini Terminals" and "Compact Terminals"
* Copyright 2000 Michael Reinelt <reinelt@eunet.at>
* Copyright 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
*
@@ -22,6 +22,14 @@
*
*
* $Log: drv_BeckmannEgle.c,v $
+ * Revision 1.9 2004/06/26 06:12:15 reinelt
+ *
+ * support for Beckmann+Egle Compact Terminals
+ * some mostly cosmetic changes in the MatrixOrbital and USBLCD driver
+ * added debugging to the generic serial driver
+ * fixed a bug in the generic text driver where icons could be drawn outside
+ * the display bounds
+ *
* Revision 1.8 2004/06/20 10:09:54 reinelt
*
* 'const'ified the whole source
@@ -76,6 +84,7 @@
#include "debug.h"
#include "cfg.h"
+#include "qprintf.h"
#include "plugin.h"
#include "widget.h"
#include "widget_text.h"
@@ -86,85 +95,348 @@
#include "drv_generic_serial.h"
+#define ESC "\033"
+
static char Name[]="Beckmann+Egle";
+
typedef struct {
- int type;
char *name;
int rows;
int cols;
+ int protocol;
+ int type;
} MODEL;
+
static MODEL Models[] = {
- { 0, "MT16x1", 1, 16,},
- { 1, "MT16x2", 2, 16,},
- { 2, "MT16x4", 4, 16,},
- { 3, "MT20x1", 1, 20,},
- { 4, "MT20x2", 2, 20,},
- { 5, "MT20x4", 4, 20,},
- { 6, "MT24x1", 1, 24,},
- { 7, "MT24x2", 2, 24,},
- { 8, "MT32x1", 1, 32,},
- { 9, "MT32x2", 2, 32,},
- { 10, "MT40x1", 1, 40,},
- { 11, "MT40x2", 2, 40,},
- { 12, "MT40x4", 4, 40,},
- { -1, "unknown", -1, -1 },
+ // MultiTerminals
+ { "MT16x1", 1, 16, 1, 0 },
+ { "MT16x2", 2, 16, 1, 1 },
+ { "MT16x4", 4, 16, 1, 2 },
+ { "MT20x1", 1, 20, 1, 3 },
+ { "MT20x2", 2, 20, 1, 4 },
+ { "MT20x4", 4, 20, 1, 5 },
+ { "MT24x1", 1, 24, 1, 6 },
+ { "MT24x2", 2, 24, 1, 7 },
+ { "MT32x1", 1, 32, 1, 8 },
+ { "MT32x2", 2, 32, 1, 9 },
+ { "MT40x1", 1, 40, 1, 10 },
+ { "MT40x2", 2, 40, 1, 11 },
+ { "MT40x4", 4, 40, 1, 12 },
+
+ // CompactTerminal
+ { "CT20x4", 4, 20, 2, 0 },
+
+ { NULL, 0, 0, 0, 0 },
};
-static int Model;
+
+static int Model;
+static int Protocol;
+
// ****************************************
// *** hardware dependant functions ***
// ****************************************
-static void drv_BE_write (const int row, const int col, const unsigned char *data, const int len)
+static void drv_BuE_clear (void)
+{
+ switch (Protocol) {
+ case 1:
+ drv_generic_serial_write (ESC "&#", 3); // clear display
+ break;
+ case 2:
+ drv_generic_serial_write (ESC "LL", 3); // clear display
+ break;
+ }
+}
+
+
+static void drv_BuE_MT_write (const int row, const int col, const unsigned char *data, const int len)
{
- char cmd[] = "\033[y;xH";
+ char cmd[] = ESC "[y;xH";
cmd[2] = (char)row;
cmd[4] = (char)col;
- drv_generic_serial_write(cmd,6);
+ drv_generic_serial_write (cmd, 6);
drv_generic_serial_write (data, len);
}
-static void drv_BE_defchar (const int ascii, const unsigned char *matrix)
+static void drv_BuE_MT_defchar (const int ascii, const unsigned char *matrix)
{
int i;
- char cmd[32];
- char *p;
-
- p = cmd;
- *p++ = '\033';
- *p++ = '&';
- *p++ = 'T'; // enter transparent mode
- *p++ = '\0'; // write cmd
- *p++ = 0x40|8*ascii; // write CGRAM
- for (i = 0; i < YRES; i++) {
- *p++ = '\1'; // write data
- *p++ = matrix[i] & 0x1f; // character bitmap
+ char cmd[22] = ESC "&T"; // enter transparent mode
+
+ cmd[3] = '\0'; // write cmd
+ cmd[4] = 0x40|8*ascii; // write CGRAM
+
+ for (i = 0; i < 8; i++) {
+ cmd[2*i+5] = '\1'; // write data
+ cmd[2*i+6] = matrix[i] & 0x1f; // character bitmap
+ }
+ cmd[21] = '\377'; // leave transparent mode
+
+ drv_generic_serial_write (cmd, 22);
+}
+
+
+static void drv_BuE_CT_write (const int row, const int col, const unsigned char *data, const int len)
+{
+ char cmd[] = ESC "LCzs1";
+
+ cmd[3] = (char)row + 1;
+ cmd[4] = (char)col + 1;
+
+ drv_generic_serial_write (cmd, 6);
+ drv_generic_serial_write (data, len);
+}
+
+
+static void drv_BuE_CT_defchar (const int ascii, const unsigned char *matrix)
+{
+ int i;
+ char cmd[13] = ESC "LZ"; // set custom char
+
+ // number of user-defined char (0..7)
+ cmd[3] = (char) ascii - CHAR0;
+
+ // ASCII code to replace
+ cmd[4] = (char) ascii;
+
+ for (i = 0; i < 8; i++) {
+ cmd[i+5] = matrix[i] & 0x1f;
+ }
+
+ drv_generic_serial_write (cmd, 13);
+}
+
+
+static int drv_BuE_CT_contrast (int contrast)
+{
+ static unsigned char Contrast = 7;
+ char cmd[4] = ESC "LKn";
+
+ // -1 is used to query the current contrast
+ if (contrast == -1) return Contrast;
+
+ if (contrast < 0 ) contrast = 0;
+ if (contrast > 15) contrast = 15;
+ Contrast = contrast;
+
+ cmd[3] = Contrast;
+
+ drv_generic_serial_write (cmd, 4);
+
+ return Contrast;
+}
+
+
+static int drv_BuE_CT_backlight (int backlight)
+{
+ static unsigned char Backlight=0;
+ char cmd[4] = ESC "LBn";
+
+ // -1 is used to query the current backlight
+ if (backlight == -1) return Backlight;
+
+ if (backlight < 0) backlight = 0;
+ if (backlight > 1) backlight = 1;
+ Backlight = backlight;
+
+ cmd[3] = Backlight;
+
+ drv_generic_serial_write (cmd, 4);
+
+ return Backlight;
+}
+
+
+static int drv_BuE_CT_gpo (int num, int val)
+{
+ static int GPO[8] = { -1, -1, -1, -1, -1, -1, -1, -1 };
+ unsigned char cmd[4] = ESC "Pnx";
+
+ if (num < 0) num = 0;
+ if (num > 7) num = 7;
+
+ // -1 is used to query the current GPO
+ if (val == -1) return GPO[num];
+
+ if (val < 0 ) val = 0;
+ if (val > 255) val = 255;
+ GPO[num] = val;
+
+ cmd[2] = (unsigned char)num;
+ cmd[3] = (unsigned char)val;
+
+ drv_generic_serial_write (cmd, 4);
+
+ return GPO[num];
+}
+
+
+static int drv_BuE_CT_gpi (int num)
+{
+ char cmd[4] = ESC "?Pn";
+ unsigned char buffer[4];
+
+ if (num < 0) num = 0;
+ if (num > 7) num = 7;
+
+ cmd[3] = (unsigned char)num;
+ drv_generic_serial_write (cmd, 4);
+
+ usleep (10000);
+
+ if (drv_generic_serial_read (buffer, 4) != 4) {
+ error ("%s: error reading port %d", Name, num);
+ return -1;
+ }
+
+ return buffer[3];
+}
+
+
+static int drv_BuE_CT_adc (void)
+{
+ unsigned char buffer[4];
+
+ drv_generic_serial_write (ESC "?A", 3);
+
+ usleep (10000);
+
+ if ((drv_generic_serial_read (buffer, 4) != 4) ||
+ (buffer[0] != 'A') ||
+ (buffer[1] != ':')
+ ) {
+ error ("%s: error reading ADC", Name);
+ return -1;
}
- *p++ = '\377'; // leave transparent mode
+
+ // 10 bit value: 8 bit high, 2 bit low
+ return 4 * buffer[2] + buffer[3];
+}
+
+
+static int drv_BuE_CT_pwm (int val)
+{
+ static int PWM = -1;
+ unsigned char cmd[4] = ESC "Adm";
+
+ // -1 is used to query the current PWM
+ if (val == -1) return PWM;
- drv_generic_serial_write (cmd, p-cmd);
+ if (val < 0) val = 0;
+ if (val > 255) val = 255;
+ PWM = val;
+
+ cmd[2] = (unsigned char) val;
+ cmd[3] = val == 0 ? 1 : 2;
+ drv_generic_serial_write (cmd, 4);
+
+ return val;
+}
+
+
+static int drv_BuE_MT_start (const char *section)
+{
+ char cmd[] = ESC "&sX";
+
+ // CSTOPB: 2 stop bits
+ if (drv_generic_serial_open(section, Name, CSTOPB) < 0) return -1;
+
+ cmd[4] = Models[Model].type;
+ drv_generic_serial_write (cmd, 4); // select display type
+ drv_generic_serial_write (ESC "&D", 3); // cursor off
+
+ return 0;
}
-static void drv_BE_clear (void)
+static int drv_BuE_CT_start (const char *section)
{
- drv_generic_serial_write ("\033&#", 3); // clear
+ char buffer[16];
+ char *size;
+ int i, len;
+
+ if (drv_generic_serial_open(section, Name, 0) < 0) return -1;
+
+#if 0
+ drv_generic_serial_write (ESC "Kr", 3); // restart terminal
+ usleep(10000);
+#endif
+
+ // Fixme: the CT does not return a serial number in byte mode
+ drv_generic_serial_write (ESC "KM\073", 4); // set parameter mode 'decimal'
+
+ // read version
+ drv_generic_serial_write (ESC "?V", 3);
+ usleep(100000);
+ if ((len = drv_generic_serial_read (buffer, -sizeof(buffer))) > 0) {
+ int v, r, s;
+ if (sscanf(buffer, "V:%d.%d,%d;", &v, &r, &s) != 3) {
+ error ("%s: error parsing display identification <%*s>", Name, len, buffer);
+ } else {
+ info ("%s: display identified as version %d.%d, S/N %d", Name, v, r, s);
+ }
+ }
+
+ drv_generic_serial_write (ESC "KM\072", 4); // set parameter mode 'byte'
+
+ // the CT20x4 can control smaller displays, too
+ size = cfg_get(section, "Size", NULL);
+ if (size != NULL && *size != '\0') {
+ int r, c;
+ char cmd[6] = ESC "LArc";
+ if (sscanf(size, "%dx%d", &c, &r) != 2 || r < 1 || c < 1) {
+ error ("%s: bad %s.Size '%s' from %s", Name, section, size, cfg_source());
+ return -1;
+ }
+ info ("%s: display size: %d rows %d columns", Name, r, c);
+ cmd[3] = (unsigned char) r;
+ cmd[4] = (unsigned char) c;
+ drv_generic_serial_write (cmd, 5); // set display size
+ DCOLS = c;
+ DROWS = r;
+ }
+
+ // set contrast
+ if (cfg_number(section, "Contrast", 7, 0, 15, &i) > 0) {
+ drv_BuE_CT_contrast(i);
+ }
+
+ // set backlight
+ if (cfg_number(section, "Backlight", 0, 0, 1, &i) > 0) {
+ drv_BuE_CT_backlight(i);
+ }
+
+ // identify I/O Port
+
+ for (i = 0; i < 8; i++) {
+ char cmd[5] = ESC "K?Pn";
+ cmd[4] = (unsigned char)i;
+ drv_generic_serial_write (cmd, 5); // query I/O port
+ usleep(10000);
+ if ((len = drv_generic_serial_read (buffer, 4)) == 4) {
+ info ("%s: Port %d is type %d", Name, i, buffer[3]);
+ } else {
+ error ("%s: error fetching type of port %d", Name, i);
+ }
+ }
+
+ return 0;
}
-static int drv_BE_start (const char *section, const int quiet)
+static int drv_BuE_start (const char *section)
{
- int i;
+ int i, ret;
char *model;
- char buffer[] = "\033&sX";
model = cfg_get(section, "Model", NULL);
if (model == NULL && *model == '\0') {
@@ -172,35 +444,39 @@ static int drv_BE_start (const char *section, const int quiet)
return -1;
}
- for (i=0; Models[i].type!=0xff; i++) {
- if (strcasecmp(Models[i].name, model)==0) break;
+ for (i = 0; Models[i].name != NULL; i++) {
+ if (strcasecmp(Models[i].name, model) == 0) break;
}
- if (Models[i].type==0xff) {
+
+ if (Models[i].name == NULL) {
error ("%s: %s.Model '%s' is unknown from %s", Name, section, model, cfg_source());
return -1;
}
- Model=i;
+
+ Model = i;
+ Protocol = Models[Model].protocol;
+
info ("%s: using model '%s'", Name, Models[Model].name);
- // CSTOPB: 2 stop bits
- if (drv_generic_serial_open(section, Name, CSTOPB)<0) return -1;
-
// initialize global variables
DROWS = Models[Model].rows;
DCOLS = Models[Model].cols;
- buffer[4] = Models[Model].type;
- drv_generic_serial_write (buffer, 4); // select display type
- drv_generic_serial_write ("\033&D", 3); // cursor off
-
- drv_BE_clear();
-
- if (!quiet) {
- if (drv_generic_text_greet (Name, Models[Model].name)) {
- sleep (3);
- drv_BE_clear();
- }
+ ret = 0;
+ switch (Protocol) {
+ case 1:
+ ret = drv_BuE_MT_start(section);
+ break;
+ case 2:
+ ret = drv_BuE_CT_start(section);
+ break;
+ }
+ if (ret != 0) {
+ return ret;
}
+
+ drv_BuE_clear();
+
return 0;
}
@@ -209,7 +485,102 @@ static int drv_BE_start (const char *section, const int quiet)
// *** plugins ***
// ****************************************
-// none at the moment...
+static void plugin_contrast (RESULT *result, const int argc, RESULT *argv[])
+{
+ double contrast;
+
+ switch (argc) {
+ case 0:
+ contrast = drv_BuE_CT_contrast(-1);
+ SetResult(&result, R_NUMBER, &contrast);
+ break;
+ case 1:
+ contrast = drv_BuE_CT_contrast(R2N(argv[0]));
+ SetResult(&result, R_NUMBER, &contrast);
+ break;
+ default:
+ error ("%s::contrast(): wrong number of parameters", Name);
+ SetResult(&result, R_STRING, "");
+ }
+}
+
+
+static void plugin_backlight (RESULT *result, const int argc, RESULT *argv[])
+{
+ double backlight;
+
+ switch (argc) {
+ case 0:
+ backlight = drv_BuE_CT_backlight(-1);
+ SetResult(&result, R_NUMBER, &backlight);
+ break;
+ case 1:
+ backlight = drv_BuE_CT_backlight(R2N(argv[0]));
+ SetResult(&result, R_NUMBER, &backlight);
+ break;
+ default:
+ error ("%s::backlight(): wrong number of parameters", Name);
+ SetResult(&result, R_STRING, "");
+ }
+}
+
+
+static void plugin_gpo (RESULT *result, const int argc, RESULT *argv[])
+{
+ double gpo;
+
+ switch (argc) {
+ case 1:
+ gpo = drv_BuE_CT_gpo(R2N(argv[0]), -1);
+ SetResult(&result, R_NUMBER, &gpo);
+ break;
+ case 2:
+ gpo = drv_BuE_CT_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_gpi (RESULT *result, RESULT *arg1)
+{
+ double gpi;
+
+ gpi = drv_BuE_CT_gpi(R2N(arg1));
+ SetResult(&result, R_NUMBER, &gpi);
+}
+
+
+static void plugin_adc (RESULT *result)
+{
+ double adc;
+
+ adc = drv_BuE_CT_adc();
+ SetResult(&result, R_NUMBER, &adc);
+}
+
+
+static void plugin_pwm (RESULT *result, const int argc, RESULT *argv[])
+{
+ double pwm;
+
+ switch (argc) {
+ case 0:
+ pwm = drv_BuE_CT_pwm(-1);
+ SetResult(&result, R_NUMBER, &pwm);
+ break;
+ case 1:
+ pwm = drv_BuE_CT_pwm(R2N(argv[0]));
+ SetResult(&result, R_NUMBER, &pwm);
+ break;
+ default:
+ error ("%s::pwm(): wrong number of parameters", Name);
+ SetResult(&result, R_STRING, "");
+ }
+}
// ****************************************
@@ -227,11 +598,11 @@ static int drv_BE_start (const char *section, const int quiet)
// list models
-int drv_BE_list (void)
+int drv_BuE_list (void)
{
int i;
- for (i = 0; Models[i].type > -1; i++) {
+ for (i = 0; Models[i].name != NULL; i++) {
printf ("%s ", Models[i].name);
}
return 0;
@@ -239,27 +610,46 @@ int drv_BE_list (void)
// initialize driver & display
-int drv_BE_init (const char *section, const int quiet)
+int drv_BuE_init (const char *section, const int quiet)
{
WIDGET_CLASS wc;
int ret;
+ // start display
+ if ((ret=drv_BuE_start (section)) != 0) {
+ return ret;
+ }
+
// display preferences
XRES = 5; // pixel width of one char
YRES = 8; // pixel height of one char
CHARS = 8; // number of user-defineable characters
- CHAR0 = 0; // ASCII of first user-defineable char
- GOTO_COST = 6; // number of bytes a goto command requires
// real worker functions
- drv_generic_text_real_write = drv_BE_write;
- drv_generic_text_real_defchar = drv_BE_defchar;
+ switch (Protocol) {
+ case 1:
+ CHAR0 = 0; // ASCII of first user-defineable char
+ GOTO_COST = 6; // number of bytes a goto command requires
+ drv_generic_text_real_write = drv_BuE_MT_write;
+ drv_generic_text_real_defchar = drv_BuE_MT_defchar;
+ break;
+ case 2:
+ CHAR0 = 128; // ASCII of first user-defineable char
+ GOTO_COST = 6; // number of bytes a goto command requires
+ drv_generic_text_real_write = drv_BuE_CT_write;
+ drv_generic_text_real_defchar = drv_BuE_CT_defchar;
+ break;
+ }
+ if (!quiet) {
+ char buffer[40];
+ qprintf(buffer, sizeof(buffer), "%s %s", Name, Models[Model].name);
+ if (drv_generic_text_greet (buffer, "www.bue.com")) {
+ sleep (3);
+ drv_BuE_clear();
+ }
+ }
- // start display
- if ((ret=drv_BE_start (section, quiet))!=0)
- return ret;
-
// initialize generic text driver
if ((ret=drv_generic_text_init(section, Name))!=0)
return ret;
@@ -292,21 +682,26 @@ int drv_BE_init (const char *section, const int quiet)
widget_register(&wc);
// register plugins
- // none at the moment...
+ AddFunction ("LCD::contrast", -1, plugin_contrast);
+ AddFunction ("LCD::backlight", -1, plugin_backlight);
+ AddFunction ("LCD::gpo", -1, plugin_gpo);
+ AddFunction ("LCD::gpi", 1, plugin_gpi);
+ AddFunction ("LCD::adc", 0, plugin_adc);
+ AddFunction ("LCD::pwm", -1, plugin_pwm);
return 0;
}
// close driver & display
-int drv_BE_quit (const int quiet) {
+int drv_BuE_quit (const int quiet) {
info("%s: shutting down.", Name);
drv_generic_text_quit();
// clear display
- drv_BE_clear();
+ drv_BuE_clear();
// say goodbye...
if (!quiet) {
@@ -321,8 +716,8 @@ int drv_BE_quit (const int quiet) {
DRIVER drv_BeckmannEgle = {
name: Name,
- list: drv_BE_list,
- init: drv_BE_init,
- quit: drv_BE_quit,
+ list: drv_BuE_list,
+ init: drv_BuE_init,
+ quit: drv_BuE_quit,
};
diff --git a/drv_MatrixOrbital.c b/drv_MatrixOrbital.c
index 0b9af92..ca19531 100644
--- a/drv_MatrixOrbital.c
+++ b/drv_MatrixOrbital.c
@@ -1,4 +1,4 @@
-/* $Id: drv_MatrixOrbital.c,v 1.33 2004/06/20 10:09:54 reinelt Exp $
+/* $Id: drv_MatrixOrbital.c,v 1.34 2004/06/26 06:12:15 reinelt Exp $
*
* new style driver for Matrix Orbital serial display modules
*
@@ -23,6 +23,14 @@
*
*
* $Log: drv_MatrixOrbital.c,v $
+ * Revision 1.34 2004/06/26 06:12:15 reinelt
+ *
+ * support for Beckmann+Egle Compact Terminals
+ * some mostly cosmetic changes in the MatrixOrbital and USBLCD driver
+ * added debugging to the generic serial driver
+ * fixed a bug in the generic text driver where icons could be drawn outside
+ * the display bounds
+ *
* Revision 1.33 2004/06/20 10:09:54 reinelt
*
* 'const'ified the whole source
@@ -286,17 +294,18 @@ static void drv_MO_defchar (const int ascii, const unsigned char *matrix)
static int drv_MO_contrast (int contrast)
{
static unsigned char Contrast=0;
- char buffer[4];
-
+ char cmd[3] = "\376Pn";
+
// -1 is used to query the current contrast
if (contrast == -1) return Contrast;
-
+
if (contrast < 0 ) contrast = 0;
if (contrast > 255) contrast = 255;
Contrast = contrast;
+
+ cmd[2] = Contrast;
- snprintf (buffer, 4, "\376P%c", Contrast);
- drv_generic_serial_write (buffer, 3);
+ drv_generic_serial_write (cmd, 3);
return Contrast;
}
@@ -305,7 +314,7 @@ static int drv_MO_contrast (int contrast)
static int drv_MO_backlight (int backlight)
{
static unsigned char Backlight=0;
- char buffer[4];
+ char cmd[3] = "\376Bn";
// -1 is used to query the current backlight
if (backlight == -1) return Backlight;
@@ -314,14 +323,13 @@ static int drv_MO_backlight (int backlight)
if (backlight > 255) backlight = 255;
Backlight = backlight;
- if (backlight<0) {
+ if (backlight < 0) {
// backlight off
- snprintf (buffer, 3, "\376F");
- drv_generic_serial_write (buffer, 2);
+ drv_generic_serial_write ("\376F", 2);
} else {
// backlight on for n minutes
- snprintf (buffer, 4, "\376B%c", (int)backlight);
- drv_generic_serial_write (buffer, 3);
+ cmd[2] = Backlight;
+ drv_generic_serial_write (cmd, 3);
}
return Backlight;
@@ -565,7 +573,7 @@ static void plugin_backlight (RESULT *result, const int argc, RESULT *argv[])
SetResult(&result, R_NUMBER, &backlight);
break;
default:
- error ("%s::backlight(): wrong number of parameters");
+ error ("%s::backlight(): wrong number of parameters", Name);
SetResult(&result, R_STRING, "");
}
}
@@ -585,7 +593,7 @@ static void plugin_gpo (RESULT *result, const int argc, RESULT *argv[])
SetResult(&result, R_NUMBER, &gpo);
break;
default:
- error ("%s:gpo(): wrong number of parameters");
+ error ("%s:gpo(): wrong number of parameters", Name);
SetResult(&result, R_STRING, "");
}
}
@@ -605,7 +613,7 @@ static void plugin_pwm (RESULT *result, const int argc, RESULT *argv[])
SetResult(&result, R_NUMBER, &pwm);
break;
default:
- error ("%s:pwm(): wrong number of parameters");
+ error ("%s:pwm(): wrong number of parameters", Name);
SetResult(&result, R_STRING, "");
}
}
diff --git a/drv_USBLCD.c b/drv_USBLCD.c
index b625b53..90977d0 100644
--- a/drv_USBLCD.c
+++ b/drv_USBLCD.c
@@ -1,4 +1,4 @@
-/* $Id: drv_USBLCD.c,v 1.12 2004/06/20 10:09:54 reinelt Exp $
+/* $Id: drv_USBLCD.c,v 1.13 2004/06/26 06:12:15 reinelt Exp $
*
* new style driver for USBLCD displays
*
@@ -26,6 +26,14 @@
*
*
* $Log: drv_USBLCD.c,v $
+ * Revision 1.13 2004/06/26 06:12:15 reinelt
+ *
+ * support for Beckmann+Egle Compact Terminals
+ * some mostly cosmetic changes in the MatrixOrbital and USBLCD driver
+ * added debugging to the generic serial driver
+ * fixed a bug in the generic text driver where icons could be drawn outside
+ * the display bounds
+ *
* Revision 1.12 2004/06/20 10:09:54 reinelt
*
* 'const'ified the whole source
@@ -210,11 +218,12 @@ static int drv_UL_start (const char *section, const int quiet)
error ("%s: no '%s.Port' entry from %s", Name, section, cfg_source());
return -1;
}
- if (port[0]=='/') {
- Port=strdup(port);
+ if (port[0] == '/') {
+ Port = strdup(port);
} else {
- Port=malloc(5+strlen(port)+1);
- sprintf(Port,"/dev/%s",port);
+ int len = 5+strlen(port)+1;
+ Port = malloc(len);
+ qprintf(Port, len, "/dev/%s", port);
}
debug ("using device %s ", Port);
@@ -225,7 +234,8 @@ static int drv_UL_start (const char *section, const int quiet)
return -1;
}
if (sscanf(s,"%dx%d",&cols,&rows)!=2 || rows<1 || cols<1) {
- error ("%s: bad size '%s'", Name, s);
+ error ("%s: bad %s.Size '%s' from %s", Name, section, s, cfg_source());
+ free (s);
return -1;
}
diff --git a/drv_generic_serial.c b/drv_generic_serial.c
index b1e1fef..9483532 100644
--- a/drv_generic_serial.c
+++ b/drv_generic_serial.c
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_serial.c,v 1.12 2004/06/20 10:09:55 reinelt Exp $
+/* $Id: drv_generic_serial.c,v 1.13 2004/06/26 06:12:15 reinelt Exp $
*
* generic driver helper for serial and usbserial displays
*
@@ -23,6 +23,14 @@
*
*
* $Log: drv_generic_serial.c,v $
+ * Revision 1.13 2004/06/26 06:12:15 reinelt
+ *
+ * support for Beckmann+Egle Compact Terminals
+ * some mostly cosmetic changes in the MatrixOrbital and USBLCD driver
+ * added debugging to the generic serial driver
+ * fixed a bug in the generic text driver where icons could be drawn outside
+ * the display bounds
+ *
* Revision 1.12 2004/06/20 10:09:55 reinelt
*
* 'const'ified the whole source
@@ -336,7 +344,7 @@ int drv_generic_serial_poll (unsigned char *string, const int len)
{
int ret;
if (Device == -1) return -1;
- ret=read (Device, string, len);
+ ret = read (Device, string, len);
if (ret < 0 && errno != EAGAIN) {
error("%s: read(%s) failed: %s", Driver, Port, strerror(errno));
}
@@ -346,16 +354,18 @@ int drv_generic_serial_poll (unsigned char *string, const int len)
int drv_generic_serial_read (unsigned char *string, const int len)
{
- int run, ret;
+ int count, run, ret;
+
+ count = len < 0 ? -len : len;
for (run = 0; run < 10; run ++) {
- ret = drv_generic_serial_poll(string, len);
+ ret = drv_generic_serial_poll(string, count);
if (ret >= 0 || errno != EAGAIN) break;
info ("%s: read(%s): EAGAIN", Driver, Port);
usleep(1000);
}
- if (ret > 0 && ret != len) {
+ if (ret > 0 && ret != count && len > 0) {
error ("%s: partial read(%s): len=%d ret=%d", Driver, Port, len, ret);
}
@@ -367,6 +377,14 @@ void drv_generic_serial_write (const unsigned char *string, const int len)
{
int run, ret;
+#if 0
+ int i;
+ for (i = 0; i < len; i++) {
+ int c = string[i];
+ debug ("serial_write: %03d %03o 0x%02x %c", c, c, c, iscntrl(c) ? '*' : c);
+ }
+#endif
+
if (Device == -1) return;
for (run = 0; run < 10; run++) {
ret = write (Device, string, len);
diff --git a/drv_generic_text.c b/drv_generic_text.c
index bd93849..8dadb26 100644
--- a/drv_generic_text.c
+++ b/drv_generic_text.c
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_text.c,v 1.18 2004/06/20 10:09:55 reinelt Exp $
+/* $Id: drv_generic_text.c,v 1.19 2004/06/26 06:12:15 reinelt Exp $
*
* generic driver helper for text-based displays
*
@@ -23,6 +23,14 @@
*
*
* $Log: drv_generic_text.c,v $
+ * Revision 1.19 2004/06/26 06:12:15 reinelt
+ *
+ * support for Beckmann+Egle Compact Terminals
+ * some mostly cosmetic changes in the MatrixOrbital and USBLCD driver
+ * added debugging to the generic serial driver
+ * fixed a bug in the generic text driver where icons could be drawn outside
+ * the display bounds
+ *
* Revision 1.18 2004/06/20 10:09:55 reinelt
*
* 'const'ified the whole source
@@ -486,11 +494,11 @@ int drv_generic_text_icon_draw (WIDGET *W)
LayoutFB[row*LCOLS+col]=ascii;
// maybe send icon to the display
- if (DisplayFB[row*DCOLS+col]!=ascii) {
+ if (row < DROWS && col < DCOLS && DisplayFB[row*DCOLS+col] != ascii) {
DisplayFB[row*DCOLS+col]=ascii;
drv_generic_text_real_write (row, col, DisplayFB+row*DCOLS+col, 1);
}
-
+
return 0;
}
diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample
index c1adc4a..e68f345 100644
--- a/lcd4linux.conf.sample
+++ b/lcd4linux.conf.sample
@@ -89,6 +89,17 @@ Display M50530-24x8 {
}
+Display CT20x4 {
+ Driver 'Beckmann+Egle'
+ Model 'CT20x4'
+ Port '/dev/tts/0'
+# Size '16x2'
+# Contrast 7
+# Backlight 1
+ Icons 1
+}
+
+
Display USBLCD {
Driver 'USBLCD'
Port '/dev/usb/lcd'
@@ -514,7 +525,7 @@ Layout Default {
}
Row3 {
Col1 'Busy'
- Col10 'Rain'
+# Col10 'Rain'
Col11 'BusyBar'
}
Row4 {
@@ -605,14 +616,15 @@ Layout testMySQL {
#Display 'MI240'
#Display 'CW12232'
#Display 'HD44780-20x4'
-#Display 'M50530-24x8'
#Display 'CF631'
#Display 'CF632'
#Display 'CF633'
-Display 'Curses'
-#Display 'USBLCD'
+#Display 'Curses'
+#Display 'M50530-24x8'
+Display 'CT20x4'
#Display 'T6963-240x64'
#Display 'XWindow'
+#Display 'USBLCD'
#Display 'Image'
Layout 'Default'