convert CFontz633 driver to use bignum library

This commit is contained in:
marschap
2006-04-26 10:00:20 +00:00
parent 3c8146daed
commit 3827d1ce50
3 changed files with 211 additions and 305 deletions
+207 -302
View File
@@ -61,6 +61,7 @@
#include "CFontz633io.h"
#include "report.h"
#include "lcd_lib.h"
#include "adv_bignum.h"
#define CF633_KEY_UP 1
#define CF633_KEY_DOWN 2
@@ -650,191 +651,6 @@ CFontz633_reboot (Driver *drvthis)
}
/*
* Sets up for vertical bars.
*/
static void
CFontz633_init_vbar (Driver *drvthis)
{
PrivateData *p = drvthis->private_data;
char a[] = {
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, 1, 1, 1,
};
char b[] = {
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, 1, 1, 1,
0, 1, 1, 1, 1, 1,
};
char c[] = {
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, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
};
char d[] = {
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, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
};
char e[] = {
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
};
char f[] = {
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
};
char g[] = {
0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1,
};
if (p->ccmode != vbar) {
//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 = vbar;
CFontz633_set_char(drvthis, 1, a);
CFontz633_set_char(drvthis, 2, b);
CFontz633_set_char(drvthis, 3, c);
CFontz633_set_char(drvthis, 4, d);
CFontz633_set_char(drvthis, 5, e);
CFontz633_set_char(drvthis, 6, f);
CFontz633_set_char(drvthis, 7, g);
}
}
/*
* Inits horizontal bars...
*/
static void
CFontz633_init_hbar (Driver *drvthis)
{
PrivateData *p = drvthis->private_data;
char a[] = {
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
};
char b[] = {
1, 1, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0,
};
char c[] = {
1, 1, 1, 0, 0, 0,
1, 1, 1, 0, 0, 0,
1, 1, 1, 0, 0, 0,
1, 1, 1, 0, 0, 0,
1, 1, 1, 0, 0, 0,
1, 1, 1, 0, 0, 0,
1, 1, 1, 0, 0, 0,
1, 1, 1, 0, 0, 0,
};
char d[] = {
1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 0, 0,
};
char e[] = {
1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 1, 0,
};
char f[] = {
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
};
if (p->ccmode != hbar) {
//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 = hbar;
CFontz633_set_char(drvthis, 1, a);
CFontz633_set_char(drvthis, 2, b);
CFontz633_set_char(drvthis, 3, c);
CFontz633_set_char(drvthis, 4, d);
CFontz633_set_char(drvthis, 5, e);
CFontz633_set_char(drvthis, 6, f);
}
}
/*
* Draws a vertical bar...
*/
@@ -849,7 +665,27 @@ CFontz633_vbar (Driver *drvthis, int x, int y, int len, int promille, int option
*/
PrivateData *p = drvthis->private_data;
CFontz633_init_vbar(drvthis);
if (p->ccmode != vbar) {
unsigned char vBar[p->cellheight];
int i;
if (p->ccmode != standard) {
/* Not supported(yet) */
report(RPT_WARNING, "%s: vbar: cannot combine two modes using user defined characters",
drvthis->name);
return;
}
p->ccmode = vbar;
memset(vBar, 0x00, sizeof(vBar));
for (i = 1; i < p->cellheight; i++) {
// add pixel line per pixel line ...
vBar[p->cellheight - i] = 0xFF;
CFontz633_set_char(drvthis, i, vBar);
}
}
lib_vbar_static(drvthis, x, y, len, promille, options, p->cellheight, 0);
}
@@ -868,28 +704,70 @@ CFontz633_hbar (Driver *drvthis, int x, int y, int len, int promille, int option
*/
PrivateData *p = drvthis->private_data;
CFontz633_init_hbar(drvthis);
if (p->ccmode != hbar) {
unsigned char hBar[p->cellheight];
int i;
if (p->ccmode != standard) {
/* Not supported(yet) */
report(RPT_WARNING, "%s: hbar: cannot combine two modes using user defined characters",
drvthis->name);
return;
}
p->ccmode = hbar;
memset(hBar, 0x00, sizeof(hBar));
for (i = 1; i <= p->cellwidth; i++) {
// fill pixel columns from left to right.
memset(hBar, 0xFF & ~((1 << (p->cellwidth - i)) - 1), sizeof(hBar)-1);
CFontz633_set_char(drvthis, i, hBar);
}
}
lib_hbar_static(drvthis, x, y, len, promille, options, p->cellwidth, 0);
}
/*
* Writes a big number.
* This is not supported on 633 because we only have 2 lines...
*/
MODULE_EXPORT void
CFontz633_num (Driver *drvthis, int x, int num)
CFontz633_num(Driver *drvthis, int x, int num)
{
/*
PrivateData *p = drvthis->private_data;
unsigned char out[5];
PrivateData *p = drvthis->private_data;
int do_init = 0;
if ((x <= 0) || (x > p->width))
if ((num < 0) || (num > 10))
return;
snprintf(out, sizeof(out), "%c%c%c", 28, x, num);
write(p->fd, out, 3);
*/
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, do_init, NUM_CCs);
}
/*
* Gets number of custom chars (always NUM_CCs)
*/
MODULE_EXPORT int
CFontz633_get_free_chars (Driver *drvthis)
{
//PrivateData *p = drvthis->private_data;
return NUM_CCs;
}
@@ -901,11 +779,12 @@ CFontz633_num (Driver *drvthis, int x, int num)
* The input is just an array of characters...
*/
MODULE_EXPORT void
CFontz633_set_char (Driver *drvthis, int n, char *dat)
CFontz633_set_char (Driver *drvthis, int n, unsigned char *dat)
{
PrivateData *p = drvthis->private_data;
unsigned char out[9];
int row, col;
unsigned char mask = (1 << p->cellwidth) - 1;
int row;
if ((n < 0) || (n >= NUM_CCs))
return;
@@ -915,13 +794,7 @@ CFontz633_set_char (Driver *drvthis, int n, char *dat)
out[0] = n; /* Custom char to define. xxx */
for (row = 0; row < p->cellheight; row++) {
int letter = 0;
for (col = 0; col < p->cellwidth; col++) {
letter <<= 1;
letter |= (dat[(row * p->cellwidth) + col] > 0);
}
out[row+1] = letter;
out[row+1] = dat[row] & mask;
}
send_bytes_message(p->fd, CF633_Set_LCD_Special_Character_Data, 9, out);
}
@@ -934,96 +807,128 @@ MODULE_EXPORT int
CFontz633_icon (Driver *drvthis, int x, int y, int icon)
{
PrivateData *p = drvthis->private_data;
char icons[8][6 * 8] = {
/* Empty Heart */
{
1, 1, 1, 1, 1, 1,
1, 1, 0, 1, 0, 1,
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
1, 1, 0, 0, 0, 1,
1, 1, 1, 0, 1, 1,
1, 1, 1, 1, 1, 1,
},
/* Filled Heart */
{
1, 1, 1, 1, 1, 1,
1, 1, 0, 1, 0, 1,
1, 0, 1, 0, 1, 0,
1, 0, 1, 1, 1, 0,
1, 0, 1, 1, 1, 0,
1, 1, 0, 1, 0, 1,
1, 1, 1, 0, 1, 1,
1, 1, 1, 1, 1, 1,
},
/* arrow_up */
{
0, 0, 0, 1, 0, 0,
0, 0, 1, 1, 1, 0,
0, 1, 0, 1, 0, 1,
0, 0, 0, 1, 0, 0,
0, 0, 0, 1, 0, 0,
0, 0, 0, 1, 0, 0,
0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0,
},
/* arrow_down */
{
0, 0, 0, 1, 0, 0,
0, 0, 0, 1, 0, 0,
0, 0, 0, 1, 0, 0,
0, 0, 0, 1, 0, 0,
0, 1, 0, 1, 0, 1,
0, 0, 1, 1, 1, 0,
0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0,
},
/* checkbox_off */
{
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1,
0, 1, 0, 0, 0, 1,
0, 1, 0, 0, 0, 1,
0, 1, 0, 0, 0, 1,
0, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0,
},
/* checkbox_on */
{
0, 0, 0, 1, 0, 0,
0, 0, 0, 1, 0, 0,
0, 1, 1, 1, 0, 1,
0, 1, 0, 1, 1, 0,
0, 1, 0, 1, 0, 1,
0, 1, 0, 0, 0, 1,
0, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0,
},
/* checkbox_gray */
{
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1,
0, 1, 0, 1, 0, 1,
0, 1, 1, 0, 1, 1,
0, 1, 0, 1, 0, 1,
0, 1, 1, 1, 1, 1,
0, 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,
1, 0, 1, 0, 1, 0,
},
};
static unsigned char heart_open[] =
{ b__XXXXX,
b__X_X_X,
b_______,
b_______,
b_______,
b__X___X,
b__XX_XX,
b__XXXXX };
static unsigned char heart_filled[] =
{ b__XXXXX,
b__X_X_X,
b___X_X_,
b___XXX_,
b___XXX_,
b__X_X_X,
b__XX_XX,
b__XXXXX };
static unsigned char arrow_up[] =
{ b____X__,
b___XXX_,
b__X_X_X,
b____X__,
b____X__,
b____X__,
b____X__,
b_______ };
static unsigned char arrow_down[] =
{ b____X__,
b____X__,
b____X__,
b____X__,
b__X_X_X,
b___XXX_,
b____X__,
b_______ };
/*
static unsigned char arrow_left[] =
{ b_______,
b____X__,
b___X___,
b__XXXXX,
b___X___,
b____X__,
b_______,
b_______ };
static unsigned char arrow_right[] =
{ b_______,
b____X__,
b_____X_,
b__XXXXX,
b_____X_,
b____X__,
b_______,
b_______ };
*/
static unsigned char checkbox_off[] =
{ b_______,
b_______,
b__XXXXX,
b__X___X,
b__X___X,
b__X___X,
b__XXXXX,
b_______ };
static unsigned char checkbox_on[] =
{ b____X__,
b____X__,
b__XXX_X,
b__X_XX_,
b__X_X_X,
b__X___X,
b__XXXXX,
b_______ };
static unsigned char checkbox_gray[] =
{ b_______,
b_______,
b__XXXXX,
b__X_X_X,
b__XX_XX,
b__X_X_X,
b__XXXXX,
b_______ };
/*
static unsigned char selector_left[] =
{ b___X___,
b___XX__,
b___XXX_,
b___XXXX,
b___XXX_,
b___XX__,
b___X___,
b_______ };
static unsigned char selector_right[] =
{ b_____X_,
b____XX_,
b___XXX_,
b__XXXX_,
b___XXX_,
b____XX_,
b_____X_,
b_______ };
static unsigned char ellipsis[] =
{ b_______,
b_______,
b_______,
b_______,
b_______,
b_______,
b__X_X_X,
b_______ };
static unsigned char block_filled[] =
{ b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX,
b__XXXXX };
*/
/* Yes we know, this is a VERY BAD implementation :-) */
switch (icon) {
@@ -1032,22 +937,22 @@ CFontz633_icon (Driver *drvthis, int x, int y, int icon)
break;
case ICON_HEART_FILLED:
p->ccmode = custom;
CFontz633_set_char(drvthis, 0, icons[1]);
CFontz633_set_char(drvthis, 0, heart_filled);
CFontz633_chr(drvthis, x, y, 0);
break;
case ICON_HEART_OPEN:
p->ccmode = custom;
CFontz633_set_char(drvthis, 0, icons[0]);
CFontz633_set_char(drvthis, 0, heart_open);
CFontz633_chr(drvthis, x, y, 0);
break;
case ICON_ARROW_UP:
p->ccmode = custom;
CFontz633_set_char(drvthis, 1, icons[2]);
CFontz633_set_char(drvthis, 1, arrow_up);
CFontz633_chr(drvthis, x, y, 1);
break;
case ICON_ARROW_DOWN:
p->ccmode = custom;
CFontz633_set_char(drvthis, 2, icons[3]);
CFontz633_set_char(drvthis, 2, arrow_down);
CFontz633_chr(drvthis, x, y, 2);
break;
case ICON_ARROW_LEFT:
@@ -1058,17 +963,17 @@ CFontz633_icon (Driver *drvthis, int x, int y, int icon)
break;
case ICON_CHECKBOX_OFF:
p->ccmode = custom;
CFontz633_set_char(drvthis, 3, icons[4]);
CFontz633_set_char(drvthis, 3, checkbox_off);
CFontz633_chr(drvthis, x, y, 3);
break;
case ICON_CHECKBOX_ON:
p->ccmode = custom;
CFontz633_set_char(drvthis, 4, icons[5]);
CFontz633_set_char(drvthis, 4, checkbox_on);
CFontz633_chr(drvthis, x, y, 4);
break;
case ICON_CHECKBOX_GRAY:
p->ccmode = custom;
CFontz633_set_char(drvthis, 5, icons[6]);
CFontz633_set_char(drvthis, 5, checkbox_gray);
CFontz633_chr(drvthis, x, y, 5);
break;
default:
+2 -1
View File
@@ -36,7 +36,8 @@ MODULE_EXPORT void CFontz633_hbar (Driver *drvthis, int x, int y, int len, int p
MODULE_EXPORT void CFontz633_num (Driver *drvthis, int x, int num);
MODULE_EXPORT int CFontz633_icon(Driver *drvthis, int x, int y, int icon);
MODULE_EXPORT void CFontz633_set_char (Driver *drvthis, int n, char *dat);
MODULE_EXPORT int CFontz633_iget_free_chars (Driver *drvthis);
MODULE_EXPORT void CFontz633_set_char (Driver *drvthis, int n, unsigned char *dat);
MODULE_EXPORT int CFontz633_get_contrast (Driver *drvthis);
MODULE_EXPORT void CFontz633_set_contrast (Driver *drvthis, int promille);
+2 -2
View File
@@ -26,7 +26,7 @@ IOWarrior_CFLAGS = @libusb_cflags@ $(AM_CFLAGS)
hd44780_CFLAGS = @libusb_cflags@ $(AM_CFLAGS)
CFontz_LDADD = libLCD.a
CFontz633_LDADD = libLCD.a
CFontz633_LDADD = libLCD.a libbignum.a
CFontzPacket_LDADD = libLCD.a libbignum.a
curses_LDADD = @LIBCURSES@
CwLnx_LDADD = libLCD.a
@@ -55,7 +55,7 @@ libbignum_a_SOURCES = adv_bignum.h adv_bignum.c
bayrad_SOURCES = lcd.h lcd_lib.h bayrad.h bayrad.c report.h
CFontz_SOURCES = lcd.h lcd_lib.h CFontz.c CFontz.h CFontz-charmap.h report.h
CFontz633_SOURCES = lcd.h lcd_lib.h CFontz633.c CFontz633.h CFontz-charmap.h CFontz633io.c CFontz633io.h report.h
CFontz633_SOURCES = lcd.h lcd_lib.h CFontz633.c CFontz633.h CFontz-charmap.h CFontz633io.c CFontz633io.h report.h adv_bignum.h
CFontzPacket_SOURCES = lcd.h lcd_lib.h CFontzPacket.c CFontzPacket.h CFontz-charmap.h CFontz633io.c CFontz633io.h report.h adv_bignum.h
curses_SOURCES = lcd.h curses_drv.h curses_drv.c report.h
CwLnx_SOURCES = lcd.h lcd_lib.h CwLnx.c CwLnx.h report.h