harmonize coding style and messages; add more checks
This commit is contained in:
+81
-95
@@ -235,7 +235,7 @@ static char MtxOrb_parse_keypad_setting (Driver *drvthis, char * keyname, char d
|
|||||||
s = drvthis->config_get_string(drvthis->name, keyname, 0, NULL);
|
s = drvthis->config_get_string(drvthis->name, keyname, 0, NULL);
|
||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
strncpy(buf, s, sizeof(buf));
|
strncpy(buf, s, sizeof(buf));
|
||||||
buf[sizeof(buf)-1]=0;
|
buf[sizeof(buf)-1] = '\0';
|
||||||
return_val = buf[0];
|
return_val = buf[0];
|
||||||
} else {
|
} else {
|
||||||
return_val = default_value;
|
return_val = default_value;
|
||||||
@@ -265,7 +265,7 @@ MtxOrb_init (Driver *drvthis)
|
|||||||
|
|
||||||
/* Alocate and store private data */
|
/* Alocate and store private data */
|
||||||
p = (PrivateData *) malloc(sizeof(PrivateData));
|
p = (PrivateData *) malloc(sizeof(PrivateData));
|
||||||
if( ! p )
|
if (p == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
if (drvthis->store_private_ptr(drvthis, p))
|
if (drvthis->store_private_ptr(drvthis, p))
|
||||||
return -1;
|
return -1;
|
||||||
@@ -273,6 +273,7 @@ MtxOrb_init (Driver *drvthis)
|
|||||||
/* Initialise the PrivateData structure */
|
/* Initialise the PrivateData structure */
|
||||||
memset(p->def, -1, sizeof(p->def));
|
memset(p->def, -1, sizeof(p->def));
|
||||||
memset(p->use, 0, sizeof(p->use));
|
memset(p->use, 0, sizeof(p->use));
|
||||||
|
p->fd = -1;
|
||||||
p->circular = -1; /* static data from MtxOrb_ask_bar */
|
p->circular = -1; /* static data from MtxOrb_ask_bar */
|
||||||
p->output_state = -1; /* static data from MtxOrb_output */
|
p->output_state = -1; /* static data from MtxOrb_output */
|
||||||
p->backlight_state = 1; /* static data from MtxOrb_backlight */
|
p->backlight_state = 1; /* static data from MtxOrb_backlight */
|
||||||
@@ -300,17 +301,18 @@ MtxOrb_init (Driver *drvthis)
|
|||||||
/* READ CONFIG FILE */
|
/* READ CONFIG FILE */
|
||||||
|
|
||||||
/* Get serial device to use */
|
/* Get serial device to use */
|
||||||
strncpy(device, drvthis->config_get_string ( drvthis->name , "device" , 0 , DEFAULT_DEVICE),sizeof(device));
|
strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(device));
|
||||||
device[sizeof(device)-1]=0;
|
device[sizeof(device)-1] = '\0';
|
||||||
report (RPT_INFO,"MtxOrb: Using device: %s", device);
|
report(RPT_INFO, "%s: using Device %s", drvthis->name, device);
|
||||||
|
|
||||||
/* Get display size */
|
/* Get display 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;
|
size[sizeof(size)-1] = '\0';
|
||||||
if( sscanf(size , "%dx%d", &w, &h ) != 2
|
if ((sscanf(size, "%dx%d", &w, &h) != 2)
|
||||||
|| (w <= 0) || (w > LCD_MAX_WIDTH)
|
|| (w <= 0) || (w > LCD_MAX_WIDTH)
|
||||||
|| (h <= 0) || (h > LCD_MAX_HEIGHT)) {
|
|| (h <= 0) || (h > LCD_MAX_HEIGHT)) {
|
||||||
report (RPT_WARNING, "MtxOrb: Cannot read size: %s. Using default value %s.", size, DEFAULT_SIZE);
|
report(RPT_WARNING, "%s: cannot read Size: %s; using default %s",
|
||||||
|
drvthis->name, size, DEFAULT_SIZE);
|
||||||
sscanf(DEFAULT_SIZE , "%dx%d", &w, &h);
|
sscanf(DEFAULT_SIZE , "%dx%d", &w, &h);
|
||||||
}
|
}
|
||||||
p->width = w;
|
p->width = w;
|
||||||
@@ -318,15 +320,16 @@ MtxOrb_init (Driver *drvthis)
|
|||||||
p->widthBYheight = w * h;
|
p->widthBYheight = w * h;
|
||||||
|
|
||||||
/* Get contrast */
|
/* Get contrast */
|
||||||
if (0<=drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST) && drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST) <= 1000) {
|
tmp = drvthis->config_get_int(drvthis->name, "Contrast", 0, DEFAULT_CONTRAST);
|
||||||
contrast = drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST);
|
if ((tmp < 0) || (tmp > 1000)) {
|
||||||
} else {
|
report(RPT_WARNING, "%s: Contrast must be between 0 and 1000; using default %d",
|
||||||
report (RPT_WARNING, "MtxOrb: Contrast must be between 0 and 1000. Using default value.");
|
drvthis->name, DEFAULT_CONTRAST);
|
||||||
|
tmp = DEFAULT_CONTRAST;
|
||||||
}
|
}
|
||||||
|
contrast = tmp;
|
||||||
|
|
||||||
/* Get speed */
|
/* Get speed */
|
||||||
tmp = drvthis->config_get_int(drvthis->name, "Speed", 0, DEFAULT_SPEED);
|
tmp = drvthis->config_get_int(drvthis->name, "Speed", 0, DEFAULT_SPEED);
|
||||||
|
|
||||||
switch (tmp) {
|
switch (tmp) {
|
||||||
case 1200:
|
case 1200:
|
||||||
speed = B1200;
|
speed = B1200;
|
||||||
@@ -341,35 +344,17 @@ MtxOrb_init (Driver *drvthis)
|
|||||||
speed = B19200;
|
speed = B19200;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
speed = DEFAULT_SPEED;
|
speed = B19200;
|
||||||
switch (speed) {
|
report(RPT_WARNING, "%s: Speed must be 1200, 2400, 9600 or 19200; using default %d",
|
||||||
case B1200:
|
drvthis->name, tmp);
|
||||||
strncpy(buf,"1200", sizeof(buf));
|
|
||||||
break;
|
|
||||||
case B2400:
|
|
||||||
strncpy(buf,"2400", sizeof(buf));
|
|
||||||
break;
|
|
||||||
case B9600:
|
|
||||||
strncpy(buf,"9600", sizeof(buf));
|
|
||||||
break;
|
|
||||||
case B19200:
|
|
||||||
strncpy(buf,"19200", sizeof(buf));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
report (RPT_WARNING , "MtxOrb: Speed must be 1200, 2400, 9600 or 19200. Using default value of %s baud!", buf);
|
|
||||||
strncpy(buf,"", sizeof(buf));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Get backlight setting*/
|
/* Get backlight setting*/
|
||||||
if(drvthis->config_get_bool( drvthis->name , "Backlight" , 0 , DEFAULT_BACKLIGHT)) {
|
p->backlightenabled = drvthis->config_get_bool(drvthis->name, "Backlight", 0, DEFAULT_BACKLIGHT);
|
||||||
p->backlightenabled = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get display type */
|
/* Get display type */
|
||||||
strncpy(buf, drvthis->config_get_string(drvthis->name, "Type", 0, DEFAULT_TYPE), sizeof(buf));
|
strncpy(buf, drvthis->config_get_string(drvthis->name, "Type", 0, DEFAULT_TYPE), sizeof(buf));
|
||||||
buf[sizeof(buf)-1]=0;
|
buf[sizeof(buf)-1] = '\0';
|
||||||
|
|
||||||
if (strncasecmp(buf, "lcd", 3) == 0) {
|
if (strncasecmp(buf, "lcd", 3) == 0) {
|
||||||
p->MtxOrb_type = MTXORB_LCD;
|
p->MtxOrb_type = MTXORB_LCD;
|
||||||
} else if (strncasecmp(buf, "lkd", 3) == 0) {
|
} else if (strncasecmp(buf, "lkd", 3) == 0) {
|
||||||
@@ -379,8 +364,9 @@ MtxOrb_init (Driver *drvthis)
|
|||||||
} else if (strncasecmp(buf, "vkd", 3) == 0) {
|
} else if (strncasecmp(buf, "vkd", 3) == 0) {
|
||||||
p->MtxOrb_type = MTXORB_VKD;
|
p->MtxOrb_type = MTXORB_VKD;
|
||||||
} else {
|
} else {
|
||||||
report (RPT_ERR, "MtxOrb: unknwon display type %s; must be one of lcd, lkd, vfd, or vkd", buf);
|
report(RPT_ERR, "%s: unknwon display Type %s; must be one of lcd, lkd, vfd, or vkd",
|
||||||
return (-1);
|
drvthis->name, buf);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get keypad settings*/
|
/* Get keypad settings*/
|
||||||
@@ -400,27 +386,27 @@ MtxOrb_init (Driver *drvthis)
|
|||||||
|
|
||||||
/* left_key */
|
/* left_key */
|
||||||
p->left_key = MtxOrb_parse_keypad_setting(drvthis, "LeftKey", MTXORB_DEFAULT_Left);
|
p->left_key = MtxOrb_parse_keypad_setting(drvthis, "LeftKey", MTXORB_DEFAULT_Left);
|
||||||
report (RPT_DEBUG, "MtxOrb: Using \"%c\" as Leftkey.", p->left_key);
|
report(RPT_DEBUG, "%s: Using \"%c\" as Leftkey.", drvthis->name, p->left_key);
|
||||||
|
|
||||||
/* right_key */
|
/* right_key */
|
||||||
p->right_key = MtxOrb_parse_keypad_setting(drvthis, "RightKey", MTXORB_DEFAULT_Right);
|
p->right_key = MtxOrb_parse_keypad_setting(drvthis, "RightKey", MTXORB_DEFAULT_Right);
|
||||||
report (RPT_DEBUG, "MtxOrb: Using \"%c\" as RightKey.", p->right_key);
|
report(RPT_DEBUG, "%s: Using \"%c\" as RightKey.", drvthis->name, p->right_key);
|
||||||
|
|
||||||
/* up_key */
|
/* up_key */
|
||||||
p->up_key = MtxOrb_parse_keypad_setting(drvthis, "UpKey", MTXORB_DEFAULT_Up);
|
p->up_key = MtxOrb_parse_keypad_setting(drvthis, "UpKey", MTXORB_DEFAULT_Up);
|
||||||
report (RPT_DEBUG, "MtxOrb: Using \"%c\" as UpKey.", p->up_key);
|
report(RPT_DEBUG, "%s: Using \"%c\" as UpKey.", drvthis->name, p->up_key);
|
||||||
|
|
||||||
/* down_key */
|
/* down_key */
|
||||||
p->down_key = MtxOrb_parse_keypad_setting(drvthis, "DownKey", MTXORB_DEFAULT_Down);
|
p->down_key = MtxOrb_parse_keypad_setting(drvthis, "DownKey", MTXORB_DEFAULT_Down);
|
||||||
report (RPT_DEBUG, "MtxOrb: Using \"%c\" as DownKey.", p->down_key);
|
report(RPT_DEBUG, "%s: Using \"%c\" as DownKey.", drvthis->name, p->down_key);
|
||||||
|
|
||||||
/* right_key */
|
/* right_key */
|
||||||
p->enter_key = MtxOrb_parse_keypad_setting(drvthis, "EnterKey", MTXORB_DEFAULT_Enter);
|
p->enter_key = MtxOrb_parse_keypad_setting(drvthis, "EnterKey", MTXORB_DEFAULT_Enter);
|
||||||
report (RPT_DEBUG, "MtxOrb: Using \"%c\" as EnterKey.", p->enter_key);
|
report(RPT_DEBUG, "%s: Using \"%c\" as EnterKey.", drvthis->name, p->enter_key);
|
||||||
|
|
||||||
/* escape_key */
|
/* escape_key */
|
||||||
p->escape_key = MtxOrb_parse_keypad_setting(drvthis, "EscapeKey", MTXORB_DEFAULT_Escape);
|
p->escape_key = MtxOrb_parse_keypad_setting(drvthis, "EscapeKey", MTXORB_DEFAULT_Escape);
|
||||||
report (RPT_DEBUG, "MtxOrb: Using \"%c\" as EscapeKey.", p->escape_key);
|
report(RPT_DEBUG, "%s: Using \"%c\" as EscapeKey.", drvthis->name, p->escape_key);
|
||||||
|
|
||||||
}
|
}
|
||||||
/* End of config file parsing*/
|
/* End of config file parsing*/
|
||||||
@@ -428,18 +414,12 @@ MtxOrb_init (Driver *drvthis)
|
|||||||
/* Set up io port correctly, and open it... */
|
/* Set up io port correctly, and open it... */
|
||||||
p->fd = open(device, O_RDWR | O_NOCTTY);
|
p->fd = open(device, O_RDWR | O_NOCTTY);
|
||||||
if (p->fd == -1) {
|
if (p->fd == -1) {
|
||||||
switch (errno) {
|
report(RPT_ERR, "%s: open(%s) failed (%s)", drvthis->name, device, strerror(errno));
|
||||||
case ENOENT: report (RPT_ERR, "MtxOrb_init: %s device file missing!\n", device);
|
if (errno == EACCES)
|
||||||
break;
|
report(RPT_ERR, "%s: %s device could not be opened...", drvthis->name, device);
|
||||||
case EACCES: report (RPT_ERR, "MtxOrb_init: %s device could not be opened...\n", device);
|
|
||||||
report (RPT_ERR, "MtxOrb_init: perhaps you should run LCDd as root?\n");
|
|
||||||
break;
|
|
||||||
default: report (RPT_ERR, "MtxOrb_init: failed (%s)\n", strerror (errno));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
} else
|
}
|
||||||
report (RPT_INFO, "MtxOrb: opened display on %s\n", device);
|
report(RPT_INFO, "%s: opened display on %s", drvthis->name, device);
|
||||||
|
|
||||||
tcgetattr(p->fd, &portset);
|
tcgetattr(p->fd, &portset);
|
||||||
|
|
||||||
@@ -468,9 +448,11 @@ MtxOrb_init (Driver *drvthis)
|
|||||||
tcsetattr(p->fd, TCSANOW, &portset);
|
tcsetattr(p->fd, TCSANOW, &portset);
|
||||||
|
|
||||||
/* Make sure the frame buffer is there... */
|
/* Make sure the frame buffer is there... */
|
||||||
if (!p->framebuf)
|
p->framebuf = (char *) calloc(p->widthBYheight, 1);
|
||||||
p->framebuf = (char *)
|
if (p->framebuf == NULL) {
|
||||||
malloc (p->widthBYheight);
|
report(RPT_ERR, "%s: unable to create framebuffer", drvthis->name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
memset(p->framebuf, ' ', p->widthBYheight);
|
memset(p->framebuf, ' ', p->widthBYheight);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -482,7 +464,9 @@ MtxOrb_init (Driver *drvthis)
|
|||||||
MtxOrb_cursorblink(drvthis, DEFAULT_CURSORBLINK);
|
MtxOrb_cursorblink(drvthis, DEFAULT_CURSORBLINK);
|
||||||
MtxOrb_set_contrast(drvthis, contrast);
|
MtxOrb_set_contrast(drvthis, contrast);
|
||||||
|
|
||||||
return 0;
|
report(RPT_DEBUG, "%s: init() done", drvthis->name);
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ValidX(x) if ((x) > p->width) { (x) = p->width; } else (x) = (x) < 1 ? 1 : (x);
|
#define ValidX(x) if ((x) > p->width) { (x) = p->width; } else (x) = (x) < 1 ? 1 : (x);
|
||||||
@@ -512,6 +496,8 @@ MtxOrb_close (Driver *drvthis)
|
|||||||
{
|
{
|
||||||
PrivateData * p = drvthis->private_data;
|
PrivateData * p = drvthis->private_data;
|
||||||
|
|
||||||
|
if (p != NULL) {
|
||||||
|
if (p->fd >= 0)
|
||||||
close(p->fd);
|
close(p->fd);
|
||||||
|
|
||||||
if (p->framebuf)
|
if (p->framebuf)
|
||||||
@@ -519,7 +505,8 @@ MtxOrb_close (Driver *drvthis)
|
|||||||
p->framebuf = NULL;
|
p->framebuf = NULL;
|
||||||
|
|
||||||
free(p);
|
free(p);
|
||||||
|
}
|
||||||
|
drvthis->store_private_ptr(drvthis, NULL);
|
||||||
debug(RPT_DEBUG, "MtxOrb: closed");
|
debug(RPT_DEBUG, "MtxOrb: closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,7 +548,7 @@ MtxOrb_string (Driver *drvthis, int x, int y, char *string)
|
|||||||
x--; y--; /* Convert 1-based coords to 0-based... */
|
x--; y--; /* Convert 1-based coords to 0-based... */
|
||||||
offset = (y * p->width) + x;
|
offset = (y * p->width) + x;
|
||||||
siz = (p->widthBYheight) - offset;
|
siz = (p->widthBYheight) - offset;
|
||||||
siz = siz > strlen(string) ? strlen(string) : siz;
|
siz = (siz > strlen(string)) ? strlen(string) : siz;
|
||||||
|
|
||||||
memcpy(p->framebuf + offset, string, siz);
|
memcpy(p->framebuf + offset, string, siz);
|
||||||
|
|
||||||
@@ -604,7 +591,6 @@ MtxOrb_flush (Driver *drvthis)
|
|||||||
* as custom characters. We know not if a custom
|
* as custom characters. We know not if a custom
|
||||||
* character has changed.
|
* character has changed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (mv == 1) {
|
if (mv == 1) {
|
||||||
snprintf(out, sizeof(out), "\x0FEG%c%c", j, i);
|
snprintf(out, sizeof(out), "\x0FEG%c%c", j, i);
|
||||||
write(p->fd, out, 4);
|
write(p->fd, out, 4);
|
||||||
@@ -679,7 +665,7 @@ MtxOrb_set_contrast (Driver *drvthis, int promille)
|
|||||||
PrivateData * p = drvthis->private_data;
|
PrivateData * p = drvthis->private_data;
|
||||||
|
|
||||||
/* Check it */
|
/* Check it */
|
||||||
if( promille < 0 || promille > 1000 )
|
if ((promille < 0) || (promille > 1000))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Store it */
|
/* Store it */
|
||||||
@@ -688,14 +674,15 @@ MtxOrb_set_contrast (Driver *drvthis, int promille)
|
|||||||
real_contrast = (int) ((long) promille * 255 / 1000 );
|
real_contrast = (int) ((long) promille * 255 / 1000 );
|
||||||
|
|
||||||
/* And do it */
|
/* And do it */
|
||||||
|
|
||||||
if (IS_LCD_DISPLAY || IS_LKD_DISPLAY) {
|
if (IS_LCD_DISPLAY || IS_LKD_DISPLAY) {
|
||||||
snprintf(out, sizeof(out), "\x0FEP%c", real_contrast);
|
snprintf(out, sizeof(out), "\x0FEP%c", real_contrast);
|
||||||
write(p->fd, out, 3);
|
write(p->fd, out, 3);
|
||||||
|
|
||||||
report(RPT_DEBUG, "MtxOrb: contrast set to %d", real_contrast);
|
report(RPT_DEBUG, "%s: contrast set to %d",
|
||||||
|
drvthis->name, real_contrast);
|
||||||
} else {
|
} else {
|
||||||
report(RPT_DEBUG, "MtxOrb: contrast not set to %d - not LCD or LKD display", real_contrast);
|
report(RPT_DEBUG, "%s: contrast not set to %d - not LCD or LKD display",
|
||||||
|
drvthis->name, real_contrast);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -797,11 +784,9 @@ MtxOrb_linewrap (Driver *drvthis, int on)
|
|||||||
|
|
||||||
if (on) {
|
if (on) {
|
||||||
write(p->fd, "\x0FE" "C", 2);
|
write(p->fd, "\x0FE" "C", 2);
|
||||||
|
|
||||||
debug(RPT_DEBUG, "MtxOrb: linewrap turned on");
|
debug(RPT_DEBUG, "MtxOrb: linewrap turned on");
|
||||||
} else {
|
} else {
|
||||||
write(p->fd, "\x0FE" "D", 2);
|
write(p->fd, "\x0FE" "D", 2);
|
||||||
|
|
||||||
debug(RPT_DEBUG, "MtxOrb: linewrap turned off");
|
debug(RPT_DEBUG, "MtxOrb: linewrap turned off");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -816,11 +801,9 @@ MtxOrb_autoscroll (Driver *drvthis, int on)
|
|||||||
|
|
||||||
if (on) {
|
if (on) {
|
||||||
write(p->fd, "\x0FEQ", 2);
|
write(p->fd, "\x0FEQ", 2);
|
||||||
|
|
||||||
debug(RPT_DEBUG, "MtxOrb: autoscroll turned on");
|
debug(RPT_DEBUG, "MtxOrb: autoscroll turned on");
|
||||||
} else {
|
} else {
|
||||||
write(p->fd, "\x0FER", 2);
|
write(p->fd, "\x0FER", 2);
|
||||||
|
|
||||||
debug(RPT_DEBUG, "MtxOrb: autoscroll turned off");
|
debug(RPT_DEBUG, "MtxOrb: autoscroll turned off");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -836,11 +819,9 @@ MtxOrb_cursorblink (Driver *drvthis, int on)
|
|||||||
|
|
||||||
if (on) {
|
if (on) {
|
||||||
write(p->fd, "\x0FES", 2);
|
write(p->fd, "\x0FES", 2);
|
||||||
|
|
||||||
debug(RPT_DEBUG, "MtxOrb: cursorblink turned on");
|
debug(RPT_DEBUG, "MtxOrb: cursorblink turned on");
|
||||||
} else {
|
} else {
|
||||||
write(p->fd, "\x0FET", 2);
|
write(p->fd, "\x0FET", 2);
|
||||||
|
|
||||||
debug(RPT_DEBUG, "MtxOrb: cursorblink turned off");
|
debug(RPT_DEBUG, "MtxOrb: cursorblink turned off");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1001,7 +982,7 @@ static void MtxOrb_mold_vbar (Driver *drvthis, int x, int y, int len)
|
|||||||
/* REMOVE THE PREVIOUS LINE FOR TESTING ONLY... */
|
/* REMOVE THE PREVIOUS LINE FOR TESTING ONLY... */
|
||||||
|
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
for (; y > 0 && len > 0; y--) {
|
for ( ; (y > 0) && (len > 0); y--) {
|
||||||
if (len >= p->cellheight)
|
if (len >= p->cellheight)
|
||||||
MtxOrb_icon(drvthis, x, y, barb);
|
MtxOrb_icon(drvthis, x, y, barb);
|
||||||
else
|
else
|
||||||
@@ -1047,14 +1028,13 @@ static void MtxOrb_old_hbar (Driver *drvthis, int x, int y, int len)
|
|||||||
debug(RPT_DEBUG, "MtxOrb: horizontal bar at %d set to %d", x, len);
|
debug(RPT_DEBUG, "MtxOrb: horizontal bar at %d set to %d", x, len);
|
||||||
|
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
for (; x <= p->width && len > 0; x++) {
|
for ( ; (x <= p->width) && (len > 0); x++) {
|
||||||
if (len >= p->cellwidth)
|
if (len >= p->cellwidth)
|
||||||
MtxOrb_icon(drvthis, x, y, barb);
|
MtxOrb_icon(drvthis, x, y, barb);
|
||||||
else
|
else
|
||||||
MtxOrb_icon(drvthis, x, y, mapr[len]);
|
MtxOrb_icon(drvthis, x, y, mapr[len]);
|
||||||
|
|
||||||
len -= p->cellwidth;
|
len -= p->cellwidth;
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
} else {
|
} else {
|
||||||
@@ -1152,8 +1132,10 @@ MtxOrb_num (Driver *drvthis, int pos, int val)
|
|||||||
/* Currently we are bignum but if bigalpha is there remove this line */
|
/* Currently we are bignum but if bigalpha is there remove this line */
|
||||||
c = val + '0'; /* We transform from 0-9 to 'O' to '9' */
|
c = val + '0'; /* We transform from 0-9 to 'O' to '9' */
|
||||||
|
|
||||||
if ((pos < -2) || (pos > 20)) return; /* are we outisde the visible spectrum */
|
if ((pos < -2) || (pos > 20)) /* are we outisde the visible spectrum */
|
||||||
if (('c' < 32) || ('c' > 127)) return; /* are we characteristic or not? */
|
return;
|
||||||
|
if ((c < 32) || (c > 127)) /* are we characteristic or not? */
|
||||||
|
return;
|
||||||
|
|
||||||
c -= 32;
|
c -= 32;
|
||||||
|
|
||||||
@@ -1193,7 +1175,7 @@ MtxOrb_set_char (Driver *drvthis, int n, char *dat)
|
|||||||
|
|
||||||
PrivateData * p = drvthis->private_data;
|
PrivateData * p = drvthis->private_data;
|
||||||
|
|
||||||
if (n < 0 || n > MAX_CUSTOM_CHARS)
|
if ((n < 0) || (n > MAX_CUSTOM_CHARS))
|
||||||
return;
|
return;
|
||||||
if (!dat)
|
if (!dat)
|
||||||
return;
|
return;
|
||||||
@@ -1244,25 +1226,24 @@ MtxOrb_icon (Driver *drvthis, int x, int y, int icon)
|
|||||||
MODULE_EXPORT const char *
|
MODULE_EXPORT const char *
|
||||||
MtxOrb_get_key (Driver *drvthis)
|
MtxOrb_get_key (Driver *drvthis)
|
||||||
{
|
{
|
||||||
char in = 0;
|
|
||||||
|
|
||||||
PrivateData * p = drvthis->private_data;
|
PrivateData * p = drvthis->private_data;
|
||||||
|
|
||||||
|
char in = 0;
|
||||||
|
|
||||||
// POLL For data or return
|
// POLL For data or return
|
||||||
struct pollfd fds[1];
|
struct pollfd fds[1];
|
||||||
fds[0].fd = p->fd;
|
fds[0].fd = p->fd;
|
||||||
fds[0].events = POLLIN;
|
fds[0].events = POLLIN;
|
||||||
fds[0].revents = 0;
|
fds[0].revents = 0;
|
||||||
poll(fds,1,0);
|
poll(fds,1,0);
|
||||||
if (fds[0].revents == 0) { return NULL; }
|
if (fds[0].revents == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
(void) read(p->fd, &in, 1);
|
(void) read(p->fd, &in, 1);
|
||||||
report(RPT_INFO, "MtxOrb: get_key: key X %i", in);
|
report(RPT_DEBUG, "%s: get_key: key 0x%02X", drvthis->name, in);
|
||||||
|
|
||||||
if ( 0 == in ) {
|
if (in == '\0')
|
||||||
debug( RPT_INFO, "MtxOrb_get_key: in=>%d\n", in );
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (!p->keypad_test_mode) {
|
if (!p->keypad_test_mode) {
|
||||||
if (in == p->left_key)
|
if (in == p->left_key)
|
||||||
@@ -1278,10 +1259,11 @@ MtxOrb_get_key (Driver *drvthis)
|
|||||||
else if (in == p->escape_key)
|
else if (in == p->escape_key)
|
||||||
return "Escape";
|
return "Escape";
|
||||||
else {
|
else {
|
||||||
report( RPT_INFO, "MtxOrb Untreated key 0x%2x", in);
|
report(RPT_INFO, "%s: untreated key 0x%02X", drvthis->name, in);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
fprintf(stdout, "MtxOrb: Received character %c\n", in);
|
fprintf(stdout, "MtxOrb: Received character %c\n", in);
|
||||||
fprintf(stdout, "MtxOrb: Press another key of your device.\n");
|
fprintf(stdout, "MtxOrb: Press another key of your device.\n");
|
||||||
}
|
}
|
||||||
@@ -1307,19 +1289,23 @@ MtxOrb_ask_bar (Driver *drvthis, int type)
|
|||||||
/* fprintf(stderr, "GLU: MtxOrb_ask_bar(%d).\n", type); */
|
/* fprintf(stderr, "GLU: MtxOrb_ask_bar(%d).\n", type); */
|
||||||
|
|
||||||
/* This bypass the search for WHITE and BLACK */
|
/* This bypass the search for WHITE and BLACK */
|
||||||
if (type==barw) return 32;
|
if (type == barw)
|
||||||
if (type==barb) return 255;
|
return 32;
|
||||||
|
if (type == barb)
|
||||||
|
return 255;
|
||||||
|
|
||||||
/* If the screen was clear then no graphic caracter are in use yet. */
|
/* If the screen was clear then no graphic caracter are in use yet. */
|
||||||
if (p->clear) {
|
if (p->clear) {
|
||||||
for (pos = 0; pos < 8; pos++) p->use[pos] = 0;
|
for (pos = 0; pos < 8; pos++)
|
||||||
|
p->use[pos] = 0;
|
||||||
p->clear = 0;
|
p->clear = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search for a match with caracter already defined. */
|
/* Search for a match with caracter already defined. */
|
||||||
pos = 8; /* Not found. */
|
pos = 8; /* Not found. */
|
||||||
for (i = 0; i < 8; i++) { /* For all including heartbeat. */
|
for (i = 0; i < 8; i++) { /* For all including heartbeat. */
|
||||||
if (p->def[i] == type) pos = i; /* Founded (should break now). */
|
if (p->def[i] == type)
|
||||||
|
pos = i; /* Founded (should break now). */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos == 8) {
|
if (pos == 8) {
|
||||||
@@ -1335,7 +1321,7 @@ MtxOrb_ask_bar (Driver *drvthis, int type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pos != 8) {
|
if (pos != 8) {
|
||||||
/* A caracter is found (Best match could solve our problem).
|
/* A character is found (Best match could solve our problem).
|
||||||
* REMOVE: fprintf(stderr, "GLU: MtxOrb_ask_bar| found at %d.\n", pos);
|
* REMOVE: fprintf(stderr, "GLU: MtxOrb_ask_bar| found at %d.\n", pos);
|
||||||
*/
|
*/
|
||||||
if (p->def[pos] != type) {
|
if (p->def[pos] != type) {
|
||||||
@@ -1397,7 +1383,7 @@ MtxOrb_ask_bar (Driver *drvthis, int type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (pos);
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************
|
/******************************
|
||||||
@@ -1407,7 +1393,7 @@ static void
|
|||||||
MtxOrb_set_known_char (Driver *drvthis, int car, int type)
|
MtxOrb_set_known_char (Driver *drvthis, int car, int type)
|
||||||
{
|
{
|
||||||
char all_bar[39][5 * 8] = {
|
char all_bar[39][5 * 8] = {
|
||||||
/* Here start 3 standard icon used by heartbear and other. */
|
/* Here start 3 standard icons used by heartbeat and other. */
|
||||||
{
|
{
|
||||||
1, 1, 1, 1, 1, /* Empty Heart */
|
1, 1, 1, 1, 1, /* Empty Heart */
|
||||||
1, 0, 1, 0, 1,
|
1, 0, 1, 0, 1,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ MODULE_EXPORT void MtxOrb_hbar (Driver * drvthis, int x, int y, int len, int pro
|
|||||||
|
|
||||||
#define DEFAULT_CONTRAST 480
|
#define DEFAULT_CONTRAST 480
|
||||||
#define DEFAULT_DEVICE "/dev/lcd"
|
#define DEFAULT_DEVICE "/dev/lcd"
|
||||||
#define DEFAULT_SPEED B19200
|
#define DEFAULT_SPEED 19200
|
||||||
#define DEFAULT_LINEWRAP 1
|
#define DEFAULT_LINEWRAP 1
|
||||||
#define DEFAULT_AUTOSCROLL 1
|
#define DEFAULT_AUTOSCROLL 1
|
||||||
#define DEFAULT_CURSORBLINK 0
|
#define DEFAULT_CURSORBLINK 0
|
||||||
|
|||||||
Reference in New Issue
Block a user