harmonize coding style and messages; add more checks
This commit is contained in:
+165
-199
@@ -154,26 +154,27 @@ void CwLnx_draw_frame(Driver *drvthis, char *dat);
|
|||||||
#define SETUP_DELAY 1 /* 2 sec */
|
#define SETUP_DELAY 1 /* 2 sec */
|
||||||
|
|
||||||
/* Parse one key from the configfile */
|
/* Parse one key from the configfile */
|
||||||
static char CwLnx_parse_keypad_setting (Driver *drvthis, char * keyname, char default_value)
|
static char CwLnx_parse_keypad_setting(Driver *drvthis, char * keyname, char default_value)
|
||||||
{
|
{
|
||||||
char return_val = 0;
|
char return_val = 0;
|
||||||
char * s;
|
char * s;
|
||||||
char buf [255];
|
char buf[255];
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
return return_val;
|
return return_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Read_LCD(int fd, char *c, int size)
|
int Read_LCD(int fd, char *c, int size)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = read(fd, c, size);
|
rc = read(fd, c, size);
|
||||||
/* usleep(DELAY); */
|
/* usleep(DELAY); */
|
||||||
return rc;
|
return rc;
|
||||||
@@ -182,19 +183,19 @@ int Read_LCD(int fd, char *c, int size)
|
|||||||
int Write_LCD(int fd, char *c, int size)
|
int Write_LCD(int fd, char *c, int size)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = write(fd, c, size);
|
rc = write(fd, c, size);
|
||||||
/* Debuging code to be cleaned when very stable */
|
/* Debuging code to be cleaned when very stable */
|
||||||
/*
|
/*
|
||||||
if (size==1) {
|
if (size == 1) {
|
||||||
if (*c>=0)
|
if (*c >= 0)
|
||||||
printf("%3d ", *c);
|
printf("%3d ", *c);
|
||||||
else
|
else {
|
||||||
{
|
if (*c+256==254)
|
||||||
if (*c+256==254)
|
printf("\n%3d ", *c+256);
|
||||||
|
else
|
||||||
printf("\n%3d ", *c+256);
|
printf("%3d ", *c+256);
|
||||||
else printf("%3d ", *c+256);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
/* usleep(DELAY); */
|
/* usleep(DELAY); */
|
||||||
@@ -497,7 +498,6 @@ int CwLnx_init(Driver * drvthis)
|
|||||||
int speed = DEFAULT_SPEED;
|
int speed = DEFAULT_SPEED;
|
||||||
char size[200] = DEFAULT_SIZE;
|
char size[200] = DEFAULT_SIZE;
|
||||||
|
|
||||||
char buf[256] = "";
|
|
||||||
int tmp;
|
int tmp;
|
||||||
int w;
|
int w;
|
||||||
int h;
|
int h;
|
||||||
@@ -506,19 +506,19 @@ int CwLnx_init(Driver * drvthis)
|
|||||||
PrivateData *p;
|
PrivateData *p;
|
||||||
|
|
||||||
/* 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;
|
||||||
|
|
||||||
/* Initialise the PrivateData structure */
|
/* Initialise the PrivateData structure */
|
||||||
|
|
||||||
p->framebuf = NULL;
|
p->framebuf = NULL;
|
||||||
|
p->backingstore = NULL;
|
||||||
|
|
||||||
/* height and width are computed from DEFAULT_SIZE */
|
/* height and width are computed from DEFAULT_SIZE */
|
||||||
/* p->width = DEFAULT_WIDTH; */
|
/* p->width = DEFAULT_WIDTH; */
|
||||||
/* p->height = DEFAULT_HEIGHT; */
|
/* p->height = DEFAULT_HEIGHT; */
|
||||||
p->cellwidth = DEFAULT_CELLWIDTH;
|
p->cellwidth = DEFAULT_CELLWIDTH;
|
||||||
p->cellheight = DEFAULT_CELLHEIGHT;
|
p->cellheight = DEFAULT_CELLHEIGHT;
|
||||||
|
|
||||||
@@ -532,23 +532,23 @@ int CwLnx_init(Driver * drvthis)
|
|||||||
p->saved_heartbeat = -1;
|
p->saved_heartbeat = -1;
|
||||||
p->heartbeat = 0;
|
p->heartbeat = 0;
|
||||||
|
|
||||||
debug(RPT_INFO, "CwLnx: init(%p)", drvthis);
|
debug(RPT_INFO, "%s: init(%p)", drvthis->name, drvthis);
|
||||||
|
|
||||||
/* Read config file */
|
/* Read config file */
|
||||||
|
|
||||||
|
|
||||||
/* Which serial device should be used */
|
/* Which serial device should be used */
|
||||||
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, "CwLnx: Using device: %s", device);
|
report(RPT_INFO, "%s: using Device %s", drvthis->name, device);
|
||||||
|
|
||||||
/* Which size */
|
/* 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;
|
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, "CwLnx: 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);
|
sscanf(DEFAULT_SIZE, "%dx%d", &w, &h);
|
||||||
}
|
}
|
||||||
p->width = w;
|
p->width = w;
|
||||||
@@ -560,98 +560,83 @@ int CwLnx_init(Driver * drvthis)
|
|||||||
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 9600:
|
case 9600:
|
||||||
speed = B9600;
|
speed = B9600;
|
||||||
break;
|
|
||||||
case 19200:
|
|
||||||
speed = B19200;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
speed = DEFAULT_SPEED;
|
|
||||||
|
|
||||||
switch (speed) {
|
|
||||||
case B9600:
|
|
||||||
strncpy(buf, "9600", sizeof(buf));
|
|
||||||
break;
|
break;
|
||||||
case B19200:
|
case 19200:
|
||||||
strncpy(buf, "19200", sizeof(buf));
|
speed = B19200;
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
|
speed = B19200;
|
||||||
report(RPT_WARNING,
|
report(RPT_WARNING, "%s: Speed must be 9600 or 19200. Using default %d",
|
||||||
"CwLnx: Speed must be 9600 or 19200. Using default value of %s baud!",
|
drvthis->name, DEFAULT_SPEED);
|
||||||
buf);
|
|
||||||
strncpy(buf, "", sizeof(buf));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* do we have a keypad? */
|
/* do we have a keypad? */
|
||||||
if (drvthis->config_get_bool( drvthis->name , "Keypad", 0, 0)) {
|
if (drvthis->config_get_bool(drvthis->name , "Keypad", 0, 0)) {
|
||||||
report (RPT_INFO, "CwLnx: Config file tell us we have a keypad...\n");
|
report(RPT_INFO, "%s: Config tells us we have a keypad", drvthis->name);
|
||||||
p->have_keypad = 1;
|
p->have_keypad = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* keypad test mode? */
|
/* keypad test mode? */
|
||||||
if (drvthis->config_get_bool( drvthis->name , "keypad_test_mode", 0, 0)) {
|
if (drvthis->config_get_bool(drvthis->name , "keypad_test_mode", 0, 0)) {
|
||||||
report (RPT_INFO, "CwLnx: Config tell us to test the keypad mapping...\n");
|
report(RPT_INFO, "%s: Config tells us to test the keypad mapping", drvthis->name);
|
||||||
p->keypad_test_mode = 1;
|
p->keypad_test_mode = 1;
|
||||||
stay_in_foreground = 1;
|
stay_in_foreground = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read the keypad mapping only if we have a keypad. */
|
/* read the keypad mapping only if we have a keypad. */
|
||||||
if (p->have_keypad)
|
if (p->have_keypad) {
|
||||||
{
|
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
/* Read keymap */
|
/* Read keymap */
|
||||||
for(x=0; x<MaxKeyMap; x++ )
|
for (x = 0; x < MaxKeyMap; x++) {
|
||||||
{
|
char buf[40];
|
||||||
char buf[40];
|
|
||||||
|
|
||||||
/* First fill with default value */
|
/* First fill with default value */
|
||||||
|
|
||||||
p->KeyMap[x] = defaultKeyMap[x];
|
p->KeyMap[x] = defaultKeyMap[x];
|
||||||
/* The line above make a warning... the code is comming from hd44780.c */
|
/* The line above make a warning... the code is comming from hd44780.c */
|
||||||
|
|
||||||
/* printf("%s-%s\n", defaultKeyMap[x], p->KeyMap[x]); */
|
/* printf("%s-%s\n", defaultKeyMap[x], p->KeyMap[x]); */
|
||||||
|
|
||||||
/* Read config value */
|
/* Read config value */
|
||||||
sprintf( buf, "KeyMap_%c", x+'A' );
|
sprintf(buf, "KeyMap_%c", x+'A');
|
||||||
s = drvthis->config_get_string( drvthis->name, buf, 0, NULL );
|
s = drvthis->config_get_string(drvthis->name, buf, 0, NULL);
|
||||||
|
|
||||||
/* Was a key specified in the config file ? */
|
|
||||||
if( s ) {
|
|
||||||
p->KeyMap[x] = strdup( s );
|
|
||||||
/* printf("CwLnx: Key '%c' to \"%s\"\n", x+'A', s ); */
|
|
||||||
report( RPT_INFO, "CwLnx: Key '%c' to \"%s\"", x+'A', s );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* Was a key specified in the config file ? */
|
||||||
|
if (s != NULL) {
|
||||||
|
p->KeyMap[x] = strdup(s);
|
||||||
|
report(RPT_INFO, "%s: Key '%c' to \"%s\"", drvthis->name, x+'A', s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* End of config file parsing */
|
/* End of config file parsing */
|
||||||
|
|
||||||
/* Allocate framebuffer memory */
|
/* Allocate framebuffer memory */
|
||||||
if (!p->framebuf) {
|
p->framebuf = malloc(p->width * p->height);
|
||||||
p->framebuf = malloc(p->width * p->height);
|
if (p->framebuf == NULL) {
|
||||||
p->backingstore = calloc(p->width * p->height, 1);
|
report(RPT_ERR, "%s: unable to create framebuffer", drvthis->name);
|
||||||
memset(p->backingstore, ' ', p->width * p->height);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!p->framebuf) {
|
|
||||||
report(RPT_ERR, "CwLnx: Error: unable to create framebuffer.\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p->backingstore = malloc(p->width * p->height);
|
||||||
|
if (p->backingstore == NULL) {
|
||||||
|
report(RPT_ERR, "%s: unable to create backingstore", drvthis->name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
memset(p->backingstore, ' ', p->width * p->height);
|
||||||
|
|
||||||
|
|
||||||
/* Set up io port correctly, and open it... */
|
/* Set up io port correctly, and open it... */
|
||||||
debug(RPT_DEBUG, "CwLnx: Opening serial device: %s", device);
|
debug(RPT_DEBUG, "%s: Opening serial device: %s", drvthis->name, device);
|
||||||
p->fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
|
p->fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||||
if (p->fd == -1) {
|
if (p->fd == -1) {
|
||||||
report(RPT_ERR, "CwLnx: init() failed (%s)\n", strerror(errno));
|
report(RPT_ERR, "%s: open(%s) failed (%s)", drvthis->name, device, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
|
||||||
report(RPT_INFO, "CwLnx: Opened display on %s", device);
|
|
||||||
}
|
}
|
||||||
|
report(RPT_INFO, "%s: opened display on %s", drvthis->name, device);
|
||||||
|
|
||||||
Init_Port(p->fd);
|
Init_Port(p->fd);
|
||||||
tcgetattr(p->fd, &portset_save);
|
tcgetattr(p->fd, &portset_save);
|
||||||
@@ -662,11 +647,11 @@ int CwLnx_init(Driver * drvthis)
|
|||||||
|
|
||||||
p->fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
|
p->fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||||
if (p->fd == -1) {
|
if (p->fd == -1) {
|
||||||
report(RPT_ERR, "CwLnx: init() failed (%s)\n", strerror(errno));
|
report(RPT_ERR, "%s: open(%s) failed (%s)", drvthis->name, device, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
|
||||||
report(RPT_INFO, "CwLnx: Opened display on %s", device);
|
|
||||||
}
|
}
|
||||||
|
report(RPT_INFO, "%s: opened display on %s", drvthis->name, device);
|
||||||
|
|
||||||
Init_Port(p->fd);
|
Init_Port(p->fd);
|
||||||
speed = B9600;
|
speed = B9600;
|
||||||
Setup_Port(p->fd, speed);
|
Setup_Port(p->fd, speed);
|
||||||
@@ -676,19 +661,13 @@ int CwLnx_init(Driver * drvthis)
|
|||||||
CwLnx_backlight(drvthis, 1); /* WHY force the backlight to on ? */
|
CwLnx_backlight(drvthis, 1); /* WHY force the backlight to on ? */
|
||||||
/* What is the default brightness ? */
|
/* What is the default brightness ? */
|
||||||
|
|
||||||
/* Set the functions the driver supports... */
|
|
||||||
|
|
||||||
/* TODO: WHY this ??? $$$ */
|
|
||||||
/* drvthis->daemonize = 1; */ /* make the server daemonize after initialization */
|
|
||||||
/* no daemonize in Driver ??? */
|
|
||||||
|
|
||||||
report(RPT_DEBUG, "CwLnx_init: done\n");
|
|
||||||
|
|
||||||
Clear_Screen(p->fd);
|
Clear_Screen(p->fd);
|
||||||
CwLnx_clear(drvthis);
|
CwLnx_clear(drvthis);
|
||||||
usleep(SETUP_DELAY);
|
usleep(SETUP_DELAY);
|
||||||
|
|
||||||
return p->fd;
|
report(RPT_DEBUG, "%s: init() done", drvthis->name);
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************
|
/******************************************************
|
||||||
@@ -699,19 +678,19 @@ CwLnx_close(Driver *drvthis)
|
|||||||
{
|
{
|
||||||
PrivateData * p = drvthis->private_data;
|
PrivateData * p = drvthis->private_data;
|
||||||
|
|
||||||
close(p->fd);
|
if (p != NULL) {
|
||||||
|
close(p->fd);
|
||||||
|
|
||||||
if (p->framebuf)
|
if (p->framebuf != NULL)
|
||||||
free(p->framebuf);
|
free(p->framebuf);
|
||||||
|
p->framebuf = NULL;
|
||||||
|
|
||||||
if (p->backingstore)
|
if (p->backingstore != NULL)
|
||||||
free(p->backingstore);
|
free(p->backingstore);
|
||||||
|
p->backingstore = NULL;
|
||||||
p->framebuf = NULL;
|
|
||||||
p->backingstore = NULL;
|
|
||||||
|
|
||||||
free(p);
|
|
||||||
|
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
debug(RPT_DEBUG, "CwLnx: closed");
|
debug(RPT_DEBUG, "CwLnx: closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -754,22 +733,18 @@ CwLnx_flushtime_backlight(Driver *drvthis)
|
|||||||
|
|
||||||
int bright;
|
int bright;
|
||||||
|
|
||||||
if ( ( (p->saved_backlight)&&(!p->backlight) )
|
if (((p->saved_backlight) && (!p->backlight))
|
||||||
|| ( (p->backlight)&&(!p->saved_backlight) ) )
|
|| ((p->backlight) && (!p->saved_backlight))) {
|
||||||
{
|
|
||||||
p->backlight = p->saved_backlight;
|
p->backlight = p->saved_backlight;
|
||||||
if (p->backlight)
|
if (p->backlight) {
|
||||||
{
|
Enable_Backlight(p->fd);
|
||||||
Enable_Backlight(p->fd);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Disable_Backlight(p->fd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Disable_Backlight(p->fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( p->brightness != p->saved_brightness )
|
if (p->brightness != p->saved_brightness) {
|
||||||
{
|
|
||||||
p->brightness = p->saved_brightness;
|
p->brightness = p->saved_brightness;
|
||||||
Backlight_Brightness(p->fd, p->brightness)
|
Backlight_Brightness(p->fd, p->brightness)
|
||||||
}
|
}
|
||||||
@@ -783,11 +758,11 @@ CwLnx_flushtime_backlight(Driver *drvthis)
|
|||||||
* It make a pixel blink at calling rate independently of flush call.
|
* It make a pixel blink at calling rate independently of flush call.
|
||||||
*/
|
*/
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
CwLnx_flushtime_heartbeat( Driver * drvthis )
|
CwLnx_flushtime_heartbeat(Driver * drvthis)
|
||||||
{
|
{
|
||||||
PrivateData * p = drvthis->private_data;
|
PrivateData * p = drvthis->private_data;
|
||||||
|
|
||||||
if ( p->heartbeat != p->saved_heartbeat ) {
|
if (p->heartbeat != p->saved_heartbeat) {
|
||||||
p->saved_heartbeat=p->heartbeat;
|
p->saved_heartbeat=p->heartbeat;
|
||||||
if (p->heartbeat) {
|
if (p->heartbeat) {
|
||||||
Enable_Pixel(p->fd, 121, 0);
|
Enable_Pixel(p->fd, 121, 0);
|
||||||
@@ -822,20 +797,18 @@ void Set_Insert(int fd, int row, int col)
|
|||||||
|
|
||||||
c = LCD_CMD;
|
c = LCD_CMD;
|
||||||
rc = Write_LCD(fd, &c, 1);
|
rc = Write_LCD(fd, &c, 1);
|
||||||
if (row==0 && col==0)
|
if (row == 0 && col == 0) {
|
||||||
{
|
|
||||||
c = LCD_INIT_INSERT;
|
c = LCD_INIT_INSERT;
|
||||||
rc = Write_LCD(fd, &c, 1);
|
rc = Write_LCD(fd, &c, 1);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
c = LCD_SET_INSERT;
|
||||||
c = LCD_SET_INSERT;
|
rc = Write_LCD(fd, &c, 1);
|
||||||
rc = Write_LCD(fd, &c, 1);
|
c = col;
|
||||||
c = col;
|
rc = Write_LCD(fd, &c, 1);
|
||||||
rc = Write_LCD(fd, &c, 1);
|
c = row;
|
||||||
c = row;
|
rc = Write_LCD(fd, &c, 1);
|
||||||
rc = Write_LCD(fd, &c, 1);
|
}
|
||||||
}
|
|
||||||
c = LCD_CMD_END;
|
c = LCD_CMD_END;
|
||||||
rc = Write_LCD(fd, &c, 1);
|
rc = Write_LCD(fd, &c, 1);
|
||||||
}
|
}
|
||||||
@@ -848,7 +821,7 @@ void CwLnx_flush_box(int lft, int top, int rgt, int bot)
|
|||||||
{
|
{
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
debug(RPT_DEBUG, "CwLnx: flush_box (%i,%i)-(%i,%i)\n", lft, top, rgt,
|
debug(RPT_DEBUG, "CwLnx: flush_box (%i,%i)-(%i,%i)", lft, top, rgt,
|
||||||
bot);
|
bot);
|
||||||
for (y = top; y <= bot; y++) {
|
for (y = top; y <= bot; y++) {
|
||||||
Set_Insert(fd, top, lft);
|
Set_Insert(fd, top, lft);
|
||||||
@@ -945,7 +918,7 @@ CwLnx_set_brightness(Driver * drvthis, int state, int promille)
|
|||||||
/*********************************************************
|
/*********************************************************
|
||||||
* Toggle the built-in linewrapping feature
|
* Toggle the built-in linewrapping feature
|
||||||
*/
|
*/
|
||||||
static void CwLnx_linewrap (int fd, int on)
|
static void CwLnx_linewrap(int fd, int on)
|
||||||
{
|
{
|
||||||
if (on)
|
if (on)
|
||||||
Enable_Wrap(fd);
|
Enable_Wrap(fd);
|
||||||
@@ -1197,7 +1170,7 @@ CwLnx_set_char(Driver * drvthis, int n, char *dat)
|
|||||||
letter <<= 1;
|
letter <<= 1;
|
||||||
letter |= (dat[(col * p->cellheight) + row] > 0);
|
letter |= (dat[(col * p->cellheight) + row] > 0);
|
||||||
}
|
}
|
||||||
c=letter;
|
c = letter;
|
||||||
Write_LCD(p->fd, &c, 1);
|
Write_LCD(p->fd, &c, 1);
|
||||||
}
|
}
|
||||||
c = LCD_CMD_END;
|
c = LCD_CMD_END;
|
||||||
@@ -1309,46 +1282,46 @@ CwLnx_icon(Driver * drvthis, int x, int y, int icon)
|
|||||||
|
|
||||||
|
|
||||||
/* Yes we know, this is a VERY BAD implementation */
|
/* Yes we know, this is a VERY BAD implementation */
|
||||||
switch( icon ) {
|
switch (icon) {
|
||||||
case ICON_HEART_FILLED:
|
case ICON_HEART_FILLED:
|
||||||
CwLnx_set_char( drvthis, 8, heart_filled );
|
CwLnx_set_char(drvthis, 8, heart_filled);
|
||||||
CwLnx_chr( drvthis, x, y, 8 );
|
CwLnx_chr(drvthis, x, y, 8);
|
||||||
break;
|
break;
|
||||||
case ICON_HEART_OPEN:
|
case ICON_HEART_OPEN:
|
||||||
CwLnx_set_char( drvthis, 8, heart_open );
|
CwLnx_set_char(drvthis, 8, heart_open);
|
||||||
CwLnx_chr( drvthis, x, y, 8 );
|
CwLnx_chr(drvthis, x, y, 8);
|
||||||
break;
|
break;
|
||||||
case ICON_CHECKBOX_GRAY:
|
case ICON_CHECKBOX_GRAY:
|
||||||
CwLnx_set_char( drvthis, 9, checkbox_gray );
|
CwLnx_set_char(drvthis, 9, checkbox_gray);
|
||||||
CwLnx_chr( drvthis, x, y, 9 );
|
CwLnx_chr(drvthis, x, y, 9);
|
||||||
break;
|
break;
|
||||||
case ICON_BLOCK_FILLED:
|
case ICON_BLOCK_FILLED:
|
||||||
CwLnx_set_char( drvthis, 10, block_filled );
|
CwLnx_set_char(drvthis, 10, block_filled);
|
||||||
CwLnx_chr( drvthis, x, y, 10 );
|
CwLnx_chr(drvthis, x, y, 10);
|
||||||
break;
|
break;
|
||||||
case ICON_ARROW_UP:
|
case ICON_ARROW_UP:
|
||||||
CwLnx_set_char( drvthis, 11, arrow_up );
|
CwLnx_set_char(drvthis, 11, arrow_up);
|
||||||
CwLnx_chr( drvthis, x, y, 11 );
|
CwLnx_chr(drvthis, x, y, 11);
|
||||||
break;
|
break;
|
||||||
case ICON_ARROW_DOWN:
|
case ICON_ARROW_DOWN:
|
||||||
CwLnx_set_char( drvthis, 12, arrow_down );
|
CwLnx_set_char(drvthis, 12, arrow_down);
|
||||||
CwLnx_chr( drvthis, x, y, 12 );
|
CwLnx_chr(drvthis, x, y, 12);
|
||||||
break;
|
break;
|
||||||
case ICON_ARROW_LEFT:
|
case ICON_ARROW_LEFT:
|
||||||
CwLnx_set_char( drvthis, 13, arrow_left );
|
CwLnx_set_char(drvthis, 13, arrow_left);
|
||||||
CwLnx_chr( drvthis, x, y, 13 );
|
CwLnx_chr(drvthis, x, y, 13);
|
||||||
break;
|
break;
|
||||||
case ICON_ARROW_RIGHT:
|
case ICON_ARROW_RIGHT:
|
||||||
CwLnx_set_char( drvthis, 14, arrow_right );
|
CwLnx_set_char(drvthis, 14, arrow_right);
|
||||||
CwLnx_chr( drvthis, x, y, 14 );
|
CwLnx_chr(drvthis, x, y, 14);
|
||||||
break;
|
break;
|
||||||
case ICON_CHECKBOX_OFF:
|
case ICON_CHECKBOX_OFF:
|
||||||
CwLnx_set_char( drvthis, 15, checkbox_off );
|
CwLnx_set_char(drvthis, 15, checkbox_off);
|
||||||
CwLnx_chr( drvthis, x, y, 15 );
|
CwLnx_chr(drvthis, x, y, 15);
|
||||||
break;
|
break;
|
||||||
case ICON_CHECKBOX_ON:
|
case ICON_CHECKBOX_ON:
|
||||||
CwLnx_set_char( drvthis, 16, checkbox_on );
|
CwLnx_set_char(drvthis, 16, checkbox_on);
|
||||||
CwLnx_chr( drvthis, x, y, 16 );
|
CwLnx_chr(drvthis, x, y, 16);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -1; /* Let the core do other icons */
|
return -1; /* Let the core do other icons */
|
||||||
@@ -1381,34 +1354,27 @@ void CwLnx_draw_frame(Driver *drvthis, char *dat)
|
|||||||
|
|
||||||
/* printf("\n_draw_frame: %d\n", count); */
|
/* printf("\n_draw_frame: %d\n", count); */
|
||||||
|
|
||||||
for (i = 0; i < p->height; i++)
|
for (i = 0; i < p->height; i++) {
|
||||||
{
|
for (j = 0; j < p->width; j++) {
|
||||||
for (j = 0; j < p->width; j++)
|
if ((*q == *r) && !((0 < *q) && (*q < 16))) {
|
||||||
{
|
mv = 1;
|
||||||
if ( (*q == *r) && !( (0<*q) && (*q<16) ) )
|
|
||||||
{
|
|
||||||
mv = 1;
|
|
||||||
/* count++; if (count==COUNT) exit(0); */
|
/* count++; if (count==COUNT) exit(0); */
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
/* Draw characters that have changed, as well
|
||||||
/* Draw characters that have changed, as well
|
* 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) {
|
||||||
*/
|
Set_Insert(p->fd, i, j);
|
||||||
if (mv == 1)
|
mv = 0;
|
||||||
{
|
}
|
||||||
Set_Insert(p->fd, i, j);
|
rc = Write_LCD(p->fd, q, 1);
|
||||||
mv = 0;
|
}
|
||||||
}
|
q++;
|
||||||
rc = Write_LCD(p->fd, q, 1);
|
r++;
|
||||||
}
|
}
|
||||||
q++;
|
}
|
||||||
r++;
|
strncpy(p->backingstore, dat, p->width * p->height);
|
||||||
}
|
|
||||||
}
|
|
||||||
strncpy(p->backingstore, dat, p->width * p->height);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************
|
/*********************************************************
|
||||||
@@ -1474,14 +1440,14 @@ CwLnx_get_key(Driver * drvthis)
|
|||||||
PrivateData * p = drvthis->private_data;
|
PrivateData * p = drvthis->private_data;
|
||||||
char key = '\0';
|
char key = '\0';
|
||||||
|
|
||||||
read (p->fd, &key, 1);
|
read(p->fd, &key, 1);
|
||||||
|
|
||||||
if (key != '\0') {
|
if (key != '\0') {
|
||||||
if ((key >= 'A') && (key <= 'F')) {
|
if ((key >= 'A') && (key <= 'F')) {
|
||||||
return p->KeyMap[key-'A'];
|
return p->KeyMap[key-'A'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
report( RPT_INFO, "CwLnx: Untreated key 0x%2x", key);
|
report(RPT_INFO, "%s: Untreated key 0x%02X", drvthis->name, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1503,21 +1469,21 @@ CwLnx_get_key(Driver * drvthis)
|
|||||||
/*I*/ int heartbeat_state;
|
/*I*/ int heartbeat_state;
|
||||||
|
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
CwLnx_heartbeat( Driver * drvthis, int type )
|
CwLnx_heartbeat(Driver * drvthis, int type)
|
||||||
{
|
{
|
||||||
PrivateData * p = drvthis->private_data;
|
PrivateData * p = drvthis->private_data;
|
||||||
|
|
||||||
if (type) {
|
if (type) {
|
||||||
if (p->heartbeat_state) {
|
if (p->heartbeat_state) {
|
||||||
p->heartbeat=1;
|
p->heartbeat = 1;
|
||||||
p->heartbeat_state = 0;
|
p->heartbeat_state = 0;
|
||||||
} else {
|
} else {
|
||||||
p->heartbeat=0;
|
p->heartbeat = 0;
|
||||||
p->heartbeat_state = 1;
|
p->heartbeat_state = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (p->heartbeat_state) {
|
if (p->heartbeat_state) {
|
||||||
p->heartbeat=0;
|
p->heartbeat = 0;
|
||||||
p->heartbeat_state = 0;
|
p->heartbeat_state = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1525,7 +1491,7 @@ CwLnx_heartbeat( Driver * drvthis, int type )
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
CwLnx_heartbeat( Driver * drvthis, int type )
|
CwLnx_heartbeat(Driver * drvthis, int type)
|
||||||
{
|
{
|
||||||
PrivateData * p = drvthis->private_data;
|
PrivateData * p = drvthis->private_data;
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
#define DEFAULT_CELLWIDTH 6
|
#define DEFAULT_CELLWIDTH 6
|
||||||
#define DEFAULT_CELLHEIGHT 8
|
#define DEFAULT_CELLHEIGHT 8
|
||||||
#define DEFAULT_DEVICE "/dev/lcd"
|
#define DEFAULT_DEVICE "/dev/lcd"
|
||||||
#define DEFAULT_SPEED B19200
|
#define DEFAULT_SPEED 19200
|
||||||
#define DEFAULT_SIZE "20x4"
|
#define DEFAULT_SIZE "20x4"
|
||||||
#define DEFAULT_BACKLIGHT 1
|
#define DEFAULT_BACKLIGHT 1
|
||||||
#define DEFAULT_BRIGHTNESS 200
|
#define DEFAULT_BRIGHTNESS 200
|
||||||
|
|||||||
Reference in New Issue
Block a user