a first go at the glk driver
This commit is contained in:
+155
-96
@@ -27,15 +27,20 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define DEBUG 1
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
#include "shared/str.h"
|
#include "shared/str.h"
|
||||||
#include "glk.h"
|
#include "glk.h"
|
||||||
#include "glkproto.h"
|
#include "glkproto.h"
|
||||||
#include "report.h"
|
#include "report.h"
|
||||||
|
|
||||||
|
#include "adv_bignum.h"
|
||||||
|
|
||||||
#define GLK_DEFAULT_DEVICE "/dev/lcd"
|
#define GLK_DEFAULT_DEVICE "/dev/lcd"
|
||||||
#define GLK_DEFAULT_SPEED 19200
|
#define GLK_DEFAULT_SPEED 19200
|
||||||
#define GLK_DEFAULT_CONTRAST 560
|
#define GLK_DEFAULT_CONTRAST 560
|
||||||
|
#define GLK_DEFAULT_CELLWIDTH 6
|
||||||
|
#define GLK_DEFAULT_CELLHEIGHT 8
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@@ -44,18 +49,23 @@
|
|||||||
|
|
||||||
typedef struct driver_private_data {
|
typedef struct driver_private_data {
|
||||||
char device[256];
|
char device[256];
|
||||||
GLKDisplay *PortFD;
|
GLKDisplay *fd;
|
||||||
speed_t speed;
|
speed_t speed;
|
||||||
|
|
||||||
unsigned char *screen_contents;
|
const char *model;
|
||||||
|
|
||||||
int fontselected;
|
int fontselected;
|
||||||
int gpo_count;
|
int gpo_count;
|
||||||
|
|
||||||
unsigned char *framebuf;
|
unsigned char *framebuf;
|
||||||
|
unsigned char *backingstore;
|
||||||
|
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
|
||||||
int cellwidth;
|
int cellwidth;
|
||||||
int cellheight;
|
int cellheight;
|
||||||
|
|
||||||
int contrast;
|
int contrast;
|
||||||
|
|
||||||
int clearcount;
|
int clearcount;
|
||||||
@@ -88,14 +98,14 @@ glk_init(Driver *drvthis)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* initialize private data */
|
/* initialize private data */
|
||||||
p->PortFD = NULL;
|
p->fd = NULL;
|
||||||
p->speed = GLK_DEFAULT_SPEED;
|
p->speed = GLK_DEFAULT_SPEED;
|
||||||
p->screen_contents = NULL;
|
p->backingstore = NULL;
|
||||||
p->fontselected = -1; // No font selected
|
p->fontselected = -1; // No font selected
|
||||||
p->gpo_count = 0;
|
p->gpo_count = 0;
|
||||||
p->framebuf = NULL;
|
p->framebuf = NULL;
|
||||||
p->cellwidth = LCD_DEFAULT_CELLWIDTH;
|
p->cellwidth = GLK_DEFAULT_CELLWIDTH;
|
||||||
p->cellheight = LCD_DEFAULT_CELLHEIGHT;
|
p->cellheight = GLK_DEFAULT_CELLHEIGHT;
|
||||||
p->contrast = GLK_DEFAULT_SPEED;
|
p->contrast = GLK_DEFAULT_SPEED;
|
||||||
p->clearcount = 0;
|
p->clearcount = 0;
|
||||||
|
|
||||||
@@ -112,14 +122,17 @@ glk_init(Driver *drvthis)
|
|||||||
|
|
||||||
if (p->speed == 9600) p->speed = B9600;
|
if (p->speed == 9600) p->speed = B9600;
|
||||||
else if (p->speed == 19200) p->speed = B19200;
|
else if (p->speed == 19200) p->speed = B19200;
|
||||||
else if (p->speed == 38400) p->speed = B38400;
|
// not in the specs:
|
||||||
|
//else if (p->speed == 38400) p->speed = B38400;
|
||||||
|
else if (p->speed == 57600) p->speed = B57600;
|
||||||
|
else if (p->speed == 115200) p->speed = B115200;
|
||||||
else {
|
else {
|
||||||
report(RPT_WARNING, "%s: illegal Speed: %d; must be one of 9600, 19200 or 38400; using default %d",
|
report(RPT_WARNING, "%s: illegal Speed: %d; must be one of 9600, 19200, 57600 or 115200; using default %d",
|
||||||
drvthis->name, p->speed, 19200);
|
drvthis->name, p->speed, GLK_DEFAULT_SPEED);
|
||||||
p->speed = B19200;
|
p->speed = B19200;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Which p->contrast */
|
/* Which contrast */
|
||||||
p->contrast = drvthis->config_get_int(drvthis->name, "Contrast" , 0 , GLK_DEFAULT_CONTRAST);
|
p->contrast = drvthis->config_get_int(drvthis->name, "Contrast" , 0 , GLK_DEFAULT_CONTRAST);
|
||||||
if ((p->contrast < 0) || (p->contrast > 1000)) {
|
if ((p->contrast < 0) || (p->contrast > 1000)) {
|
||||||
report(RPT_WARNING, "%s: Contrast must be between 0 and 1000. Using default %d",
|
report(RPT_WARNING, "%s: Contrast must be between 0 and 1000. Using default %d",
|
||||||
@@ -130,61 +143,74 @@ glk_init(Driver *drvthis)
|
|||||||
/* End of config file parsing */
|
/* End of config file parsing */
|
||||||
|
|
||||||
/* open device */
|
/* open device */
|
||||||
p->PortFD = glkopen(p->device, p->speed);
|
p->fd = glkopen(p->device, p->speed);
|
||||||
if (p->PortFD == NULL) {
|
if (p->fd == NULL) {
|
||||||
report(RPT_ERR, "%s: unable to open device %s", drvthis->name, p->device);
|
report(RPT_ERR, "%s: unable to open device %s", drvthis->name, p->device);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query the module for a device type
|
// Query the module for a device type
|
||||||
glkputl(p->PortFD, GLKCommand, 0x37, EOF);
|
glkputl(p->fd, GLKCommand, 0x37, EOF);
|
||||||
i = glkget(p->PortFD);
|
i = glkget(p->fd);
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
report(RPT_ERR, "%s: GLK did not respond to READ MODULE TYPE", drvthis->name);
|
report(RPT_ERR, "%s: GLK did not respond to READ MODULE TYPE", drvthis->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0x10 : // GLC12232
|
case 0x10 :
|
||||||
|
p->model = "GLC12232";
|
||||||
p->width = 20; p->height = 4;
|
p->width = 20; p->height = 4;
|
||||||
break;
|
break;
|
||||||
case 0x11 : // GLC12864
|
case 0x11 :
|
||||||
|
p->model = "GLC12864";
|
||||||
p->width = 20; p->height = 8;
|
p->width = 20; p->height = 8;
|
||||||
break;
|
break;
|
||||||
case 0x12 : // GLC128128
|
case 0x12 :
|
||||||
|
p->model = "GLC128128";
|
||||||
p->width = 20; p->height = 16;
|
p->width = 20; p->height = 16;
|
||||||
break;
|
break;
|
||||||
case 0x13 : // GLC24064
|
case 0x13 :
|
||||||
p->width = 40; p->height = 8; p->gpo_count = 1;
|
p->model = "GLC24064";
|
||||||
|
p->width = 40; p->height = 8;
|
||||||
|
p->gpo_count = 1;
|
||||||
break;
|
break;
|
||||||
case 0x14 : // GLK12864-25
|
case 0x14 :
|
||||||
|
p->model = "GLK12864-25";
|
||||||
p->width = 20; p->height = 8;
|
p->width = 20; p->height = 8;
|
||||||
break;
|
break;
|
||||||
case 0x15 : // GLK24064-25
|
case 0x15 :
|
||||||
p->width = 40; p->height = 8; p->gpo_count = 1;
|
p->model = "GLK24064-25";
|
||||||
|
p->width = 40; p->height = 8;
|
||||||
|
p->gpo_count = 1;
|
||||||
break;
|
break;
|
||||||
case 0x21 : // GLK128128-25
|
case 0x21 :
|
||||||
|
p->model = "GLK128128-25";
|
||||||
p->width = 20; p->height = 16;
|
p->width = 20; p->height = 16;
|
||||||
break;
|
break;
|
||||||
case 0x22 : // GLK12232-25
|
case 0x22 :
|
||||||
p->width = 20; p->height = 4; p->gpo_count = 2;
|
p->model = "GLK12232-25";
|
||||||
|
p->width = 20; p->height = 4;
|
||||||
|
p->gpo_count = 2;
|
||||||
break;
|
break;
|
||||||
case 0x23 : // GLK12232-25SM
|
case 0x23 :
|
||||||
p->width = 20; p->height = 4; p->gpo_count = 2;
|
case 0x24 :
|
||||||
break;
|
p->model = "GLK12232-25-SM";
|
||||||
case 0x24 : // GLK12232-25SM-Penguin
|
p->width = 20; p->height = 4;
|
||||||
p->width = 20; p->height = 4; p->gpo_count = 2;
|
p->gpo_count = 2;
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
report(RPT_ERR, "%s: unrecognized module type: 0x%02X", drvthis->name, i);
|
report(RPT_ERR, "%s: unrecognized module type: 0x%02X", drvthis->name, i);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
report(RPT_INFO, "%s: Model identified by byte: 0x%02X; size: %ix%i",
|
||||||
|
drvthis->name, i, p->width, p->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
p->framebuf = malloc(p->width * p->height);
|
p->framebuf = malloc(p->width * p->height);
|
||||||
p->screen_contents = malloc(p->width * p->height);
|
p->backingstore = malloc(p->width * p->height);
|
||||||
|
|
||||||
if (p->framebuf == NULL || p->screen_contents == NULL) {
|
if (p->framebuf == NULL || p->backingstore == NULL) {
|
||||||
report(RPT_ERR, "%s: Unable to allocate memory for screen buffers", drvthis->name);
|
report(RPT_ERR, "%s: Unable to allocate memory for screen buffers", drvthis->name);
|
||||||
glk_close(drvthis);
|
glk_close(drvthis);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -193,19 +219,19 @@ glk_init(Driver *drvthis)
|
|||||||
memset(p->framebuf, ' ', p->width * p->height);
|
memset(p->framebuf, ' ', p->width * p->height);
|
||||||
|
|
||||||
// glk_clear();
|
// glk_clear();
|
||||||
// glkputl(p->PortFD, GLKCommand, 0x58, EOF);
|
glkputl(p->fd, GLKCommand, 0x58, EOF);
|
||||||
|
|
||||||
|
|
||||||
// Enable flow control
|
// Enable flow control
|
||||||
glkflow(p->PortFD, 40, 2);
|
glkflow(p->fd, 40, 2);
|
||||||
|
|
||||||
// Set read character timeout to 0
|
// Set read character timeout to 0
|
||||||
glktimeout(p->PortFD, 0);
|
glktimeout(p->fd, 0);
|
||||||
|
|
||||||
// Enable auto-transmit of up/down key events
|
// Enable auto-transmit of up/down key events
|
||||||
// This allows us to generate REPEAT keys distinct from
|
// This allows us to generate REPEAT keys distinct from
|
||||||
// normal keys using timeouts. (see glk_get_key)
|
// normal keys using timeouts. (see glk_get_key)
|
||||||
glkputl(p->PortFD, GLKCommand, 0x7e, 1, GLKCommand, 0x41, EOF);
|
glkputl(p->fd, GLKCommand, 0x7e, 1, GLKCommand, 0x41, EOF);
|
||||||
|
|
||||||
// Set p->contrast
|
// Set p->contrast
|
||||||
glk_set_contrast(drvthis, p->contrast);
|
glk_set_contrast(drvthis, p->contrast);
|
||||||
@@ -225,14 +251,16 @@ glk_close(Driver *drvthis)
|
|||||||
PrivateData *p = drvthis->private_data;
|
PrivateData *p = drvthis->private_data;
|
||||||
|
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
if (p->PortFD != NULL)
|
if (p->fd != NULL)
|
||||||
glkclose(p->PortFD);
|
glkclose(p->fd);
|
||||||
|
|
||||||
if (p->framebuf != NULL)
|
if (p->framebuf != NULL)
|
||||||
free(p->framebuf);
|
free(p->framebuf);
|
||||||
|
p->framebuf = NULL;
|
||||||
|
|
||||||
if (p->screen_contents != NULL)
|
if (p->backingstore != NULL)
|
||||||
free(p->screen_contents);
|
free(p->backingstore);
|
||||||
|
p->backingstore = NULL;
|
||||||
|
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
@@ -298,8 +326,8 @@ void glk_clear_forced(Driver *drvthis)
|
|||||||
PrivateData *p = drvthis->private_data;
|
PrivateData *p = drvthis->private_data;
|
||||||
|
|
||||||
p->clearcount = CLEARCOUNT;
|
p->clearcount = CLEARCOUNT;
|
||||||
glkputl(p->PortFD, GLKCommand, 0x58, EOF);
|
glkputl(p->fd, GLKCommand, 0x58, EOF);
|
||||||
memset(p->screen_contents, ' ', p->width * p->height);
|
memset(p->backingstore, ' ', p->width * p->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -309,6 +337,8 @@ glk_clear(Driver *drvthis)
|
|||||||
PrivateData *p = drvthis->private_data;
|
PrivateData *p = drvthis->private_data;
|
||||||
|
|
||||||
memset(p->framebuf, ' ', p->width * p->height);
|
memset(p->framebuf, ' ', p->width * p->height);
|
||||||
|
|
||||||
|
// do a hardware clear very CLEARCOUNT invocation
|
||||||
if (--p->clearcount < 0)
|
if (--p->clearcount < 0)
|
||||||
glk_clear_forced(drvthis);
|
glk_clear_forced(drvthis);
|
||||||
}
|
}
|
||||||
@@ -324,7 +354,7 @@ glk_flush(Driver *drvthis)
|
|||||||
|
|
||||||
// puts("glk_flush()");
|
// puts("glk_flush()");
|
||||||
unsigned char *pf = p->framebuf;
|
unsigned char *pf = p->framebuf;
|
||||||
unsigned char *qf = p->screen_contents;
|
unsigned char *qf = p->backingstore;
|
||||||
int x, y;
|
int x, y;
|
||||||
unsigned char *ps = NULL;
|
unsigned char *ps = NULL;
|
||||||
|
|
||||||
@@ -336,24 +366,25 @@ glk_flush(Driver *drvthis)
|
|||||||
for (x = 0; x < p->width; ++x) {
|
for (x = 0; x < p->width; ++x) {
|
||||||
if ((*qf == *pf) && (xs >= 0)) {
|
if ((*qf == *pf) && (xs >= 0)) {
|
||||||
/* Write accumulated string */
|
/* Write accumulated string */
|
||||||
glkputl(p->PortFD, GLKCommand, 0x79, xs * 6 + 1, y * 8, EOF);
|
glkputl(p->fd, GLKCommand, 0x79, xs * p->cellwidth + 1, y * p->cellheight, EOF);
|
||||||
glkputa(p->PortFD, x - xs, ps);
|
glkputa(p->fd, x - xs, ps);
|
||||||
debug(RPT_DEBUG, "flush: Writing at (%d,%d) for %d", xs, y, x - xs);
|
debug(RPT_DEBUG, "flush: Writing at (%d,%d) for %d", xs, y, x - xs);
|
||||||
xs = -1;
|
xs = -1;
|
||||||
} else if ((*qf != *pf) && (xs < 0)) {
|
}
|
||||||
|
else if ((*qf != *pf) && (xs < 0)) {
|
||||||
/* Start new string of changes */
|
/* Start new string of changes */
|
||||||
ps = pf;
|
ps = pf;
|
||||||
xs = x;
|
xs = x;
|
||||||
}
|
}
|
||||||
*qf++ = *pf++; /* Update screen_contents from framebuf */
|
*qf++ = *pf++; /* Update p->backingstore from p->framebuf */
|
||||||
}
|
}
|
||||||
if (xs >= 0) {
|
if (xs >= 0) {
|
||||||
/* Write accumulated line */
|
/* Write accumulated line */
|
||||||
glkputl(p->PortFD, GLKCommand, 0x79, xs * 6 + 1, y * 8, EOF);
|
glkputl(p->fd, GLKCommand, 0x79, xs * p->cellwidth + 1, y * p->cellheight, EOF);
|
||||||
glkputa(p->PortFD, p->width - xs, ps);
|
glkputa(p->fd, p->width - xs, ps);
|
||||||
debug(RPT_DEBUG, "flush: Writing at (%d,%d) for %d", xs, y, p->width - xs);
|
debug(RPT_DEBUG, "flush: Writing at (%d,%d) for %d", xs, y, p->width - xs);
|
||||||
}
|
}
|
||||||
} /* For y */
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -391,13 +422,13 @@ glk_chr(Driver *drvthis, int x, int y, char c)
|
|||||||
x--; // Convert 1-based coords to 0-based...
|
x--; // Convert 1-based coords to 0-based...
|
||||||
y--;
|
y--;
|
||||||
|
|
||||||
if (p->fontselected != 2) {
|
if (p->fontselected != 1) {
|
||||||
debug(RPT_DEBUG, "Switching to font 2");
|
debug(RPT_DEBUG, "Switching to font 1");
|
||||||
/* Select font 2 */
|
/* Select font 2 */
|
||||||
glkputl(p->PortFD, GLKCommand, 0x31, 2, EOF);
|
glkputl(p->fd, GLKCommand, 0x31, 1, EOF);
|
||||||
p->fontselected = 2;
|
p->fontselected = 1;
|
||||||
/* Set font metrics */
|
/* Set font metrics */
|
||||||
glkputl(p->PortFD, GLKCommand, 0x32, 1, 0, 1, 1, 32, EOF);
|
glkputl(p->fd, GLKCommand, 0x32, 1, 0, 0, 0, 32, EOF);
|
||||||
/* Clear the screen */
|
/* Clear the screen */
|
||||||
glk_clear_forced(drvthis);
|
glk_clear_forced(drvthis);
|
||||||
}
|
}
|
||||||
@@ -452,9 +483,10 @@ glk_set_contrast(Driver *drvthis, int promille)
|
|||||||
|
|
||||||
// Do it: map logical [0, 1000] -> physical [0, 255] for the hardware
|
// Do it: map logical [0, 1000] -> physical [0, 255] for the hardware
|
||||||
debug(RPT_DEBUG, "Contrast: %d", p->contrast);
|
debug(RPT_DEBUG, "Contrast: %d", p->contrast);
|
||||||
glkputl(p->PortFD, GLKCommand, 0x50, (int) ((long) promille * 255 / 1000), EOF);
|
glkputl(p->fd, GLKCommand, 0x50, (int) ((long) promille * 255 / 1000), EOF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Turns the lcd backlight on or off...
|
// Turns the lcd backlight on or off...
|
||||||
//
|
//
|
||||||
@@ -465,14 +497,15 @@ glk_backlight(Driver *drvthis, int on)
|
|||||||
|
|
||||||
if (on) {
|
if (on) {
|
||||||
debug(RPT_DEBUG, "Backlight ON");
|
debug(RPT_DEBUG, "Backlight ON");
|
||||||
glkputl(p->PortFD, GLKCommand, 0x42, 0, EOF);
|
glkputl(p->fd, GLKCommand, 0x42, 0, EOF);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
debug(RPT_DEBUG, "Backlight OFF");
|
debug(RPT_DEBUG, "Backlight OFF");
|
||||||
glkputl(p->PortFD, GLKCommand, 0x46, EOF);
|
glkputl(p->fd, GLKCommand, 0x46, EOF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Sets general purpose outputs on or off
|
// Sets general purpose outputs on or off
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
@@ -481,67 +514,87 @@ glk_output(Driver *drvthis, int on)
|
|||||||
PrivateData *p = drvthis->private_data;
|
PrivateData *p = drvthis->private_data;
|
||||||
|
|
||||||
if (p->gpo_count < 2) {
|
if (p->gpo_count < 2) {
|
||||||
glkputl(p->PortFD, GLKCommand, ((on) ? 'W' : 'V'), EOF);
|
glkputl(p->fd, GLKCommand, ((on) ? 'W' : 'V'), EOF);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 1; i <= p->gpo_count; ++i, on >>= 1) {
|
for (i = 1; i <= p->gpo_count; ++i, on >>= 1) {
|
||||||
glkputl(p->PortFD, GLKCommand, ((on & 1) ? 'W' : 'V'), i, EOF);
|
glkputl(p->fd, GLKCommand, ((on & 1) ? 'W' : 'V'), i, EOF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// Tells the driver to get ready for vertical bargraphs.
|
|
||||||
//
|
|
||||||
static void
|
|
||||||
glk_init_vbar(Driver *drvthis)
|
|
||||||
{
|
|
||||||
//PrivateData *p = drvthis->private_data;
|
|
||||||
|
|
||||||
debug(RPT_DEBUG, "glk_init_vbar()");
|
/**
|
||||||
}
|
* Write a big number to the screen.
|
||||||
|
* \param drvthis Pointer to driver structure.
|
||||||
//////////////////////////////////////////////////////////////////////
|
* \param x Horizontal character position (column).
|
||||||
// Tells the driver to get ready for horizontal bargraphs.
|
* \param num Character to write (0 - 10 with 10 representing ':')
|
||||||
//
|
*/
|
||||||
static void
|
|
||||||
glk_init_hbar(Driver *drvthis)
|
|
||||||
{
|
|
||||||
//PrivateData *p = drvthis->private_data;
|
|
||||||
|
|
||||||
debug(RPT_DEBUG, "glk_init_hbar()");
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// Draws a big (4-row) number.
|
|
||||||
//
|
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
glk_num(Driver *drvthis, int x, int num)
|
IOWarrior_num(Driver *drvthis, int x, int num)
|
||||||
{
|
{
|
||||||
PrivateData *p = drvthis->private_data;
|
//PrivateData *p = drvthis->private_data;
|
||||||
|
int do_init = 1;
|
||||||
|
|
||||||
debug(RPT_DEBUG, "glk_num(%d, %d)", x, num);
|
debug(RPT_DEBUG, "glk_num(%d, %d)", x, num);
|
||||||
|
|
||||||
if ((num < 0) || (num > 10))
|
if ((num < 0) || (num > 10))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* no need to check for alternative ccmodes: we have no custom characters
|
||||||
|
if (p->ccmode != bignum) {
|
||||||
|
if (p->ccmode != standard) {
|
||||||
|
// Not supported (yet)
|
||||||
|
report(RPT_WARNING, "%s: num: cannot combine two modes using user-defined characters",
|
||||||
|
drvthis->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
p->ccmode = bignum;
|
||||||
|
|
||||||
|
do_init = 1;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Lib_adv_bignum does everything needed to show the bignumbers.
|
||||||
|
lib_adv_bignum(drvthis, x, num, 0, do_init);
|
||||||
|
|
||||||
|
/* previous implementation using alternative font:
|
||||||
if (p->fontselected != 3) {
|
if (p->fontselected != 3) {
|
||||||
debug(RPT_DEBUG, "Switching to font 3");
|
debug(RPT_DEBUG, "Switching to font 3");
|
||||||
/* Select Big Numbers font */
|
// Select Big Numbers font
|
||||||
glkputl(p->PortFD, GLKCommand, 0x31, 3, EOF);
|
glkputl(p->fd, GLKCommand, 0x31, 3, EOF);
|
||||||
p->fontselected = 3;
|
p->fontselected = 3;
|
||||||
/* Set font metrics */
|
// Set font metrics
|
||||||
glkputl(p->PortFD, GLKCommand, 0x32, 1, 0, 1, 1, 32, EOF);
|
glkputl(p->fd, GLKCommand, 0x32, 1, 0, 1, 1, 32, EOF);
|
||||||
/* Clear the screen */
|
// Clear the screen
|
||||||
glk_clear_forced(drvthis);
|
glk_clear_forced(drvthis);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((x > 0) && (x <= p->width))
|
if ((x > 0) && (x <= p->width))
|
||||||
p->framebuf[x-1] = (num >= 10) ? ':' : (num + '0');
|
p->framebuf[x-1] = (num >= 10) ? ':' : (num + '0');
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get number of custom characters available.
|
||||||
|
* \param drvthis Pointer to driver structure.
|
||||||
|
* \return Number of custom characters (always 0).
|
||||||
|
*/
|
||||||
|
MODULE_EXPORT int
|
||||||
|
glk_get_free_chars(Driver *drvthis)
|
||||||
|
{
|
||||||
|
//PrivateData *p = drvthis->private_data;
|
||||||
|
|
||||||
|
debug(RPT_DEBUG, "glk_get_free_chars()");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Changes the font data of character n.
|
// Changes the font data of character n.
|
||||||
//
|
//
|
||||||
@@ -553,6 +606,7 @@ glk_set_char(Driver *drvthis, int n, char *dat)
|
|||||||
debug(RPT_DEBUG, "glk_set_char(%d)", n);
|
debug(RPT_DEBUG, "glk_set_char(%d)", n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// Draws a vertical bar, from the bottom of the screen up.
|
// Draws a vertical bar, from the bottom of the screen up.
|
||||||
//
|
//
|
||||||
@@ -587,6 +641,7 @@ glk_old_vbar(Driver *drvthis, int x, int len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// Draws a horizontal bar to the right.
|
// Draws a horizontal bar to the right.
|
||||||
//
|
//
|
||||||
@@ -631,7 +686,7 @@ glk_old_icon(Driver *drvthis, int which, int dest)
|
|||||||
PrivateData *p = drvthis->private_data;
|
PrivateData *p = drvthis->private_data;
|
||||||
unsigned char old, new;
|
unsigned char old, new;
|
||||||
unsigned char *pf = p->framebuf;
|
unsigned char *pf = p->framebuf;
|
||||||
unsigned char *qf = p->screen_contents;
|
unsigned char *qf = p->backingstore;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
debug(RPT_DEBUG, "glk_old_icon(%i, %i)", which, dest);
|
debug(RPT_DEBUG, "glk_old_icon(%i, %i)", which, dest);
|
||||||
@@ -658,7 +713,7 @@ glk_old_icon(Driver *drvthis, int which, int dest)
|
|||||||
/* Replace all old icons with new icon in new frame */
|
/* Replace all old icons with new icon in new frame */
|
||||||
for (count = p->width * p->height; count > 0; count--) {
|
for (count = p->width * p->height; count > 0; count--) {
|
||||||
if (*qf == old) {
|
if (*qf == old) {
|
||||||
debug(RPT_DEBUG, "icon %d to %d at %d", old, new, qf - p->screen_contents);
|
debug(RPT_DEBUG, "icon %d to %d at %d", old, new, qf - p->backingstore);
|
||||||
*pf = new;
|
*pf = new;
|
||||||
}
|
}
|
||||||
++qf; ++pf;
|
++qf; ++pf;
|
||||||
@@ -683,19 +738,21 @@ glk_get_key(Driver *drvthis)
|
|||||||
|
|
||||||
debug(RPT_DEBUG, "glk_get_key()");
|
debug(RPT_DEBUG, "glk_get_key()");
|
||||||
|
|
||||||
c = glkgetc(p->PortFD);
|
c = glkgetc(p->fd);
|
||||||
|
|
||||||
if ((c >= 'A') && (c <= 'Z')) {
|
if ((c >= 'A') && (c <= 'Z')) {
|
||||||
/* Key down event */
|
/* Key down event */
|
||||||
keycode = c;
|
keycode = c;
|
||||||
gettimeofday(&lastkey, NULL);
|
gettimeofday(&lastkey, NULL);
|
||||||
debug(RPT_DEBUG, "KEY %c at %ld.%06ld", c, lastkey.tv_sec, lastkey.tv_usec);
|
debug(RPT_DEBUG, "KEY %c at %ld.%06ld", c, lastkey.tv_sec, lastkey.tv_usec);
|
||||||
} else if ((c >= 'a') && (c <= 'z')) {
|
}
|
||||||
|
else if ((c >= 'a') && (c <= 'z')) {
|
||||||
/* Key up event */
|
/* Key up event */
|
||||||
debug(RPT_DEBUG, "KEY %c UP", c);
|
debug(RPT_DEBUG, "KEY %c UP", c);
|
||||||
keycode = -1;
|
keycode = -1;
|
||||||
c = 0;
|
c = 0;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* Assume timeout */
|
/* Assume timeout */
|
||||||
c = 0;
|
c = 0;
|
||||||
if (keycode > 0) {
|
if (keycode > 0) {
|
||||||
@@ -744,3 +801,5 @@ glk_get_key(Driver *drvthis)
|
|||||||
|
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ MODULE_EXPORT void glk_old_hbar(Driver *drvthis, int x, int y, int len);
|
|||||||
MODULE_EXPORT void glk_num(Driver *drvthis, int x, int num);
|
MODULE_EXPORT void glk_num(Driver *drvthis, int x, int num);
|
||||||
MODULE_EXPORT void glk_old_icon(Driver *drvthis, int which, int dest);
|
MODULE_EXPORT void glk_old_icon(Driver *drvthis, int which, int dest);
|
||||||
|
|
||||||
|
MODULE_EXPORT int glk_get_free_chars(Driver *drvthis);
|
||||||
MODULE_EXPORT void glk_set_char(Driver *drvthis, int n, char *dat);
|
MODULE_EXPORT void glk_set_char(Driver *drvthis, int n, char *dat);
|
||||||
|
|
||||||
MODULE_EXPORT int glk_get_contrast(Driver *drvthis);
|
MODULE_EXPORT int glk_get_contrast(Driver *drvthis);
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ GLKDisplay *glkopen(char *name, tcflag_t speed)
|
|||||||
/* Get current settings */
|
/* Get current settings */
|
||||||
if (tcgetattr(fd, &new) < 0) {
|
if (tcgetattr(fd, &new) < 0) {
|
||||||
int errsave = errno;
|
int errsave = errno;
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
errno = errsave;
|
errno = errsave;
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@@ -99,6 +100,7 @@ GLKDisplay *glkopen(char *name, tcflag_t speed)
|
|||||||
tcflush(fd, TCIOFLUSH);
|
tcflush(fd, TCIOFLUSH);
|
||||||
if (tcsetattr(fd, TCSANOW, &new) < 0) {
|
if (tcsetattr(fd, TCSANOW, &new) < 0) {
|
||||||
int errsave = errno;
|
int errsave = errno;
|
||||||
|
|
||||||
glkclose(retval);
|
glkclose(retval);
|
||||||
errno = errsave;
|
errno = errsave;
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@@ -438,14 +440,14 @@ glkputl(GLKDisplay *fd, ...)
|
|||||||
retval = glkput(fd, value);
|
retval = glkput(fd, value);
|
||||||
value = va_arg(ap, int);
|
value = va_arg(ap, int);
|
||||||
}
|
}
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
return(retval);
|
return(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* glkputs
|
/* glkputs
|
||||||
*
|
*
|
||||||
* Send a null terminated string of characters to the
|
* Send a null terminated string of characters to the GLK.
|
||||||
* GLK.
|
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
glkputs(GLKDisplay *fd, char *str)
|
glkputs(GLKDisplay *fd, char *str)
|
||||||
|
|||||||
Reference in New Issue
Block a user