lots of little fixes for harmonizing it with CFontz633.c
This commit is contained in:
@@ -38,7 +38,7 @@
|
||||
* Driver status
|
||||
* 04/04/2002: Working driver
|
||||
* 05/06/2002: Reading of return value
|
||||
* 02/09/2002: KeyPad handeling and return string
|
||||
* 02/09/2002: KeyPad handling and return string
|
||||
* 03/09/2002: New icon incorporated
|
||||
* 27/01/2003: Adapted for CFontz 631
|
||||
* 16/05/2005: Adapted for CFontz 635
|
||||
@@ -53,7 +53,6 @@
|
||||
* + Stopping the live reporting (of temperature)
|
||||
* + Stopping the reporting of temp and fan (is it necessary after reboot)
|
||||
* + Use of library for hbar and vbar (good but library could be better)
|
||||
* + Support for keypad (Using a KeyRing)
|
||||
*
|
||||
* THINGS TO DO:
|
||||
* + Make the caching at least for heartbeat icon
|
||||
@@ -106,6 +105,7 @@
|
||||
#define CELLWIDTH DEFAULT_CELL_WIDTH
|
||||
#define CELLHEIGHT DEFAULT_CELL_HEIGHT
|
||||
|
||||
|
||||
/* Constants for userdefchar_mode */
|
||||
#define NUM_CCs 8 /* max. number of custom characters */
|
||||
|
||||
@@ -135,7 +135,7 @@ typedef struct driver_private_data {
|
||||
int width, height;
|
||||
int cellwidth, cellheight;
|
||||
|
||||
/* framebuffer and buffer for backingstore LCD contents */
|
||||
/* framebuffer and buffer for old LCD contents */
|
||||
unsigned char *framebuf;
|
||||
unsigned char *backingstore;
|
||||
|
||||
@@ -148,6 +148,7 @@ typedef struct driver_private_data {
|
||||
int offbrightness;
|
||||
} PrivateData;
|
||||
|
||||
|
||||
/* Vars for the server core */
|
||||
MODULE_EXPORT char *api_version = API_VERSION;
|
||||
MODULE_EXPORT int stay_in_foreground = 0;
|
||||
@@ -189,9 +190,9 @@ CFontz633_init (Driver * drvthis, char *args)
|
||||
return -1;
|
||||
|
||||
/* Initialize the PrivateData structure */
|
||||
|
||||
p->cellwidth = DEFAULT_CELL_WIDTH;
|
||||
p->cellheight = DEFAULT_CELL_HEIGHT;
|
||||
p->ccmode = standard;
|
||||
|
||||
debug(RPT_INFO, "CFontz633: init(%p,%s)", drvthis, args );
|
||||
|
||||
@@ -208,7 +209,7 @@ CFontz633_init (Driver * drvthis, char *args)
|
||||
}
|
||||
p->model = tmp;
|
||||
|
||||
/* Which serial 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));
|
||||
p->device[sizeof(p->device)-1] = '\0';
|
||||
debug (RPT_INFO,"CFontzPacket_init: Device (in config) is '%s'", p->device);
|
||||
@@ -224,7 +225,7 @@ CFontz633_init (Driver * drvthis, char *args)
|
||||
strncpy(size, drvthis->config_get_string (drvthis->name, "Size", 0, default_size), sizeof(size));
|
||||
size[sizeof(size)-1] = '\0';
|
||||
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)
|
||||
|| (h <= 0) || (h > LCD_MAX_HEIGHT)) {
|
||||
report (RPT_WARNING, "CFontzPacket_init: Cannot read size: %s. Using default value.\n", size);
|
||||
@@ -285,7 +286,7 @@ CFontz633_init (Driver * drvthis, char *args)
|
||||
report (RPT_INFO, "CFontzPacket_init: USB is indicated (in config).\n");
|
||||
|
||||
/* Set up io port correctly, and open it... */
|
||||
debug( RPT_DEBUG, "CFontzPacket_init: Opening the device: %s", p->device);
|
||||
debug( RPT_DEBUG, "CFontzPacket_init: 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, "CFontzPacket_init: failed (%s)\n", strerror (errno));
|
||||
@@ -327,7 +328,7 @@ CFontz633_init (Driver * drvthis, char *args)
|
||||
/* Do it... */
|
||||
tcsetattr (p->fd, TCSANOW, &portset);
|
||||
|
||||
/* Make sure the frame buffer is there... */
|
||||
/* make sure the frame buffer is there... */
|
||||
p->framebuf = (unsigned char *) malloc(p->width * p->height);
|
||||
if (p->framebuf == NULL) {
|
||||
report(RPT_ERR, "CFontzPacket_init: unable to create framebuffer.\n");
|
||||
@@ -335,7 +336,7 @@ CFontz633_init (Driver * drvthis, char *args)
|
||||
}
|
||||
memset(p->framebuf, ' ', p->width * p->height);
|
||||
|
||||
/* Make sure the framebuffer backing store is there... */
|
||||
/* make sure the framebuffer backing store is there... */
|
||||
p->backingstore = (unsigned char *) malloc(p->width * p->height);
|
||||
if (p->backingstore == NULL) {
|
||||
report(RPT_ERR, "CFontzPacket_init: unable to create framebuffer backing store.\n");
|
||||
@@ -348,7 +349,6 @@ CFontz633_init (Driver * drvthis, char *args)
|
||||
debug(RPT_INFO, "CFontzPacket: reboot requested\n" );
|
||||
CFontz633_reboot (drvthis);
|
||||
reboot = 0;
|
||||
sleep (2);
|
||||
debug(RPT_INFO, "CFontzPacket: reboot done" );
|
||||
}
|
||||
|
||||
@@ -372,6 +372,9 @@ CFontz633_close (Driver * drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
if (p != NULL) {
|
||||
close(p->fd);
|
||||
|
||||
if (p->framebuf)
|
||||
free(p->framebuf);
|
||||
p->framebuf = NULL;
|
||||
@@ -380,8 +383,8 @@ CFontz633_close (Driver * drvthis)
|
||||
free(p->backingstore);
|
||||
p->backingstore = NULL;
|
||||
|
||||
if (p != NULL)
|
||||
free(p);
|
||||
}
|
||||
drvthis->store_private_ptr(drvthis, NULL);
|
||||
}
|
||||
|
||||
@@ -499,11 +502,12 @@ CFontz633_flush (Driver * drvthis)
|
||||
MODULE_EXPORT char *
|
||||
CFontz633_get_key (Driver *drvthis)
|
||||
{
|
||||
unsigned char akey;
|
||||
PrivateData *p = drvthis->private_data;
|
||||
unsigned char key;
|
||||
|
||||
akey = GetKeyFromKeyRing();
|
||||
key = GetKeyFromKeyRing(&p->keyring);
|
||||
|
||||
switch(akey) {
|
||||
switch (key) {
|
||||
case CF633_KEY_LEFT:
|
||||
return "Left";
|
||||
break;
|
||||
@@ -544,12 +548,12 @@ CFontz633_get_key (Driver *drvthis)
|
||||
case CF631_KEY_UR_RELEASE:
|
||||
case CF631_KEY_LL_RELEASE:
|
||||
case CF631_KEY_LR_RELEASE:
|
||||
// report( RPT_INFO, "cfontz633: Returning key 0x%2x", akey);
|
||||
// report( RPT_INFO, "cfontz633: Returning key release 0x%2x", key);
|
||||
return NULL;
|
||||
break;
|
||||
|
||||
default:
|
||||
// report( RPT_INFO, "cfontz633: Untreated key 0x%2x", akey);
|
||||
if (key != '\0')
|
||||
report( RPT_INFO, "cfontz633: Untreated unknown key 0x%2x", key);
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
@@ -651,10 +655,11 @@ CFontz633_no_live_report (Driver *drvthis)
|
||||
PrivateData *p = drvthis->private_data;
|
||||
char out[2] = { 0, 0 };
|
||||
|
||||
if (p->model == 633)
|
||||
if (p->model == 633) {
|
||||
for (out[0] = 0; out[0] < 8; out[0]++)
|
||||
send_bytes_message(p->fd, 2, CF633_Set_Up_Live_Fan_or_Temperature_Display, out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@@ -694,6 +699,7 @@ CFontz633_reboot (Driver *drvthis)
|
||||
char out[3] = { 8, 18, 99 };
|
||||
|
||||
send_bytes_message(p->fd, 3, CF633_Reboot, out);
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
|
||||
@@ -704,7 +710,6 @@ static void
|
||||
CFontz633_init_vbar (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
char a[] = {
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
@@ -802,7 +807,6 @@ static void
|
||||
CFontz633_init_hbar (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
char a[] = {
|
||||
1, 0, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0, 0,
|
||||
@@ -867,7 +871,7 @@ CFontz633_init_hbar (Driver * drvthis)
|
||||
if (p->ccmode != hbar) {
|
||||
if (p->ccmode != standard) {
|
||||
/* Not supported(yet) */
|
||||
report(RPT_WARNING, "CFontz633_init_vbar: Cannot combine two modes using user defined characters");
|
||||
report(RPT_WARNING, "CFontz633_init_hbar: Cannot combine two modes using user defined characters");
|
||||
return;
|
||||
}
|
||||
p->ccmode = hbar;
|
||||
@@ -929,8 +933,8 @@ CFontz633_num (Driver * drvthis, int x, int num)
|
||||
{
|
||||
/*
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
char out[5];
|
||||
|
||||
snprintf (out, sizeof(out), "%c%c%c", 28, x, num);
|
||||
write (p->fd, out, 3);
|
||||
*/
|
||||
@@ -1127,7 +1131,6 @@ CFontz633_clear (Driver * drvthis)
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
memset(p->framebuf, ' ', p->width * p->height);
|
||||
|
||||
p->ccmode = standard;
|
||||
}
|
||||
|
||||
@@ -1158,8 +1161,7 @@ CFontz633_string (Driver * drvthis, int x, int y, char string[])
|
||||
x--;
|
||||
y--;
|
||||
|
||||
for (i = 0; string[i] != '\0'; 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