harmonize coding style and messages; add more checksi; simplyfy slightly
This commit is contained in:
@@ -100,6 +100,7 @@ NoritakeVFD_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;
|
||||
@@ -110,7 +111,7 @@ NoritakeVFD_init (Driver *drvthis)
|
||||
/* Which device should be used */
|
||||
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));
|
||||
@@ -118,8 +119,8 @@ NoritakeVFD_init (Driver *drvthis)
|
||||
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;
|
||||
@@ -128,8 +129,8 @@ NoritakeVFD_init (Driver *drvthis)
|
||||
/* Which backlight 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;
|
||||
@@ -138,8 +139,8 @@ NoritakeVFD_init (Driver *drvthis)
|
||||
/* Which 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;
|
||||
@@ -157,7 +158,7 @@ NoritakeVFD_init (Driver *drvthis)
|
||||
p->fd = open (p->device, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
|
||||
if (p->fd == -1) {
|
||||
report (RPT_ERR, "%s: open() of %s failed (%s)\n", __FUNCTION__, p->device, strerror (errno));
|
||||
report(RPT_ERR, "%s: open() of %s failed (%s)", drvthis->name, p->device, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -187,7 +188,7 @@ NoritakeVFD_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);
|
||||
@@ -195,7 +196,7 @@ NoritakeVFD_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);
|
||||
@@ -205,13 +206,13 @@ NoritakeVFD_init (Driver *drvthis)
|
||||
if (reboot) {
|
||||
NoritakeVFD_reboot(drvthis);
|
||||
sleep(4);
|
||||
reboot = 0;
|
||||
}
|
||||
NoritakeVFD_hidecursor(drvthis);
|
||||
NoritakeVFD_set_brightness(drvthis, 1, p->brightness);
|
||||
NoritakeVFD_autoscroll(drvthis, 0);
|
||||
|
||||
report (RPT_DEBUG, "%s: done\n", __FUNCTION__);
|
||||
report(RPT_DEBUG, "%s: init() done", drvthis->name);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -224,6 +225,7 @@ NoritakeVFD_close (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
if (p != NULL) {
|
||||
if (p->fd >= 0)
|
||||
close(p->fd);
|
||||
|
||||
if (p->framebuf)
|
||||
@@ -299,7 +301,7 @@ NoritakeVFD_flush_box (Driver *drvthis, int lft, int top, int rgt, int bot)
|
||||
int y;
|
||||
char out[LCD_MAX_WIDTH];
|
||||
|
||||
debug (RPT_DEBUG, "%s: flush_box (%i,%i)-(%i,%i)\n", __FUNCTION__, lft, top, rgt, bot);
|
||||
debug(RPT_DEBUG, "%s: flush_box(%i,%i)-(%i,%i)", __FUNCTION__, lft, top, rgt, bot);
|
||||
|
||||
for (y = top; y <= bot; y++) {
|
||||
int pos = y*p->width;
|
||||
@@ -318,9 +320,9 @@ MODULE_EXPORT void
|
||||
NoritakeVFD_chr (Driver *drvthis, int x, int y, char c)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
y--;
|
||||
x--;
|
||||
|
||||
/*if (c < 32 && (int)c >= 0)
|
||||
c += 128;*/
|
||||
p->framebuf[(y * p->width) + x ] = c;
|
||||
@@ -366,10 +368,8 @@ NoritakeVFD_autoscroll (Driver *drvthis, int on)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
char out[4];
|
||||
if (on)
|
||||
snprintf (out, sizeof(out), "%c", 0x12);
|
||||
else
|
||||
snprintf (out, sizeof(out), "%c", 0x11);
|
||||
|
||||
snprintf(out, sizeof(out), "%c", (on) ? 0x12 : 0x11);
|
||||
write(p->fd, out, 1);
|
||||
}
|
||||
|
||||
@@ -381,6 +381,7 @@ NoritakeVFD_hidecursor (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
char out[4];
|
||||
|
||||
snprintf(out, sizeof(out), "%c", 0x14);
|
||||
write(p->fd, out, 1);
|
||||
}
|
||||
@@ -393,6 +394,7 @@ NoritakeVFD_reboot (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
char out[4];
|
||||
|
||||
snprintf(out, sizeof(out), "%c%c", 0x1B, 'I');
|
||||
write(p->fd, out, 2);
|
||||
}
|
||||
@@ -567,7 +569,6 @@ NoritakeVFD_hbar (Driver *drvthis, int x, int y, int len, int promille, int opti
|
||||
|
||||
NoritakeVFD_init_hbar(drvthis);
|
||||
//lib_hbar_static(drvthis, x, y, len, promille, options, p->cellheight, 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -669,7 +670,6 @@ NoritakeVFD_draw_frame (Driver *drvthis, unsigned char *dat)
|
||||
return;
|
||||
|
||||
for (i = 0; i < p->height; i++) {
|
||||
|
||||
row = dat + (p->width * i);
|
||||
b_row = p->backingstore + (p->width * i);
|
||||
|
||||
@@ -696,6 +696,7 @@ MODULE_EXPORT void
|
||||
NoritakeVFD_clear (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
memset(p->framebuf, ' ', p->width * p->height);
|
||||
}
|
||||
|
||||
@@ -708,10 +709,11 @@ MODULE_EXPORT void
|
||||
NoritakeVFD_string (Driver *drvthis, int x, int y, char string[])
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
int i;
|
||||
|
||||
x--;
|
||||
y--;
|
||||
int i;
|
||||
for (i = 0; string[i]; i++) {
|
||||
for (i = 0; string[i] != '\0'; i++) {
|
||||
// Check for buffer overflows...
|
||||
if ((y * p->width) + x + i > (p->width * p->height))
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user