space cleanups

This commit is contained in:
marschap
2005-06-12 17:39:25 +00:00
parent d6971eaec5
commit a597e2cdcf
2 changed files with 33 additions and 29 deletions
+13 -11
View File
@@ -145,7 +145,7 @@ CFontz633_init (Driver *drvthis, char *args)
char size[200] = DEFAULT_SIZE; char size[200] = DEFAULT_SIZE;
PrivateData *p; PrivateData *p;
/* Allocate and store private data */ /* Allocate and store private data */
p = (PrivateData *) calloc(1, sizeof(PrivateData)); p = (PrivateData *) calloc(1, sizeof(PrivateData));
if (p == NULL) if (p == NULL)
@@ -172,11 +172,11 @@ CFontz633_init (Driver *drvthis, char *args)
/* 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, "CFontz633_init: Cannot read size: %s. Using default value.\n", size); report (RPT_WARNING, "CFontz633_init: Cannot read size: %s. Using default value.\n", size);
sscanf( DEFAULT_SIZE, "%dx%d", &w, &h ); sscanf(DEFAULT_SIZE, "%dx%d", &w, &h);
} }
p->width = w; p->width = w;
p->height = h; p->height = h;
@@ -188,7 +188,7 @@ CFontz633_init (Driver *drvthis, char *args)
tmp = DEFAULT_CONTRAST; tmp = DEFAULT_CONTRAST;
} }
p->contrast = tmp; p->contrast = tmp;
/* Which backlight brightness */ /* 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)) { if ((tmp < 0) || (tmp > 1000)) {
@@ -212,7 +212,9 @@ CFontz633_init (Driver *drvthis, char *args)
else if (tmp == 9600) speed = B9600; else if (tmp == 9600) speed = B9600;
else if (tmp == 19200) speed = B19200; else if (tmp == 19200) speed = B19200;
else if (tmp == 115200) speed = B115200; else if (tmp == 115200) speed = B115200;
else { report (RPT_WARNING, "CFontz633_init: Speed must be 1200, 2400, 9600, 19200 or 115200. Using default value.\n", speed); else {
report (RPT_WARNING, "CFontz633_init: Speed must be 1200, 2400, 9600, 19200 or 115200. Using default value.\n");
speed = DEFAULT_SPEED;
} }
/* New firmware version? /* New firmware version?
@@ -251,7 +253,7 @@ CFontz633_init (Driver *drvthis, char *args)
} else { } else {
#ifdef HAVE_CFMAKERAW #ifdef HAVE_CFMAKERAW
/* The easy way */ /* The easy way */
cfmakeraw( &portset ); cfmakeraw(&portset);
#else #else
/* The hard way */ /* The hard way */
portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP
@@ -461,7 +463,7 @@ CFontz633_get_key (Driver *drvthis)
break; break;
default: default:
if (key != '\0') if (key != '\0')
report( RPT_INFO, "cfontz633: Untreated key 0x%2x", key); report( RPT_INFO, "cfontz633: Untreated key 0x%2x", key);
return NULL; return NULL;
break; break;
} }
@@ -544,12 +546,12 @@ CFontz633_set_brightness(Driver *drvthis, int state, int promille)
/* Check it */ /* Check it */
if (promille < 0 || promille > 1000) if (promille < 0 || promille > 1000)
return; return;
/* store the software value since there is not get */ /* store the software value since there is not get */
if (state == BACKLIGHT_ON) { if (state == BACKLIGHT_ON) {
p->brightness = promille; p->brightness = promille;
//CFontz633_backlight(drvthis, BACKLIGHT_ON); //CFontz633_backlight(drvthis, BACKLIGHT_ON);
} }
else { else {
p->offbrightness = promille; p->offbrightness = promille;
//CFontz633_backlight(drvthis, BACKLIGHT_OFF); //CFontz633_backlight(drvthis, BACKLIGHT_OFF);
@@ -568,7 +570,7 @@ CFontz633_backlight (Driver *drvthis, int on)
int hardware_value = (on == BACKLIGHT_ON) int hardware_value = (on == BACKLIGHT_ON)
? p->brightness ? p->brightness
: p->offbrightness; : p->offbrightness;
/* map range [0, 1000] -> [0, 100] that the hardware understands */ /* map range [0, 1000] -> [0, 100] that the hardware understands */
hardware_value /= 10; hardware_value /= 10;
send_onebyte_message(p->fd, CF633_Set_LCD_And_Keypad_Backlight, hardware_value); send_onebyte_message(p->fd, CF633_Set_LCD_And_Keypad_Backlight, hardware_value);
@@ -813,7 +815,7 @@ CFontz633_init_hbar (Driver *drvthis)
// return; // return;
//} //}
p->ccmode = hbar; p->ccmode = hbar;
CFontz633_set_char (drvthis, 1, a); CFontz633_set_char (drvthis, 1, a);
CFontz633_set_char (drvthis, 2, b); CFontz633_set_char (drvthis, 2, b);
CFontz633_set_char (drvthis, 3, c); CFontz633_set_char (drvthis, 3, c);
+20 -18
View File
@@ -6,7 +6,7 @@
* *
* -- David GLAUDE * -- David GLAUDE
*/ */
/* /*
* This is the LCDproc driver for CrystalFontz LCD using Packet protocol. * This is the LCDproc driver for CrystalFontz LCD using Packet protocol.
* It support the CrystalFontz 633 USB/Serial, the 631 USB and the 635 USB * It support the CrystalFontz 633 USB/Serial, the 631 USB and the 635 USB
* (get yours from http://crystalfontz.com) * (get yours from http://crystalfontz.com)
@@ -31,7 +31,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
*/ */
/* /*
@@ -211,7 +211,7 @@ CFontz633_init (Driver *drvthis, char *args)
report (RPT_WARNING, "CFontzPacket_init: Model must be 631, 633 or 635. Using default value: %d\n", tmp); report (RPT_WARNING, "CFontzPacket_init: Model must be 631, 633 or 635. Using default value: %d\n", tmp);
} }
p->model = tmp; p->model = tmp;
/* Which device should be used */ /* 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'; p->device[sizeof(p->device)-1] = '\0';
@@ -224,15 +224,15 @@ CFontz633_init (Driver *drvthis, char *args)
default_size = DEFAULT_SIZE_CF633; default_size = DEFAULT_SIZE_CF633;
else if (p->model == 635) else if (p->model == 635)
default_size = DEFAULT_SIZE_CF635; default_size = DEFAULT_SIZE_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'; size[sizeof(size)-1] = '\0';
debug (RPT_INFO,"CFontzPacket_init: Size (in config) is '%s'", size); debug (RPT_INFO,"CFontzPacket_init: Size (in config) is '%s'", size);
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, "CFontzPacket_init: Cannot read size: %s. Using default value.\n", size); report (RPT_WARNING, "CFontzPacket_init: Cannot read size: %s. Using default value.\n", size);
sscanf( default_size, "%dx%d", &w, &h ); sscanf(default_size, "%dx%d", &w, &h);
} }
p->width = w; p->width = w;
p->height = h; p->height = h;
@@ -271,7 +271,9 @@ CFontz633_init (Driver *drvthis, char *args)
debug (RPT_INFO,"CFontzPacket_init: Speed (in config) is '%d'", tmp); debug (RPT_INFO,"CFontzPacket_init: Speed (in config) is '%d'", tmp);
if (tmp == 19200) speed = B19200; if (tmp == 19200) speed = B19200;
else if (tmp == 115200) speed = B115200; else if (tmp == 115200) speed = B115200;
else { report (RPT_WARNING, "CFontz633_init: Speed must be 19200 or 11500. Using default value.\n", speed); else {
report (RPT_WARNING, "CFontz633_init: Speed must be 19200 or 11500. Using default value.\n");
speed = DEFAULT_SPEED;
} }
/* New firmware version? /* New firmware version?
@@ -312,7 +314,7 @@ CFontz633_init (Driver *drvthis, char *args)
} else { } else {
#ifdef HAVE_CFMAKERAW #ifdef HAVE_CFMAKERAW
/* The easy way */ /* The easy way */
cfmakeraw( &portset ); cfmakeraw(&portset);
#else #else
/* The hard way */ /* The hard way */
portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP
@@ -456,7 +458,7 @@ CFontz633_flush (Driver *drvthis)
*/ */
unsigned char *xp = p->framebuf; unsigned char *xp = p->framebuf;
unsigned char *xq = p->backingstore; unsigned char *xq = p->backingstore;
for (i = 0; i < p->width; i++) { for (i = 0; i < p->width; i++) {
if (*xp++ != *xq++) { if (*xp++ != *xq++) {
send_bytes_message(p->fd, CF633_Set_LCD_Contents_Line_One, 16, p->framebuf); send_bytes_message(p->fd, CF633_Set_LCD_Contents_Line_One, 16, p->framebuf);
@@ -489,17 +491,17 @@ CFontz633_flush (Driver *drvthis)
debug (RPT_INFO,"Framebuf: '%.*s'", p->width, xp ); debug (RPT_INFO,"Framebuf: '%.*s'", p->width, xp );
debug (RPT_INFO," backingstore: '%.*s'", p->width, xq ); debug (RPT_INFO," backingstore: '%.*s'", p->width, xq );
for (j = 0; j < p->width; ) { for (j = 0; j < p->width; ) {
// skip over identical portions // skip over identical portions
for ( ; *xp == *xq && j < p->width; xp++, xq++, j++ ) for ( ; *xp == *xq && j < p->width; xp++, xq++, j++ )
; ;
// deal with the differences // deal with the differences
if (j < p->width) { if (j < p->width) {
unsigned char out[23]; unsigned char out[23];
int diff_length; int diff_length;
int first_diff = j; int first_diff = j;
// get length of differing portions // get length of differing portions
for ( ; *xp != *xq && j < p->width; xp++, xq++, j++ ) for ( ; *xp != *xq && j < p->width; xp++, xq++, j++ )
; ;
@@ -508,14 +510,14 @@ CFontz633_flush (Driver *drvthis)
diff_length = j - first_diff; diff_length = j - first_diff;
out[0] = first_diff; // column out[0] = first_diff; // column
out[1] = i; // line out[1] = i; // line
debug (RPT_INFO,"WriteDiff: l=%d c=%d count=%d string='%.*s'", debug (RPT_INFO,"WriteDiff: l=%d c=%d count=%d string='%.*s'",
out[0], out[1], diff_length, diff_length, 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); send_bytes_message(p->fd, CF633_Send_Data_to_LCD, diff_length + 2, out);
} }
} // j < p->width } // j < p->width
} // i < p->height } // i < p->height
memcpy(p->backingstore, p->framebuf, p->width * p->height); memcpy(p->backingstore, p->framebuf, p->width * p->height);
@@ -685,12 +687,12 @@ CFontz633_set_brightness(Driver *drvthis, int state, int promille)
/* Check it */ /* Check it */
if (promille < 0 || promille > 1000) if (promille < 0 || promille > 1000)
return; return;
/* store the software value since there is not get */ /* store the software value since there is not get */
if (state == BACKLIGHT_ON) { if (state == BACKLIGHT_ON) {
p->brightness = promille; p->brightness = promille;
//CFontz633_backlight(drvthis, BACKLIGHT_ON); //CFontz633_backlight(drvthis, BACKLIGHT_ON);
} }
else { else {
p->offbrightness = promille; p->offbrightness = promille;
//CFontz633_backlight(drvthis, BACKLIGHT_OFF); //CFontz633_backlight(drvthis, BACKLIGHT_OFF);
@@ -709,7 +711,7 @@ CFontz633_backlight (Driver *drvthis, int on)
int hardware_value = (on == BACKLIGHT_ON) int hardware_value = (on == BACKLIGHT_ON)
? p->brightness ? p->brightness
: p->offbrightness; : p->offbrightness;
/* map range [0, 1000] -> [0, 100] that the hardware understands */ /* map range [0, 1000] -> [0, 100] that the hardware understands */
hardware_value /= 10; hardware_value /= 10;
send_onebyte_message(p->fd, CF633_Set_LCD_And_Keypad_Backlight, hardware_value); send_onebyte_message(p->fd, CF633_Set_LCD_And_Keypad_Backlight, hardware_value);
@@ -740,7 +742,7 @@ CFontz633_no_live_report (Driver *drvthis)
if (p->model == 633) { if (p->model == 633) {
for (out[0] = 0; out[0] < 8; out[0]++) for (out[0] = 0; out[0] < 8; out[0]++)
send_bytes_message(p->fd, CF633_Set_Up_Live_Fan_or_Temperature_Display, 2, out); send_bytes_message(p->fd, CF633_Set_Up_Live_Fan_or_Temperature_Display, 2, out);
} }
} }