From 95a54cfbc171b15a8a5fca7dfc710f88ffafe176 Mon Sep 17 00:00:00 2001 From: marschap Date: Tue, 25 Apr 2006 20:13:28 +0000 Subject: [PATCH] convert bignum library; adapt serialVFD, CFontzPacket, IOWarrior --- ChangeLog | 2 + docs/API-v0.5.txt | 2 +- docs/lcdproc-dev/driver-api.docbook | 6 +- server/drivers/CFontzPacket.c | 213 +----- server/drivers/IOWarrior.c | 219 +----- server/drivers/Makefile.am | 10 +- server/drivers/adv_bignum.c | 1094 +++++++++++++++------------ server/drivers/adv_bignum.h | 29 +- server/drivers/lcd.h | 2 +- server/drivers/serialVFD.c | 198 ++--- server/drivers/serialVFD.h | 2 +- 11 files changed, 740 insertions(+), 1037 deletions(-) diff --git a/ChangeLog b/ChangeLog index 079c172..c9ec06e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,8 @@ v.0.5dev (ongoing development) + config file support in lcdproc client (thanks Andrew Foss) * install server & client config files in $(sysconfdir) + new client lcdvc: virtual console on LCD + * convert adv_bignum library to bitwise set_char() + * adapt IOWarrior, CFontzPacket, seriaVFD to modified bignum library v0.5.0 This version has split off from unstable-0.4.3. Includes major changes. diff --git a/docs/API-v0.5.txt b/docs/API-v0.5.txt index 11d0d2e..a28edb2 100644 --- a/docs/API-v0.5.txt +++ b/docs/API-v0.5.txt @@ -117,7 +117,7 @@ API_VERSION in the code. // - It is currently unclear how this system should work exactly // - The set_char function expects a simple block of data with 1 byte for each pixel-line. // (So that is 8 bytes for a 5x8 char) - void (*set_char) (Driver *drvthis, char ch, char *dat); + void (*set_char) (Driver *drvthis, char ch, unsigned char *dat); int (*get_free_chars) (Driver *drvthis); // get width & height of a character cell (in pixels) diff --git a/docs/lcdproc-dev/driver-api.docbook b/docs/lcdproc-dev/driver-api.docbook index d26d7b9..0c9d1fe 100644 --- a/docs/lcdproc-dev/driver-api.docbook +++ b/docs/lcdproc-dev/driver-api.docbook @@ -132,7 +132,7 @@ API_VERSION in the code. // - It is currently unclear how this system should work exactly // - The set_char function expects a simple block of data with 1 byte for each pixel-line. // (So that is 8 bytes for a 5x8 char) - void (*set_char) (Driver *drvthis, char ch, char *dat); + void (*set_char) (Driver *drvthis, char ch, unsigned char *dat); int (*get_free_chars) (Driver *drvthis); // get width / height of a character cell (in pixels) @@ -473,10 +473,12 @@ typedef struct my_driver_private { void (*set_char) Driver *drvthis char ch - char *dat + unsigned char *dat +The set_char function expects a simple block of data with 1 byte for each pixel-line. +(So that is 8 bytes for a 5x8 char) diff --git a/server/drivers/CFontzPacket.c b/server/drivers/CFontzPacket.c index c526315..ebf4cb8 100644 --- a/server/drivers/CFontzPacket.c +++ b/server/drivers/CFontzPacket.c @@ -75,30 +75,7 @@ #include "report.h" #include "lcd_lib.h" #include "CFontz-charmap.h" - -#define b_______ 0x00 -#define b_____X_ 0x03 -#define b_____XX 0x03 -#define b____X__ 0x04 -#define b____XX_ 0x06 -#define b____XXX 0x07 -#define b___X___ 0x08 -#define b___XX__ 0x09 -#define b___X_X_ 0x0A -#define b___XXX_ 0x0E -#define b___XXXX 0x0F -#define b__X____ 0x10 -#define b__X___X 0x11 -#define b__X_X_X 0x15 -#define b__X_XX_ 0x16 -#define b__XX___ 0x18 -#define b__XX_XX 0x1B -#define b__XXX__ 0x1C -#define b__XXX_X 0x1D -#define b__XXXX_ 0x1E -#define b__XXXXX 0x1F -#define b_XXX___ 0x38 -#define b_XXXXXX 0x3F +#include "adv_bignum.h" #define CFP_KEY_UP 1 @@ -943,200 +920,32 @@ CFontzPacket_hbar (Driver *drvthis, int x, int y, int len, int promille, int opt /* - * Inits big numbers + * Writes a big number. */ -static void -CFontzPacket_init_num(Driver *drvthis) +MODULE_EXPORT void +CFontzPacket_num(Driver *drvthis, int x, int num) { PrivateData *p = drvthis->private_data; +int do_init = 0; -unsigned char bignum_ccs[8][CELLHEIGHT] = { - [0] - { b_XXX___, - b_XXX___, - b_XXX___, - b_XXX___, - b_______, - b_______, - b_______, - b_______ }, - [1] - { b____XXX, - b____XXX, - b____XXX, - b____XXX, - b_XXX___, - b_XXX___, - b_XXX___, - b_XXX___ }, - [2] - { b_XXXXXX, - b_XXXXXX, - b_XXXXXX, - b_XXXXXX, - b_______, - b_______, - b_______, - b_______ }, - [3] - { b_______, - b_______, - b_______, - b_______, - b_XXX___, - b_XXX___, - b_XXX___, - b_XXX___ }, - [4] - { b_XXX___, - b_XXX___, - b_XXX___, - b_XXX___, - b____XXX, - b____XXX, - b____XXX, - b____XXX }, - [5] - { b_______, - b_______, - b_______, - b_______, - b_XXXXXX, - b_XXXXXX, - b_XXXXXX, - b_XXXXXX }, - [6] - { b_XXX___, - b_XXX___, - b_XXX___, - b_XXX___, - b_XXX___, - b_XXX___, - b_XXX___, - b_XXX___ }, - [7] - { b____XXX, - b____XXX, - b____XXX, - b____XXX, - b_______, - b_______, - b_______, - b_______ } -}; + if ((num < 0) || (num > 10)) + return; if (p->ccmode != bignum) { - int i; - if (p->ccmode != standard) { /* Not supported (yet) */ - report(RPT_WARNING, "%s: init_num: cannot combine two modes using user defined characters", + report(RPT_WARNING, "%s: num: cannot combine two modes using user defined characters", drvthis->name); return; } p->ccmode = bignum; - for (i = 0; i < NUM_CCs; i++) - CFontzPacket_set_char(drvthis, i, bignum_ccs[i]); + do_init = 1; } -} - -/* - * Writes a big number. - * Only works on 4-line displays - */ -MODULE_EXPORT void -CFontzPacket_num(Driver *drvthis, int x, int num) -{ -PrivateData *p = drvthis->private_data; - -/* each bignum is constructed in a 3 x 4 matrix and consists - * of only the 8 characters defined above as well as ' ' - * - * The following table defines the 11 big numbers '0'-'9', ':' - * and the custom base characters they consist of - */ -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: (only 1st column used) */ - { 32, 32, 32 }, - { 0, 32, 32 }, - { 0, 32, 32 }, - { 32, 32, 32 } } -}; - - if ((num < 0) || (num > 10)) - return; - - if (p->height >= 4) { - int y = (p->height - 2) / 2; /* center vertically */ - int x2, y2; - - CFontzPacket_init_num(drvthis); - - for (x2 = 0; x2 < 3; x2++) { - for (y2 = 0; y2 < 4; y2++) { - CFontzPacket_chr(drvthis, x+x2, y+y2, bignum_map[num][y2][x2]); - } - if (num == 10) - x2 = 2; /* = break, for colon only */ - } - } - else { - CFontzPacket_chr(drvthis, x, 1 + (p->height - 1) / 2, - (num == 10) ? ':' : (num + '0')); - } + // Lib_adv_bignum does everything needed to show the bignumbers. + lib_adv_bignum(drvthis, x, num, do_init, NUM_CCs); } diff --git a/server/drivers/IOWarrior.c b/server/drivers/IOWarrior.c index 27820f1..6d5a42a 100644 --- a/server/drivers/IOWarrior.c +++ b/server/drivers/IOWarrior.c @@ -44,27 +44,7 @@ #include "IOWarrior.h" #include "report.h" #include "lcd_lib.h" - -#define b_______ 0x00 -#define b_____X_ 0x03 -#define b_____XX 0x03 -#define b____X__ 0x04 -#define b____XX_ 0x06 -#define b___X___ 0x08 -#define b___XX__ 0x09 -#define b___X_X_ 0x0A -#define b___XXX_ 0x0E -#define b___XXXX 0x0F -#define b__X____ 0x10 -#define b__X___X 0x11 -#define b__X_X_X 0x15 -#define b__X_XX_ 0x16 -#define b__XX___ 0x18 -#define b__XX_XX 0x1B -#define b__XXX__ 0x1C -#define b__XXX_X 0x1D -#define b__XXXX_ 0x1E -#define b__XXXXX 0x1F +#include "adv_bignum.h" @@ -747,108 +727,6 @@ PrivateData *p = drvthis->private_data; } -/******************************************************************* - * API: Sets up for big numbers - */ -static void -IOWarrior_init_num(Driver *drvthis) -{ -PrivateData *p = drvthis->private_data; - -unsigned char bignum_ccs[8][CELLHEIGHT] = { - [0] - { b__XX___, - b__XX___, - b__XX___, - b__XX___, - b_______, - b_______, - b_______, - b_______ }, - [1] - { b_____XX, - b_____XX, - b_____XX, - b_____XX, - b__XX___, - b__XX___, - b__XX___, - b__XX___ }, - [2] - { b__XX_XX, - b__XX_XX, - b__XX_XX, - b__XX_XX, - b_______, - b_______, - b_______, - b_______ }, - [3] - { b_______, - b_______, - b_______, - b_______, - b__XX___, - b__XX___, - b__XX___, - b__XX___ }, - [4] - { b__XX___, - b__XX___, - b__XX___, - b__XX___, - b_____XX, - b_____XX, - b_____XX, - b_____XX }, - [5] - { b_______, - b_______, - b_______, - b_______, - b__XX_XX, - b__XX_XX, - b__XX_XX, - b__XX_XX }, - [6] - { b__XX___, - b__XX___, - b__XX___, - b__XX___, - b__XX___, - b__XX___, - b__XX___, - b__XX___ }, - [7] - { b_____XX, - b_____XX, - b_____XX, - b_____XX, - b_______, - b_______, - b_______, - b_______ } -}; - - if (p->ccmode != bignum) { - int i; - - if (p->ccmode != standard) { - /* Not supported (yet) */ - report(RPT_WARNING, "%s: init_num: cannot combine two modes using user defined characters", - drvthis->name); - return; - } - - p->ccmode = bignum; - - for (i = 0; i < NUM_CCs; i++) { - IOWarrior_set_char(drvthis, i, bignum_ccs[i]); - } - } -} - - /******************************************************************* * API: Writes a big number. */ @@ -856,91 +734,26 @@ MODULE_EXPORT void IOWarrior_num(Driver *drvthis, int x, int num) { PrivateData *p = drvthis->private_data; +int do_init = 0; -/* each bignum is constructed in a 3 x 4 matrix and consists - * of only the 8 characters defined above as well as ' ' - * - * The following table defines the 11 big numbers '0'-'9', ':' - * and the custom base characters they consist of - */ -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: (only 1st column used) */ - { 32, 32, 32 }, - { 0, 32, 32 }, - { 0, 32, 32 }, - { 32, 32, 32 } } -}; + if ((num < 0) || (num > 10)) + return; - if ((num < 0) || (num > 10)) - return; + 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; + } - IOWarrior_init_num(drvthis); + p->ccmode = bignum; - if (p->height >= 4) { - int y = (p->height - 2) / 2; /* center vertically */ - int x2, y2; + do_init = 1; + } - for (x2 = 0; x2 < 3; x2++) { - for (y2 = 0; y2 < 4; y2++) { - IOWarrior_chr(drvthis, x+x2, y+y2, bignum_map[num][y2][x2]); - } - if (num == 10) - x2 = 2; /* = break, for colon only */ - } - } - else - IOWarrior_chr(drvthis, x, 1 + (p->height - 1)/ 2, - (num == 10) ? ':' : (num + '0')); + // Lib_adv_bignum does everything needed to show the bignumbers. + lib_adv_bignum(drvthis, x, num, do_init, NUM_CCs); } diff --git a/server/drivers/Makefile.am b/server/drivers/Makefile.am index 85cfd4b..d6ea385 100644 --- a/server/drivers/Makefile.am +++ b/server/drivers/Makefile.am @@ -27,7 +27,7 @@ hd44780_CFLAGS = @libusb_cflags@ $(AM_CFLAGS) CFontz_LDADD = libLCD.a CFontz633_LDADD = libLCD.a -CFontzPacket_LDADD = libLCD.a +CFontzPacket_LDADD = libLCD.a libbignum.a curses_LDADD = @LIBCURSES@ CwLnx_LDADD = libLCD.a glcdlib_LDADD = libLCD.a @LIBGLCD@ @@ -35,7 +35,7 @@ hd44780_LDADD = libLCD.a @HD44780_DRIVERS@ @libusb_libs@ hd44780_DEPENDENCIES = @HD44780_DRIVERS@ icp_a106_LDADD = libLCD.a imon_LDADD = libLCD.a -IOWarrior_LDADD = @libusb_libs@ libLCD.a +IOWarrior_LDADD = @libusb_libs@ libLCD.a libbignum.a irman_LDADD = @LIBIRMAN@ lirc_LDADD = @LIBLIRC_CLIENT@ lcterm_LDADD = libLCD.a @@ -47,7 +47,7 @@ svga_LDADD = @LIBSVGA@ t6963_LDADD = libLCD.a tyan_LDADD = libLCD.a ula200_LDADD = libLCD.a @LIBFTDI@ -sli_LDADD = libLCD.a +sli_LDADD = libLCD.a xosd_LDADD = @LIBXOSD@ libLCD_a_SOURCES = lcd_lib.h lcd_lib.c @@ -56,7 +56,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 -CFontzPacket_SOURCES = lcd.h lcd_lib.h CFontzPacket.c CFontzPacket.h CFontz-charmap.h CFontz633io.c CFontz633io.h report.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 glcdlib_SOURCES = lcd.h lcd_lib.h glcdlib.h glcdlib.c report.h @@ -66,7 +66,7 @@ EXTRA_hd44780_SOURCES = hd44780-4bit.c hd44780-4bit.h hd44780-ext8bit.c hd44780- icp_a106_SOURCES = lcd.h lcd_lib.h icp_a106.c icp_a106.h report.h imon_SOURCES = lcd.h lcd_lib.h imon.h imon.c report.h -IOWarrior_SOURCES = lcd.h lcd_lib.h hd44780-charmap.h IOWarrior.c IOWarrior.h report.h +IOWarrior_SOURCES = lcd.h lcd_lib.h hd44780-charmap.h IOWarrior.c IOWarrior.h report.h adv_bignum.h irman_SOURCES = lcd.h irmanin.c irmanin.h report.h joy_SOURCES = lcd.h joy.c joy.h port.h report.h lb216_SOURCES = lcd.h lb216.c lb216.h report.h diff --git a/server/drivers/adv_bignum.c b/server/drivers/adv_bignum.c index 075a771..bf49321 100644 --- a/server/drivers/adv_bignum.c +++ b/server/drivers/adv_bignum.c @@ -84,7 +84,6 @@ - static void adv_bignum_num_2_0 (Driver *drvthis, int x, int num, int height, int do_init); static void adv_bignum_num_2_1 (Driver *drvthis, int x, int num, int height, int do_init); static void adv_bignum_num_2_2 (Driver *drvthis, int x, int num, int height, int do_init); @@ -93,6 +92,7 @@ static void adv_bignum_num_2_28 (Driver *drvthis, int x, int num, int height, in static void adv_bignum_num_4_0 (Driver *drvthis, int x, int num, int height, int do_init); static void adv_bignum_num_4_3 (Driver *drvthis, int x, int num, int height, int do_init); +static void adv_bignum_num_4_8 (Driver *drvthis, int x, int num, int height, int do_init); static void adv_bignum_write_num (Driver *drvthis, char write_num_map[][4][4], int x, int num, int height); @@ -102,35 +102,39 @@ static void adv_bignum_write_num (Driver *drvthis, char write_num_map[][4][4], i // The called bignumberfunction is depending on the display's height and the // number of customcharacters. void -lib_adv_bignum(Driver *drvthis, int x, int num, int height, int do_init, int customchars) +lib_adv_bignum(Driver *drvthis, int x, int num, int do_init, int customchars) { - +int height = drvthis->height(drvthis); + switch (height) { // Display heigth: case 2: // 2 lines case 3: // are 3 line displays really existing? - if (customchars == 0){// 2 lines and customchars = 0 + if (customchars == 0) { // 2 lines and customchars = 0 adv_bignum_num_2_0 (drvthis, x, num, height, do_init); } - else if (customchars ==1 ){// 2 lines and customchars = 1 + else if (customchars == 1) { // 2 lines and customchars = 1 adv_bignum_num_2_1 (drvthis, x, num, height, do_init); } - else if (customchars < 5){// 2 lines and customchars = 2 ... 4 + else if (customchars < 5) { // 2 lines and customchars = 2 ... 4 adv_bignum_num_2_2 (drvthis, x, num, height, do_init); } - else if (customchars < 28){ // 2 lines and customchars = 5 ... 27 + else if (customchars < 28) { // 2 lines and customchars = 5 ... 27 adv_bignum_num_2_5 (drvthis, x, num, height, do_init); } - else { // 2 lines and customchars >= 28 + else { // 2 lines and customchars >= 28 adv_bignum_num_2_28 (drvthis, x, num, height, do_init); } break; case 4: // 4 lines - if (customchars < 3){// 4 lines and customchars < 3 + if (customchars == 0) { // 4 lines and customchars < 3 adv_bignum_num_4_0 (drvthis, x, num, height, do_init); } - else { // 4 lines and customchars >= 3 + else if (customchars < 8) { // 4 lines and customchars < 8 adv_bignum_num_4_3 (drvthis, x, num, height, do_init); } + else { // 4 lines and customchars >= 8 + adv_bignum_num_4_8 (drvthis, x, num, height, do_init); + } break; default: return; @@ -139,18 +143,19 @@ lib_adv_bignum(Driver *drvthis, int x, int num, int height, int do_init, int cus } ///////////////////////////////////////////////////////////////////////////////////////////// -// This function writes the selected type of bignumber by calling the drivers_char function. -// It is called by displaydepending bignumber function to write the numbers. +// This function writes the selected type of bignumber by calling the driver's chr function. +// It is called by display-depending bignumber functions to write the numbers. static void adv_bignum_write_num (Driver *drvthis, char write_num_map[][4][4], int x, int num, int height) { int y, dx; - for (y = 0; y < height; y++) - { - if (num == 10) // ":" is only 1 character wide. - drvthis->chr (drvthis, x, y+1, write_num_map[num][y][0]); - else - for (dx = 0; dx <3; dx++) - drvthis->chr (drvthis, x + dx, y+1, write_num_map[num][y][dx]); + + for (y = 0; y < height; y++) { + if (num == 10) // ":" is only 1 character wide. + drvthis->chr(drvthis, x, y+1, write_num_map[num][y][0]); + else { + for (dx = 0; dx < 3; dx++) + drvthis->chr(drvthis, x + dx, y+1, write_num_map[num][y][dx]); + } } @@ -294,21 +299,22 @@ static void adv_bignum_num_2_1 (Driver *drvthis, int x, int num, int height, int {" "}, {" "} } }; // Defines the character placing inside the bignumber. - if (do_init) // Set customcharacters if needed. - { - static char bignum[1][5 * 8] = { // stored customcharacter - { - 1, 1, 1, 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, - }}; - drvthis->set_char (drvthis, 0, &bignum[0][0]); // put the customcharacter into the display - } + + if (do_init) { // Set customcharacters if needed. + static unsigned char bignum[1][8] = { // stored customcharacter + [0] { + b__XXXXX, + b_______, + b_______, + b_______, + b_______, + b_______, + b_______, + b_______, } + }; + drvthis->set_char (drvthis, 0, bignum[0]); // put the customcharacter into the display + } + adv_bignum_write_num (drvthis, num_map, x, num, height); // write the number } @@ -376,34 +382,34 @@ static void adv_bignum_num_2_2 (Driver *drvthis, int x, int num, int height, int " ", " " } }; // Defines the character placing inside the bignumber. - if (do_init) // Set customcharacters if needed. - { - static char bignum[2][5 * 8] = { // stored customcharacters - { - 1, 1, 1, 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, - }, - { - 1, 1, 1, 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, 1, 1, 1, - 1, 1, 1, 1, 1, - }}; + + if (do_init) { // Set customcharacters if needed. + static unsigned char bignum[2][8] = { // stored customcharacters + [0] { + b__XXXXX, + b_______, + b_______, + b_______, + b_______, + b_______, + b_______, + b_______, }, + [1] { + b__XXXXX, + b_______, + b_______, + b_______, + b_______, + b_______, + b__XXXXX, + b__XXXXX, } + }; int i; - for (i = 0; i <= 2 ; i++) { // put the customcharacters into the display - drvthis->set_char (drvthis, i, &bignum[i][0]); - } + for (i = 0; i < 2; i++) { // put the customcharacters into the display + drvthis->set_char (drvthis, i, bignum[i]); } + } + adv_bignum_write_num (drvthis, num_map, x, num, height); // write the number } @@ -458,65 +464,63 @@ static void adv_bignum_num_2_5 (Driver *drvthis, int x, int num, int height, int {'.'}, {" "}, {" "}}}; // Defines the character placing inside the bignumber. - if (do_init) // Set customcharacters if needed. - { - static char bignum[5][5 * 8] = { // stored customcharacters - { - 1, 1, 1, 1, 1, - 1, 1, 1, 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, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - }, - { - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - }, - { - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - }, - { - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - }}; + + if (do_init) { // Set customcharacters if needed. + static unsigned char bignum[5][8] = { // stored customcharacters + [0] { + b__XXXXX, + b__XXXXX, + b_______, + b_______, + b_______, + b_______, + b_______, + b_______, }, + [1] { + b_______, + b_______, + b_______, + b_______, + b_______, + b__XXXXX, + b__XXXXX, + b__XXXXX, }, + [2] { + b__XXX__, + b__XXX__, + b__XXX__, + b__XXX__, + b__XXX__, + b__XXX__, + b__XXX__, + b__XXX__, }, + [3] { + b____XXX, + b____XXX, + b____XXX, + b____XXX, + b____XXX, + b____XXX, + b____XXX, + b____XXX, }, + [4] { + b__XXXXX, + b__XXXXX, + b_______, + b_______, + b_______, + b__XXXXX, + b__XXXXX, + b__XXXXX, } + }; int i; - for (i = 0; i <= 5 ; i++) { // put the customcharacters into the display - drvthis->set_char (drvthis, i, &bignum[i][0]); - } + + for (i = 0; i < 5 ; i++) { // put the customcharacters into the display + drvthis->set_char (drvthis, i, bignum[i]); } - adv_bignum_write_num (drvthis, num_map, x, num, height); // write the number + } + + adv_bignum_write_num (drvthis, num_map, x, num, height); // write the number } @@ -571,296 +575,268 @@ static void adv_bignum_num_2_28 (Driver *drvthis, int x, int num, int height, in {" "}, {" "}}}; // Defines the character placing inside the bignumber. - if (do_init) // Set customcharacters if needed. - { - - static char bignum[28][5 * 8] = { // stored customcharacters - { //0 - 0, 0, 0, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 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 - 0, 0, 0, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - }, - { //2 - 1, 1, 0, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0 - }, - { //3 - 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, - 0, 0, 1, 1, 1, - 0, 0, 0, 1, 1, - 0, 0, 0, 1, 1, - }, - { //4 - 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, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - }, - { //5 - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 0, 0, 0, - 1, 0, 0, 0, 0, - }, - { //6 - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 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, - }, - { //7 - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - }, - { //8 - 0, 0, 1, 1, 1, - 0, 1, 1, 1, 1, - 1, 1, 1, 1, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - }, - { //9 - 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - }, - { //10 - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - }, - { //11 - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - }, - { //12 - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 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, - }, - { //13 - 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - }, - { //14 - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 0, 1, 1, - 0, 0, 0, 1, 1, - }, - { //15 - 0, 0, 0, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - }, - { //16 - 1, 1, 0, 0, 0, - 1, 1, 1, 0, 0, - 1, 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, - }, - { //17 - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 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, - }, - { //18 - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, - 0, 0, 0, 1, 1, - 0, 0, 0, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - }, - { //19 - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 0, 0, 0, - 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - }, - { //20 - 0, 1, 1, 1, 0, - 0, 1, 1, 1, 0, - 1, 1, 1, 1, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - }, - { //21 - 0, 0, 0, 0, 1, - 0, 0, 0, 1, 1, - 0, 0, 1, 1, 1, - 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 0, 1, - 1, 1, 0, 0, 1, - 1, 1, 0, 0, 1, - }, - { //22 - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 0, 0, 0, 0, 1, - 0, 0, 0, 0, 1, - 0, 0, 0, 0, 1, - 0, 0, 0, 0, 1, - 0, 0, 0, 0, 1, - }, - { //23 - 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, - }, - { //24 - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, - }, - { //25 - 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, 0, 0, 0, 1, - }, - { //26 - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - 0, 0, 1, 1, 1, - }, - { //27 - 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, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - } + if (do_init) { // Set customcharacters if needed. + static unsigned char bignum[28][8] = { // stored customcharacters + [0] { //0 + b_____XX, + b____XXX, + b____XXX, + b_______, + b_______, + b_______, + b_______, + b_______, }, + [1] { //1 + b_____XX, + b____XXX, + b____XXX, + b____XXX, + b_______, + b_______, + b_______, + b_______, }, + [2] { //2 + b__XX___, + b__XXX__, + b__XXX__, + b__XXX__, + b__XXX__, + b__XXX__, + b__XXX__, + b__XXX__, }, + [3] { //3 + b_______, + b_______, + b_______, + b_______, + b____XXX, + b____XXX, + b_____XX, + b_____XX, }, + [4] { //4 + b_______, + b_______, + b_______, + b_______, + b__XXXXX, + b__XXXXX, + b__XXXXX, + b__XXXXX, }, + [5] { //5 + b__XXX__, + b__XXX__, + b__XXX__, + b__XXX__, + b__XXX__, + b__XXX__, + b__XX___, + b__X____, }, + [6] { //6 + b__XXXXX, + b__XXXXX, + b__XXXXX, + b_______, + b_______, + b_______, + b_______, + b_______, }, + [7] { //7 + b_______, + b_______, + b_______, + b______X, + b____XXX, + b____XXX, + b____XXX, + b____XXX, }, + [8] { //8 + b____XXX, + b___XXXX, + b__XXXX_, + b__XXX__, + b__XXXXX, + b__XXXXX, + b__XXXXX, + b__XXXXX, }, + [9] { //9 + b__X____, + b_______, + b_______, + b_______, + b__XXX__, + b__XXX__, + b__XXX__, + b__XXX__, }, + [10] { //10 + b____XXX, + b____XXX, + b____XXX, + b____XXX, + b____XXX, + b____XXX, + b____XXX, + b____XXX, }, + [11] { //11 + b__XXXXX, + b__XXXXX, + b__XXXXX, + b_______, + b_______, + b_______, + b__XXXXX, + b__XXXXX, }, + [12] { //12 + b__XXX__, + b__XXX__, + b__XXX__, + b_______, + b_______, + b_______, + b_______, + b_______, }, + [13] { //13 + b__XXXXX, + b_______, + b_______, + b_______, + b__XXXXX, + b__XXXXX, + b__XXXXX, + b__XXXXX, }, + [14] { //14 + b____XXX, + b____XXX, + b____XXX, + b____XXX, + b____XXX, + b____XXX, + b_____XX, + b_____XX, }, + [15] { //15 + b_____XX, + b____XXX, + b____XXX, + b____XXX, + b____XXX, + b____XXX, + b____XXX, + b____XXX, }, + [16] { //16 + b__XX___, + b__XXX__, + b__XXX__, + b_______, + b_______, + b_______, + b_______, + b_______, }, + [17] { //17 + b____XXX, + b____XXX, + b____XXX, + b_______, + b_______, + b_______, + b_______, + b_______, }, + [18] { //18 + b__XXXXX, + b__XXXXX, + b__XXXXX, + b_______, + b_____XX, + b_____XX, + b____XXX, + b____XXX, }, + [19] { //19 + b__XXX__, + b__XXX__, + b__XXX__, + b__XXX__, + b__XX___, + b__X____, + b_______, + b_______, }, + [20] { //20 + b___XXX_, + b___XXX_, + b__XXXX_, + b__XXX__, + b__XXX__, + b__XXX__, + b__XXX__, + b__XXX__, }, + [21] { //21 + b______X, + b_____XX, + b____XXX, + b___XXXX, + b__XXXXX, + b__XXX_X, + b__XX__X, + b__XX__X, }, + [22] { //22 + b__XXXXX, + b__XXXXX, + b__XXXXX, + b______X, + b______X, + b______X, + b______X, + b______X, }, + [23] { //23 + b__X____, + b__X____, + b__X____, + b__X____, + b__X____, + b__X____, + b__X____, + b__X____, }, + [24] { //24 + b__XXX__, + b__XXX__, + b__XXX__, + b__X____, + b__X____, + b__X____, + b__X____, + b__X____, }, + [25] { //25 + b_______, + b_______, + b_______, + b_______, + b_______, + b_______, + b______X, + b______X, }, + [26] { //26 + b____XXX, + b____XXX, + b___XXXX, + b__XXXXX, + b____XXX, + b____XXX, + b____XXX, + b____XXX, }, + [27] { //27 + b_______, + b_______, + b_______, + b____XX_, + b____XX_, + b_______, + b_______, + b_______, } }; int i; - for (i = 0; i <= 28 ; i++) { // put the customcharacters into the display - drvthis->set_char (drvthis, i, &bignum[i][0]); - } + + for (i = 0; i < 28 ; i++) { // put the customcharacters into the display + drvthis->set_char (drvthis, i, bignum[i]); } + } + adv_bignum_write_num (drvthis, num_map, x, num, height); // write the number } @@ -931,100 +907,246 @@ static char num_map[][4][4] = { " " } }; // Defines the character placing inside the bignumber. - adv_bignum_write_num (drvthis, num_map, x, num, height); // write the number + adv_bignum_write_num(drvthis, num_map, x, num, height); // write the number } ///////////////////////////////////////////////////////////////////////////////////////////// -// This function is usable for a 4 line display with 5 or more custom characters. +// This function is usable for a 4 line display with 3 or more custom characters. // (nice bignumbers) static void adv_bignum_num_4_3 (Driver *drvthis, int x, int num, int height, int do_init) { static char num_map[][4][4] = {{{3 ,1 ,3}, /*0*/ - {3 ,' ' ,3}, - {3 ,' ' ,3}, - {3 ,2 ,3}}, - {{' ' ,' ' ,3},/*1*/ - {' ' ,' ' ,3}, - {' ' ,' ' ,3}, - {' ' ,' ' ,3}}, - {{' ' ,1 ,3},/*2*/ - {' ' ,2 ,3}, - {3 ,' ' ,3}, - {3 ,2 ,3}}, - {{' ' ,1 ,3},/*3*/ - {' ' ,' ' ,3}, - {' ' ,2 ,3}, - {' ' ,' ' ,3}}, - {{3 ,2 ,3},/*4*/ - {3 ,2 ,3}, - {' ' ,' ' ,3}, - {' ' ,' ' ,3}}, - {{3 ,1 ,3},/*5*/ - {3 ,2 ,3}, - {' ' ,' ' ,3}, - {' ' ,2 ,3}}, - {{3 ,1 ,3},/*6*/ - {3 ,' ' ,3}, - {3 ,1 ,3}, - {3 ,2 ,3}}, - {{' ' ,1 ,3},/*7*/ - {' ' ,' ' ,3}, - {' ' ,' ' ,3}, - {' ' ,' ' ,3}}, - {{3 ,1 ,3},/*8*/ - {3 ,2 ,3}, - {3 ,' ' ,3}, - {3 ,2 ,3}}, - {{3 ,1 ,3},/*9*/ - {3 ,2 ,3}, - {' ' ,' ' ,3}, - {' ' ,2 ,3}}, - {{" "},/*:*/ - {'.'}, - {'.'}, - {" "}}}; // Defines the character placing inside the bignumber. -if (do_init) // Set customcharacters if needed. - { - static char bignum[5][5 * 8] = { // stored customcharacters - { - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 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, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - }, - { - 0, 1, 1, 1, 0, - 0, 1, 1, 1, 0, - 0, 1, 1, 1, 0, - 0, 1, 1, 1, 0, - 0, 1, 1, 1, 0, - 0, 1, 1, 1, 0, - 0, 1, 1, 1, 0, - 0, 1, 1, 1, 0, - } - }; + {3 ,' ' ,3}, + {3 ,' ' ,3}, + {3 ,2 ,3}}, + {{' ' ,' ' ,3},/*1*/ + {' ' ,' ' ,3}, + {' ' ,' ' ,3}, + {' ' ,' ' ,3}}, + {{' ' ,1 ,3},/*2*/ + {' ' ,2 ,3}, + {3 ,' ' ,' '}, + {3 ,2 ,' '}}, + {{' ' ,1 ,3},/*3*/ + {' ' ,2 ,3}, + {' ' ,' ' ,3}, + {' ' ,2 ,3}}, + {{3 ,' ' ,3},/*4*/ + {3 ,2 ,3}, + {' ' ,' ' ,3}, + {' ' ,' ' ,3}}, + {{3 ,1 ,' '},/*5*/ + {3 ,2 ,' '}, + {' ' ,' ' ,3}, + {' ' ,2 ,3}}, + {{3 ,1 ,' '},/*6*/ + {3 ,2 ,' '}, + {3 ,' ' ,3}, + {3 ,2 ,3}}, + {{' ' ,1 ,3},/*7*/ + {' ' ,' ' ,3}, + {' ' ,' ' ,3}, + {' ' ,' ' ,3}}, + {{3 ,1 ,3},/*8*/ + {3 ,2 ,3}, + {3 ,' ' ,3}, + {3 ,2 ,3}}, + {{3 ,1 ,3},/*9*/ + {3 ,2 ,3}, + {' ' ,' ' ,3}, + {' ' ,2 ,3}}, + {{" "},/*:*/ + {'.'}, + {'.'}, + {" "}}}; // Defines the character placing inside the bignumber. + + if (do_init) { // Set customcharacters if needed. + static unsigned char bignum[3][8] = { // stored customcharacters + [0] { + b__XXXXX, + b__XXXXX, + b__XXXXX, + b_______, + b_______, + b_______, + b_______, + b_______, }, + [1] { + b_______, + b_______, + b_______, + b_______, + b__XXXXX, + b__XXXXX, + b__XXXXX, + b__XXXXX, }, + [2] { + b___XXX_, + b___XXX_, + b___XXX_, + b___XXX_, + b___XXX_, + b___XXX_, + b___XXX_, + b___XXX_, } + }; int i; - for (i = 0; i <= 3 ; i++) { // put the customcharacters into the display - drvthis->set_char (drvthis, i, &bignum[i][0]); + + for (i = 0; i < 3; i++) { // put the customcharacters into the display + drvthis->set_char(drvthis, i+1, bignum[i]); + } } + + adv_bignum_write_num(drvthis, num_map, x, num, height); // write the number } - adv_bignum_write_num (drvthis, num_map, x, num, height); // write the number +///////////////////////////////////////////////////////////////////////////////////////////// +// This function is usable for a 4 line display with 8 or more custom characters. +// (nice bignumbers) +static void adv_bignum_num_4_8 (Driver *drvthis, int x, int num, int height, int do_init) +{ +static char num_map[][4][4] = { + { /* 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: (only 1st column used) */ + { 32, 32, 32 }, + { 0, 32, 32 }, + { 0, 32, 32 }, + { 32, 32, 32 } } +}; // Defines the character placing inside the bignumber. + + if (do_init) { // Set customcharacters if needed. + static unsigned char bignum[8][8] = { // stored customcharacters + [0] { + b__XX___, + b__XX___, + b__XX___, + b__XX___, + b_______, + b_______, + b_______, + b_______, }, + [1] { + b_____XX, + b_____XX, + b_____XX, + b_____XX, + b__XX___, + b__XX___, + b__XX___, + b__XX___, }, + [2] { + b__XX_XX, + b__XX_XX, + b__XX_XX, + b__XX_XX, + b_______, + b_______, + b_______, + b_______, }, + [3] { + b_______, + b_______, + b_______, + b_______, + b__XX___, + b__XX___, + b__XX___, + b__XX___, }, + [4] { + b__XX___, + b__XX___, + b__XX___, + b__XX___, + b_____XX, + b_____XX, + b_____XX, + b_____XX, }, + [5] { + b_______, + b_______, + b_______, + b_______, + b__XX_XX, + b__XX_XX, + b__XX_XX, + b__XX_XX, }, + [6] { + b__XX___, + b__XX___, + b__XX___, + b__XX___, + b__XX___, + b__XX___, + b__XX___, + b__XX___, }, + [7] { + b_____XX, + b_____XX, + b_____XX, + b_____XX, + b_______, + b_______, + b_______, + b_______, } + }; + int i; + + for (i = 0; i < 8 ; i++) { // put the customcharacters into the display + drvthis->set_char(drvthis, i, bignum[i]); + } + } + + adv_bignum_write_num(drvthis, num_map, x, num, height); // write the number } diff --git a/server/drivers/adv_bignum.h b/server/drivers/adv_bignum.h index 107a8be..b860bb8 100644 --- a/server/drivers/adv_bignum.h +++ b/server/drivers/adv_bignum.h @@ -27,7 +27,34 @@ #include "lcd.h" -void lib_adv_bignum (Driver *drvthis, int x, int num, int height , int do_init, int customchars); +#define b_______ 0x00 +#define b______X 0x01 +#define b_____X_ 0x03 +#define b_____XX 0x03 +#define b____X__ 0x04 +#define b____XX_ 0x06 +#define b____XXX 0x07 +#define b___X___ 0x08 +#define b___XX__ 0x09 +#define b___X_X_ 0x0A +#define b___XXX_ 0x0E +#define b___XXXX 0x0F +#define b__X____ 0x10 +#define b__X___X 0x11 +#define b__X_X_X 0x15 +#define b__X_XX_ 0x16 +#define b__XX___ 0x18 +#define b__XX__X 0x19 +#define b__XX_XX 0x1B +#define b__XXX__ 0x1C +#define b__XXX_X 0x1D +#define b__XXXX_ 0x1E +#define b__XXXXX 0x1F +#define b_XXX___ 0x38 +#define b_XXXXXX 0x3F + + +void lib_adv_bignum (Driver *drvthis, int x, int num, int do_init, int customchars); diff --git a/server/drivers/lcd.h b/server/drivers/lcd.h index ff81d78..eea33d3 100644 --- a/server/drivers/lcd.h +++ b/server/drivers/lcd.h @@ -150,7 +150,7 @@ typedef struct lcd_logical_driver { void (*cursor) (struct lcd_logical_driver* drvthis, int x, int y, int type); /* user-defined character functions, are those still supported ? */ - void (*set_char) (struct lcd_logical_driver* drvthis, int n, char *dat); + void (*set_char) (struct lcd_logical_driver* drvthis, int n, unsigned char *dat); int (*get_free_chars) (struct lcd_logical_driver* drvthis); int (*cellwidth) (struct lcd_logical_driver* drvthis); int (*cellheight) (struct lcd_logical_driver* drvthis); diff --git a/server/drivers/serialVFD.c b/server/drivers/serialVFD.c index efc2190..e461a91 100644 --- a/server/drivers/serialVFD.c +++ b/server/drivers/serialVFD.c @@ -426,13 +426,14 @@ serialVFD_init (Driver *drvthis) p->charmap[tmp] = charmap_0[tmp]; //{bytes to send, icon bit mapped to bit 0, icon bit mapped to bit 1, ...} - const int usr_chr_dot_assignment_0[57]={7, 1, 2, 3, 4, 5, 0, 0, 0, - 6, 7, 8, 9,10, 0, 0, 0, + const int usr_chr_dot_assignment_0[57]={ 7, + 1, 2, 3, 4, 5, 0, 0, 0, + 6, 7, 8, 9,10, 0, 0, 0, 11,12,13,14,15, 0, 0, 0, 16,17,18,19,20, 0, 0, 0, 21,22,23,24,25, 0, 0, 0, 26,27,28,29,30, 0, 0, 0, - 31,32,33,34,35, 0, 0, 0}; + 31,32,33,34,35, 0, 0, 0 }; for (tmp = 0; tmp < 57 ;tmp++) p->usr_chr_dot_assignment[tmp] = usr_chr_dot_assignment_0[tmp]; @@ -497,8 +498,9 @@ serialVFD_init (Driver *drvthis) //{bytes to send, icon bit mapped to bit 0, icon bit mapped to bit 1, ...} - const int usr_chr_dot_assignment_1[57]={7, 1, 2, 3, 4, 5, 0, 0, 0, - 6, 7, 8, 9,10, 0, 0, 0, + const int usr_chr_dot_assignment_1[57]={ 7, + 1, 2, 3, 4, 5, 0, 0, 0, + 6, 7, 8, 9,10, 0, 0, 0, 11,12,13,14,15, 0, 0, 0, 16,17,18,19,20, 0, 0, 0, 21,22,23,24,25, 0, 0, 0, @@ -546,12 +548,13 @@ serialVFD_init (Driver *drvthis) p->charmap[tmp]=tmp; //{bytes to send, icon bit mapped to bit 0, icon bit mapped to bit 1, ...} - const int usr_chr_dot_assignment_2[57]={5, 1, 2, 3, 4, 5, 6, 7, 8, + const int usr_chr_dot_assignment_2[57]={ 5, + 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16, 17,18,19,20,21,22,23,24, 25,26,27,28,29,30,31,32, 33,34,35, 0, 0, 0, 0, 0}; - for (tmp=0;tmp < 57 ;tmp++) + for (tmp=0; tmp < 57; tmp++) p->usr_chr_dot_assignment[tmp]=usr_chr_dot_assignment_2[tmp]; //Where to place the usercharacters (0..30) in the asciicode. @@ -615,11 +618,12 @@ serialVFD_init (Driver *drvthis) p->charmap[tmp] = charmap_3[tmp]; //{bytes to send, icon bit mapped to bit 0, icon bit mapped to bit 1, ...} - const int usr_chr_dot_assignment_3[57]={5, 8, 7, 6, 5, 4, 3, 2, 1, + const int usr_chr_dot_assignment_3[57]={ 5, + 8, 7, 6, 5, 4, 3, 2, 1, 16,15,14,13,12,11,10, 9, 24,23,22,21,20,19,18,17, 32,31,30,29,28,27,26,25, - 0, 0, 0, 0, 0,35,34,33}; + 0, 0, 0, 0, 0,35,34,33}; for (tmp=0;tmp < 57 ;tmp++) p->usr_chr_dot_assignment[tmp]=usr_chr_dot_assignment_3[tmp]; @@ -710,7 +714,7 @@ serialVFD_hbar (Driver *drvthis, int x, int y, int len, int promille, int option // The input is just an array of characters... // MODULE_EXPORT void -serialVFD_set_char (Driver *drvthis, int n, char *dat) +serialVFD_set_char (Driver *drvthis, int n, unsigned char *dat) { //set char in p->custom_char PrivateData *p = drvthis->private_data; unsigned int byte, bit; @@ -724,8 +728,14 @@ serialVFD_set_char (Driver *drvthis, int n, char *dat) int letter = 0; for (bit = 0; bit < 8; bit++) { - if ((int) p->usr_chr_dot_assignment[bit+8*byte+1] != 0) - letter |= (dat[(int)p->usr_chr_dot_assignment[bit+8*byte+1]-1] << bit); + int pos = (int) p->usr_chr_dot_assignment[bit+8*byte+1]; + + if (pos > 0) { + int posbyte = (pos-1) / 5; + int posbit = 4 - ((pos-1) % 5); + + letter |= ((dat[posbyte] >> posbit) & 1) << bit;; + } } p->custom_char[n][byte] = letter; } @@ -848,7 +858,7 @@ serialVFD_num( Driver * drvthis, int x, int num ) p->ccmode = CCMODE_BIGNUM; // Switch customcharactermode to bignum. } // Lib_adv_bignum does everything needed to show the bignumbers. - lib_adv_bignum(drvthis, x, num, p->height, do_init, p->customchars); + lib_adv_bignum(drvthis, x, num, do_init, p->customchars); } @@ -860,27 +870,25 @@ MODULE_EXPORT int serialVFD_icon (Driver *drvthis, int x, int y, int icon) { PrivateData *p = drvthis->private_data; - char icons[2][5 * 7] = { - { - 1, 1, 1, 1, 1, // Empty Heart - 1, 0, 1, 0, 1, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, - 1, 1, 0, 1, 1, - }, + 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 }; - { - 1, 1, 1, 1, 1, // Filled Heart - 1, 0, 1, 0, 1, - 0, 1, 0, 1, 0, - 0, 1, 1, 1, 0, - 0, 1, 1, 1, 0, - 1, 0, 1, 0, 1, - 1, 1, 0, 1, 1, - }, - }; // Yes we know, this is a VERY BAD implementation :-) switch (icon) { case ICON_BLOCK_FILLED: @@ -888,12 +896,12 @@ serialVFD_icon (Driver *drvthis, int x, int y, int icon) break; case ICON_HEART_FILLED: p->ccmode = CCMODE_STANDARD; - serialVFD_set_char(drvthis, 0, icons[1]); + serialVFD_set_char(drvthis, 0, heart_filled); serialVFD_chr(drvthis, x, y, 0); break; case ICON_HEART_OPEN: p->ccmode = CCMODE_STANDARD; - serialVFD_set_char(drvthis, 0, icons[0]); + serialVFD_set_char(drvthis, 0, heart_open); serialVFD_chr(drvthis, x, y, 0); break; default: @@ -911,69 +919,20 @@ static void serialVFD_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, - 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, - 1, 1, 1, 1, 1, - 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, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - }; - char d[] = { - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - }; - char e[] = { - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 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, - }; - char f[] = { - 0, 0, 0, 0, 0, - 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 != CCMODE_VBAR) { + unsigned char vBar[p->cellheight]; + int i; + p->ccmode = CCMODE_VBAR; - serialVFD_set_char(drvthis, 1, a); - serialVFD_set_char(drvthis, 2, b); - serialVFD_set_char(drvthis, 3, c); - serialVFD_set_char(drvthis, 4, d); - serialVFD_set_char(drvthis, 5, e); - serialVFD_set_char(drvthis, 6, f); + + memset(vBar, 0x00, sizeof(vBar)); + + for (i = 1; i < p->cellheight; i++) { + // add pixel line per pixel line ... + vBar[p->cellheight - i] = 0xFF; + serialVFD_set_char(drvthis, i, vBar); + } } } @@ -984,49 +943,18 @@ static void serialVFD_init_hbar (Driver *drvthis) { PrivateData *p = drvthis->private_data; - char a[] = { - 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, - }; - char b[] = { - 1, 1, 0, 0, 0, - 1, 1, 0, 0, 0, - 1, 1, 0, 0, 0, - 1, 1, 0, 0, 0, - 1, 1, 0, 0, 0, - 1, 1, 0, 0, 0, - 1, 1, 0, 0, 0, - }; - char c[] = { - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, - }; - char d[] = { - 1, 1, 1, 1, 0, - 1, 1, 1, 1, 0, - 1, 1, 1, 1, 0, - 1, 1, 1, 1, 0, - 1, 1, 1, 1, 0, - 1, 1, 1, 1, 0, - 1, 1, 1, 1, 0, - }; if (p->ccmode != CCMODE_HBAR) { + unsigned char hBar[p->cellheight]; + int i; + p->ccmode = CCMODE_HBAR; - serialVFD_set_char(drvthis, 1, a); - serialVFD_set_char(drvthis, 2, b); - serialVFD_set_char(drvthis, 3, c); - serialVFD_set_char(drvthis, 4, d); + + for (i = 1; i < p->cellwidth; i++) { + // fill pixel columns from left to right. + memset(hBar, 0xFF & ~((1 << (p->cellwidth - i)) - 1), sizeof(hBar)); + serialVFD_set_char(drvthis, i, hBar); + } } } diff --git a/server/drivers/serialVFD.h b/server/drivers/serialVFD.h index 264439d..3eef2e6 100644 --- a/server/drivers/serialVFD.h +++ b/server/drivers/serialVFD.h @@ -59,7 +59,7 @@ MODULE_EXPORT void serialVFD_vbar (Driver *drvthis, int x, int y, int len, int p MODULE_EXPORT void serialVFD_hbar (Driver *drvthis, int x, int y, int len, int promille, int options); MODULE_EXPORT int serialVFD_icon(Driver *drvthis, int x, int y, int icon); -MODULE_EXPORT void serialVFD_set_char (Driver *drvthis, int n, char *dat); +MODULE_EXPORT void serialVFD_set_char (Driver *drvthis, int n, unsigned char *dat); MODULE_EXPORT int serialVFD_get_brightness (Driver *drvthis, int state); MODULE_EXPORT void serialVFD_set_brightness (Driver *drvthis, int state, int promille);