harmonize coding style and messages, add more checks
This commit is contained in:
+95
-82
@@ -126,63 +126,69 @@ CFontz_init (Driver *drvthis)
|
||||
return -1;
|
||||
|
||||
/* Initialize the PrivateData structure */
|
||||
p->fd = -1;
|
||||
p->cellwidth = DEFAULT_CELL_WIDTH;
|
||||
p->cellheight = DEFAULT_CELL_HEIGHT;
|
||||
p->ccmode = standard;
|
||||
|
||||
debug(RPT_INFO, "CFontz: init(%p)", drvthis );
|
||||
debug(RPT_INFO, "CFontz: init(%p)", drvthis);
|
||||
|
||||
/* Read config file */
|
||||
/* Which device should be used */
|
||||
strncpy(p->device, drvthis->config_get_string (drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(p->device));
|
||||
strncpy(p->device, drvthis->config_get_string(drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(p->device));
|
||||
p->device[sizeof(p->device)-1] = '\0';
|
||||
debug (RPT_INFO,"CFontz: Using device: %s", p->device);
|
||||
report(RPT_INFO, "%s: using Device %s", drvthis->name, p->device);
|
||||
|
||||
/* Which size */
|
||||
strncpy(size, drvthis->config_get_string (drvthis->name, "Size", 0, DEFAULT_SIZE), sizeof(size));
|
||||
strncpy(size, drvthis->config_get_string(drvthis->name, "Size", 0, DEFAULT_SIZE), sizeof(size));
|
||||
size[sizeof(size)-1] = '\0';
|
||||
if ((sscanf(size, "%dx%d", &w, &h) != 2)
|
||||
|| (w <= 0) || (w > LCD_MAX_WIDTH)
|
||||
|| (h <= 0) || (h > LCD_MAX_HEIGHT)) {
|
||||
report (RPT_WARNING, "CFontz_init: Cannot read size: %s. Using default value.\n", size);
|
||||
report(RPT_WARNING, "%s: cannot read Size: %s; using default %s",
|
||||
drvthis->name, size, DEFAULT_SIZE);
|
||||
sscanf(DEFAULT_SIZE, "%dx%d", &w, &h);
|
||||
}
|
||||
p->width = w;
|
||||
p->height = h;
|
||||
|
||||
/* Which contrast */
|
||||
tmp = drvthis->config_get_int (drvthis->name, "Contrast", 0, DEFAULT_CONTRAST);
|
||||
tmp = drvthis->config_get_int(drvthis->name, "Contrast", 0, DEFAULT_CONTRAST);
|
||||
if ((tmp < 0) || (tmp > 1000)) {
|
||||
report (RPT_WARNING, "CFontz_init: Contrast must be between 0 and 1000. Using default value.\n");
|
||||
report(RPT_WARNING, "%s: Contrast must be between 0 and 1000; using default %d",
|
||||
drvthis->name, DEFAULT_CONTRAST);
|
||||
tmp = DEFAULT_CONTRAST;
|
||||
}
|
||||
p->contrast = tmp;
|
||||
|
||||
/* Which backlight brightness */
|
||||
tmp = drvthis->config_get_int (drvthis->name, "Brightness", 0, DEFAULT_BRIGHTNESS);
|
||||
tmp = drvthis->config_get_int(drvthis->name, "Brightness", 0, DEFAULT_BRIGHTNESS);
|
||||
if ((tmp < 0) || (tmp > 255)) {
|
||||
report (RPT_WARNING, "CFontz_init: Brightness must be between 0 and 255. Using default value.\n");
|
||||
report(RPT_WARNING, "%s: Brightness must be between 0 and 255; using default %d",
|
||||
drvthis->name, DEFAULT_BRIGHTNESS);
|
||||
tmp = DEFAULT_BRIGHTNESS;
|
||||
}
|
||||
p->brightness = tmp;
|
||||
|
||||
/* Which backlight-off "brightness" */
|
||||
tmp = drvthis->config_get_int (drvthis->name, "OffBrightness", 0, DEFAULT_OFFBRIGHTNESS);
|
||||
tmp = drvthis->config_get_int(drvthis->name, "OffBrightness", 0, DEFAULT_OFFBRIGHTNESS);
|
||||
if ((tmp < 0) || (tmp > 255)) {
|
||||
report (RPT_WARNING, "CFontz_init: OffBrightness must be between 0 and 255. Using default value.\n");
|
||||
report(RPT_WARNING, "%s: OffBrightness must be between 0 and 255; using default %d",
|
||||
drvthis->name, DEFAULT_OFFBRIGHTNESS);
|
||||
tmp = DEFAULT_OFFBRIGHTNESS;
|
||||
}
|
||||
p->offbrightness = tmp;
|
||||
|
||||
/* Which speed */
|
||||
tmp = drvthis->config_get_int (drvthis->name, "Speed", 0, DEFAULT_SPEED);
|
||||
tmp = drvthis->config_get_int(drvthis->name, "Speed", 0, DEFAULT_SPEED);
|
||||
if (tmp == 1200) speed = B1200;
|
||||
else if (tmp == 2400) speed = B2400;
|
||||
else if (tmp == 9600) speed = B9600;
|
||||
else if (tmp == 19200) speed = B19200;
|
||||
else if (tmp == 115200) speed = B115200;
|
||||
else {
|
||||
report (RPT_WARNING, "CFontz_init: Speed must be 1200, 2400, 9600, 19200 or 115200. Using default value.\n");
|
||||
report(RPT_WARNING, "%s: Speed must be 1200, 2400, 9600, 19200 or 115200; using default %d",
|
||||
drvthis->name, DEFAULT_SPEED);
|
||||
speed = DEFAULT_SPEED;
|
||||
}
|
||||
|
||||
@@ -196,14 +202,15 @@ CFontz_init (Driver *drvthis)
|
||||
usb = drvthis->config_get_bool(drvthis->name, "USB", 0, 0);
|
||||
|
||||
/* Set up io port correctly, and open it... */
|
||||
debug( RPT_DEBUG, "CFontz: Opening device: %s", p->device);
|
||||
debug(RPT_DEBUG, "CFontz: Opening device: %s", p->device);
|
||||
p->fd = open(p->device, (usb) ? (O_RDWR | O_NOCTTY) : (O_RDWR | O_NOCTTY | O_NDELAY));
|
||||
if (p->fd == -1) {
|
||||
report (RPT_ERR, "CFontz_init: failed (%s)\n", strerror (errno));
|
||||
report(RPT_ERR, "%s: open(%s) failed (%s)",
|
||||
drvthis->name, p->device, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
tcgetattr (p->fd, &portset);
|
||||
tcgetattr(p->fd, &portset);
|
||||
|
||||
/* We use RAW mode */
|
||||
if (usb) {
|
||||
@@ -232,36 +239,36 @@ CFontz_init (Driver *drvthis)
|
||||
}
|
||||
|
||||
/* Set port speed */
|
||||
cfsetospeed (&portset, speed);
|
||||
cfsetispeed (&portset, B0);
|
||||
cfsetospeed(&portset, speed);
|
||||
cfsetispeed(&portset, B0);
|
||||
|
||||
/* Do it... */
|
||||
tcsetattr (p->fd, TCSANOW, &portset);
|
||||
tcsetattr(p->fd, TCSANOW, &portset);
|
||||
|
||||
/* make sure the frame buffer is there... */
|
||||
p->framebuf = (unsigned char *) malloc(p->width * p->height);
|
||||
if (p->framebuf == NULL) {
|
||||
report(RPT_ERR, "CFontz_init: unable to create p->framebuffer.\n");
|
||||
report(RPT_ERR, "%s: unable to create framebuffer", drvthis->name);
|
||||
return -1;
|
||||
}
|
||||
memset(p->framebuf, ' ', p->width * p->height);
|
||||
|
||||
// Set display-specific stuff..
|
||||
if (reboot) {
|
||||
report (RPT_INFO, "LCDd: rebooting CrystalFontz LCD...\n");
|
||||
CFontz_reboot (drvthis);
|
||||
report(RPT_INFO, "%s: rebooting LCD...", drvthis->name);
|
||||
CFontz_reboot(drvthis);
|
||||
}
|
||||
sleep (1);
|
||||
CFontz_hidecursor (drvthis);
|
||||
CFontz_linewrap (drvthis, 1);
|
||||
CFontz_autoscroll (drvthis, 0);
|
||||
//CFontz_backlight (drvthis, backlight_brightness); // render.c variables should not be used in drivers !
|
||||
CFontz_hidecursor(drvthis);
|
||||
CFontz_linewrap(drvthis, 1);
|
||||
CFontz_autoscroll(drvthis, 0);
|
||||
//CFontz_backlight(drvthis, backlight_brightness); // render.c variables should not be used in drivers !
|
||||
|
||||
CFontz_set_contrast (drvthis, p->contrast);
|
||||
CFontz_set_contrast(drvthis, p->contrast);
|
||||
|
||||
report (RPT_DEBUG, "CFontz_init: done\n");
|
||||
report(RPT_DEBUG, "%s: init() done", drvthis->name);
|
||||
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
@@ -273,7 +280,8 @@ CFontz_close (Driver *drvthis)
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
if (p != NULL) {
|
||||
close(p->fd);
|
||||
if (p->fd >= 0)
|
||||
close(p->fd);
|
||||
|
||||
if (p->framebuf)
|
||||
free(p->framebuf);
|
||||
@@ -323,9 +331,9 @@ CFontz_flush (Driver *drvthis)
|
||||
}
|
||||
|
||||
for (i = 0; i < p->height; i++) {
|
||||
snprintf (out, sizeof(out), "%c%c%c", 17, 0, i);
|
||||
write (p->fd, out, 3);
|
||||
write (p->fd, p->framebuf + (p->width * i), p->width);
|
||||
snprintf(out, sizeof(out), "%c%c%c", 17, 0, i);
|
||||
write(p->fd, out, 3);
|
||||
write(p->fd, p->framebuf + (p->width * i), p->width);
|
||||
}
|
||||
/*
|
||||
snprintf(out, sizeof(out), "%c", 1);
|
||||
@@ -346,13 +354,15 @@ CFontz_chr (Driver *drvthis, int x, int y, unsigned char c)
|
||||
y--;
|
||||
x--;
|
||||
|
||||
if ((x < 0) || (y < 0) || (x >= p->width) || (y >= p->height))
|
||||
return;
|
||||
|
||||
if (c < 32)
|
||||
c += 128;
|
||||
|
||||
// For V2 of the firmware to get the block to display right
|
||||
if (p->newfirmware && c == 255) {
|
||||
if (p->newfirmware && (c == 255))
|
||||
c = 214;
|
||||
}
|
||||
|
||||
p->framebuf[(y * p->width) + x] = c;
|
||||
}
|
||||
@@ -382,15 +392,15 @@ CFontz_set_contrast (Driver *drvthis, int promille)
|
||||
char out[4];
|
||||
|
||||
// Check it
|
||||
if (promille < 0 || promille > 1000)
|
||||
if ((promille < 0) || (promille > 1000))
|
||||
return;
|
||||
|
||||
// Store it
|
||||
p->contrast = promille;
|
||||
|
||||
// And do it
|
||||
snprintf (out, sizeof(out), "%c%c", 15, (unsigned char) (promille / 10) ); // converted to be 0 to 100
|
||||
write (p->fd, out, 3);
|
||||
snprintf(out, sizeof(out), "%c%c", 15, (unsigned char) (promille / 10)); // converted to be 0 to 100
|
||||
write(p->fd, out, 3);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
@@ -402,12 +412,9 @@ CFontz_backlight (Driver *drvthis, int on)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
char out[4];
|
||||
if (on) {
|
||||
snprintf (out, sizeof(out), "%c%c", 14, p->brightness);
|
||||
} else {
|
||||
snprintf (out, sizeof(out), "%c%c", 14, p->offbrightness);
|
||||
}
|
||||
write (p->fd, out, 3);
|
||||
|
||||
snprintf(out, sizeof(out), "%c%c", 14, (on) ? p->brightness : p->offbrightness);
|
||||
write(p->fd, out, 3);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
@@ -419,8 +426,8 @@ CFontz_linewrap (Driver *drvthis, int on)
|
||||
PrivateData *p = drvthis->private_data;
|
||||
char out[4];
|
||||
|
||||
snprintf (out, sizeof(out), "%c", (on) ? 23 : 24);
|
||||
write (p->fd, out, 1);
|
||||
snprintf(out, sizeof(out), "%c", (on) ? 23 : 24);
|
||||
write(p->fd, out, 1);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
@@ -431,8 +438,9 @@ CFontz_autoscroll (Driver *drvthis, int on)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
char out[4];
|
||||
snprintf (out, sizeof(out), "%c", (on) ? 19 : 20);
|
||||
write (p->fd, out, 1);
|
||||
|
||||
snprintf(out, sizeof(out), "%c", (on) ? 19 : 20);
|
||||
write(p->fd, out, 1);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
@@ -443,8 +451,9 @@ CFontz_hidecursor (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
char out[4];
|
||||
snprintf (out, sizeof(out), "%c", 4);
|
||||
write (p->fd, out, 1);
|
||||
|
||||
snprintf(out, sizeof(out), "%c", 4);
|
||||
write(p->fd, out, 1);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
@@ -455,8 +464,9 @@ CFontz_reboot (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
char out[4];
|
||||
snprintf (out, sizeof(out), "%c", 26);
|
||||
write (p->fd, out, 1);
|
||||
|
||||
snprintf(out, sizeof(out), "%c", 26);
|
||||
write(p->fd, out, 1);
|
||||
sleep(4);
|
||||
}
|
||||
|
||||
@@ -539,13 +549,13 @@ CFontz_init_vbar (Driver *drvthis)
|
||||
};
|
||||
|
||||
if (p->ccmode != vbar) {
|
||||
CFontz_set_char (drvthis, 1, a);
|
||||
CFontz_set_char (drvthis, 2, b);
|
||||
CFontz_set_char (drvthis, 3, c);
|
||||
CFontz_set_char (drvthis, 4, d);
|
||||
CFontz_set_char (drvthis, 5, e);
|
||||
CFontz_set_char (drvthis, 6, f);
|
||||
CFontz_set_char (drvthis, 7, g);
|
||||
CFontz_set_char(drvthis, 1, a);
|
||||
CFontz_set_char(drvthis, 2, b);
|
||||
CFontz_set_char(drvthis, 3, c);
|
||||
CFontz_set_char(drvthis, 4, d);
|
||||
CFontz_set_char(drvthis, 5, e);
|
||||
CFontz_set_char(drvthis, 6, f);
|
||||
CFontz_set_char(drvthis, 7, g);
|
||||
p->ccmode = vbar;
|
||||
}
|
||||
}
|
||||
@@ -620,12 +630,12 @@ CFontz_init_hbar (Driver *drvthis)
|
||||
};
|
||||
|
||||
if (p->ccmode != hbar) {
|
||||
CFontz_set_char (drvthis, 1, a);
|
||||
CFontz_set_char (drvthis, 2, b);
|
||||
CFontz_set_char (drvthis, 3, c);
|
||||
CFontz_set_char (drvthis, 4, d);
|
||||
CFontz_set_char (drvthis, 5, e);
|
||||
CFontz_set_char (drvthis, 6, f);
|
||||
CFontz_set_char(drvthis, 1, a);
|
||||
CFontz_set_char(drvthis, 2, b);
|
||||
CFontz_set_char(drvthis, 3, c);
|
||||
CFontz_set_char(drvthis, 4, d);
|
||||
CFontz_set_char(drvthis, 5, e);
|
||||
CFontz_set_char(drvthis, 6, f);
|
||||
p->ccmode = hbar;
|
||||
}
|
||||
}
|
||||
@@ -687,8 +697,8 @@ CFontz_set_char (Driver *drvthis, int n, char *dat)
|
||||
if (!dat)
|
||||
return;
|
||||
|
||||
snprintf (out, sizeof(out), "%c%c", 25, n);
|
||||
write (p->fd, out, 2);
|
||||
snprintf(out, sizeof(out), "%c%c", 25, n);
|
||||
write(p->fd, out, 2);
|
||||
|
||||
for (row = 0; row < p->cellheight; row++) {
|
||||
letter = 0;
|
||||
@@ -696,7 +706,7 @@ CFontz_set_char (Driver *drvthis, int n, char *dat)
|
||||
letter <<= 1;
|
||||
letter |= (dat[(row * p->cellheight) + col] > 0);
|
||||
}
|
||||
write (p->fd, &letter, 1);
|
||||
write(p->fd, &letter, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -747,17 +757,17 @@ CFontz_icon (Driver *drvthis, int x, int y, int icon)
|
||||
if (p->ccmode == bignum)
|
||||
p->ccmode = standard;
|
||||
|
||||
switch( icon ) {
|
||||
switch (icon) {
|
||||
case ICON_BLOCK_FILLED:
|
||||
CFontz_chr(drvthis, x, y, 255 );
|
||||
CFontz_chr(drvthis, x, y, 255);
|
||||
break;
|
||||
case ICON_HEART_FILLED:
|
||||
CFontz_set_char(drvthis, 0, icons[1] );
|
||||
CFontz_chr(drvthis, x, y, 0 );
|
||||
CFontz_set_char(drvthis, 0, icons[1]);
|
||||
CFontz_chr(drvthis, x, y, 0);
|
||||
break;
|
||||
case ICON_HEART_OPEN:
|
||||
CFontz_set_char(drvthis, 0, icons[0] );
|
||||
CFontz_chr(drvthis, x, y, 0 );
|
||||
CFontz_set_char(drvthis, 0, icons[0]);
|
||||
CFontz_chr(drvthis, x, y, 0);
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
@@ -772,7 +782,8 @@ MODULE_EXPORT void
|
||||
CFontz_clear (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
memset (p->framebuf, ' ', p->width * p->height);
|
||||
|
||||
memset(p->framebuf, ' ', p->width * p->height);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
@@ -789,17 +800,19 @@ CFontz_string (Driver *drvthis, int x, int y, unsigned char string[])
|
||||
x--;
|
||||
y--;
|
||||
|
||||
for (i = 0; string[i] != '\0'; i++) {
|
||||
if ((y < 0) || (y >= p->height))
|
||||
return;
|
||||
|
||||
for (i = 0; (string[i] != '\0') && (x < p->width); i++, x++) {
|
||||
unsigned char c = string[i];
|
||||
|
||||
// For V2 of the firmware to get the block to display right
|
||||
if (p->newfirmware && string[i] == 255) {
|
||||
string[i] = 214;
|
||||
}
|
||||
if (p->newfirmware && (c == 255))
|
||||
c = 214;
|
||||
|
||||
// Check for buffer overflows...
|
||||
if ((y * p->width) + x + i > (p->width * p->height))
|
||||
break;
|
||||
p->framebuf[(y * p->width) + x + i] = string[i];
|
||||
if (x >= 0)
|
||||
p->framebuf[(y * p->width) + x] = c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+67
-61
@@ -154,66 +154,67 @@ CFontz633_init (Driver *drvthis)
|
||||
return -1;
|
||||
|
||||
/* Initialize the PrivateData structure */
|
||||
p->fd = -1;
|
||||
p->cellwidth = DEFAULT_CELL_WIDTH;
|
||||
p->cellheight = DEFAULT_CELL_HEIGHT;
|
||||
p->ccmode = standard;
|
||||
|
||||
debug(RPT_INFO, "%s(%p)", __FUNCTION__, drvthis );
|
||||
debug(RPT_INFO, "%s(%p)", __FUNCTION__, drvthis);
|
||||
|
||||
EmptyKeyRing(&keyring);
|
||||
EmptyReceiveBuffer(&receivebuffer);
|
||||
|
||||
/* Read config file */
|
||||
/* Which device should be used */
|
||||
strncpy(p->device, drvthis->config_get_string (drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(p->device));
|
||||
strncpy(p->device, drvthis->config_get_string(drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(p->device));
|
||||
p->device[sizeof(p->device)-1] = '\0';
|
||||
debug (RPT_INFO,"%s: Device (in config) is: '%s'", __FUNCTION__, p->device);
|
||||
report(RPT_INFO, "%s: using Device %s", drvthis->name, p->device);
|
||||
|
||||
/* Which size */
|
||||
strncpy(size, drvthis->config_get_string (drvthis->name, "Size", 0, DEFAULT_SIZE), sizeof(size));
|
||||
strncpy(size, drvthis->config_get_string(drvthis->name, "Size", 0, DEFAULT_SIZE), sizeof(size));
|
||||
size[sizeof(size)-1] = '\0';
|
||||
if ((sscanf(size, "%dx%d", &w, &h) != 2)
|
||||
|| (w <= 0) || (w > LCD_MAX_WIDTH)
|
||||
|| (h <= 0) || (h > LCD_MAX_HEIGHT)) {
|
||||
report (RPT_WARNING, "%s: Cannot parse size: %s. Using default %s.\n",
|
||||
__FUNCTION__, size, DEFAULT_SIZE);
|
||||
report(RPT_WARNING, "%s: cannot parse Size: %s; using default %s",
|
||||
drvthis->name, size, DEFAULT_SIZE);
|
||||
sscanf(DEFAULT_SIZE, "%dx%d", &w, &h);
|
||||
}
|
||||
p->width = w;
|
||||
p->height = h;
|
||||
|
||||
/* Which contrast */
|
||||
tmp = drvthis->config_get_int (drvthis->name, "Contrast", 0, DEFAULT_CONTRAST);
|
||||
tmp = drvthis->config_get_int(drvthis->name, "Contrast", 0, DEFAULT_CONTRAST);
|
||||
if ((tmp < 0) || (tmp > 1000)) {
|
||||
report (RPT_WARNING, "%s: Contrast must be between 0 and 1000. Using default %d.\n",
|
||||
__FUNCTION__, DEFAULT_CONTRAST);
|
||||
report(RPT_WARNING, "%s: Contrast must be between 0 and 1000; using default %d",
|
||||
drvthis->name, DEFAULT_CONTRAST);
|
||||
tmp = DEFAULT_CONTRAST;
|
||||
}
|
||||
p->contrast = tmp;
|
||||
|
||||
/* Which backlight brightness */
|
||||
tmp = drvthis->config_get_int (drvthis->name, "Brightness", 0, DEFAULT_BRIGHTNESS);
|
||||
tmp = drvthis->config_get_int(drvthis->name, "Brightness", 0, DEFAULT_BRIGHTNESS);
|
||||
if ((tmp < 0) || (tmp > 1000)) {
|
||||
report (RPT_WARNING, "%s: Brightness must be between 0 and 1000. Using default %d.\n",
|
||||
__FUNCTION__, DEFAULT_BRIGHTNESS);
|
||||
report(RPT_WARNING, "%s: Brightness must be between 0 and 1000; using default %d",
|
||||
drvthis->name, DEFAULT_BRIGHTNESS);
|
||||
tmp = DEFAULT_BRIGHTNESS;
|
||||
}
|
||||
p->brightness = tmp;
|
||||
|
||||
/* Which backlight-off "brightness" */
|
||||
tmp = drvthis->config_get_int (drvthis->name, "OffBrightness", 0, DEFAULT_OFFBRIGHTNESS);
|
||||
tmp = drvthis->config_get_int(drvthis->name, "OffBrightness", 0, DEFAULT_OFFBRIGHTNESS);
|
||||
if ((tmp < 0) || (tmp > 1000)) {
|
||||
report (RPT_WARNING, "%s: OffBrightness must be between 0 and 1000. Using default %d.\n",
|
||||
__FUNCTION__, DEFAULT_OFFBRIGHTNESS);
|
||||
report(RPT_WARNING, "%s: OffBrightness must be between 0 and 1000; using default %d",
|
||||
drvthis->name, DEFAULT_OFFBRIGHTNESS);
|
||||
tmp = DEFAULT_OFFBRIGHTNESS;
|
||||
}
|
||||
p->offbrightness = tmp;
|
||||
|
||||
/* Which speed */
|
||||
tmp = drvthis->config_get_int (drvthis->name, "Speed", 0, DEFAULT_SPEED);
|
||||
tmp = drvthis->config_get_int(drvthis->name, "Speed", 0, DEFAULT_SPEED);
|
||||
if ((tmp != 1200) && (tmp != 2400) && (tmp != 9600) && (tmp != 19200) && (tmp != 115200)) {
|
||||
report (RPT_WARNING, "%s: Speed must be 1200, 2400, 9600, 19200 or 115200. Using default %d.\n",
|
||||
__FUNCTION__, DEFAULT_SPEED);
|
||||
report(RPT_WARNING, "%s: Speed must be 1200, 2400, 9600, 19200 or 115200; using default %d",
|
||||
drvthis->name, DEFAULT_SPEED);
|
||||
tmp = DEFAULT_SPEED;
|
||||
}
|
||||
if (tmp == 1200) p->speed = B1200;
|
||||
@@ -235,14 +236,14 @@ CFontz633_init (Driver *drvthis)
|
||||
p->usb = drvthis->config_get_bool(drvthis->name, "USB", 0, 0);
|
||||
|
||||
/* Set up io port correctly, and open it... */
|
||||
debug( RPT_DEBUG, "%s: Opening device: %s", __FUNCTION__, p->device);
|
||||
debug(RPT_DEBUG, "%s: Opening device: %s", __FUNCTION__, p->device);
|
||||
p->fd = open(p->device, (p->usb) ? (O_RDWR | O_NOCTTY) : (O_RDWR | O_NOCTTY | O_NDELAY));
|
||||
if (p->fd == -1) {
|
||||
report (RPT_ERR, "%s: open() failed (%s)\n", __FUNCTION__, strerror (errno));
|
||||
report(RPT_ERR, "%s: open(%s) failed (%s)", drvthis->name, p->device, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
tcgetattr (p->fd, &portset);
|
||||
tcgetattr(p->fd, &portset);
|
||||
|
||||
/* We use RAW mode */
|
||||
if (p->usb) {
|
||||
@@ -252,7 +253,7 @@ CFontz633_init (Driver *drvthis)
|
||||
portset.c_oflag &= ~OPOST;
|
||||
portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN );
|
||||
portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS );
|
||||
portset.c_cflag |= CS8 | CREAD | CLOCAL ;
|
||||
portset.c_cflag |= CS8 | CREAD | CLOCAL;
|
||||
portset.c_cc[VMIN] = 0;
|
||||
portset.c_cc[VTIME] = 0;
|
||||
} else {
|
||||
@@ -266,21 +267,21 @@ CFontz633_init (Driver *drvthis)
|
||||
portset.c_oflag &= ~OPOST;
|
||||
portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN );
|
||||
portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS );
|
||||
portset.c_cflag |= CS8 | CREAD | CLOCAL ;
|
||||
portset.c_cflag |= CS8 | CREAD | CLOCAL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Set port speed */
|
||||
cfsetospeed (&portset, p->speed);
|
||||
cfsetispeed (&portset, B0);
|
||||
cfsetospeed(&portset, p->speed);
|
||||
cfsetispeed(&portset, B0);
|
||||
|
||||
/* Do it... */
|
||||
tcsetattr (p->fd, TCSANOW, &portset);
|
||||
tcsetattr(p->fd, TCSANOW, &portset);
|
||||
|
||||
/* make sure the frame buffer is there... */
|
||||
p->framebuf = (unsigned char *) malloc(p->width * p->height);
|
||||
if (p->framebuf == NULL) {
|
||||
report(RPT_ERR, "%s: unable to create framebuffer.\n", __FUNCTION__);
|
||||
report(RPT_ERR, "%s: unable to create framebuffer", drvthis->name);
|
||||
return -1;
|
||||
}
|
||||
memset(p->framebuf, ' ', p->width * p->height);
|
||||
@@ -288,24 +289,25 @@ CFontz633_init (Driver *drvthis)
|
||||
/* make sure the framebuffer backing store is there... */
|
||||
p->backingstore = (unsigned char *) malloc(p->width * p->height);
|
||||
if (p->backingstore == NULL) {
|
||||
report(RPT_ERR, "%s: unable to create framebuffer backing store.\n", __FUNCTION__);
|
||||
report(RPT_ERR, "%s: unable to create framebuffer backing store", drvthis->name);
|
||||
return -1;
|
||||
}
|
||||
memset(p->backingstore, ' ', p->width * p->height);
|
||||
|
||||
/* Set display-specific stuff.. */
|
||||
if (reboot) {
|
||||
CFontz633_reboot (drvthis);
|
||||
report(RPT_INFO, "%s: rebooting LCD...", drvthis->name);
|
||||
CFontz633_reboot(drvthis);
|
||||
reboot = 0;
|
||||
}
|
||||
|
||||
CFontz633_hidecursor (drvthis);
|
||||
CFontz633_hidecursor(drvthis);
|
||||
|
||||
CFontz633_set_contrast (drvthis, p->contrast);
|
||||
CFontz633_no_live_report (drvthis);
|
||||
CFontz633_hardware_clear (drvthis);
|
||||
CFontz633_set_contrast(drvthis, p->contrast);
|
||||
CFontz633_no_live_report(drvthis);
|
||||
CFontz633_hardware_clear(drvthis);
|
||||
|
||||
report (RPT_DEBUG, "%s: done\n", __FUNCTION__);
|
||||
report(RPT_DEBUG, "%s: init() done", drvthis->name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -320,7 +322,8 @@ CFontz633_close (Driver *drvthis)
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
if (p != NULL) {
|
||||
close(p->fd);
|
||||
if (p->fd >= 0)
|
||||
close(p->fd);
|
||||
|
||||
if (p->framebuf)
|
||||
free(p->framebuf);
|
||||
@@ -443,9 +446,7 @@ MODULE_EXPORT const char *
|
||||
CFontz633_get_key (Driver *drvthis)
|
||||
{
|
||||
// PrivateData *p = drvthis->private_data;
|
||||
unsigned char key;
|
||||
|
||||
key = GetKeyFromKeyRing(&keyring);
|
||||
unsigned char key = GetKeyFromKeyRing(&keyring);
|
||||
|
||||
switch (key) {
|
||||
case CF633_KEY_LEFT:
|
||||
@@ -468,7 +469,7 @@ CFontz633_get_key (Driver *drvthis)
|
||||
break;
|
||||
default:
|
||||
if (key != '\0')
|
||||
report( RPT_INFO, "cfontz633: Untreated key 0x%2x", key);
|
||||
report(RPT_INFO, "%s: Untreated key 0x%02X", drvthis->name, key);
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
@@ -488,7 +489,8 @@ CFontz633_chr (Driver *drvthis, int x, int y, char c)
|
||||
y--;
|
||||
x--;
|
||||
|
||||
p->framebuf[(y * p->width) + x] = c;
|
||||
if ((x >= 0) && (y >= 0) && (x < p->width) && (y < p->height))
|
||||
p->framebuf[(y * p->width) + x] = c;
|
||||
}
|
||||
|
||||
|
||||
@@ -729,18 +731,19 @@ CFontz633_init_vbar (Driver *drvthis)
|
||||
if (p->ccmode != vbar) {
|
||||
//if (p->ccmode != standard) {
|
||||
// /* Not supported(yet) */
|
||||
// report(RPT_WARNING, "CFontz633_init_vbar: Cannot combine two modes using user defined characters");
|
||||
// report(RPT_WARNING, "%s: init_vbar: cannot combine two modes using user defined characters"
|
||||
// drvthis->name);
|
||||
// return;
|
||||
//}
|
||||
p->ccmode = vbar;
|
||||
|
||||
CFontz633_set_char (drvthis, 1, a);
|
||||
CFontz633_set_char (drvthis, 2, b);
|
||||
CFontz633_set_char (drvthis, 3, c);
|
||||
CFontz633_set_char (drvthis, 4, d);
|
||||
CFontz633_set_char (drvthis, 5, e);
|
||||
CFontz633_set_char (drvthis, 6, f);
|
||||
CFontz633_set_char (drvthis, 7, g);
|
||||
CFontz633_set_char(drvthis, 1, a);
|
||||
CFontz633_set_char(drvthis, 2, b);
|
||||
CFontz633_set_char(drvthis, 3, c);
|
||||
CFontz633_set_char(drvthis, 4, d);
|
||||
CFontz633_set_char(drvthis, 5, e);
|
||||
CFontz633_set_char(drvthis, 6, f);
|
||||
CFontz633_set_char(drvthis, 7, g);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -816,17 +819,18 @@ CFontz633_init_hbar (Driver *drvthis)
|
||||
if (p->ccmode != hbar) {
|
||||
//if (p->ccmode != standard) {
|
||||
// /* Not supported(yet) */
|
||||
// report(RPT_WARNING, "CFontz633_init_hbar: Cannot combine two modes using user defined characters");
|
||||
// report(RPT_WARNING, "%s: init_hbar: Cannot combine two modes using user defined characters",
|
||||
// drvthis->name);
|
||||
// return;
|
||||
//}
|
||||
p->ccmode = hbar;
|
||||
|
||||
CFontz633_set_char (drvthis, 1, a);
|
||||
CFontz633_set_char (drvthis, 2, b);
|
||||
CFontz633_set_char (drvthis, 3, c);
|
||||
CFontz633_set_char (drvthis, 4, d);
|
||||
CFontz633_set_char (drvthis, 5, e);
|
||||
CFontz633_set_char (drvthis, 6, f);
|
||||
CFontz633_set_char(drvthis, 1, a);
|
||||
CFontz633_set_char(drvthis, 2, b);
|
||||
CFontz633_set_char(drvthis, 3, c);
|
||||
CFontz633_set_char(drvthis, 4, d);
|
||||
CFontz633_set_char(drvthis, 5, e);
|
||||
CFontz633_set_char(drvthis, 6, f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -880,8 +884,8 @@ CFontz633_num (Driver *drvthis, int x, int num)
|
||||
PrivateData *p = drvthis->private_data;
|
||||
unsigned char out[5];
|
||||
|
||||
snprintf (out, sizeof(out), "%c%c%c", 28, x, num);
|
||||
write (p->fd, out, 3);
|
||||
snprintf(out, sizeof(out), "%c%c%c", 28, x, num);
|
||||
write(p->fd, out, 3);
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -1110,11 +1114,13 @@ CFontz633_string (Driver *drvthis, int x, int y, char string[])
|
||||
x--;
|
||||
y--;
|
||||
|
||||
for (i = 0; string[i] != '\0'; i++) {
|
||||
if ((y < 0) || (y >= p->height))
|
||||
return;
|
||||
|
||||
for (i = 0; (string[i] != '\0') && (x < p->width); i++, x++) {
|
||||
/* Check for buffer overflows... */
|
||||
if ((y * p->width) + x + i > (p->width * p->height))
|
||||
break;
|
||||
p->framebuf[(y * p->width) + x + i] = string[i];
|
||||
if (x >= 0)
|
||||
p->framebuf[(y * p->width) + x] = string[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -194,31 +194,32 @@ CFontzPacket_init (Driver *drvthis)
|
||||
return -1;
|
||||
|
||||
/* Initialize the PrivateData structure */
|
||||
p->fd = -1;
|
||||
p->cellwidth = DEFAULT_CELL_WIDTH;
|
||||
p->cellheight = DEFAULT_CELL_HEIGHT;
|
||||
p->ccmode = standard;
|
||||
p->LEDstate = 0xFFFF;
|
||||
|
||||
debug(RPT_INFO, "%s(%p)", __FUNCTION__, drvthis );
|
||||
debug(RPT_INFO, "%s(%p)", __FUNCTION__, drvthis);
|
||||
|
||||
EmptyKeyRing(&keyring);
|
||||
EmptyReceiveBuffer(&receivebuffer);
|
||||
|
||||
/* Read config file */
|
||||
/* Which model is it (CF633, CF631 or CF635)? */
|
||||
tmp = drvthis->config_get_int (drvthis->name, "Model", 0, 633);
|
||||
debug (RPT_INFO, "%s: Model (in config) is '%d'", __FUNCTION__, tmp);
|
||||
tmp = drvthis->config_get_int(drvthis->name, "Model", 0, 633);
|
||||
debug(RPT_INFO, "%s: Model (in config) is '%d'", __FUNCTION__, tmp);
|
||||
if ((tmp != 631) && (tmp != 633) && (tmp != 635)) {
|
||||
tmp = 633;
|
||||
report (RPT_WARNING, "%s: Model must be 631, 633 or 635. Using default %d.\n",
|
||||
__FUNCTION__, tmp);
|
||||
report(RPT_WARNING, "%s: Model must be 631, 633 or 635; using default %d",
|
||||
drvthis->name, tmp);
|
||||
}
|
||||
p->model = tmp;
|
||||
|
||||
/* Which device should be used */
|
||||
strncpy(p->device, drvthis->config_get_string (drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(p->device));
|
||||
strncpy(p->device, drvthis->config_get_string(drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(p->device));
|
||||
p->device[sizeof(p->device)-1] = '\0';
|
||||
debug (RPT_INFO, "%s: Device (in config) is '%s'", __FUNCTION__, p->device);
|
||||
report(RPT_INFO, "%s: using Device %s", drvthis->name, p->device);
|
||||
|
||||
/* Which size */
|
||||
if (p->model == 631) {
|
||||
@@ -232,57 +233,57 @@ CFontzPacket_init (Driver *drvthis)
|
||||
default_speed = DEFAULT_SPEED_CF635;
|
||||
}
|
||||
|
||||
strncpy(size, drvthis->config_get_string (drvthis->name, "Size", 0, default_size), sizeof(size));
|
||||
strncpy(size, drvthis->config_get_string(drvthis->name, "Size", 0, default_size), sizeof(size));
|
||||
size[sizeof(size)-1] = '\0';
|
||||
debug (RPT_INFO, "%s: Size (in config) is '%s'", __FUNCTION__, size);
|
||||
debug(RPT_INFO, "%s: Size (in config) is '%s'", __FUNCTION__, size);
|
||||
if ((sscanf(size, "%dx%d", &w, &h) != 2)
|
||||
|| (w <= 0) || (w > LCD_MAX_WIDTH)
|
||||
|| (h <= 0) || (h > LCD_MAX_HEIGHT)) {
|
||||
report (RPT_WARNING, "%s: Cannot parse size: %s. Using default %s.\n",
|
||||
__FUNCTION__, size, default_size);
|
||||
report(RPT_WARNING, "%s: cannot parse Size: %s; using default %s",
|
||||
drvthis->name, size, default_size);
|
||||
sscanf(default_size, "%dx%d", &w, &h);
|
||||
}
|
||||
p->width = w;
|
||||
p->height = h;
|
||||
|
||||
debug (RPT_INFO, "%s: Size used: %dx%d", __FUNCTION__, p->width, p->height);
|
||||
debug(RPT_INFO, "%s: Size used: %dx%d", __FUNCTION__, p->width, p->height);
|
||||
|
||||
/* Which contrast */
|
||||
tmp = drvthis->config_get_int (drvthis->name, "Contrast", 0, DEFAULT_CONTRAST);
|
||||
debug (RPT_INFO, "%s: Contrast (in config) is '%d'", __FUNCTION__, tmp);
|
||||
tmp = drvthis->config_get_int(drvthis->name, "Contrast", 0, DEFAULT_CONTRAST);
|
||||
debug(RPT_INFO, "%s: Contrast (in config) is '%d'", __FUNCTION__, tmp);
|
||||
if ((tmp < 0) || (tmp > 1000)) {
|
||||
report (RPT_WARNING, "%s: Contrast must be between 0 and 1000. Using default %d.\n",
|
||||
__FUNCTION__, DEFAULT_CONTRAST);
|
||||
report(RPT_WARNING, "%s: Contrast must be between 0 and 1000; using default %d",
|
||||
drvthis->name, DEFAULT_CONTRAST);
|
||||
tmp = DEFAULT_CONTRAST;
|
||||
}
|
||||
p->contrast = tmp;
|
||||
|
||||
/* Which backlight brightness */
|
||||
tmp = drvthis->config_get_int (drvthis->name, "Brightness", 0, DEFAULT_BRIGHTNESS);
|
||||
debug (RPT_INFO, "%s: Brightness (in config) is '%d'", __FUNCTION__, tmp);
|
||||
tmp = drvthis->config_get_int(drvthis->name, "Brightness", 0, DEFAULT_BRIGHTNESS);
|
||||
debug(RPT_INFO, "%s: Brightness (in config) is '%d'", __FUNCTION__, tmp);
|
||||
if ((tmp < 0) || (tmp > 1000)) {
|
||||
report (RPT_WARNING, "%s: Brightness must be between 0 and 1000. Using default %d.\n",
|
||||
__FUNCTION__, DEFAULT_BRIGHTNESS);
|
||||
report(RPT_WARNING, "%s: Brightness must be between 0 and 1000; using default %d",
|
||||
drvthis->name, DEFAULT_BRIGHTNESS);
|
||||
tmp = DEFAULT_BRIGHTNESS;
|
||||
}
|
||||
p->brightness = tmp;
|
||||
|
||||
/* Which backlight-off "brightness" */
|
||||
tmp = drvthis->config_get_int (drvthis->name, "OffBrightness", 0, DEFAULT_OFFBRIGHTNESS);
|
||||
debug (RPT_INFO, "%s: OffBrightness (in config) is '%d'", __FUNCTION__, tmp);
|
||||
tmp = drvthis->config_get_int(drvthis->name, "OffBrightness", 0, DEFAULT_OFFBRIGHTNESS);
|
||||
debug(RPT_INFO, "%s: OffBrightness (in config) is '%d'", __FUNCTION__, tmp);
|
||||
if ((tmp < 0) || (tmp > 1000)) {
|
||||
report (RPT_WARNING, "%s: OffBrightness must be between 0 and 1000. Using default %d.\n",
|
||||
__FUNCTION__, DEFAULT_OFFBRIGHTNESS);
|
||||
report(RPT_WARNING, "%s: OffBrightness must be between 0 and 1000; using default %d",
|
||||
drvthis->name, DEFAULT_OFFBRIGHTNESS);
|
||||
tmp = DEFAULT_OFFBRIGHTNESS;
|
||||
}
|
||||
p->offbrightness = tmp;
|
||||
|
||||
/* Which speed ? CF633 support 19200 only, CF631 & CF635 USB use 115200. */
|
||||
tmp = drvthis->config_get_int (drvthis->name, "Speed", 0, default_speed);
|
||||
debug (RPT_INFO, "%s: Speed (in config) is '%d'", __FUNCTION__, tmp);
|
||||
tmp = drvthis->config_get_int(drvthis->name, "Speed", 0, default_speed);
|
||||
debug(RPT_INFO, "%s: Speed (in config) is '%d'", __FUNCTION__, tmp);
|
||||
if ((tmp != 19200) && (tmp != 115200)) {
|
||||
report (RPT_WARNING, "%s: Speed must be 19200 or 11500. Using default %d.\n",
|
||||
__FUNCTION__, default_speed);
|
||||
report(RPT_WARNING, "%s: Speed must be 19200 or 11500; using default %d",
|
||||
drvthis->name, default_speed);
|
||||
tmp = default_speed;
|
||||
}
|
||||
p->speed = (tmp == 19200) ? B19200 : B115200;
|
||||
@@ -299,13 +300,13 @@ CFontzPacket_init (Driver *drvthis)
|
||||
/* Am I USB or not? */
|
||||
p->usb = drvthis->config_get_bool(drvthis->name, "USB", 0, 0);
|
||||
if (p->usb)
|
||||
report (RPT_INFO, "%s: USB is indicated (in config)", __FUNCTION__);
|
||||
report(RPT_INFO, "%s: USB is indicated (in config)", drvthis->name);
|
||||
|
||||
/* Set up io port correctly, and open it... */
|
||||
debug( RPT_DEBUG, "%s: Opening device: %s", __FUNCTION__, p->device);
|
||||
debug(RPT_DEBUG, "%s: Opening device: %s", __FUNCTION__, p->device);
|
||||
p->fd = open(p->device, (p->usb) ? (O_RDWR | O_NOCTTY) : (O_RDWR | O_NOCTTY | O_NDELAY));
|
||||
if (p->fd == -1) {
|
||||
report (RPT_ERR, "%s: open() failed (%s)\n", __FUNCTION__, strerror (errno));
|
||||
report(RPT_ERR, "%s: open(%s) failed (%s)", drvthis->name, p->device, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -319,7 +320,7 @@ CFontzPacket_init (Driver *drvthis)
|
||||
portset.c_oflag &= ~OPOST;
|
||||
portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN );
|
||||
portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS );
|
||||
portset.c_cflag |= CS8 | CREAD | CLOCAL ;
|
||||
portset.c_cflag |= CS8 | CREAD | CLOCAL;
|
||||
portset.c_cc[VMIN] = 0;
|
||||
portset.c_cc[VTIME] = 0;
|
||||
} else {
|
||||
@@ -333,7 +334,7 @@ CFontzPacket_init (Driver *drvthis)
|
||||
portset.c_oflag &= ~OPOST;
|
||||
portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN );
|
||||
portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS );
|
||||
portset.c_cflag |= CS8 | CREAD | CLOCAL ;
|
||||
portset.c_cflag |= CS8 | CREAD | CLOCAL;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -347,7 +348,7 @@ CFontzPacket_init (Driver *drvthis)
|
||||
/* make sure the frame buffer is there... */
|
||||
p->framebuf = (unsigned char *) malloc(p->width * p->height);
|
||||
if (p->framebuf == NULL) {
|
||||
report(RPT_ERR, "%s: unable to create framebuffer.\n", __FUNCTION__);
|
||||
report(RPT_ERR, "%s: unable to create framebuffer", drvthis->name);
|
||||
return -1;
|
||||
}
|
||||
memset(p->framebuf, ' ', p->width * p->height);
|
||||
@@ -355,29 +356,29 @@ CFontzPacket_init (Driver *drvthis)
|
||||
/* make sure the framebuffer backing store is there... */
|
||||
p->backingstore = (unsigned char *) malloc(p->width * p->height);
|
||||
if (p->backingstore == NULL) {
|
||||
report(RPT_ERR, "%s: unable to create framebuffer backing store.\n", __FUNCTION__);
|
||||
report(RPT_ERR, "%s: unable to create framebuffer backing store", drvthis->name);
|
||||
return -1;
|
||||
}
|
||||
memset(p->backingstore, ' ', p->width * p->height);
|
||||
|
||||
/* Set display-specific stuff.. */
|
||||
if (reboot) {
|
||||
debug(RPT_INFO, "CFontzPacket: reboot requested (in config)\n" );
|
||||
CFontzPacket_reboot (drvthis);
|
||||
report(RPT_INFO, "%s: rebooting LCD...", drvthis->name);
|
||||
CFontzPacket_reboot(drvthis);
|
||||
reboot = 0;
|
||||
debug(RPT_DEBUG, "CFontzPacket: reboot done" );
|
||||
debug(RPT_DEBUG, "%s: reboot done", __FUNCTION__);
|
||||
}
|
||||
|
||||
CFontzPacket_hidecursor (drvthis);
|
||||
CFontzPacket_hidecursor(drvthis);
|
||||
|
||||
CFontzPacket_set_contrast (drvthis, p->contrast);
|
||||
CFontzPacket_no_live_report (drvthis);
|
||||
CFontzPacket_hardware_clear (drvthis);
|
||||
CFontzPacket_set_contrast(drvthis, p->contrast);
|
||||
CFontzPacket_no_live_report(drvthis);
|
||||
CFontzPacket_hardware_clear(drvthis);
|
||||
|
||||
/* turn LEDs off on a CF635 */
|
||||
CFontzPacket_output(drvthis, 0);
|
||||
|
||||
report (RPT_DEBUG, "%s: done\n", __FUNCTION__);
|
||||
report(RPT_DEBUG, "%s: init() done", drvthis->name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -392,7 +393,8 @@ CFontzPacket_close (Driver *drvthis)
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
if (p != NULL) {
|
||||
close(p->fd);
|
||||
if (p->fd >= 0)
|
||||
close(p->fd);
|
||||
|
||||
if (p->framebuf)
|
||||
free(p->framebuf);
|
||||
@@ -502,8 +504,8 @@ CFontzPacket_flush (Driver *drvthis)
|
||||
unsigned char *sp = p->framebuf + (i * p->width);
|
||||
unsigned char *sq = p->backingstore + (i * p->width);
|
||||
|
||||
debug (RPT_DEBUG, "Framebuf: '%.*s'", p->width, sp );
|
||||
debug (RPT_DEBUG, " backingstore: '%.*s'", p->width, sq );
|
||||
debug(RPT_DEBUG, "Framebuf: '%.*s'", p->width, sp);
|
||||
debug(RPT_DEBUG, "Backingstore: '%.*s'", p->width, sq);
|
||||
|
||||
#if defined(CFONTZPACKET_OLD_OPTIMATION)
|
||||
/* Strategy:
|
||||
@@ -512,7 +514,7 @@ CFontzPacket_flush (Driver *drvthis)
|
||||
|
||||
for (j = 0; j < p->width; ) {
|
||||
// skip over identical portions
|
||||
for ( ; *sp == *sq && j < p->width; sp++, sq++, j++ )
|
||||
for ( ; *sp == *sq && j < p->width; sp++, sq++, j++)
|
||||
;
|
||||
|
||||
// deal with the differences
|
||||
@@ -522,7 +524,7 @@ CFontzPacket_flush (Driver *drvthis)
|
||||
int first_diff = j;
|
||||
|
||||
// get length of differing portions
|
||||
for ( ; *sp != *sq && j < p->width; sp++, sq++, j++ )
|
||||
for ( ; *sp != *sq && j < p->width; sp++, sq++, j++)
|
||||
;
|
||||
|
||||
// send the difference to the screen
|
||||
@@ -530,11 +532,11 @@ CFontzPacket_flush (Driver *drvthis)
|
||||
out[0] = first_diff; // column
|
||||
out[1] = i; // line
|
||||
|
||||
debug (RPT_DEBUG, "%s: l=%d c=%d count=%d string='%.*s'",
|
||||
debug(RPT_DEBUG, "%s: l=%d c=%d count=%d string='%.*s'",
|
||||
__FUNCTION__, out[0], out[1], diff_length, diff_length,
|
||||
&p->framebuf[first_diff + (i * p->width)] );
|
||||
&p->framebuf[first_diff + (i * p->width)]);
|
||||
|
||||
memcpy(&out[2], &p->framebuf[first_diff + (i * p->width)], diff_length );
|
||||
memcpy(&out[2], &p->framebuf[first_diff + (i * p->width)], diff_length);
|
||||
send_bytes_message(p->fd, CF633_Send_Data_to_LCD, diff_length + 2, out);
|
||||
}
|
||||
} // j < p->width
|
||||
@@ -565,7 +567,7 @@ CFontzPacket_flush (Driver *drvthis)
|
||||
out[0] = j; // column
|
||||
out[1] = i; // line
|
||||
|
||||
debug (RPT_DEBUG, "%s: l=%d c=%d count=%d string='%.*s'",
|
||||
debug(RPT_DEBUG, "%s: l=%d c=%d count=%d string='%.*s'",
|
||||
__FUNCTION__, out[0], out[1], length, length, sp);
|
||||
|
||||
memcpy(&out[2], sp, length);
|
||||
@@ -584,10 +586,8 @@ CFontzPacket_flush (Driver *drvthis)
|
||||
MODULE_EXPORT const char *
|
||||
CFontzPacket_get_key (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
unsigned char key;
|
||||
|
||||
key = GetKeyFromKeyRing(&keyring);
|
||||
//PrivateData *p = drvthis->private_data;
|
||||
unsigned char key = GetKeyFromKeyRing(&keyring);
|
||||
|
||||
switch (key) {
|
||||
case CFP_KEY_LEFT:
|
||||
@@ -630,12 +630,12 @@ CFontzPacket_get_key (Driver *drvthis)
|
||||
case CFP_KEY_UR_RELEASE:
|
||||
case CFP_KEY_LL_RELEASE:
|
||||
case CFP_KEY_LR_RELEASE:
|
||||
// report( RPT_INFO, "CFontzPacket: Returning key release 0x%2x", key);
|
||||
// report(RPT_INFO, "%s: Ignoring key release 0x%02X", drvthis->name, key);
|
||||
return NULL;
|
||||
break;
|
||||
default:
|
||||
if (key != '\0')
|
||||
report( RPT_INFO, "CFontzPacket: Untreated unknown key 0x%2x", key);
|
||||
report(RPT_INFO, "%s: Untreated key 0x%02X", drvthis->name, key);
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
@@ -655,9 +655,10 @@ CFontzPacket_chr (Driver *drvthis, int x, int y, char c)
|
||||
y--;
|
||||
x--;
|
||||
|
||||
p->framebuf[(y * p->width) + x] = (p->model == 633)
|
||||
? c
|
||||
: CFontz_charmap[(unsigned) c];
|
||||
if ((x >= 0) && (y >= 0) && (x < p->width) && (y < p->height))
|
||||
p->framebuf[(y * p->width) + x] = (p->model == 633)
|
||||
? c
|
||||
: CFontz_charmap[(unsigned) c];
|
||||
}
|
||||
|
||||
|
||||
@@ -673,7 +674,8 @@ CFontzPacket_raw_chr (Driver *drvthis, int x, int y, unsigned char c)
|
||||
y--;
|
||||
x--;
|
||||
|
||||
p->framebuf[(y * p->width) + x] = c;
|
||||
if ((x >= 0) && (y >= 0) && (x < p->width) && (y < p->height))
|
||||
p->framebuf[(y * p->width) + x] = c;
|
||||
}
|
||||
|
||||
|
||||
@@ -921,18 +923,19 @@ CFontzPacket_init_vbar (Driver *drvthis)
|
||||
if (p->ccmode != vbar) {
|
||||
if (p->ccmode != standard) {
|
||||
/* Not supported(yet) */
|
||||
report(RPT_WARNING, "CFontzPacket_init_vbar: Cannot combine two modes using user defined characters");
|
||||
report(RPT_WARNING, "%s: init_vbar: cannot combine two modes using user defined characters",
|
||||
drvthis->name);
|
||||
return;
|
||||
}
|
||||
p->ccmode = vbar;
|
||||
|
||||
CFontzPacket_set_char (drvthis, 1, a);
|
||||
CFontzPacket_set_char (drvthis, 2, b);
|
||||
CFontzPacket_set_char (drvthis, 3, c);
|
||||
CFontzPacket_set_char (drvthis, 4, d);
|
||||
CFontzPacket_set_char (drvthis, 5, e);
|
||||
CFontzPacket_set_char (drvthis, 6, f);
|
||||
CFontzPacket_set_char (drvthis, 7, g);
|
||||
CFontzPacket_set_char(drvthis, 1, a);
|
||||
CFontzPacket_set_char(drvthis, 2, b);
|
||||
CFontzPacket_set_char(drvthis, 3, c);
|
||||
CFontzPacket_set_char(drvthis, 4, d);
|
||||
CFontzPacket_set_char(drvthis, 5, e);
|
||||
CFontzPacket_set_char(drvthis, 6, f);
|
||||
CFontzPacket_set_char(drvthis, 7, g);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1008,17 +1011,18 @@ CFontzPacket_init_hbar (Driver *drvthis)
|
||||
if (p->ccmode != hbar) {
|
||||
if (p->ccmode != standard) {
|
||||
/* Not supported(yet) */
|
||||
report(RPT_WARNING, "CFontzPacket_init_hbar: Cannot combine two modes using user defined characters");
|
||||
report(RPT_WARNING, "%s: init_hbar: cannot combine two modes using user defined characters",
|
||||
drvthis->name);
|
||||
return;
|
||||
}
|
||||
p->ccmode = hbar;
|
||||
|
||||
CFontzPacket_set_char (drvthis, 1, a);
|
||||
CFontzPacket_set_char (drvthis, 2, b);
|
||||
CFontzPacket_set_char (drvthis, 3, c);
|
||||
CFontzPacket_set_char (drvthis, 4, d);
|
||||
CFontzPacket_set_char (drvthis, 5, e);
|
||||
CFontzPacket_set_char (drvthis, 6, f);
|
||||
CFontzPacket_set_char(drvthis, 1, a);
|
||||
CFontzPacket_set_char(drvthis, 2, b);
|
||||
CFontzPacket_set_char(drvthis, 3, c);
|
||||
CFontzPacket_set_char(drvthis, 4, d);
|
||||
CFontzPacket_set_char(drvthis, 5, e);
|
||||
CFontzPacket_set_char(drvthis, 6, f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1148,7 +1152,8 @@ char bignum_ccs[8][CELLWIDTH*CELLHEIGHT] = {
|
||||
|
||||
if (p->ccmode != standard) {
|
||||
/* Not supported (yet) */
|
||||
report(RPT_WARNING, "CFontzPacket_init_num: Cannot combine two modes using user defined characters");
|
||||
report(RPT_WARNING, "%s: init_num: cannot combine two modes using user defined characters",
|
||||
drvthis->name);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1501,13 +1506,16 @@ CFontzPacket_string (Driver *drvthis, int x, int y, char string[])
|
||||
x--;
|
||||
y--;
|
||||
|
||||
for (i = 0; string[i] != '\0'; i++) {
|
||||
if ((y < 0) || (y >= p->height))
|
||||
return;
|
||||
|
||||
for (i = 0; (string[i] != '\0') && (x < p->width); i++, x++) {
|
||||
/* Check for buffer overflows... */
|
||||
if ((y * p->width) + x + i > (p->width * p->height))
|
||||
break;
|
||||
p->framebuf[(y * p->width) + x + i] = (p->model == 633)
|
||||
? string[i]
|
||||
: CFontz_charmap[(unsigned) string[i]];
|
||||
if (x >= 0)
|
||||
p->framebuf[(y * p->width) + x] =
|
||||
(p->model == 633)
|
||||
? string[i]
|
||||
: CFontz_charmap[(unsigned) string[i]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user