Work in progress for BigDigit + TODO comment

This commit is contained in:
dglaude
2001-11-23 16:17:45 +00:00
parent 4e434eab7d
commit 44e71c451e
+102 -60
View File
@@ -49,13 +49,13 @@ extern int debug_level;
// TODO: Remove this custom_type if not in use anymore. // TODO: Remove this custom_type if not in use anymore.
typedef enum { typedef enum {
hbar = 1, bar = 2,
vbar = 2,
bign = 4, bign = 4,
beat = 8 beat = 8
} custom_type; } custom_type;
// TODO: This is my ugglyest piece of code. #define DIRTY_CHAR 254
#define START_ICON 22
typedef enum { typedef enum {
baru1 = 0, baru1 = 0,
baru2 = 1, baru2 = 1,
@@ -79,12 +79,13 @@ typedef enum {
barl2 = 19, barl2 = 19,
barl3 = 20, barl3 = 20,
barl4 = 21, barl4 = 21,
empty_heart = 22,
filled_heart = 23,
ellipsis = 24,
barw = 32, barw = 32,
barb = 255 barb = 255
} bar_type; } bar_type;
// The following variable should be per instance of the driver.
static char * lcd_contents = (char *) 0; // for incremental updates
static int custom = 0; static int custom = 0;
static enum {MTXORB_LCD, MTXORB_LKD, MTXORB_VFD, MTXORB_VKD} MtxOrb_type; static enum {MTXORB_LCD, MTXORB_LKD, MTXORB_VFD, MTXORB_VKD} MtxOrb_type;
static int fd; static int fd;
@@ -128,6 +129,17 @@ static void MtxOrb_set_known_char (int car, int type);
* End of what was in MtxOrb.h * End of what was in MtxOrb.h
*/ */
static int
MtxOrb_clear_custom ()
{
int pos;
for (pos = 0; pos < 9; pos++) {
def[pos] = -1; // Not in use.
use[pos] = 0; // Not in use.
}
}
static int static int
MtxOrb_set_type (char * str) { MtxOrb_set_type (char * str) {
char c; char c;
@@ -387,11 +399,6 @@ MtxOrb_init (lcd_logical_driver * driver, char *args)
malloc (MtxOrb->wid * MtxOrb->hgt); malloc (MtxOrb->wid * MtxOrb->hgt);
memset (MtxOrb->framebuf, ' ', MtxOrb->wid * MtxOrb->hgt); memset (MtxOrb->framebuf, ' ', MtxOrb->wid * MtxOrb->hgt);
// Allocate and clear the buffer for incremental updates
lcd_contents = (unsigned char *) malloc (MtxOrb->wid * MtxOrb->hgt);
if (!lcd_contents) { return -1; }
memset(lcd_contents, ' ', MtxOrb->wid * MtxOrb->hgt);
/* /*
* Configure display * Configure display
*/ */
@@ -468,11 +475,6 @@ MtxOrb_close ()
MtxOrb->framebuf = NULL; MtxOrb->framebuf = NULL;
if (lcd_contents)
free (lcd_contents);
lcd_contents = NULL;
if (debug_level > 3) if (debug_level > 3)
syslog(LOG_DEBUG, "MtxOrb: closed"); syslog(LOG_DEBUG, "MtxOrb: closed");
} }
@@ -741,6 +743,7 @@ MtxOrb_cursorblink (int on)
static void static void
MtxOrb_init_vbar () MtxOrb_init_vbar ()
{ {
custom = bar;
} }
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
@@ -749,6 +752,7 @@ MtxOrb_init_vbar ()
static void static void
MtxOrb_init_hbar () MtxOrb_init_hbar ()
{ {
custom = bar;
} }
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
@@ -976,10 +980,22 @@ MtxOrb_init_num ()
if (custom != bign) { if (custom != bign) {
write (fd, "\x0FEn", 2); write (fd, "\x0FEn", 2);
custom = bign; custom = bign;
} MtxOrb_clear_custom ();
} }
// TODO: Might not work, bignum is untested... an untested with dynamic bar. }
// TODO: MtxOrb_set_char is d ing the j b "real-time" as oppose
// to at flush time. Call to this function should be done in flush
// this mean in raw_frame. GLU
//
// TODO: Rather than to use the hardware BigNum we should use software
// emulation, this will make it work simultaniously as hbar/vbar. GLU
//
// TODO: Before the desinitive solution we need to make the caracter
// hiden behind the hardware bignum dirty so that they get cleaned
// when draw_frame is called. There is no dirty char so I will use 254
// hoping nowone is using that char. GLU
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Writes a big number. // Writes a big number.
@@ -987,6 +1003,7 @@ MtxOrb_init_num ()
static void static void
MtxOrb_num (int x, int num) MtxOrb_num (int x, int num)
{ {
int y, dx;
char out[5]; char out[5];
if (debug_level > 4) if (debug_level > 4)
@@ -994,17 +1011,34 @@ MtxOrb_num (int x, int num)
snprintf (out, sizeof(out), "\x0FE#%c%c", x, num); snprintf (out, sizeof(out), "\x0FE#%c%c", x, num);
write (fd, out, 4); write (fd, out, 4);
// Make this space dirty as far as frame buffer knows.
for (y = 1; y < 5; y++)
for (dx = 0; dx < 3; dx++)
MtxOrb_chr (x + dx, y, DIRTY_CHAR);
} }
// TODO: This could be higly optimised if data where to be pre-computed. // TODO: Every time we define a custom char within the LCD,
// we have to compute the binary value we are going to use.
// It is easy to keep the bitmap in this source file,
// but we compute that once rather than every time. GLU
//
// TODO: MtxOrb_set_char is doing the job "real-time" as oppose
// to at flush time. Call to this function should be done in flush
// this mean in draw_frame.
//
// TODO: _icon should not call this directly, this is why we define
// so frequently the heartbeat custom char.
//
// TODO: We make one 3 bytes write folowed by MtxOrb->cellhgt one byte
// write. This should be done in one single write.
#define MAX_CUSTOM_CHARS 7 #define MAX_CUSTOM_CHARS 7
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Sets a custom character from 0-7... // Sets a custom character from 0-7...
// //
// For input, values > 0 mean "on" and values <= 0 are "off".
//
// The input is just an array of characters... // The input is just an array of characters...
// //
static void static void
@@ -1027,8 +1061,8 @@ MtxOrb_set_char (int n, char *dat)
for (col = 0; col < MtxOrb->cellwid; col++) { for (col = 0; col < MtxOrb->cellwid; col++) {
// shift to make room for new scan line data // shift to make room for new scan line data
letter <<= 1; letter <<= 1;
// Now read a single bit of data
// Now read a single bit of data -- one entry in dat[] -- // -- one entry in dat[] --
// and add it to the binary data in "letter" // and add it to the binary data in "letter"
letter |= (dat[(row * MtxOrb->cellwid) + col] > 0); letter |= (dat[(row * MtxOrb->cellwid) + col] > 0);
} }
@@ -1036,48 +1070,54 @@ MtxOrb_set_char (int n, char *dat)
} }
} }
// TODO (DONE): All the icon are now define at the end of the custom char
// used for hbar/vbar. GLU
//
// TODO: Don't make direct call to caracter definition if the caracter is
// already defined.
static void static void
MtxOrb_icon (int which, char dest) MtxOrb_icon (int which, char dest)
{ {
char icons[3][5 * 8] = { // char icons[3][5 * 8] = {
{ // {
1, 1, 1, 1, 1, // Empty Heart // 1, 1, 1, 1, 1, // Empty Heart
1, 0, 1, 0, 1, // 1, 0, 1, 0, 1,
0, 0, 0, 0, 0, // 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, // 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, // 0, 0, 0, 0, 0,
1, 0, 0, 0, 1, // 1, 0, 0, 0, 1,
1, 1, 0, 1, 1, // 1, 1, 0, 1, 1,
1, 1, 1, 1, 1, // 1, 1, 1, 1, 1,
}, // },
//
{ // {
1, 1, 1, 1, 1, // Filled Heart // 1, 1, 1, 1, 1, // Filled Heart
1, 0, 1, 0, 1, // 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, // 0, 1, 0, 1, 0,
0, 1, 1, 1, 0, // 0, 1, 1, 1, 0,
0, 1, 1, 1, 0, // 0, 1, 1, 1, 0,
1, 0, 1, 0, 1, // 1, 0, 1, 0, 1,
1, 1, 0, 1, 1, // 1, 1, 0, 1, 1,
1, 1, 1, 1, 1, // 1, 1, 1, 1, 1,
}, // },
//
{ // {
0, 0, 0, 0, 0, // Ellipsis // 0, 0, 0, 0, 0, // Ellipsis
0, 0, 0, 0, 0, // 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, // 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, // 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, // 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, // 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, // 0, 0, 0, 0, 0,
1, 0, 1, 0, 1, // 1, 0, 1, 0, 1,
}, // },
//
}; // };
if (custom == bign) if (custom == bign)
custom = beat; custom = beat;
MtxOrb_set_char (dest, &icons[which][0]); MtxOrb_set_known_char (dest, START_ICON+which);
// MtxOrb_set_char (dest, &icons[which][0]);
} }
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
@@ -1313,6 +1353,7 @@ MtxOrb_ask_bar (int type)
static void static void
MtxOrb_heartbeat (int type) MtxOrb_heartbeat (int type)
{ {
int the_icon=255;
static int timer = 0; static int timer = 0;
int whichIcon; int whichIcon;
static int saved_type = HEARTBEAT_ON; static int saved_type = HEARTBEAT_ON;
@@ -1326,10 +1367,11 @@ MtxOrb_heartbeat (int type)
// This defines a custom character EVERY time... // This defines a custom character EVERY time...
// not efficient... is this necessary? // not efficient... is this necessary?
MtxOrb_icon (whichIcon, 0); // MtxOrb_icon (whichIcon, 0);
the_icon=MtxOrb_ask_bar (whichIcon+START_ICON);
// Put character on screen... // Put character on screen...
MtxOrb_chr (MtxOrb->wid, 1, 0); MtxOrb_chr (MtxOrb->wid, 1, the_icon);
// change display... // change display...
MtxOrb_flush (); MtxOrb_flush ();