Bignum support.

This commit is contained in:
robijn
2002-01-14 22:09:10 +00:00
parent f244d66500
commit d10b943524
+188
View File
@@ -761,6 +761,98 @@ HD44780_hbar (Driver *drvthis, int x, int y, int len)
MODULE_EXPORT void
HD44780_init_num (Driver *drvthis)
{
PrivateData *p = (PrivateData *) drvthis->private_data;
int i;
char bignum_udcs[8][5*8] = {{
1, 1, 0, 0, 0,
1, 1, 0, 0, 0,
1, 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, 0, 1, 1,
0, 0, 0, 1, 1,
0, 0, 0, 1, 1,
0, 0, 0, 0, 0,
1, 1, 0, 0, 0,
1, 1, 0, 0, 0,
1, 1, 0, 0, 0,
0, 0, 0, 0, 0
}, {
1, 1, 0, 1, 1,
1, 1, 0, 1, 1,
1, 1, 0, 1, 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,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
1, 1, 0, 0, 0,
1, 1, 0, 0, 0,
1, 1, 0, 0, 0,
0, 0, 0, 0, 0
}, {
1, 1, 0, 0, 0,
1, 1, 0, 0, 0,
1, 1, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 1, 1,
0, 0, 0, 1, 1,
0, 0, 0, 1, 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,
1, 1, 0, 1, 1,
1, 1, 0, 1, 1,
1, 1, 0, 1, 1,
0, 0, 0, 0, 0
}, {
1, 1, 0, 0, 0,
1, 1, 0, 0, 0,
1, 1, 0, 0, 0,
0, 0, 0, 0, 0,
1, 1, 0, 0, 0,
1, 1, 0, 0, 0,
1, 1, 0, 0, 0,
0, 0, 0, 0, 0
}, {
0, 0, 0, 1, 1,
0, 0, 0, 1, 1,
0, 0, 0, 1, 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
}};
if( p->udcmode == UDCMODE_BIGNUM ) {
/* Work already done */
return;
}
if( p->udcmode != UDCMODE_STANDARD ) {
/* Not supported (yet) */
report( RPT_WARNING, "HD44780_init_num: Cannot combine two modes using user defined characters" );
return;
}
p->udcmode = UDCMODE_BIGNUM;
for( i=0; i<8; i++ ) {
HD44780_set_char (drvthis, i, bignum_udcs[i]);
}
}
/////////////////////////////////////////////////////////////////
@@ -769,6 +861,102 @@ HD44780_init_num (Driver *drvthis)
MODULE_EXPORT void
HD44780_num (Driver *drvthis, int x, int num)
{
PrivateData *p = (PrivateData *) drvthis->private_data;
char bignum_map[11][4][3] = {
{ /* 0: */
{1,2,3},
{6,32,6},
{6,32,6},
{7,2,32}
},
{ /* 1: */
{7,6,32},
{32,6,32},
{32,6,32},
{7,2,32},
},
{ /* 2: */
{1,2,3},
{32,5,0},
{1,32,32},
{2,2,0},
},
{ /* 3: */
{1,2,3},
{32,5,0},
{3,32,6},
{7,2,32}
},
{ /* 4: */
{32,3,6},
{1,32,6},
{2,2,6},
{32,32,0}
},
{ /* 5: */
{1,2,0},
{2,2,3},
{3,32,6},
{7,2,32}
},
{ /* 6: */
{1,2,32},
{6,5,32},
{6,32,6},
{7,2,32}
},
{ /* 7: */
{2,2,6},
{32,1,32},
{32,6,32},
{32,0,32}
},
{ /* 8: */
{1,2,3},
{4,5,0},
{6,32,6},
{7,2,32}
},
{ /* 9: */
{1,2,3},
{4,3,6},
{32,1,32},
{7,32,32}
},
{ /* colon: */
{32},
{7},
{7},
{32}
}};
if( num < 0 || num > 10 ) return;
HD44780_init_num(drvthis);
if( p->width >= 20 && p->height >= 4 ) {
int y = ( p->height - 2 ) / 2;
int x2, y2;
for( x2 = 0; x2 <= 2; x2 ++ ) {
for( y2 = 0; y2 <= 3; y2 ++ ) {
HD44780_chr( drvthis, x+x2, y+y2, bignum_map[num][y2][x2] );
}
if( num == 10 ) {
x2 = 2; /* =break, for colon only */
}
}
}
else {
int y = ( p->height - 1 ) / 2;
if( num == 11 ) {
HD44780_chr( drvthis, x, y, ':' );
} else {
HD44780_chr( drvthis, x, y, num + '0' );
}
}
}
/////////////////////////////////////////////////////////////