Moving stuff into PrivateData (WIP)
This commit is contained in:
+58
-34
@@ -71,7 +71,9 @@
|
|||||||
#define IS_VFD_DISPLAY (MtxOrb_type == MTXORB_VFD)
|
#define IS_VFD_DISPLAY (MtxOrb_type == MTXORB_VFD)
|
||||||
#define IS_VKD_DISPLAY (MtxOrb_type == MTXORB_VKD)
|
#define IS_VKD_DISPLAY (MtxOrb_type == MTXORB_VKD)
|
||||||
|
|
||||||
#define NotEnoughArgs (i + 1 > argc)
|
/* TODO: Remove this if not in use anymore...
|
||||||
|
* #define NotEnoughArgs (i + 1 > argc)
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
NOTE: This does not appear to make use of the
|
NOTE: This does not appear to make use of the
|
||||||
@@ -163,8 +165,6 @@ static int clear = 1;
|
|||||||
/* static int use[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; */
|
/* static int use[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; */
|
||||||
|
|
||||||
static char *framebuf = NULL;
|
static char *framebuf = NULL;
|
||||||
static int width = LCD_DEFAULT_WIDTH;
|
|
||||||
static int height = LCD_DEFAULT_HEIGHT;
|
|
||||||
static int cellwidth = LCD_DEFAULT_CELLWIDTH;
|
static int cellwidth = LCD_DEFAULT_CELLWIDTH;
|
||||||
static int cellheight = LCD_DEFAULT_CELLHEIGHT;
|
static int cellheight = LCD_DEFAULT_CELLHEIGHT;
|
||||||
static int contrast = DEFAULT_CONTRAST;
|
static int contrast = DEFAULT_CONTRAST;
|
||||||
@@ -184,6 +184,10 @@ typedef struct p {
|
|||||||
int circular; /* static data from MtxOrb_ask_bar */
|
int circular; /* static data from MtxOrb_ask_bar */
|
||||||
int output_state; /* static data from MtxOrb_output */
|
int output_state; /* static data from MtxOrb_output */
|
||||||
int backlight_state; /* static data from MtxOrb_backlight */
|
int backlight_state; /* static data from MtxOrb_backlight */
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int widthBYheight; /* Avoid computing width * height frequently */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
int type;
|
int type;
|
||||||
int port;
|
int port;
|
||||||
@@ -192,7 +196,6 @@ typedef struct p {
|
|||||||
char * lcd_contents_text;
|
char * lcd_contents_text;
|
||||||
char * framebuf_graph;
|
char * framebuf_graph;
|
||||||
char * lcd_contents_graph;
|
char * lcd_contents_graph;
|
||||||
int width, height;
|
|
||||||
//int cellwidth, cellheight;
|
//int cellwidth, cellheight;
|
||||||
int graph_width, graph_height;
|
int graph_width, graph_height;
|
||||||
int cursor_x, cursor_y;
|
int cursor_x, cursor_y;
|
||||||
@@ -269,7 +272,9 @@ MtxOrb_init (Driver *drvthis, char *args)
|
|||||||
p->circular = -1; /* static data from MtxOrb_ask_bar */
|
p->circular = -1; /* static data from MtxOrb_ask_bar */
|
||||||
p->output_state = -1; /* static data from MtxOrb_output */
|
p->output_state = -1; /* static data from MtxOrb_output */
|
||||||
p->backlight_state = 1; /* static data from MtxOrb_backlight */
|
p->backlight_state = 1; /* static data from MtxOrb_backlight */
|
||||||
|
p->width = LCD_DEFAULT_WIDTH;
|
||||||
|
p->height = LCD_DEFAULT_HEIGHT;
|
||||||
|
p->widthBYheight = LCD_DEFAULT_WIDTH * LCD_DEFAULT_HEIGHT;
|
||||||
|
|
||||||
MtxOrb_type = MTXORB_LKD; /* Assume it's an LCD w/keypad */
|
MtxOrb_type = MTXORB_LKD; /* Assume it's an LCD w/keypad */
|
||||||
|
|
||||||
@@ -292,8 +297,9 @@ MtxOrb_init (Driver *drvthis, char *args)
|
|||||||
report (RPT_WARNING, "MtxOrb: Cannot read size: %s. Using default value %s.", size, DEFAULT_SIZE);
|
report (RPT_WARNING, "MtxOrb: Cannot read size: %s. Using default value %s.", size, DEFAULT_SIZE);
|
||||||
sscanf( DEFAULT_SIZE , "%dx%d", &w, &h );
|
sscanf( DEFAULT_SIZE , "%dx%d", &w, &h );
|
||||||
}
|
}
|
||||||
width = w;
|
p->width = w;
|
||||||
height = h;
|
p->height = h;
|
||||||
|
p->widthBYheight = w * h;
|
||||||
|
|
||||||
/* Get contrast */
|
/* Get contrast */
|
||||||
if (0<=drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST) && drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST) <= 255) {
|
if (0<=drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST) && drvthis->config_get_int ( drvthis->name , "Contrast" , 0 , DEFAULT_CONTRAST) <= 255) {
|
||||||
@@ -433,8 +439,8 @@ MtxOrb_init (Driver *drvthis, char *args)
|
|||||||
/* Make sure the frame buffer is there... */
|
/* Make sure the frame buffer is there... */
|
||||||
if (!framebuf)
|
if (!framebuf)
|
||||||
framebuf = (unsigned char *)
|
framebuf = (unsigned char *)
|
||||||
malloc (width * height);
|
malloc (p->width * p->height);
|
||||||
memset (framebuf, ' ', width * height);
|
memset (framebuf, ' ', p->width * p->height);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Configure display
|
* Configure display
|
||||||
@@ -448,8 +454,8 @@ MtxOrb_init (Driver *drvthis, char *args)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ValidX(x) if ((x) > width) { (x) = width; } else (x) = (x) < 1 ? 1 : (x);
|
#define ValidX(x) if ((x) > p->width) { (x) = p->width; } else (x) = (x) < 1 ? 1 : (x);
|
||||||
#define ValidY(y) if ((y) > height) { (y) = height; } else (y) = (y) < 1 ? 1 : (y);
|
#define ValidY(y) if ((y) > p->height) { (y) = p->height; } else (y) = (y) < 1 ? 1 : (y);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: Check this quick hack to detect clear of the screen.
|
* TODO: Check this quick hack to detect clear of the screen.
|
||||||
@@ -462,8 +468,10 @@ MtxOrb_init (Driver *drvthis, char *args)
|
|||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
MtxOrb_clear (Driver *drvthis)
|
MtxOrb_clear (Driver *drvthis)
|
||||||
{
|
{
|
||||||
|
PrivateData * p = drvthis->private_data;
|
||||||
|
|
||||||
if (framebuf != NULL)
|
if (framebuf != NULL)
|
||||||
memset (framebuf, ' ', (width * height));
|
memset (framebuf, ' ', (p->width * p->height));
|
||||||
|
|
||||||
/* We don't use hardware clear anymore.
|
/* We don't use hardware clear anymore.
|
||||||
* We use incremental update with the frame_buffer. */
|
* We use incremental update with the frame_buffer. */
|
||||||
@@ -498,7 +506,9 @@ MtxOrb_close (Driver *drvthis)
|
|||||||
MODULE_EXPORT int
|
MODULE_EXPORT int
|
||||||
MtxOrb_width (Driver *drvthis)
|
MtxOrb_width (Driver *drvthis)
|
||||||
{
|
{
|
||||||
return width;
|
PrivateData * p = drvthis->private_data;
|
||||||
|
|
||||||
|
return p->width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************
|
/******************************
|
||||||
@@ -507,7 +517,9 @@ MtxOrb_width (Driver *drvthis)
|
|||||||
MODULE_EXPORT int
|
MODULE_EXPORT int
|
||||||
MtxOrb_height (Driver *drvthis)
|
MtxOrb_height (Driver *drvthis)
|
||||||
{
|
{
|
||||||
return height;
|
PrivateData * p = drvthis->private_data;
|
||||||
|
|
||||||
|
return p->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
@@ -515,12 +527,14 @@ MtxOrb_string (Driver *drvthis, int x, int y, char *string)
|
|||||||
{
|
{
|
||||||
int offset, siz;
|
int offset, siz;
|
||||||
|
|
||||||
|
PrivateData * p = drvthis->private_data;
|
||||||
|
|
||||||
ValidX(x);
|
ValidX(x);
|
||||||
ValidY(y);
|
ValidY(y);
|
||||||
|
|
||||||
x--; y--; /* Convert 1-based coords to 0-based... */
|
x--; y--; /* Convert 1-based coords to 0-based... */
|
||||||
offset = (y * width) + x;
|
offset = (y * p->width) + x;
|
||||||
siz = (width * height) - offset;
|
siz = (p->width * p->height) - offset;
|
||||||
siz = siz > strlen(string) ? strlen(string) : siz;
|
siz = siz > strlen(string) ? strlen(string) : siz;
|
||||||
|
|
||||||
memcpy(framebuf + offset, string, siz);
|
memcpy(framebuf + offset, string, siz);
|
||||||
@@ -534,15 +548,17 @@ MtxOrb_flush (Driver *drvthis)
|
|||||||
char out[12];
|
char out[12];
|
||||||
int i,j,mv = 1;
|
int i,j,mv = 1;
|
||||||
static char *old = NULL;
|
static char *old = NULL;
|
||||||
char *p, *q;
|
char *xp, *xq;
|
||||||
|
|
||||||
|
PrivateData * p = drvthis->private_data;
|
||||||
|
|
||||||
if (old == NULL) {
|
if (old == NULL) {
|
||||||
old = malloc(width * height);
|
old = malloc(p->width * p->height);
|
||||||
|
|
||||||
write(fd, "\x0FEG\x01\x01", 4);
|
write(fd, "\x0FEG\x01\x01", 4);
|
||||||
write(fd, framebuf, width * height);
|
write(fd, framebuf, p->width * p->height);
|
||||||
|
|
||||||
strncpy(old, framebuf, width * height);
|
strncpy(old, framebuf, p->width * p->height);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -556,13 +572,13 @@ MtxOrb_flush (Driver *drvthis)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
p = framebuf;
|
xp = framebuf;
|
||||||
q = old;
|
xq = old;
|
||||||
|
|
||||||
for (i = 1; i <= height; i++) {
|
for (i = 1; i <= p->height; i++) {
|
||||||
for (j = 1; j <= width; j++) {
|
for (j = 1; j <= p->width; j++) {
|
||||||
|
|
||||||
if ((*p == *q) && (*p > 8))
|
if ((*xp == *xq) && (*xp > 8))
|
||||||
mv = 1;
|
mv = 1;
|
||||||
else {
|
else {
|
||||||
/* Draw characters that have changed, as well
|
/* Draw characters that have changed, as well
|
||||||
@@ -575,10 +591,10 @@ MtxOrb_flush (Driver *drvthis)
|
|||||||
write (fd, out, 4);
|
write (fd, out, 4);
|
||||||
mv = 0;
|
mv = 0;
|
||||||
}
|
}
|
||||||
write (fd, p, 1);
|
write (fd, xp, 1);
|
||||||
}
|
}
|
||||||
p++;
|
xp++;
|
||||||
q++;
|
xq++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -590,7 +606,7 @@ MtxOrb_flush (Driver *drvthis)
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
strncpy(old, framebuf, width * height);
|
strncpy(old, framebuf, p->width * p->height);
|
||||||
|
|
||||||
debug(RPT_DEBUG, "MtxOrb: frame buffer flushed");
|
debug(RPT_DEBUG, "MtxOrb: frame buffer flushed");
|
||||||
}
|
}
|
||||||
@@ -608,6 +624,8 @@ MtxOrb_chr (Driver *drvthis, int x, int y, char c)
|
|||||||
* that characters 0..4 (or similar) are graphic fonts
|
* that characters 0..4 (or similar) are graphic fonts
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
PrivateData * p = drvthis->private_data;
|
||||||
|
|
||||||
ValidX(x);
|
ValidX(x);
|
||||||
ValidY(y);
|
ValidY(y);
|
||||||
|
|
||||||
@@ -619,7 +637,7 @@ MtxOrb_chr (Driver *drvthis, int x, int y, char c)
|
|||||||
|
|
||||||
/* write to frame buffer */
|
/* write to frame buffer */
|
||||||
y--; x--; /* translate to 0-index */
|
y--; x--; /* translate to 0-index */
|
||||||
offset = (y * width) + x;
|
offset = (y * p->width) + x;
|
||||||
framebuf[offset] = c;
|
framebuf[offset] = c;
|
||||||
|
|
||||||
debug(RPT_DEBUG, "writing character %02X to position (%d,%d)", c, x, y);
|
debug(RPT_DEBUG, "writing character %02X to position (%d,%d)", c, x, y);
|
||||||
@@ -958,6 +976,8 @@ MtxOrb_old_vbar (Driver *drvthis, int x, int len)
|
|||||||
|
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
|
PrivateData * p = drvthis->private_data;
|
||||||
|
|
||||||
debug(RPT_DEBUG, "MtxOrb: vertical bar at %d set to %d", x, len);
|
debug(RPT_DEBUG, "MtxOrb: vertical bar at %d set to %d", x, len);
|
||||||
|
|
||||||
/* REMOVE THE NEXT LINE FOR TESTING ONLY... */
|
/* REMOVE THE NEXT LINE FOR TESTING ONLY... */
|
||||||
@@ -965,7 +985,7 @@ MtxOrb_old_vbar (Driver *drvthis, int x, int len)
|
|||||||
/* REMOVE THE PREVIOUS LINE FOR TESTING ONLY... */
|
/* REMOVE THE PREVIOUS LINE FOR TESTING ONLY... */
|
||||||
|
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
for (y = height; y > 0 && len > 0; y--) {
|
for (y = p->height; y > 0 && len > 0; y--) {
|
||||||
if (len >= cellheight)
|
if (len >= cellheight)
|
||||||
MtxOrb_icon (drvthis, x, y, barb);
|
MtxOrb_icon (drvthis, x, y, barb);
|
||||||
else
|
else
|
||||||
@@ -975,7 +995,7 @@ MtxOrb_old_vbar (Driver *drvthis, int x, int len)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
len = -len;
|
len = -len;
|
||||||
for (y = 2; y <= height && len > 0; y++) {
|
for (y = 2; y <= p->height && len > 0; y++) {
|
||||||
if (len >= cellheight)
|
if (len >= cellheight)
|
||||||
MtxOrb_icon (drvthis, x, y, barb);
|
MtxOrb_icon (drvthis, x, y, barb);
|
||||||
else
|
else
|
||||||
@@ -999,13 +1019,15 @@ MtxOrb_old_hbar (Driver *drvthis, int x, int y, int len)
|
|||||||
unsigned char mapr[6] = { barw, barr1, barr2, barr3, barr4, barb };
|
unsigned char mapr[6] = { barw, barr1, barr2, barr3, barr4, barb };
|
||||||
unsigned char mapl[6] = { barw, barl1, barl2, barl3, barl4, barb };
|
unsigned char mapl[6] = { barw, barl1, barl2, barl3, barl4, barb };
|
||||||
|
|
||||||
|
PrivateData * p = drvthis->private_data;
|
||||||
|
|
||||||
ValidX(x);
|
ValidX(x);
|
||||||
ValidY(y);
|
ValidY(y);
|
||||||
|
|
||||||
debug(RPT_DEBUG, "MtxOrb: horizontal bar at %d set to %d", x, len);
|
debug(RPT_DEBUG, "MtxOrb: horizontal bar at %d set to %d", x, len);
|
||||||
|
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
for (; x <= width && len > 0; x++) {
|
for (; x <= p->width && len > 0; x++) {
|
||||||
if (len >= cellwidth)
|
if (len >= cellwidth)
|
||||||
MtxOrb_icon (drvthis, x, y, barb);
|
MtxOrb_icon (drvthis, x, y, barb);
|
||||||
else
|
else
|
||||||
@@ -1290,12 +1312,14 @@ MtxOrb_heartbeat (Driver *drvthis, int type)
|
|||||||
static int timer = 0;
|
static int timer = 0;
|
||||||
int whichIcon;
|
int whichIcon;
|
||||||
|
|
||||||
|
PrivateData * p = drvthis->private_data;
|
||||||
|
|
||||||
if (type == HEARTBEAT_ON) {
|
if (type == HEARTBEAT_ON) {
|
||||||
/* Set this to pulsate like a real heart beat... */
|
/* Set this to pulsate like a real heart beat... */
|
||||||
whichIcon = (! ((timer + 4) & 5));
|
whichIcon = (! ((timer + 4) & 5));
|
||||||
|
|
||||||
/* Ask for the right heartbeat icon... */
|
/* Ask for the right heartbeat icon... */
|
||||||
MtxOrb_icon (drvthis, width, 1, whichIcon);
|
MtxOrb_icon (drvthis, p->width, 1, whichIcon);
|
||||||
|
|
||||||
/* change display... */
|
/* change display... */
|
||||||
MtxOrb_flush (drvthis);
|
MtxOrb_flush (drvthis);
|
||||||
|
|||||||
Reference in New Issue
Block a user