CFontzPacket updates:
- Add a structure describing known models, their features and default settings. - Use partial screen updates for newer CFA633 versions. - For CFA533/633 use the same character mapping as for HD44780. - Fixed a few typos. - Use C-style comments only. - Add a warning about the driver being deprecated to CFontz633. Users should use CFontzPacket with Model=633 instead.
This commit is contained in:
@@ -40,11 +40,7 @@
|
||||
* 03/09/2002: New icon incorporated
|
||||
* 27/01/2003: Adapted for CFontz 631
|
||||
* 16/05/2005: Adapted for CFontz 635
|
||||
*
|
||||
* THINGS NOT DONE:
|
||||
* + No checking if right hardware is connected (firmware/hardware)
|
||||
* + No support for multiple instance (private structure done)
|
||||
* + No cache of custom char usage (like in MtxOrb)
|
||||
* 24/01/2010: Add CFontz 533, add model description
|
||||
*
|
||||
* THINGS DONE:
|
||||
* + Stopping the live reporting (of temperature)
|
||||
@@ -128,10 +124,12 @@ typedef struct CFontzPacket_private_data {
|
||||
int fd;
|
||||
|
||||
int model;
|
||||
int newfirmware;
|
||||
int oldfirmware;
|
||||
int usb;
|
||||
int speed;
|
||||
|
||||
CFA_Model *model_desc;
|
||||
|
||||
/* dimensions */
|
||||
int width, height;
|
||||
int cellwidth, cellheight;
|
||||
@@ -152,6 +150,15 @@ typedef struct CFontzPacket_private_data {
|
||||
} PrivateData;
|
||||
|
||||
|
||||
static CFA_Model CFA_ModelList[] = {
|
||||
{533, "16x2", 19200 , HD44780_charmap, CFA_HAS_TEMP | CFA_HAS_4_TEMP_SLOTS},
|
||||
{631, "20x2", 115200, CFontz_charmap , CFA_HAS_FAN | CFA_HAS_TEMP |
|
||||
CFA_HAS_KS0073 | CFA_HAS_4_TEMP_SLOTS},
|
||||
{633, "16x2", 19200 , HD44780_charmap, CFA_HAS_FAN | CFA_HAS_TEMP},
|
||||
{635, "20x4", 115200, CFontz_charmap , CFA_HAS_KS0073},
|
||||
{0, NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
/* Vars for the server core */
|
||||
MODULE_EXPORT char *api_version = API_VERSION;
|
||||
MODULE_EXPORT int stay_in_foreground = 0;
|
||||
@@ -175,11 +182,9 @@ MODULE_EXPORT int
|
||||
CFontzPacket_init (Driver *drvthis)
|
||||
{
|
||||
struct termios portset;
|
||||
int tmp, w, h;
|
||||
int tmp, w, h, i;
|
||||
int cf_reboot = 0;
|
||||
char size[200] = DEFAULT_SIZE;
|
||||
int default_speed = DEFAULT_SPEED;
|
||||
char *default_size = DEFAULT_SIZE;
|
||||
|
||||
PrivateData *p;
|
||||
|
||||
@@ -203,42 +208,38 @@ CFontzPacket_init (Driver *drvthis)
|
||||
EmptyReceiveBuffer(&receivebuffer);
|
||||
|
||||
/* Read config file */
|
||||
/* Which model is it (CF633, CF631 or CF635)? */
|
||||
|
||||
/* Try to find a matching model from our list of known modules */
|
||||
tmp = drvthis->config_get_int(drvthis->name, "Model", 0, 633);
|
||||
debug(RPT_INFO, "%s: Model (in config) is '%d'", __FUNCTION__, tmp);
|
||||
if ((tmp != 631) && (tmp != 633) && (tmp != 635)) {
|
||||
tmp = 633;
|
||||
report(RPT_WARNING, "%s: Model must be 631, 633 or 635; using default %d",
|
||||
drvthis->name, tmp);
|
||||
i = 0;
|
||||
while ((CFA_ModelList[i].model != 0) && (CFA_ModelList[i].model != tmp)) {
|
||||
i++;
|
||||
}
|
||||
if (CFA_ModelList[i].model == 0) {
|
||||
report(RPT_ERR, "%s: Invalid model configured", drvthis->name);
|
||||
return -1;
|
||||
}
|
||||
p->model = tmp;
|
||||
|
||||
/* Determine size & speed depending on model */
|
||||
if (p->model == 631) {
|
||||
default_size = DEFAULT_SIZE_CF631;
|
||||
default_speed = DEFAULT_SPEED_CF631;
|
||||
} else if (p->model == 633) {
|
||||
default_size = DEFAULT_SIZE_CF633;
|
||||
default_speed = DEFAULT_SPEED_CF633;
|
||||
} else if (p->model == 635) {
|
||||
default_size = DEFAULT_SIZE_CF635;
|
||||
default_speed = DEFAULT_SPEED_CF635;
|
||||
}
|
||||
p->model_desc = &(CFA_ModelList[i]);
|
||||
report(RPT_INFO, "%s: Found configuration for %d", __FUNCTION__, p->model_desc->model);
|
||||
debug(RPT_INFO, "%s: Flags are 0x%04X", __FUNCTION__, p->model_desc->flags);
|
||||
|
||||
/* 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';
|
||||
report(RPT_INFO, "%s: using Device %s", drvthis->name, p->device);
|
||||
|
||||
strncpy(size, drvthis->config_get_string(drvthis->name, "Size", 0, default_size), sizeof(size));
|
||||
/* Size setting */
|
||||
strncpy(size, drvthis->config_get_string(drvthis->name, "Size", 0, p->model_desc->size), sizeof(size));
|
||||
size[sizeof(size)-1] = '\0';
|
||||
debug(RPT_INFO, "%s: Size (in config) is '%s'", __FUNCTION__, size);
|
||||
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",
|
||||
drvthis->name, size, default_size);
|
||||
sscanf(default_size, "%dx%d", &w, &h);
|
||||
drvthis->name, size, p->model_desc->size);
|
||||
sscanf(p->model_desc->size, "%dx%d", &w, &h);
|
||||
}
|
||||
p->width = w;
|
||||
p->height = h;
|
||||
@@ -275,21 +276,18 @@ CFontzPacket_init (Driver *drvthis)
|
||||
}
|
||||
p->offbrightness = tmp;
|
||||
|
||||
/* Which speed ? CF633 support 19200 only, CF631 & CF635 USB use 115200. */
|
||||
tmp = drvthis->config_get_int(drvthis->name, "Speed", 0, default_speed);
|
||||
/* Get speed setting. */
|
||||
tmp = drvthis->config_get_int(drvthis->name, "Speed", 0, p->model_desc->speed);
|
||||
debug(RPT_INFO, "%s: Speed (in config) is '%d'", __FUNCTION__, tmp);
|
||||
if ((tmp != 19200) && (tmp != 115200)) {
|
||||
report(RPT_WARNING, "%s: Speed must be 19200 or 11500; using default %d",
|
||||
drvthis->name, default_speed);
|
||||
tmp = default_speed;
|
||||
drvthis->name, p->model_desc->speed);
|
||||
tmp = p->model_desc->speed;
|
||||
}
|
||||
p->speed = (tmp == 19200) ? B19200 : B115200;
|
||||
|
||||
/* New firmware version?
|
||||
* I will try to behave differently for firmware 0.6 or above.
|
||||
* Currently this is not in use.
|
||||
*/
|
||||
p->newfirmware = drvthis->config_get_bool(drvthis->name, "NewFirmware", 0, 0);
|
||||
/* Does the display has an old firmware (<= 0.6)? */
|
||||
p->oldfirmware = drvthis->config_get_bool(drvthis->name, "OldFirmware", 0, 0);
|
||||
|
||||
/* Reboot display? */
|
||||
cf_reboot = drvthis->config_get_bool(drvthis->name, "Reboot", 0, 0);
|
||||
@@ -467,11 +465,10 @@ CFontzPacket_flush (Driver *drvthis)
|
||||
int modified = 0;
|
||||
int i, j;
|
||||
|
||||
if (p->model == 633) {
|
||||
if ((p->model == 633) && p->oldfirmware) {
|
||||
/*
|
||||
* For CF633 we don't use delta update yet. Older HW/FW types
|
||||
* only support updates of full or partial line starting from
|
||||
* pos 0.
|
||||
* Older CFA-633 HW/FW types only support updates of full or
|
||||
* partial line starting from pos 0.
|
||||
*/
|
||||
unsigned char *xp = p->framebuf;
|
||||
unsigned char *xq = p->backingstore;
|
||||
@@ -499,7 +496,7 @@ CFontzPacket_flush (Driver *drvthis)
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* CF631 / CF635 protocol is more flexible and we can do real
|
||||
* The current protocol is more flexible and we can do real
|
||||
* delta update.
|
||||
*/
|
||||
|
||||
@@ -554,7 +551,7 @@ CFontzPacket_flush (Driver *drvthis)
|
||||
|
||||
/* send something to the LCD to allow keys to be received */
|
||||
if (!modified)
|
||||
send_bytes_message(p->fd, CF633_Ping_Command, 0, NULL);
|
||||
send_zerobyte_message(p->fd, CF633_Ping_Command);
|
||||
}
|
||||
|
||||
|
||||
@@ -567,7 +564,6 @@ CFontzPacket_flush (Driver *drvthis)
|
||||
MODULE_EXPORT const char *
|
||||
CFontzPacket_get_key (Driver *drvthis)
|
||||
{
|
||||
//PrivateData *p = drvthis->private_data;
|
||||
unsigned char key = GetKeyFromKeyRing(&keyring);
|
||||
|
||||
switch (key) {
|
||||
@@ -642,9 +638,7 @@ CFontzPacket_chr (Driver *drvthis, int x, int y, char c)
|
||||
x--;
|
||||
|
||||
if ((x >= 0) && (y >= 0) && (x < p->width) && (y < p->height))
|
||||
p->framebuf[(y * p->width) + x] = (p->model == 633)
|
||||
? c
|
||||
: CFontz_charmap[(unsigned) c];
|
||||
p->framebuf[(y * p->width) + x] = p->model_desc->charmap[(unsigned char) c];
|
||||
}
|
||||
|
||||
|
||||
@@ -705,7 +699,7 @@ CFontzPacket_set_contrast (Driver *drvthis, int promille)
|
||||
|
||||
/* map range [0, 1000] to a range that the hardware understands */
|
||||
/* on CF633: [0, 50], on CF631 & CF635: [0, 255] */
|
||||
hardware_contrast = (p->model == 633)
|
||||
hardware_contrast = ((p->model == 633) || (p->model == 533))
|
||||
? (p->contrast / 20)
|
||||
: ((p->contrast * 255) / 1000);
|
||||
|
||||
@@ -795,9 +789,13 @@ CFontzPacket_no_live_report (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
unsigned char out[2] = { 0, 0 };
|
||||
int slots = 8;
|
||||
|
||||
if (p->model == 633) {
|
||||
for (out[0] = 0; out[0] < 8; out[0]++)
|
||||
if ((p->model_desc->flags & CFA_HAS_FAN) || (p->model_desc->flags & CFA_HAS_TEMP)) {
|
||||
if (p->model_desc->flags & CFA_HAS_4_TEMP_SLOTS)
|
||||
slots = 4;
|
||||
|
||||
for (out[0] = 0; out[0] < slots; out[0]++)
|
||||
send_bytes_message(p->fd, CF633_Set_Up_Live_Fan_or_Temperature_Display, 2, out);
|
||||
}
|
||||
}
|
||||
@@ -812,7 +810,7 @@ CFontzPacket_no_fan_report (Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
if (p->model == 633)
|
||||
if (p->model_desc->flags & CFA_HAS_FAN)
|
||||
send_onebyte_message(p->fd, CF633_Set_Up_Fan_Reporting, 0);
|
||||
}
|
||||
|
||||
@@ -827,7 +825,7 @@ CFontzPacket_no_temp_report (Driver *drvthis)
|
||||
PrivateData *p = drvthis->private_data;
|
||||
unsigned char out[4] = { 0, 0, 0, 0 };
|
||||
|
||||
if (p->model == 633)
|
||||
if (p->model_desc->flags & CFA_HAS_TEMP)
|
||||
send_bytes_message(p->fd, CF633_Set_Up_Temperature_Reporting, 4, out);
|
||||
}
|
||||
|
||||
@@ -876,8 +874,11 @@ CFontzPacket_vbar (Driver *drvthis, int x, int y, int len, int promille, int opt
|
||||
memset(vBar, 0x00, sizeof(vBar));
|
||||
|
||||
for (i = 1; i < p->cellheight; i++) {
|
||||
// add pixel line per pixel line ...
|
||||
// NOTE: cellwidth != bar width: 0x1F = 0xFF & ((1 << (p->cellwidth - 1)) - 1)
|
||||
/*
|
||||
* add pixel line per pixel line ...
|
||||
* NOTE: cellwidth != bar width:
|
||||
* 0x1F = 0xFF & ((1 << (p->cellwidth - 1)) - 1)
|
||||
*/
|
||||
vBar[p->cellheight - i] = 0x1F;
|
||||
CFontzPacket_set_char(drvthis, i, vBar);
|
||||
}
|
||||
@@ -916,7 +917,7 @@ CFontzPacket_hbar (Driver *drvthis, int x, int y, int len, int promille, int opt
|
||||
memset(hBar, 0x00, sizeof(hBar));
|
||||
|
||||
for (i = 1; i <= p->cellwidth; i++) {
|
||||
// fill pixel columns from left to right.
|
||||
/* fill pixel columns from left to right. */
|
||||
memset(hBar, 0xFF & ~((1 << (p->cellwidth - i)) - 1), sizeof(hBar)-1);
|
||||
CFontzPacket_set_char(drvthis, i, hBar);
|
||||
}
|
||||
@@ -935,8 +936,8 @@ CFontzPacket_hbar (Driver *drvthis, int x, int y, int len, int promille, int opt
|
||||
MODULE_EXPORT void
|
||||
CFontzPacket_num(Driver *drvthis, int x, int num)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
int do_init = 0;
|
||||
PrivateData *p = drvthis->private_data;
|
||||
int do_init = 0;
|
||||
|
||||
if ((num < 0) || (num > 10))
|
||||
return;
|
||||
@@ -954,7 +955,7 @@ int do_init = 0;
|
||||
do_init = 1;
|
||||
}
|
||||
|
||||
// Lib_adv_bignum does everything needed to show the bignumbers.
|
||||
/* Lib_adv_bignum does everything needed to show the bignumbers. */
|
||||
lib_adv_bignum(drvthis, x, num, 0, do_init);
|
||||
}
|
||||
|
||||
@@ -967,8 +968,6 @@ int do_init = 0;
|
||||
MODULE_EXPORT int
|
||||
CFontzPacket_get_free_chars (Driver *drvthis)
|
||||
{
|
||||
//PrivateData *p = drvthis->private_data;
|
||||
|
||||
return NUM_CCs;
|
||||
}
|
||||
|
||||
@@ -996,6 +995,8 @@ CFontzPacket_set_char (Driver *drvthis, int n, unsigned char *dat)
|
||||
return;
|
||||
|
||||
out[0] = n; /* Custom char to define. xxx */
|
||||
if (p->model_desc->flags & CFA_HAS_KS0073)
|
||||
dat[p->cellheight-1] = 0;
|
||||
|
||||
for (row = 0; row < p->cellheight; row++) {
|
||||
out[row+1] = dat[row] & mask;
|
||||
@@ -1129,6 +1130,7 @@ CFontzPacket_icon (Driver *drvthis, int x, int y, int icon)
|
||||
b_______,
|
||||
b__X_X_X,
|
||||
b_______ };
|
||||
*/
|
||||
static unsigned char block_filled[] =
|
||||
{ b__XXXXX,
|
||||
b__XXXXX,
|
||||
@@ -1138,15 +1140,16 @@ CFontzPacket_icon (Driver *drvthis, int x, int y, int icon)
|
||||
b__XXXXX,
|
||||
b__XXXXX,
|
||||
b__XXXXX };
|
||||
*/
|
||||
|
||||
/* Yes we know, this is a VERY BAD implementation :-) */
|
||||
switch (icon) {
|
||||
case ICON_BLOCK_FILLED:
|
||||
if (p->model == 633)
|
||||
CFontzPacket_chr(drvthis, x, y, 255);
|
||||
if (p->model_desc->flags & CFA_HAS_KS0073) {
|
||||
CFontzPacket_set_char(drvthis, 7, block_filled);
|
||||
CFontzPacket_chr(drvthis, x, y, 7);
|
||||
}
|
||||
else
|
||||
CFontzPacket_raw_chr(drvthis, x, y, 31);
|
||||
CFontzPacket_raw_chr(drvthis, x, y, 255);
|
||||
break;
|
||||
case ICON_HEART_FILLED:
|
||||
CFontzPacket_set_char(drvthis, 0, heart_filled);
|
||||
@@ -1157,32 +1160,32 @@ CFontzPacket_icon (Driver *drvthis, int x, int y, int icon)
|
||||
CFontzPacket_chr(drvthis, x, y, 0);
|
||||
break;
|
||||
case ICON_ARROW_UP:
|
||||
if (p->model == 633) {
|
||||
if (p->model_desc->flags & CFA_HAS_KS0073)
|
||||
CFontzPacket_raw_chr(drvthis, x, y, 0xDE);
|
||||
else {
|
||||
CFontzPacket_set_char(drvthis, 1, arrow_up);
|
||||
CFontzPacket_chr(drvthis, x, y, 1);
|
||||
}
|
||||
else
|
||||
CFontzPacket_raw_chr(drvthis, x, y, 0xDE);
|
||||
break;
|
||||
case ICON_ARROW_DOWN:
|
||||
if (p->model == 633) {
|
||||
if (p->model_desc->flags & CFA_HAS_KS0073)
|
||||
CFontzPacket_raw_chr(drvthis, x, y, 0xE0);
|
||||
else {
|
||||
CFontzPacket_set_char(drvthis, 2, arrow_down);
|
||||
CFontzPacket_chr(drvthis, x, y, 2);
|
||||
}
|
||||
else
|
||||
CFontzPacket_raw_chr(drvthis, x, y, 0xE0);
|
||||
break;
|
||||
case ICON_ARROW_LEFT:
|
||||
if (p->model == 633)
|
||||
CFontzPacket_raw_chr(drvthis, x, y, 0x7F);
|
||||
else
|
||||
if (p->model_desc->flags & CFA_HAS_KS0073)
|
||||
CFontzPacket_raw_chr(drvthis, x, y, 0xE1);
|
||||
else
|
||||
CFontzPacket_raw_chr(drvthis, x, y, 0x7F);
|
||||
break;
|
||||
case ICON_ARROW_RIGHT:
|
||||
if (p->model == 633)
|
||||
CFontzPacket_raw_chr(drvthis, x, y, 0x7E);
|
||||
else
|
||||
if (p->model_desc->flags & CFA_HAS_KS0073)
|
||||
CFontzPacket_raw_chr(drvthis, x, y, 0xDF);
|
||||
else
|
||||
CFontzPacket_raw_chr(drvthis, x, y, 0x7E);
|
||||
break;
|
||||
case ICON_CHECKBOX_OFF:
|
||||
CFontzPacket_set_char(drvthis, 3, checkbox_off);
|
||||
@@ -1197,12 +1200,12 @@ CFontzPacket_icon (Driver *drvthis, int x, int y, int icon)
|
||||
CFontzPacket_chr(drvthis, x, y, 5);
|
||||
break;
|
||||
case ICON_SELECTOR_AT_LEFT:
|
||||
if (p->model == 633)
|
||||
if (!(p->model_desc->flags & CFA_HAS_KS0073))
|
||||
return -1;
|
||||
CFontzPacket_raw_chr(drvthis, x, y, 0x10);
|
||||
break;
|
||||
case ICON_SELECTOR_AT_RIGHT:
|
||||
if (p->model == 633)
|
||||
if (!(p->model_desc->flags & CFA_HAS_KS0073))
|
||||
return -1;
|
||||
CFontzPacket_raw_chr(drvthis, x, y, 0x11);
|
||||
break;
|
||||
@@ -1225,21 +1228,23 @@ CFontzPacket_cursor (Driver *drvthis, int x, int y, int state)
|
||||
{
|
||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||
|
||||
if (p->model != 633) {
|
||||
if (!p->oldfirmware) {
|
||||
unsigned char cpos[2] = { 0, 0 };
|
||||
|
||||
/* set cursor state */
|
||||
switch (state) {
|
||||
case CURSOR_OFF: // no cursor
|
||||
case CURSOR_OFF: /* no cursor */
|
||||
send_onebyte_message(p->fd, CF633_Set_LCD_Cursor_Style, 0);
|
||||
break;
|
||||
case CURSOR_UNDER: // underline cursor
|
||||
case CURSOR_UNDER: /* underline cursor */
|
||||
send_onebyte_message(p->fd, CF633_Set_LCD_Cursor_Style, 2);
|
||||
break;
|
||||
case CURSOR_BLOCK: // inverting blinking block
|
||||
send_onebyte_message(p->fd, CF633_Set_LCD_Cursor_Style, 4);
|
||||
case CURSOR_BLOCK: /* inverting blinking block */
|
||||
if (p->model == 631 || p->model == 635)
|
||||
send_onebyte_message(p->fd, CF633_Set_LCD_Cursor_Style, 4);
|
||||
break;
|
||||
case CURSOR_DEFAULT_ON: // blinking block
|
||||
case CURSOR_DEFAULT_ON: /* blinking block */
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
send_onebyte_message(p->fd, CF633_Set_LCD_Cursor_Style, 1);
|
||||
break;
|
||||
@@ -1305,11 +1310,10 @@ CFontzPacket_string (Driver *drvthis, int x, int y, const char string[])
|
||||
|
||||
for (i = 0; (string[i] != '\0') && (x < p->width); i++, x++) {
|
||||
/* Check for buffer overflows... */
|
||||
if (x >= 0)
|
||||
if (x >= 0) {
|
||||
p->framebuf[(y * p->width) + x] =
|
||||
(p->model == 633)
|
||||
? string[i]
|
||||
: CFontz_charmap[(unsigned) string[i]];
|
||||
p->model_desc->charmap[(unsigned char) string[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1323,8 +1327,8 @@ MODULE_EXPORT void
|
||||
CFontzPacket_output(Driver *drvthis, int state)
|
||||
{
|
||||
static const unsigned char CFontz635_LEDs[CF635_NUM_LEDs] = {
|
||||
11, 9, 7, 5, // Green LEDs first, Top first
|
||||
12,10, 8, 6, // Red LEDs next, Top first
|
||||
11, 9, 7, 5, /* Green LEDs first, Top first */
|
||||
12,10, 8, 6, /* Red LEDs next, Top first */
|
||||
};
|
||||
PrivateData *p = drvthis->private_data;
|
||||
unsigned char out[2];
|
||||
|
||||
Reference in New Issue
Block a user