aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharbaum <harbaum@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2006-08-08 20:16:29 +0000
committerharbaum <harbaum@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2006-08-08 20:16:29 +0000
commita36ad95b8536da26e94846f9b7996b3ec09c8d13 (patch)
tree3f649d4fdf7330f97f3f0321670b0a416a129750
parent8029d9e8c20c56b5013ff3ce2a203084e12dd638 (diff)
downloadlcd4linux-a36ad95b8536da26e94846f9b7996b3ec09c8d13.tar.gz
[lcd4linux @ 2006-08-08 20:16:28 by harbaum]
Added "extracolor" (used for e.g. bar border) and RGB support for LEDMATRIX git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@684 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
-rw-r--r--drv_LEDMatrix.c49
-rw-r--r--drv_generic_graphic.c16
-rw-r--r--widget.c12
-rw-r--r--widget.h7
4 files changed, 54 insertions, 30 deletions
diff --git a/drv_LEDMatrix.c b/drv_LEDMatrix.c
index da8cb8e..bf4757d 100644
--- a/drv_LEDMatrix.c
+++ b/drv_LEDMatrix.c
@@ -1,4 +1,4 @@
-/* $Id: drv_LEDMatrix.c,v 1.1 2006/08/05 21:08:01 harbaum Exp $
+/* $Id: drv_LEDMatrix.c,v 1.2 2006/08/08 20:16:28 harbaum Exp $
*
* LED matrix driver for LCD4Linux
* (see http://www.harbaum.org/till/ledmatrix for hardware)
@@ -23,6 +23,9 @@
*
*
* $Log: drv_LEDMatrix.c,v $
+ * Revision 1.2 2006/08/08 20:16:28 harbaum
+ * Added "extracolor" (used for e.g. bar border) and RGB support for LEDMATRIX
+ *
* Revision 1.1 2006/08/05 21:08:01 harbaum
* New LEDMATRIX driver (see http://www.harbaum.org/till/ledmatrix)
*
@@ -79,22 +82,18 @@
#define DSP_CMD_IR 4
#define DSP_CMD_BEEP 5
-#define DSP_PORT 4711
+#define DSP_DEFAULT_PORT 4711
#define DSP_MEM (80 * 32 * 2 / 8)
+#define DEFAULT_X_OFFSET 1 // with a font width of 6
+
static char Name[] = "LEDMatrix";
static char *IPAddress = NULL;
static int sock = -1;
static struct sockaddr_in dsp_addr;
static unsigned char tx_buffer[DSP_MEM+1];
-
-#if 0
-typedef enum { RED, GREEN, AMBER } col_t;
-
-static col_t fg_col, bg_col, hg_col;
-#endif
-
+static int port = DSP_DEFAULT_PORT;
static void drv_LEDMatrix_blit(const int row, const int col, const int height, const int width)
{
@@ -102,14 +101,16 @@ static void drv_LEDMatrix_blit(const int row, const int col, const int height, c
for (r = row; r < row + height; r++) {
for (c = col; c < col + width; c++) {
- /* drv_generic_graphic_black() returns 1 if pixel is black */
- /* drv_generic_graphic_gray() returns a gray value 0..255 */
- /* drv_generic_graphic_rgb() returns a RGB color */
- if (drv_generic_graphic_black(r, c)) {
- tx_buffer[1 + 20*r + c/4] |= 0xc0>>(2*(c&3));
- } else {
- tx_buffer[1 + 20*r + c/4] &= ~(0xc0>>(2*(c&3)));
- }
+ /* LEDMATRIX supports three colors: 10b == green, 01b == red, 11b == amber */
+
+ unsigned char color = 0;
+ RGBA p = drv_generic_graphic_rgb(r, c);
+ if( p.G >= 128 ) color |= 0x80;
+ if( p.R >= 128 ) color |= 0x40;
+ /* ignore blue ... */
+
+ tx_buffer[1 + 20*r + c/4] &= ~(0xc0>>(2*(c&3)));
+ tx_buffer[1 + 20*r + c/4] |= color>>(2*(c&3));
}
}
@@ -126,6 +127,7 @@ static int drv_LEDMatrix_start(const char *section)
char *s;
struct sockaddr_in cli_addr;
struct hostent *hp;
+ int val;
IPAddress = cfg_get(section, "IPAddress", NULL);
if (IPAddress == NULL || *IPAddress == '\0') {
@@ -133,6 +135,13 @@ static int drv_LEDMatrix_start(const char *section)
return -1;
}
+ if (cfg_number(section, "Port", 0, 0, 65535, &val) > 0) {
+ info("%s: port set to %d", Name, val);
+ port = val;
+ } else {
+ info("%s: using default port", Name, port);
+ }
+
/* display size is hard coded */
DCOLS = 80;
DROWS = 32;
@@ -145,7 +154,7 @@ static int drv_LEDMatrix_start(const char *section)
free(s);
/* contact display */
- info("%s: contacting %s\n", Name, IPAddress);
+ info("%s: contacting %s", Name, IPAddress);
/* try to resolve as a hostname */
if((hp = gethostbyname(IPAddress)) == NULL) {
@@ -162,11 +171,11 @@ static int drv_LEDMatrix_start(const char *section)
memset((char *) &dsp_addr, 0, sizeof(dsp_addr));
dsp_addr.sin_family = AF_INET;
dsp_addr.sin_addr.s_addr = *(int*)hp->h_addr;
- dsp_addr.sin_port = htons(DSP_PORT);
+ dsp_addr.sin_port = htons(port);
cli_addr.sin_family = AF_INET;
cli_addr.sin_addr.s_addr = htons(INADDR_ANY);
- cli_addr.sin_port = htons(DSP_PORT);
+ cli_addr.sin_port = htons(port);
if (bind(sock, (struct sockaddr *) &cli_addr, sizeof(cli_addr)) < 0) {
error("%s: can't bind local address: %s", Name, strerror(errno));
diff --git a/drv_generic_graphic.c b/drv_generic_graphic.c
index 197450c..2c564c6 100644
--- a/drv_generic_graphic.c
+++ b/drv_generic_graphic.c
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_graphic.c,v 1.29 2006/07/31 03:48:09 reinelt Exp $
+/* $Id: drv_generic_graphic.c,v 1.30 2006/08/08 20:16:29 harbaum Exp $
*
* generic driver helper for graphic displays
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_generic_graphic.c,v $
+ * Revision 1.30 2006/08/08 20:16:29 harbaum
+ * Added "extracolor" (used for e.g. bar border) and RGB support for LEDMATRIX
+ *
* Revision 1.29 2006/07/31 03:48:09 reinelt
* preparations for scrolling
*
@@ -462,7 +465,7 @@ int drv_generic_graphic_icon_draw(WIDGET * W)
int drv_generic_graphic_bar_draw(WIDGET * W)
{
WIDGET_BAR *Bar = W->data;
- RGBA fg, bg;
+ RGBA fg, bg, border;
int layer, row, col, len, res, rev, max, val1, val2;
int x, y;
DIRECTION dir;
@@ -477,6 +480,7 @@ int drv_generic_graphic_bar_draw(WIDGET * W)
fg = W->fg_valid ? W->fg_color : FG_COL;
bg = W->bg_valid ? W->bg_color : BG_COL;
+ border = W->extra_valid ? W->extra_color : fg;
/* sanity check */
if (layer < 0 || layer >= LAYERS) {
@@ -524,13 +528,13 @@ int drv_generic_graphic_bar_draw(WIDGET * W)
drv_generic_graphic_FB[layer][(row + y) * LCOLS + col + x] = rev ? fg : bg;
if (style) {
- drv_generic_graphic_FB[layer][(row) * LCOLS + col + x] = fg;
- drv_generic_graphic_FB[layer][(row + YRES - 1) * LCOLS + col + x] = fg;
+ drv_generic_graphic_FB[layer][(row) * LCOLS + col + x] = border;
+ drv_generic_graphic_FB[layer][(row + YRES - 1) * LCOLS + col + x] = border;
}
}
if (style) {
- drv_generic_graphic_FB[layer][(row + y) * LCOLS + col] = fg;
- drv_generic_graphic_FB[layer][(row + y) * LCOLS + col + max - 1] = fg;
+ drv_generic_graphic_FB[layer][(row + y) * LCOLS + col] = border;
+ drv_generic_graphic_FB[layer][(row + y) * LCOLS + col + max - 1] = border;
}
}
break;
diff --git a/widget.c b/widget.c
index 0f17c9c..e2aef42 100644
--- a/widget.c
+++ b/widget.c
@@ -1,4 +1,4 @@
-/* $Id: widget.c,v 1.24 2006/08/08 19:28:18 reinelt Exp $
+/* $Id: widget.c,v 1.25 2006/08/08 20:16:29 harbaum Exp $
*
* generic widget handling
*
@@ -21,6 +21,9 @@
*
*
* $Log: widget.c,v $
+ * Revision 1.25 2006/08/08 20:16:29 harbaum
+ * Added "extracolor" (used for e.g. bar border) and RGB support for LEDMATRIX
+ *
* Revision 1.24 2006/08/08 19:28:18 reinelt
* widget type checking corrected
*
@@ -224,8 +227,8 @@ int widget_add(const char *name, const int type, const int layer, const int row,
int i;
char *section;
char *class;
- int fg_valid, bg_valid;
- RGBA FG, BG;
+ int fg_valid, bg_valid, extra_valid;
+ RGBA FG, BG, EXTRACOL;
WIDGET_CLASS *Class;
WIDGET *Widget;
@@ -250,6 +253,7 @@ int widget_add(const char *name, const int type, const int layer, const int row,
/* get widget foreground color */
fg_valid = widget_color(section, name, "foreground", &FG);
bg_valid = widget_color(section, name, "background", &BG);
+ extra_valid = widget_color(section, name, "extracolor", &EXTRACOL);
free(section);
@@ -312,8 +316,10 @@ int widget_add(const char *name, const int type, const int layer, const int row,
Widget->parent = Parent;
Widget->fg_color = FG;
Widget->bg_color = BG;
+ Widget->extra_color = EXTRACOL;
Widget->fg_valid = fg_valid;
Widget->bg_valid = bg_valid;
+ Widget->extra_valid = extra_valid;
Widget->layer = layer;
Widget->row = row;
Widget->col = col;
diff --git a/widget.h b/widget.h
index 13fd297..fc1a5b0 100644
--- a/widget.h
+++ b/widget.h
@@ -1,4 +1,4 @@
-/* $Id: widget.h,v 1.19 2006/02/21 15:55:59 cmay Exp $
+/* $Id: widget.h,v 1.20 2006/08/08 20:16:29 harbaum Exp $
*
* generic widget handling
*
@@ -23,6 +23,9 @@
*
*
* $Log: widget.h,v $
+ * Revision 1.20 2006/08/08 20:16:29 harbaum
+ * Added "extracolor" (used for e.g. bar border) and RGB support for LEDMATRIX
+ *
* Revision 1.19 2006/02/21 15:55:59 cmay
* removed new update function for keypad, consolidated it with draw
*
@@ -124,8 +127,10 @@ typedef struct WIDGET {
struct WIDGET *parent;
RGBA fg_color;
RGBA bg_color;
+ RGBA extra_color;
int fg_valid;
int bg_valid;
+ int extra_valid;
int layer;
int row;
int col;