Refactor ubiquitous CGmode enum into lcd.h and convert remaining drivers

to use it.
This commit is contained in:
mmdolze
2011-01-06 10:59:19 +00:00
parent 46c45a87e5
commit 96525e30b7
23 changed files with 66 additions and 226 deletions
+1
View File
@@ -9,6 +9,7 @@ v.0.5dev (ongoing development)
+ sed1330 driver: Add support for HG25504 (L. Lagendijk)
* Build system: Fix xosd detection
* Reset ccmode on screen clear for NoritakeVFD, tyan driver
* All drivers: Refactor CGmode enum into lcd.h
v0.5.4
* Update driver includes and LDFLAGS (fixed glk and bayrad binding error)
-9
View File
@@ -50,15 +50,6 @@
/* Constants for userdefchar_mode */
#define NUM_CCs 8 /* max. number of custom characters */
typedef enum {
standard, /* only char 0 is used for heartbeat */
vbar, /* vertical bars */
hbar, /* horizontal bars */
custom, /* custom settings */
bignum, /* big numbers */
bigchar /* big characters */
} CGmode;
/** private data for the \c CFontz driver */
typedef struct CFontz_private_data {
char device[200];
-10
View File
@@ -78,16 +78,6 @@
/* Constants for userdefchar_mode */
#define NUM_CCs 8 /* max. number of custom characters */
typedef enum {
standard, /* only char 0 is used for heartbeat */
vbar, /* vertical bars */
hbar, /* horizontal bars */
custom, /* custom settings */
bignum, /* big numbers */
bigchar /* big characters */
} CGmode;
/** private data for the \c CFonts633 driver */
typedef struct CFontz633_private_data {
char device[200];
-9
View File
@@ -99,15 +99,6 @@
/* Constants for userdefchar_mode */
#define NUM_CCs 8 /* max. number of custom characters */
typedef enum {
standard, /* only char 0 is used for heartbeat */
vbar, /* vertical bars */
hbar, /* horizontal bars */
custom, /* custom settings */
bignum, /* big numbers */
bigchar /* big characters */
} CGmode;
/** private data for the \c CFontzPacket driver */
typedef struct CFontzPacket_private_data {
-10
View File
@@ -76,16 +76,6 @@
static char *defaultKeyMap[MaxKeyMap] = { "Up", "Down", "Left", "Right", "Enter", "Escape" };
typedef enum {
standard, /* only char 0 is used for heartbeat */
vbar, /* vertical bars */
hbar, /* horizontal bars */
custom, /* custom settings */
bignum, /* big numbers */
bigchar /* big characters */
} CGmode;
/** private data for the \c CwLnx driver */
typedef struct CwLnx_private_data {
int fd;
-9
View File
@@ -64,15 +64,6 @@
/* Constants for userdefchar_mode */
#define NUM_CCs 8 /* max. number of custom characters */
typedef enum {
standard, /* only char 0 is used for heartbeat */
vbar, /* vertical bars */
hbar, /* horizontal bars */
bignum, /* big numbers */
bigchar, /* big characters */
custom /* custom icons */
} CGmode;
typedef struct cgram_cache {
unsigned char cache[LCD_DEFAULT_CELLHEIGHT];
-9
View File
@@ -103,15 +103,6 @@ typedef enum {
/* Constants for userdefchar_mode */
#define NUM_CCs 8 /* max. number of custom characters */
typedef enum {
standard, /* only char 0 is used for heartbeat */
vbar, /* vertical bars */
hbar, /* horizontal bars */
custom, /* custom settings */
bignum, /* big numbers */
bigchar /* big characters */
} CGmode;
/** private data for the \c MtxOrb driver */
typedef struct MtxOrb_private_data {
-8
View File
@@ -69,14 +69,6 @@
/* Constants for userdefchar_mode */
#define NUM_CCs 2 /* max. number of custom characters */
typedef enum {
standard, /* only char 0 is used for heartbeat */
vbar, /* vertical bars */
hbar, /* horizontal bars */
custom, /* custom settings */
bignum, /* big numbers */
} CGmode;
/** private data for the \c NoritakeVFD driver */
typedef struct NoritakeVFD_private_data {
char device[200];
-9
View File
@@ -73,15 +73,6 @@ typedef enum {
SURE_ELEC_EDITION3 = 3,
} SureElec_edition;
typedef enum {
standard, /* only char 0 is used for heartbeat */
vbar, /* vertical bars */
hbar, /* horizontal bars */
custom, /* custom settings */
bignum, /* big numbers */
bigchar /* big characters */
} CGmode;
/** private data for the \c SureElec driver */
typedef struct SureElec_private_data {
int fd; /* Serial port file descriptor */
+9 -13
View File
@@ -38,10 +38,6 @@
#include "lcd_lib.h"
#define NUM_CCs 8 /* number of characters */
#define CCMODE_STANDARD 0 /* only char 0 is used for heartbeat */
#define CCMODE_VBAR 1
#define CCMODE_HBAR 2
#define CCMODE_BIGNUM 3
#define BAYRAD_DEFAULT_DEVICE "/dev/lcd"
@@ -56,7 +52,7 @@ typedef struct bayrad_private_data {
int cellwidth;
int cellheight;
char *framebuf;
char ccmode;
CGmode ccmode;
} PrivateData;
@@ -94,7 +90,7 @@ bayrad_init(Driver *drvthis)
p->cellwidth = 5;
p->cellheight = 8;
p->framebuf = NULL;
p->ccmode = CCMODE_STANDARD;
p->ccmode = standard;
/* Read config file */
@@ -266,7 +262,7 @@ bayrad_clear(Driver *drvthis)
PrivateData *p = drvthis->private_data;
memset(p->framebuf, ' ', p->width * p->height);
p->ccmode = CCMODE_STANDARD;
p->ccmode = standard;
}
@@ -455,18 +451,18 @@ bayrad_init_vbar(Driver *drvthis)
//debug(RPT_DEBUG,"Init Vertical bars");
if (p->ccmode == CCMODE_VBAR) {
if (p->ccmode == vbar) {
/* Work already done */
return;
}
if (p->ccmode != CCMODE_STANDARD) {
if (p->ccmode != standard) {
/* Not supported (yet) */
report(RPT_WARNING, "%s: cannot combine two modes using user-defined characters",
drvthis->name);
return;
}
p->ccmode = CCMODE_VBAR;
p->ccmode = vbar;
bayrad_set_char(drvthis, 1, bar_up[0]);
bayrad_set_char(drvthis, 2, bar_up[1]);
@@ -535,18 +531,18 @@ bayrad_init_hbar(Driver *drvthis)
//debug(RPT_DEBUG,"Init Horizontal bars");
if (p->ccmode == CCMODE_HBAR) {
if (p->ccmode == hbar) {
/* Work already done */
return;
}
if (p->ccmode != CCMODE_STANDARD) {
if (p->ccmode != standard) {
/* Not supported (yet) */
report(RPT_WARNING, "%s: cannot combine two modes using user-defined characters",
drvthis->name);
return;
}
p->ccmode = CCMODE_HBAR;
p->ccmode = hbar;
bayrad_set_char(drvthis, 1, bar_right[0]);
bayrad_set_char(drvthis, 2, bar_right[1]);
-9
View File
@@ -75,15 +75,6 @@
#define NUM_CCs 8 /* number of custom characters */
typedef enum {
standard, /* only char 0 is used for heartbeat */
vbar, /* vertical bars */
hbar, /* horizontal bars */
bignum, /* big numbers */
bigchar /* big characters */
} CGmode;
typedef struct cgram_cache {
unsigned char cache[LCD_DEFAULT_CELLHEIGHT];
int clean;
+8 -10
View File
@@ -1,5 +1,7 @@
/** \file server/drivers/lb216.c
* LCDd \c lb216 driver for the LB216 by R.T.N. Australia.
*
* \todo Convert to new style hbar and vbar!
*/
/*
@@ -37,14 +39,6 @@
#define LB216_DEFAULT_SPEED 9600
#define LB216_DEFAULT_BRIGHTNESS 255
typedef enum {
normal = 0,
hbar = 1,
vbar = 2,
bign = 4,
beat = 8
} custom_type;
/** private data for the \c lb216 driver */
typedef struct LB216_private_data {
char device[256];
@@ -56,7 +50,7 @@ typedef struct LB216_private_data {
int cellwidth;
int cellheight;
int backlight_brightness;
custom_type custom;
CGmode custom;
} PrivateData;
@@ -97,7 +91,7 @@ LB216_init(Driver *drvthis)
p->height = LCD_DEFAULT_HEIGHT;
p->cellwidth = LCD_DEFAULT_CELLWIDTH;
p->cellheight = LCD_DEFAULT_CELLHEIGHT;
p->custom = normal;
p->custom = standard;
/* Read config file */
@@ -544,6 +538,8 @@ LB216_vbar(Driver *drvthis, int x, int len)
char map[9] = { 32, 1, 2, 3, 4, 5, 6, 7, 255 };
int y;
LB216_init_vbar(drvthis);
for (y = p->height; (y > 0) && (len > 0); y--) {
if (len >= p->cellheight)
LB216_chr(drvthis, x, y, map[8]);
@@ -563,6 +559,8 @@ LB216_hbar(Driver *drvthis, int x, int y, int len)
PrivateData *p = drvthis->private_data;
char map[7] = { 32, 1, 2, 3, 4, 5 };
LB216_init_hbar(drvthis);
for ( ; (x <= p->width) && (len > 0); x++) {
if (len >= p->cellwidth)
LB216_chr(drvthis, x, y, map[5]);
+10
View File
@@ -105,6 +105,16 @@
#define CURSOR_BLOCK 4
#define CURSOR_UNDER 5
/* Type of characters currently stored in CGRAM. */
typedef enum {
standard, /* only char 0 is used for heartbeat */
vbar, /* vertical bars */
hbar, /* horizontal bars */
custom, /* custom settings */
bignum, /* big numbers */
bigchar /* big characters */
} CGmode;
/* What does the shared module handle look like on the current platform? */
#define MODULE_HANDLE void*
+13 -21
View File
@@ -46,19 +46,11 @@
#include "lcterm.h"
#include "report.h"
typedef enum
{
CCMODE_STANDARD, /* only char 0 is used for heartbeat */
CCMODE_VBAR,
CCMODE_HBAR,
CCMODE_BIGNUM
} CCMode;
/** private data for the \c lcterm driver */
typedef struct lcterm_private_data {
CCMode ccmode; /**< custom character mode for current display */
CCMode last_ccmode; /**< custom character set that is loaded in the display */
CGmode ccmode; /**< custom character mode for current display */
CGmode last_ccmode; /**< custom character set that is loaded in the display */
unsigned char *framebuf; /**< frame buffer */
unsigned char *last_framebuf; /**< old frame buffer contents */
int width; /**< display width in characters */
@@ -100,7 +92,7 @@ lcterm_init (Driver *drvthis)
// initialize private data
p->fd = -1;
p->ccmode = p->last_ccmode = CCMODE_STANDARD;
p->ccmode = p->last_ccmode = standard;
// READ CONFIG FILE:
// which serial device should be used
@@ -242,7 +234,7 @@ lcterm_clear (Driver *drvthis)
PrivateData *p = (PrivateData *) drvthis->private_data;
memset(p->framebuf, ' ', p->width * p->height);
p->ccmode = CCMODE_STANDARD;
p->ccmode = standard;
}
@@ -436,17 +428,17 @@ lcterm_init_vbar (Driver *drvthis)
1, 1, 1, 1, 1,
};
if (p->last_ccmode == CCMODE_VBAR) /* Work already done */
if (p->last_ccmode == vbar) /* Work already done */
return;
if (p->ccmode != CCMODE_STANDARD) {
if (p->ccmode != standard) {
/* Not supported (yet) */
report(RPT_WARNING, "%s: init_vbar: cannot combine two modes using user-defined characters",
drvthis->name);
return;
}
p->ccmode = p->last_ccmode = CCMODE_VBAR;
p->ccmode = p->last_ccmode = vbar;
lcterm_set_char(drvthis, 1, vbar_1);
lcterm_set_char(drvthis, 2, vbar_2);
@@ -518,17 +510,17 @@ lcterm_init_hbar (Driver *drvthis)
1, 1, 1, 1, 1,
};
if (p->last_ccmode == CCMODE_HBAR) /* Work already done */
if (p->last_ccmode == hbar) /* Work already done */
return;
if (p->ccmode != CCMODE_STANDARD) {
if (p->ccmode != standard) {
/* Not supported (yet) */
report(RPT_WARNING, "%s: init_hbar: cannot combine two modes using user-defined characters",
drvthis->name);
return;
}
p->ccmode = p->last_ccmode = CCMODE_HBAR;
p->ccmode = p->last_ccmode = hbar;
lcterm_set_char(drvthis, 1, hbar_1);
lcterm_set_char(drvthis, 2, hbar_2);
@@ -656,19 +648,19 @@ lcterm_init_num (Driver *drvthis)
0, 0, 0, 0, 0
}};
if (p->last_ccmode == CCMODE_BIGNUM) {
if (p->last_ccmode == bignum) {
/* Work already done */
return;
}
if (p->ccmode != CCMODE_STANDARD) {
if (p->ccmode != standard) {
/* Not supported (yet) */
report(RPT_WARNING, "%s: init_num: cannot combine two modes using user-defined characters",
drvthis->name);
return;
}
p->ccmode = p->last_ccmode = CCMODE_BIGNUM;
p->ccmode = p->last_ccmode = bignum;
for (i = 0; i < 8; i++)
lcterm_set_char(drvthis, i, bignum_ccs[i]);
-9
View File
@@ -44,15 +44,6 @@
///////////////////////////////////////////////////////////////////////////////
// private data types
//
typedef enum {
standard, /* only char 0 is used for heartbeat */
vbar, /* vertical bars */
hbar, /* horizontal bars */
bignum, /* big numbers */
bigchar, /* big characters */
custom /* custom icons */
} CGmode;
typedef struct cgram_cache {
unsigned char cache[CELLHEIGHT];
int clean;
+4 -11
View File
@@ -1,5 +1,7 @@
/** \file server/drivers/mtc_s16209x.c
* LCDd \c mtc_s16209x driver for the MTC_S16209x LCD display by Microtips Technology Inc.
*
* \todo Convert to new style hbar and vbar!
*/
/*
@@ -86,15 +88,6 @@ char lcd_showunderline[] = "\xFE\x0E"; // From Show_UnderLine()
char lcd_hideunderline[] = "\xFE\x0B"; // From Hide_UnderLine()
typedef enum {
normal = 1,
hbar = 1,
vbar = 2,
bign = 4,
beat = 8
} custom_type;
/** private data for the \c mtc_s16209x driver */
typedef struct MTC_S16209X_private_data {
char device[256];
@@ -104,7 +97,7 @@ typedef struct MTC_S16209X_private_data {
int height;
int cellwidth;
int cellheight;
custom_type custom;
CGmode custom;
} PrivateData;
@@ -151,7 +144,7 @@ MTC_S16209X_init (Driver *drvthis)
p->height = 2; //was: LCD_DEFAULT_HEIGHT; (is now hardcoded)
p->cellwidth = LCD_DEFAULT_CELLWIDTH;
p->cellheight = LCD_DEFAULT_CELLHEIGHT;
p->custom = normal;
p->custom = standard;
/* Read config file */
-9
View File
@@ -65,15 +65,6 @@
#define NUM_CCs 8 /* max. number of custom characters */
typedef enum {
standard, /* only char 0 is used for heartbeat */
vbar, /* vertical bars */
hbar, /* horizontal bars */
custom, /* custom settings */
bignum, /* big numbers */
bigchar /* big characters */
} CGmode;
/* PrivateData struct */
typedef struct picolcd_private_data {
usb_dev_handle *lcd;
+4 -18
View File
@@ -323,7 +323,7 @@ pyramid_init (Driver *drvthis)
p->customchars=CUSTOMCHARS;
p->cellwidth=CELLWIDTH;
p->cellheight=CELLHEIGHT;
p->custom = normal;
p->custom = standard;
strcpy(p->last_key_pressed, NOKEY);
p->last_key_time = timestamp(p);
@@ -845,12 +845,12 @@ pyramid_init_custom1 (Driver *drvthis)
0, 0, 0, 0, 0,
};
if (p->custom != custom1) {
if (p->custom != custom) {
pyramid_set_char (drvthis, 1, a);
pyramid_set_char (drvthis, 2, b);
pyramid_set_char (drvthis, 3, c);
pyramid_set_char (drvthis, 4, d);
p->custom = custom1;
p->custom = custom;
}
}
@@ -997,19 +997,6 @@ pyramid_icon (Driver *drvthis, int x, int y, int icon)
},
};
PrivateData *p = (PrivateData *) drvthis->private_data;
#if 0
// notify the others that we messed up their character set.
// Unused for heartbeats as we should always leave that icon alone.
//
// Leaving this in the code as notification for other similar cases
if (p->custom == bign) {
debug(RPT_DEBUG, "%s: Switching to beat", __FUNCTION__);
p->custom = beat;
}
#endif
switch( icon ) {
case ICON_BLOCK_FILLED:
pyramid_chr( drvthis, x, y, 255 );
@@ -1028,13 +1015,11 @@ pyramid_icon (Driver *drvthis, int x, int y, int icon)
case ICON_ARROW_UP:
pyramid_set_char( drvthis, 2, icons[2] );
pyramid_chr( drvthis, x, y, 2 );
p->custom = icon;
break;
case ICON_ARROW_DOWN:
pyramid_set_char( drvthis, 3, icons[3] );
pyramid_chr( drvthis, x, y, 3 );
p->custom = icon;
break;
case ICON_ARROW_LEFT:
@@ -1045,6 +1030,7 @@ pyramid_icon (Driver *drvthis, int x, int y, int icon)
pyramid_chr( drvthis, x, y, '\176' );
break;
/* FIXME: Does setting CC to position 10-13 really work? */
case ICON_CHECKBOX_ON:
pyramid_set_char( drvthis, 10, icons[4] );
pyramid_chr( drvthis, x, y, 10 );
+1 -11
View File
@@ -44,16 +44,6 @@
#define CELLWIDTH 5
typedef enum {
normal = 0,
hbar = 1,
vbar = 2,
beat = 4,
icon = 8,
custom1 = 16
} custom_type;
/** private data for the \c pyramid driver */
typedef struct pyramid_private_data {
/* device io */
@@ -72,7 +62,7 @@ typedef struct pyramid_private_data {
/* output handling */
char framebuffer[WIDTH*HEIGHT+2];
int FB_modified;
custom_type custom;
CGmode custom;
/* button handling */
char last_key_pressed[6];
+11 -11
View File
@@ -110,7 +110,7 @@ serialVFD_init (Driver *drvthis)
/* Initialize the PrivateData structure */
p->cellwidth = DEFAULT_CELL_WIDTH;
p->cellheight = DEFAULT_CELL_HEIGHT;
p->ccmode = CCMODE_STANDARD;
p->ccmode = standard;
p->ISO_8859_1 = 1;
p->refresh_timer = 480;
p->hw_brightness = 0;
@@ -562,11 +562,11 @@ serialVFD_num(Driver * drvthis, int x, int num)
PrivateData *p = drvthis->private_data;
int do_init = 0;
if (p->ccmode != CCMODE_BIGNUM) {
if (p->ccmode != bignum) {
/* If custom characters are not yet set up Lib_adv_bignum has
* to do it. */
do_init = 1;
p->ccmode = CCMODE_BIGNUM;
p->ccmode = bignum;
}
lib_adv_bignum(drvthis, x, num, 0, do_init);
}
@@ -610,7 +610,7 @@ serialVFD_icon (Driver *drvthis, int x, int y, int icon)
break;
case ICON_HEART_FILLED:
if (p->customchars > 0) {
p->ccmode = CCMODE_STANDARD;
p->ccmode = standard;
serialVFD_set_char(drvthis, 0, heart_filled);
serialVFD_chr(drvthis, x, y, 0);
}
@@ -619,7 +619,7 @@ serialVFD_icon (Driver *drvthis, int x, int y, int icon)
break;
case ICON_HEART_OPEN:
if (p->customchars > 0) {
p->ccmode = CCMODE_STANDARD;
p->ccmode = standard;
serialVFD_set_char(drvthis, 0, heart_open);
serialVFD_chr(drvthis, x, y, 0);
}
@@ -778,7 +778,7 @@ serialVFD_get_info (Driver *drvthis)
* Set up vertical bars.
* \param drvthis Pointer to driver structure.
*
* \note
* \todo
* Called only by vbar(). Can possibly be included there.
* This should also make CCMODE independent of the implementation of the bars.
*/
@@ -787,11 +787,11 @@ serialVFD_init_vbar (Driver *drvthis)
{
PrivateData *p = drvthis->private_data;
if (p->ccmode != CCMODE_VBAR) {
if (p->ccmode != vbar) {
unsigned char vBar[p->cellheight];
int i;
p->ccmode = CCMODE_VBAR;
p->ccmode = vbar;
memset(vBar, 0x00, sizeof(vBar));
@@ -808,7 +808,7 @@ serialVFD_init_vbar (Driver *drvthis)
* Set up horizontal bars.
* \param drvthis Pointer to driver structure.
*
* \note
* \todo
* Called only by hbar(). Can possibly be included there.
* This should also make CCMODE independent of the implementation of the bars.
*/
@@ -817,11 +817,11 @@ serialVFD_init_hbar (Driver *drvthis)
{
PrivateData *p = drvthis->private_data;
if (p->ccmode != CCMODE_HBAR) {
if (p->ccmode != hbar) {
unsigned char hBar[p->cellheight];
int i;
p->ccmode = CCMODE_HBAR;
p->ccmode = hbar;
for (i = 1; i < p->cellwidth; i++) {
/* fill pixel columns from left to right. */
+1 -9
View File
@@ -26,14 +26,6 @@
#ifndef SERIALVFD_H
#define SERIALVFD_H
#define CCMODE_STANDARD 0 /* only char 0 is used for heartbeat */
#define CCMODE_VBAR 1
#define CCMODE_HBAR 2
#define CCMODE_BIGNUM 3
#define CCMODE_BIGCHAR 4
#define CCMODE_CUSTOM 5
#define DEFAULT_CELL_WIDTH 5
#define DEFAULT_CELL_HEIGHT 7
#define DEFAULT_DEVICE "/dev/lcd"
@@ -85,7 +77,7 @@ typedef struct serialVFD_private_data {
/* framebuffer and buffer for old LCD contents */
unsigned char *framebuf;
unsigned char *backingstore;
int ccmode;
CGmode ccmode;
int on_brightness;
int off_brightness;
int hw_brightness;
-9
View File
@@ -42,15 +42,6 @@
/* Constants for userdefchar_mode */
#define NUM_CCs 8 /* max. number of custom characters */
typedef enum {
standard, /* only char 0 is used for heartbeat */
vbar, /* vertical bars */
hbar, /* horizontal bars */
bignum, /* big numbers */
bigchar, /* big characters */
custom /* custom icons */
} CGmode;
typedef struct cgram_cache {
unsigned char cache[LCD_DEFAULT_CELLHEIGHT];
+4 -13
View File
@@ -1,5 +1,7 @@
/** \file server/drivers/wirz-sli.c
* LCDd \c sli driver for the SLI devices by Wirz, http://www.wirz.com/.
*
* \todo Convert to new style hbar and vbar!
*/
/* wirz-sli.c -- Source file for LCDproc Wirz SLI driver
@@ -27,14 +29,6 @@
#define SLI_DEFAULT_DEVICE "/dev/lcd"
typedef enum {
normal = 0,
hbar = 1,
vbar = 2,
bign = 4,
beat = 8
} custom_type;
/** private data for the \c sli driver */
typedef struct sli_private_data {
char device[256];
@@ -45,7 +39,7 @@ typedef struct sli_private_data {
int height;
int cellwidth;
int cellheight;
int custom;
CGmode custom;
} PrivateData;
@@ -74,7 +68,7 @@ sli_init (Driver *drvthis)
return -1;
/* initialize private data */
p->custom = normal;
p->custom = standard;
p->fd = -1;
p->framebuf = NULL;
p->width = 16;
@@ -540,7 +534,6 @@ sli_set_char (Driver *drvthis, int n, char *dat)
MODULE_EXPORT int
sli_icon (Driver *drvthis, int x, int y, int icon)
{
PrivateData *p = drvthis->private_data;
static char icons[3][5 * 8] = {
{
1, 1, 1, 1, 1, // Empty Heart
@@ -577,8 +570,6 @@ sli_icon (Driver *drvthis, int x, int y, int icon)
};
if (p->custom == bign)
p->custom = beat;
switch (icon) {
case ICON_BLOCK_FILLED:
sli_chr(drvthis, x, y, 255);