aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2011-12-25 16:33:50 +0000
committerJonathan McCrohan <jmccrohan@gmail.com>2011-12-25 16:33:50 +0000
commitbf9af8ac0ec29b5c03717c21c37bc8ca018066ca (patch)
treebc5126550fb60f8e65c3e08b5c7b73c53b811572
parent23e6413da8152658a969d8c01ab726b4297148d5 (diff)
downloadlcd4linux-bf9af8ac0ec29b5c03717c21c37bc8ca018066ca.tar.gz
Import upstream version 0.11.0~svn1164
-rwxr-xr-xdrv_D4D.c446
-rw-r--r--drv_generic_text.h3
-rw-r--r--lcd4linux_i2c.h3
-rw-r--r--timer.h3
-rw-r--r--widget_bar.h4
-rw-r--r--widget_gpo.h3
-rw-r--r--widget_icon.h3
-rw-r--r--widget_image.h3
-rw-r--r--widget_keypad.h3
-rw-r--r--widget_text.h3
-rw-r--r--widget_timer.h3
11 files changed, 315 insertions, 162 deletions
diff --git a/drv_D4D.c b/drv_D4D.c
index 22e0c73..811fea4 100755
--- a/drv_D4D.c
+++ b/drv_D4D.c
@@ -1,9 +1,9 @@
-/* $Id: drv_D4D.c 1153 2011-07-27 05:12:30Z michael $
+/* $Id: drv_D4D.c 1163 2011-12-09 03:16:17Z sonic74 $
* $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/drv_D4D.c $
*
* LCD4Linux driver for 4D Systems Display Graphics Modules
*
- * Copyright (C) 2008 Sven Killig <sven@killig.de>
+ * Copyright (C) 2008, 2011 Sven Killig <sven@killig.de>
* Modified from sample code by:
* Copyright (C) 2005 Michael Reinelt <michael@reinelt.co.at>
* Copyright (C) 2005, 2006, 2007 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
@@ -61,9 +61,12 @@
#include "drv_generic_graphic.h"
#include "drv_generic_serial.h"
+#include <sys/ioctl.h>
+#include <linux/serial.h>
+
static char Name[] = "D4D";
char NAME_[20];
-int FONT = 1, MODE = 0, EXTRA = 0, SECTOR = 0, SECTOR_SIZE, NOPOWERCYCLE = 0;
+int FONT = 1, MODE = 0, EXTRA = 0, SECTOR = 0, SECTOR_SIZE, POWERCYCLE = 0;
/* int CONTRAST_; */
#define address_mmsb(variable) ((variable >> 24) & 0xFF)
@@ -98,24 +101,6 @@ int RGB_24to8(int red, int grn, int blu)
/****************************************/
-static int drv_D4D_open(const char *section)
-{
- int fd;
- fd = drv_generic_serial_open(section, Name, 0);
- if (fd < 0)
- return -1;
- fcntl(fd, F_SETFL, 0); /* blocking read */
- return 0;
-}
-
-
-static int drv_D4D_close(void)
-{
- drv_generic_serial_close();
- return 0;
-}
-
-
static void drv_D4D_receive_ACK()
{
char ret[1];
@@ -128,8 +113,11 @@ static void drv_D4D_receive_ACK()
}
}
+
static void drv_D4D_send_nowait(const char *data, const unsigned int len)
{
+ if (len > 1 && data[0] >= 32 && data[0] < 127)
+ debug("drv_D4D_send_nowait('%c'", data[0]);
drv_generic_serial_write(data, len);
}
@@ -139,32 +127,156 @@ static void drv_D4D_send(const char *data, const unsigned int len)
drv_D4D_receive_ACK();
}
-static void drv_D4D_send_nowait_extra(const char *data, const unsigned int len, unsigned char pos1, unsigned char pos2)
+static void drv_D4D_send_extra_nowait(const char *data, const unsigned int len, unsigned char pos1, unsigned char pos2,
+ unsigned char pos3, unsigned char pos4)
{
- /* possibly leave out bytes at pos1 and pos2 for older protocol format */
+ /* possibly leave out bytes at posn for GOLDELOX protocol format */
if (EXTRA) {
drv_D4D_send_nowait(data, len);
} else {
- unsigned int i;
- char send[1];
+ unsigned int i, j = 0, lenNew = len;
+ char send[len];
for (i = 0; i < len; i++) {
- if (!pos1 || i != pos1) {
- if (!pos2 || i != pos2) {
- send[0] = data[i];
- drv_generic_serial_write(send, 1);
- }
+ if (i != pos1 && i != pos2 && i != pos3 && i != pos4) {
+ send[j++] = data[i];
+ } else {
+ lenNew--;
}
}
+ drv_D4D_send_nowait(send, lenNew);
}
}
-static void drv_D4D_send_extra(const char *data, const unsigned int len, char pos1, char pos2)
+static void drv_D4D_send_extra(const char *data, const unsigned int len, unsigned char pos1, unsigned char pos2,
+ unsigned char pos3, unsigned char pos4)
{
- drv_D4D_send_nowait_extra(data, len, pos1, pos2);
+ drv_D4D_send_extra_nowait(data, len, pos1, pos2, pos3, pos4);
drv_D4D_receive_ACK();
}
+static int drv_D4D_open(const char *section)
+{
+ info("drv_D4D_open()");
+ int fd, picaso = 0;
+ struct termios portset;
+ static speed_t Speed = 0;
+ fd = drv_generic_serial_open(section, Name, 0);
+ if (fd < 0)
+ return -1;
+ int flags;
+ flags = fcntl(fd, F_GETFL);
+ flags &= ~FNDELAY;
+ fcntl(fd, F_SETFL, flags);
+
+ cfg_number(section, "PICASO", 0, 1200, 4000000, &picaso);
+ if (picaso) {
+ info("switching to 9600 baud");
+ if (tcgetattr(fd, &portset) == -1) {
+ error("%s: tcgetattr failed: %s", Name, strerror(errno));
+ return -1;
+ }
+ cfsetispeed(&portset, B9600);
+ cfsetospeed(&portset, B9600);
+ if (tcsetattr(fd, TCSANOW, &portset) == -1) {
+ error("%s: tcsetattr failed: %s", Name, strerror(errno));
+ return -1;
+ }
+ }
+
+ char cmd[] = { 'U' };
+ drv_D4D_send(cmd, sizeof(cmd));
+ debug("2");
+
+ if (picaso) {
+ char baud[] = { 'Q', 0 };
+ switch (picaso) {
+ case 1200:
+ Speed = B1200;
+ baud[1] = 0x03;
+ break;
+ case 2400:
+ Speed = B2400;
+ baud[1] = 0x04;
+ break;
+ case 4800:
+ Speed = B4800;
+ baud[1] = 0x05;
+ break;
+ case 9600:
+ Speed = B9600;
+ baud[1] = 0x06;
+ break;
+ case 19200:
+ Speed = B19200;
+ baud[1] = 0x08;
+ break;
+ case 38400:
+ Speed = B38400;
+ baud[1] = 0x0A;
+ break;
+ case 57600:
+ Speed = B57600;
+ baud[1] = 0x0B;
+ break;
+ case 115200:
+ Speed = B115200;
+ baud[1] = 0x0D;
+ break;
+ default:
+ if (picaso >= 128000 && picaso < 256000) { /* FTDI: 129032 */
+ Speed = B38400;
+ baud[1] = 0x0E;
+ break;
+ } else if (picaso >= 256000) { /* FTDI: 282353 */
+ Speed = B38400;
+ baud[1] = 0x0F;
+ break;
+ }
+ error("%s: unsupported speed '%d' from %s", Name, picaso, cfg_source());
+ return -1;
+ }
+ drv_D4D_send_nowait(baud, sizeof(baud));
+ sleep(1);
+ debug("3");
+ cfsetispeed(&portset, Speed);
+ cfsetospeed(&portset, Speed);
+ if (picaso >= 128000) {
+ struct serial_struct sstruct;
+ if (ioctl(fd, TIOCGSERIAL, &sstruct) < 0) {
+ error("Error: could not get comm ioctl\n");
+ return -1;
+ }
+ sstruct.custom_divisor = sstruct.baud_base / picaso;
+ info("baud_base=%d; custom_divisor=%d -> effective baud:%d", sstruct.baud_base, sstruct.custom_divisor,
+ sstruct.baud_base / sstruct.custom_divisor);
+ sstruct.flags |= ASYNC_SPD_CUST;
+ if (ioctl(fd, TIOCSSERIAL, &sstruct) < 0) {
+ error("Error: could not set custom comm baud divisor\n");
+ return -1;
+ }
+ }
+ debug("4");
+ info("switching to %d baud", picaso);
+ if (tcsetattr(fd, /*TCSANOW*/ TCSAFLUSH /*TCSADRAIN*/, &portset) == -1) {
+ error("%s: tcsetattr failed: %s", Name, strerror(errno));
+ return -1;
+ }
+ debug("5");
+
+ }
+
+ return 0;
+}
+
+
+static int drv_D4D_close(void)
+{
+ drv_generic_serial_close();
+ return 0;
+}
+
+
static void drv_D4D_clear(void)
{
char cmd[] = { 'E' };
@@ -213,24 +325,33 @@ static void drv_D4D_write(const int row, const int col, const char *data, int le
cmdNull[0] = 0;
drv_D4D_send(cmdNull, 1);
- char cmd_user[] = { 'D', 0, 0, 0, 0, 0, msb(FG_COLOR), lsb(FG_COLOR) }; /* user defined symbols */
+ /* 1, 2, 3, 4, 5, 6
+ g, c,mx,lx,my,ly */
+ char cmd_user[] = { 'D', 0, 0, 0, 0, 0, 0, msb(FG_COLOR), lsb(FG_COLOR) }; /* user defined symbols */
for (i = 0; i < k; i++) {
cmd_user[2] = user_char[i];
- cmd_user[3] = user_x[i];
- cmd_user[4] = msb(user_y[i]);
- cmd_user[5] = lsb(user_y[i]);
- drv_D4D_send_extra(cmd_user, sizeof(cmd_user), 1, 4);
+ cmd_user[3] = msb(user_x[i]);
+ cmd_user[4] = lsb(user_x[i]);
+ cmd_user[5] = msb(user_y[i]);
+ cmd_user[6] = lsb(user_y[i]);
+ drv_D4D_send_extra(cmd_user, sizeof(cmd_user), 1, 3, 5, -1);
}
} else { /* font on SD card */
int sec;
- char cmd_sd[] = { '@', 'I', 0, msb(row * YRES), lsb(row * YRES), XRES, msb(YRES), lsb(YRES), 16, 0, 0, 0 };
+ /* 2, 3, 4 , 5 , 6 , 7 , 8 , 9 , 10,11,12,13
+ mx,lx, my , ly , mw , lw , mh , lh , cm,hs,ms,ls */
+ char cmd_sd[] =
+ { '@', 'I', 0, 0, msb(row * YRES), lsb(row * YRES), msb(XRES), lsb(XRES), msb(YRES), lsb(YRES), 16, 0, 0,
+ 0
+ };
for (i = 0; i < len; i++) {
- cmd_sd[2] = (col + i) * XRES;
+ cmd_sd[2] = msb((col + i) * XRES);
+ cmd_sd[3] = lsb((col + i) * XRES);
sec = SECTOR + (unsigned char) data[i] * SECTOR_SIZE;
- cmd_sd[9] = address_hi(sec);
- cmd_sd[10] = address_mid(sec);
- cmd_sd[11] = address_lo(sec);
- drv_D4D_send_extra(cmd_sd, sizeof(cmd_sd), 3, 6);
+ cmd_sd[11] = address_hi(sec);
+ cmd_sd[12] = address_mid(sec);
+ cmd_sd[13] = address_lo(sec);
+ drv_D4D_send_extra(cmd_sd, sizeof(cmd_sd), 2, 4, 6, 8);
}
}
}
@@ -238,7 +359,7 @@ static void drv_D4D_write(const int row, const int col, const char *data, int le
static void drv_D4D_defchar(const int ascii, const unsigned char *matrix)
{
- /* error("drv_D4D_defchar"); */
+ info("drv_D4D_defchar");
char cmd[11];
int i;
@@ -249,62 +370,61 @@ static void drv_D4D_defchar(const int ascii, const unsigned char *matrix)
for (i = 0; i < 8; i++) {
cmd[i + 3] = *matrix++;
}
- drv_D4D_send_extra(cmd, sizeof(cmd), 1, 0);
+ drv_D4D_send_extra(cmd, sizeof(cmd), 1, -1, -1, -1);
}
static void drv_D4D_blit(const int row, const int col, const int height, const int width)
{
- /* error("drv_D4D_blit(%i, %i, %i, %i)",row, col, height, width); */
+ debug("drv_D4D_blit(%i, %i, %i, %i)", row, col, height, width);
int r, c;
- RGBA rgb, pixel0_0, pixel;
+ RGBA rgb;
short int color;
- char colorArray[2];
-
+ char colorArray[width * height * MODE / 8];
/* optimization: single colour rectangle? */
- pixel0_0 = drv_generic_graphic_rgb(0, 0);
- char unicolor = 1;
+ /* commented out because obviously seldom used and expensive */
+ /*RGBA pixel0_0, pixel;
+ pixel0_0 = drv_generic_graphic_rgb(row, col);
+ char unicolor = 1;
+ for (r = row; (r < row + height) && unicolor; r++) {
+ for (c = col; (c < col + width) && unicolor; c++) {
+ pixel = drv_generic_graphic_rgb(r, c);
+ if (pixel0_0.R != pixel.R || pixel0_0.G != pixel.G || pixel0_0.B != pixel.B || pixel0_0.A != pixel.A)
+ unicolor = 0;
+ }
+ }
+
+ if (unicolor) {
+ color = RGB_24to16(pixel0_0.R, pixel0_0.G, pixel0_0.B);
+ unsigned char col2 = col + width - 1;
+ unsigned char row2 = row + height - 1;
+ char cmdRect[] =
+ { 'r', msb(col), lsb(col), msb(row), lsb(row), msb(col2), lsb(col2), msb(row2), lsb(row2), msb(color),
+ lsb(color)
+ };
+ debug("Rectangle(%i, %i, %i, %i, %i", col, row, col2, row2, color);
+ drv_D4D_send_extra(cmdRect, sizeof(cmdRect), 1, 3, 5, 7);
+ } else { */
+ char cmd[] =
+ { 'I', msb(col), lsb(col), msb(row), lsb(row), msb(width), lsb(width), msb(height), lsb(height), MODE };
+ int p = 0;
+ drv_D4D_send_extra_nowait(cmd, sizeof(cmd), 1, 3, 5, 7);
for (r = row; r < row + height; r++) {
- if (!unicolor)
- break;
for (c = col; c < col + width; c++) {
- if (!unicolor)
- break;
- pixel = drv_generic_graphic_rgb(r, c);
- if (pixel0_0.R != pixel.R || pixel0_0.G != pixel.G || pixel0_0.B != pixel.B || pixel0_0.A != pixel.A)
- unicolor = 0;
- }
- }
-
- if (unicolor) {
- color = RGB_24to16(pixel0_0.R, pixel0_0.G, pixel0_0.B);
- char row2 = row + height - 1;
- char cmdRect[] =
- { 'r', col, msb(row), lsb(row), col + width - 1, msb(row2), lsb(row2), msb(color), lsb(color) };
- drv_D4D_send_extra(cmdRect, sizeof(cmdRect), 2, 5);
- } else {
- char cmd[] = { 'I', col, msb(row), lsb(row), width, msb(height), lsb(height), MODE };
- drv_D4D_send_nowait_extra(cmd, sizeof(cmd), 2, 5);
- for (r = row; r < row + height; r++) {
- for (c = col; c < col + width; c++) {
- rgb = drv_generic_graphic_rgb(r, c);
- if (MODE == 8) {
- colorArray[0] = RGB_24to8(rgb.R, rgb.G, rgb.B);
- drv_D4D_send_nowait(colorArray, 1);
- } else {
- color = RGB_24to16(rgb.R, rgb.G, rgb.B);
- colorArray[0] = msb(color);
- drv_D4D_send_nowait(colorArray, 1); /* doesn't werk if sent together (error: "partial write(/dev/tts/1): len=2 ret=1") */
- /* colorArray[1]=lsb(color); */
- colorArray[0] = lsb(color);
- drv_D4D_send_nowait(colorArray, 1);
- }
- /* drv_D4D_send_nowait(colorArray, MODE/8); */
+ rgb = drv_generic_graphic_rgb(r, c);
+ if (MODE == 8) {
+ colorArray[p++] = RGB_24to8(rgb.R, rgb.G, rgb.B);
+ } else {
+ color = RGB_24to16(rgb.R, rgb.G, rgb.B);
+ colorArray[p++] = msb(color);
+ colorArray[p++] = lsb(color);
}
}
- drv_D4D_receive_ACK();
}
+ drv_D4D_send_nowait(colorArray, width * height * MODE / 8); /* doesn't werk if sent together (error: "partial write(/dev/tts/1): len=2 ret=1") */
+ drv_D4D_receive_ACK();
+ /*} */
}
@@ -325,7 +445,7 @@ static int drv_D4D_contrast(int contrast)
static int drv_D4D_start(const char *section)
{
- /* error("drv_D4D_start()"); */
+ info("drv_D4D_start()");
int contrast;
int xres_cfg = -1, yres_cfg = -1;
char *s;
@@ -335,14 +455,19 @@ static int drv_D4D_start(const char *section)
return -1;
}
- char cmd[] = { 'U' };
- drv_D4D_send(cmd, sizeof(cmd));
-
-
- char getVersion[] = { 'V', 0 };
+ char getVersion[] = { 'V', 0 /*1 */ };
drv_D4D_send_nowait(getVersion, sizeof(getVersion));
char answer[5];
- drv_generic_serial_read(answer, sizeof(answer));
+ debug("reading answer[0]");
+ drv_generic_serial_read(answer + 0, 1); /* ,5: PICASO 0/1, Speed 9600: error: "partial read(/dev/ttyUSB0): len=5 ret=1" */
+ debug("reading answer[1]");
+ drv_generic_serial_read(answer + 1, 1);
+ debug("reading answer[2]");
+ drv_generic_serial_read(answer + 2, 1);
+ debug("reading answer[3]");
+ drv_generic_serial_read(answer + 3, 1);
+ debug("reading answer[4]");
+ drv_generic_serial_read(answer + 4, 1);
char *ids[] = { "uOLED", "uLCD", "uVGA" };
char *id;
if (answer[0] <= 2)
@@ -380,7 +505,8 @@ static int drv_D4D_start(const char *section)
res[i] = 240;
break;
default:
- error("Can't detect display dimensions!");
+ error("Can't detect display dimensions! answer: {%d, %d, %d, %d, %d}", answer[0], answer[1], answer[2],
+ answer[3], answer[4]);
return -1;
}
}
@@ -390,38 +516,38 @@ static int drv_D4D_start(const char *section)
cfg_number(section, "Mode", 0, 0, 16, &MODE);
- s = cfg_get(section, "Font", NULL);
- if (s == NULL || *s == '\0') {
- error("%s: no '%s.Font' entry from %s", Name, section, cfg_source());
- return -1;
- }
- if (sscanf(s, "%dx%d", &xres_cfg, &yres_cfg) < 1 || xres_cfg < 0) {
- error("%s: bad %s.Font '%s' from %s", Name, section, s, cfg_source());
- free(s);
- return -1;
- }
+ if (MODE == 0) {
+ s = cfg_get(section, "Font", NULL);
+ if (s == NULL || *s == '\0') {
+ error("%s: no '%s.Font' entry from %s", Name, section, cfg_source());
+ return -1;
+ }
+ if (sscanf(s, "%dx%d", &xres_cfg, &yres_cfg) < 1 || xres_cfg < 0) {
+ error("%s: bad %s.Font '%s' from %s", Name, section, s, cfg_source());
+ free(s);
+ return -1;
+ }
- if (yres_cfg == -1) { /* font on SD card */
- SECTOR = xres_cfg * 512;
- char setAddress[] =
- { '@', 'A', address_mmsb(SECTOR), address_mlsb(SECTOR), address_lmsb(SECTOR), address_llsb(SECTOR) };
- drv_D4D_send(setAddress, sizeof(setAddress));
- char answer1[1];
- char readByte[] = { '@', 'r' };
- drv_D4D_send_nowait(readByte, sizeof(readByte));
- drv_generic_serial_read(answer1, sizeof(answer1));
- XRES = answer1[0];
- drv_D4D_send_nowait(readByte, sizeof(readByte));
- drv_generic_serial_read(answer1, sizeof(answer1));
- YRES = answer1[0];
- SECTOR = xres_cfg + 1;
- SECTOR_SIZE = ceil((double) XRES * (double) YRES * 2.0 / 512.0);
- } else {
- XRES = xres_cfg;
- YRES = yres_cfg;
- }
+ if (yres_cfg == -1) { /* font on SD card */
+ SECTOR = xres_cfg * 512;
+ char setAddress[] =
+ { '@', 'A', address_mmsb(SECTOR), address_mlsb(SECTOR), address_lmsb(SECTOR), address_llsb(SECTOR) };
+ drv_D4D_send(setAddress, sizeof(setAddress));
+ char answer1[1];
+ char readByte[] = { '@', 'r' };
+ drv_D4D_send_nowait(readByte, sizeof(readByte));
+ drv_generic_serial_read(answer1, sizeof(answer1));
+ XRES = answer1[0];
+ drv_D4D_send_nowait(readByte, sizeof(readByte));
+ drv_generic_serial_read(answer1, sizeof(answer1));
+ YRES = answer1[0];
+ SECTOR = xres_cfg + 1;
+ SECTOR_SIZE = ceil((double) XRES * (double) YRES * 2.0 / 512.0);
+ } else {
+ XRES = xres_cfg;
+ YRES = yres_cfg;
+ }
- if (MODE == 0) {
color = cfg_get(section, "foreground", "ffffff");
if (color2RGBA(color, &FG_COL_) < 0) {
@@ -474,8 +600,8 @@ static int drv_D4D_start(const char *section)
- cfg_number(section, "NoPowerCycle", 0, 1, 65536, &NOPOWERCYCLE);
- if (!NOPOWERCYCLE) {
+ cfg_number(section, "PowerCycle", 0, 0, 1, &POWERCYCLE);
+ if (POWERCYCLE) {
char powerOn[] = { 'Y', 3, 1 };
drv_D4D_send(powerOn, sizeof(powerOn));
@@ -523,7 +649,7 @@ int drv_D4D_text_draw(WIDGET * W)
}
-int lastVal[40 * 40 * 2]; /* ToDo: MAX_WIDGETS*2 */
+int lastVal[40 * 40 * 2]; /* Fixme: MAX_WIDGETS*2 */
int drv_D4D_bar_draw(WIDGET * W)
{
/* optimizations:
@@ -534,14 +660,14 @@ int drv_D4D_bar_draw(WIDGET * W)
int row, col, len, res, max, val1, val2;
DIRECTION dir;
#if 0
- STYLE style; /* Fixme: unused variable */
+ STYLE style; /* Fixme: missing style support */
#endif
row = W->row;
col = W->col;
dir = Bar->direction;
#if 0
- style = Bar->style; /* Fixme: unused variable */
+ style = Bar->style; /* Fixme: missing style support */
#endif
len = Bar->length;
@@ -567,12 +693,12 @@ int drv_D4D_bar_draw(WIDGET * W)
FG_COLOR = RGB_24to16(fg.R, fg.G, fg.B);
BG_COLOR = RGB_24to16(bg.R, bg.G, bg.B);
- char cmd[9];
+ char cmd[11];
cmd[0] = 'r';
int val[2];
val[0] = val1;
val[1] = val2;
- int i, vals;
+ int i, vals, x1, x2;
int lastValIndex0 = row * DCOLS + col;
int cells = DROWS * DCOLS;
if (val1 == val2 && lastVal[lastValIndex0] == lastVal[lastValIndex0 + cells])
@@ -582,23 +708,33 @@ int drv_D4D_bar_draw(WIDGET * W)
for (i = 0; i < vals; i++) {
int lastValIndex = lastValIndex0 + cells * (i /*+1 */ );
int y1 = row * YRES + (YRES / 2) * i;
- cmd[2] = msb(y1);
- cmd[3] = lsb(y1);
- int y2 = y1 + (YRES) / vals - 1;
- cmd[5] = msb(y2);
- cmd[6] = lsb(y2);
+ cmd[3] = msb(y1);
+ cmd[4] = lsb(y1);
+ int y2 = y1 + YRES / vals - 1;
+ cmd[7] = msb(y2);
+ cmd[8] = lsb(y2);
if (val[i] > lastVal[lastValIndex]) {
- cmd[1] = col * XRES + lastVal[lastValIndex];
- cmd[4] = cmd[1] + val[i] - lastVal[lastValIndex] - 1;
- cmd[7] = msb(FG_COLOR);
- cmd[8] = lsb(FG_COLOR);
- drv_D4D_send_extra(cmd, sizeof(cmd), 2, 5);
+ x1 = col * XRES + lastVal[lastValIndex];
+ cmd[1] = msb(x1);
+ cmd[2] = lsb(x1);
+ x2 = x1 + val[i] - lastVal[lastValIndex] - 1;
+ cmd[5] = msb(x2);
+ cmd[6] = lsb(x2);
+ cmd[9] = msb(FG_COLOR);
+ cmd[10] = lsb(FG_COLOR);
+ drv_D4D_send_extra(cmd, sizeof(cmd), 1, 3, 5, 7);
} else if (val[i] < lastVal[lastValIndex]) {
- cmd[1] = col * XRES + val[i] - 1 + 1;
- cmd[4] = cmd[1] + lastVal[lastValIndex] - val[i];
- cmd[7] = msb(BG_COLOR);
- cmd[8] = lsb(BG_COLOR);
- drv_D4D_send_extra(cmd, sizeof(cmd), 2, 5);
+ x1 = col * XRES + val[i] - 1 + 1;
+ cmd[1] = msb(x1);
+ cmd[2] = lsb(x1);
+ x2 = x1 + lastVal[lastValIndex] - val[i];
+ cmd[5] = msb(x2);
+ cmd[6] = lsb(x2);
+ cmd[9] = msb(BG_COLOR);
+ cmd[10] = lsb(BG_COLOR);
+ drv_D4D_send_extra(cmd, sizeof(cmd), 1, 3, 5, 7);
+ } else {
+ /* do nothing */
}
lastVal[lastValIndex] = val[i];
}
@@ -650,11 +786,11 @@ int drv_D4D_list(void)
int drv_D4D_init(const char *section, const int quiet)
{
- /* error("drv_D4D_init()"); */
+ info("drv_D4D_init()");
WIDGET_CLASS wc;
int ret;
- info("%s: %s", Name, "$Rev: 1153 $");
+ info("%s: %s", Name, "$Rev: 1163 $");
if ((ret = drv_D4D_start(section)) != 0)
return ret;
@@ -732,7 +868,7 @@ int drv_D4D_init(const char *section, const int quiet)
int drv_D4D_quit(const int quiet)
{
- /* error("drv_D4D_quit()"); */
+ info("drv_D4D_quit()");
info("%s: shutting down.", Name);
@@ -740,7 +876,7 @@ int drv_D4D_quit(const int quiet)
drv_generic_text_quit();
- if (!NOPOWERCYCLE) {
+ if (POWERCYCLE) {
drv_D4D_clear();
}
@@ -761,12 +897,18 @@ int drv_D4D_quit(const int quiet)
if (MODE)
drv_generic_graphic_quit();
- if (!NOPOWERCYCLE) {
+ if (POWERCYCLE) {
char powerDown[] = { 'Y', 3, 0 };
drv_D4D_send(powerDown, sizeof(powerDown));
}
- debug("closing connection");
+ if (EXTRA) {
+ info("switching to 9600 baud");
+ char baud[] = { 'Q', 0x06 };
+ drv_D4D_send_nowait(baud, sizeof(baud));
+ }
+
+ info("closing connection");
drv_D4D_close();
return (0);
diff --git a/drv_generic_text.h b/drv_generic_text.h
index b37edfc..86a1574 100644
--- a/drv_generic_text.h
+++ b/drv_generic_text.h
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_text.h 840 2007-09-09 12:17:42Z michael $
+/* $Id: drv_generic_text.h 1164 2011-12-22 10:48:01Z mjona $
* $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/drv_generic_text.h $
*
* generic driver helper for text-based displays
@@ -31,6 +31,7 @@
#include "drv_generic.h"
#include "widget.h"
+#include "widget_bar.h"
extern int CHARS, CHAR0; /* number of user-defineable characters, ASCII of first char */
extern int ICONS; /* number of user-defineable characters reserved for icons */
diff --git a/lcd4linux_i2c.h b/lcd4linux_i2c.h
index 14c4508..f6820b3 100644
--- a/lcd4linux_i2c.h
+++ b/lcd4linux_i2c.h
@@ -1,4 +1,4 @@
-/* $Id: lcd4linux_i2c.h 728 2007-01-14 11:14:38Z michael $
+/* $Id: lcd4linux_i2c.h 1164 2011-12-22 10:48:01Z mjona $
* $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/lcd4linux_i2c.h $
*
* user space i2c sturctures and defines, taken from the official kernel i2c
@@ -459,6 +459,7 @@ struct i2c_rdwr_ioctl_data {
#define I2C_RDRW_IOCTL_MAX_MSGS 42
+#include <stdlib.h>
#include <sys/ioctl.h>
static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command, int size, union i2c_smbus_data *data)
diff --git a/timer.h b/timer.h
index c470a10..47aa531 100644
--- a/timer.h
+++ b/timer.h
@@ -1,4 +1,4 @@
-/* $Id: timer.h 1136 2010-11-28 16:07:16Z mzuther $
+/* $Id: timer.h 1164 2011-12-22 10:48:01Z mjona $
* $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/timer.h $
*
* generic timer handling
@@ -28,6 +28,7 @@
#ifndef _TIMER_H_
#define _TIMER_H_
+#include <time.h>
int timer_add(void (*callback) (void *data), void *data, const int interval, const int one_shot);
diff --git a/widget_bar.h b/widget_bar.h
index c50cb6d..ba8a55f 100644
--- a/widget_bar.h
+++ b/widget_bar.h
@@ -1,4 +1,4 @@
-/* $Id: widget_bar.h 840 2007-09-09 12:17:42Z michael $
+/* $Id: widget_bar.h 1164 2011-12-22 10:48:01Z mjona $
* $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/widget_bar.h $
*
* bar widget handling
@@ -29,6 +29,8 @@
#define _WIDGET_BAR_H_
#include "property.h"
+#include "widget.h"
+#include "rgb.h"
typedef enum { DIR_EAST = 1, DIR_WEST = 2, DIR_NORTH = 4, DIR_SOUTH = 8 } DIRECTION;
typedef enum { STYLE_HOLLOW = 1, STYLE_FIRST = 2, STYLE_LAST = 4 } STYLE;
diff --git a/widget_gpo.h b/widget_gpo.h
index d67fdfa..df5eba3 100644
--- a/widget_gpo.h
+++ b/widget_gpo.h
@@ -1,4 +1,4 @@
-/* $Id: widget_gpo.h 840 2007-09-09 12:17:42Z michael $
+/* $Id: widget_gpo.h 1164 2011-12-22 10:48:01Z mjona $
* $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/widget_gpo.h $
*
* GPO widget handling
@@ -29,6 +29,7 @@
#define _WIDGET_GPO_H_
#include "property.h"
+#include "widget.h"
typedef struct WIDGET_GPO {
PROPERTY expression; /* main GPO expression */
diff --git a/widget_icon.h b/widget_icon.h
index 2d61699..31c2378 100644
--- a/widget_icon.h
+++ b/widget_icon.h
@@ -1,4 +1,4 @@
-/* $Id: widget_icon.h 1035 2009-05-19 10:42:01Z michael $
+/* $Id: widget_icon.h 1164 2011-12-22 10:48:01Z mjona $
* $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/widget_icon.h $
*
* icon widget handling
@@ -29,6 +29,7 @@
#define _WIDGET_ICON_H_
#include "property.h"
+#include "widget.h"
typedef struct WIDGET_ICON {
PROPERTY speed; /* update interval (msec) */
diff --git a/widget_image.h b/widget_image.h
index c8a79f4..1e9d0b5 100644
--- a/widget_image.h
+++ b/widget_image.h
@@ -1,4 +1,4 @@
-/* $Id: widget_image.h 840 2007-09-09 12:17:42Z michael $
+/* $Id: widget_image.h 1164 2011-12-22 10:48:01Z mjona $
* $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/widget_image.h $
*
* image widget handling
@@ -29,6 +29,7 @@
#define _WIDGET_IMAGE_H_
#include "property.h"
+#include "widget.h"
#include "rgb.h"
typedef struct WIDGET_IMAGE {
diff --git a/widget_keypad.h b/widget_keypad.h
index f825c7f..d0ed1ca 100644
--- a/widget_keypad.h
+++ b/widget_keypad.h
@@ -1,4 +1,4 @@
-/* $Id: widget_keypad.h 748 2007-01-20 05:00:06Z michael $
+/* $Id: widget_keypad.h 1164 2011-12-22 10:48:01Z mjona $
* $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/widget_keypad.h $
*
* keypad widget handling
@@ -29,6 +29,7 @@
#define _WIDGET_KEYPAD_H_
#include "property.h"
+#include "widget.h"
typedef enum {
WIDGET_KEY_UP = 1,
diff --git a/widget_text.h b/widget_text.h
index 858635a..af8b6be 100644
--- a/widget_text.h
+++ b/widget_text.h
@@ -1,4 +1,4 @@
-/* $Id: widget_text.h 1083 2010-01-18 13:12:25Z michael $
+/* $Id: widget_text.h 1164 2011-12-22 10:48:01Z mjona $
* $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/widget_text.h $
*
* simple text widget handling
@@ -29,6 +29,7 @@
#define _WIDGET_TEXT_H_
#include "property.h"
+#include "widget.h"
typedef enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_MARQUEE, ALIGN_AUTOMATIC, ALIGN_PINGPONG_LEFT,
ALIGN_PINGPONG_CENTER, ALIGN_PINGPONG_RIGHT
diff --git a/widget_timer.h b/widget_timer.h
index dece0b8..586cf61 100644
--- a/widget_timer.h
+++ b/widget_timer.h
@@ -1,4 +1,4 @@
-/* $Id: widget_timer.h 840 2007-09-09 12:17:42Z michael $
+/* $Id: widget_timer.h 1164 2011-12-22 10:48:01Z mjona $
* $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/widget_timer.h $
*
* timer widget handling
@@ -29,6 +29,7 @@
#define _WIDGET_TIMER_H_
#include "property.h"
+#include "widget.h"
typedef struct WIDGET_TIMER {
PROPERTY expression; /* main timer expression */