refactor adv_bignum:
* support display heights > 4 (treated like height = 4); * determine number of user-defineable chars using get_free_chars(); * allow custom chars starting at a character position (offset) != 0 * update and extend documentation
This commit is contained in:
@@ -7,6 +7,7 @@ Key:
|
||||
|
||||
v.0.5dev (ongoing development)
|
||||
* fix switching on/off the Load screen in lcdproc client using the menu
|
||||
* refactor adv_bignum: support height > 4, loadable chars with offset
|
||||
|
||||
v.0.5.1
|
||||
+ config file support in lcdproc client (Andrew Foss)
|
||||
|
||||
@@ -161,7 +161,7 @@ port_deny_multiple(0x378,3);
|
||||
<title>adv_bignum.h : Write Big-Numbers</title>
|
||||
|
||||
<para>
|
||||
<filename>adv_bignum.h</filename> is the headerfile for <filename>lib_bignum.a</filename>
|
||||
<filename>adv_bignum.h</filename> is the headerfile for <filename>libbignum.a</filename>
|
||||
(made from <filename>adv_bignum.c</filename>) which contains everything needed to show big-numbers,
|
||||
including the fonts for the different displays.
|
||||
(All files are located in the <filename>server/drivers/</filename> directory.) </para>
|
||||
@@ -172,27 +172,79 @@ port_deny_multiple(0x378,3);
|
||||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem><para>
|
||||
The display's <replaceable>cellwidth</replaceable> has to be <literal>5</literal>
|
||||
(<literal>6</literal> works also in some cases) and the <replaceable>cellheight</replaceable>
|
||||
<literal>7</literal> or <literal>8</literal>.
|
||||
</para></listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
The following functions have to be implemented by the driver:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<function>chr()</function>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<function>set_char()</function> (only if the display has custom-characters)
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><function>height()</function></term>
|
||||
<listitem>
|
||||
<para>
|
||||
to determine the display's height and thus the maximal height of the
|
||||
big numbers to be displayed.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><function>get_free_chars()</function></term>
|
||||
<listitem>
|
||||
<para>
|
||||
to determine the number of user-defineable characters that can be
|
||||
used in the generation of big numbers.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><function>set_char()</function></term>
|
||||
<listitem>
|
||||
<para>
|
||||
to define a character necessary to write a big number.
|
||||
Of course this is only necessary if there really are user-definieable
|
||||
characters, i.e. only if <function>get_free_chars()</function> returns
|
||||
a value greater <literal>0</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><function>chr()</function></term>
|
||||
<listitem>
|
||||
<para>
|
||||
to actually write the characters the big numbers consist of.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
The display's <replaceable>cellwidth</replaceable> has to be <literal>5</literal>
|
||||
(<literal>6</literal> works also in some cases) and the <replaceable>cellheight</replaceable>
|
||||
<literal>7</literal> or <literal>8</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
The custom-characters (if any) have to be at character positions
|
||||
<replaceable>offset</replaceable><literal>+0</literal>,
|
||||
<replaceable>offset</replaceable><literal>+1</literal>,
|
||||
<replaceable>offset</replaceable><literal>+2</literal>, ...
|
||||
<replaceable>offset</replaceable><literal>+</literal>
|
||||
<function>get_free_chars()</function><literal>-1</literal>,
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
<replaceable>offset</replaceable><literal>+</literal>
|
||||
<function>get_free_chars()</function><literal>-1</literal> must be less than <literal>32</literal>,
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem><para>
|
||||
The custom-characters (if available) have to be at char 0, 1, 2, ..... ,n
|
||||
</para></listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
@@ -204,7 +256,7 @@ port_deny_multiple(0x378,3);
|
||||
|
||||
|
||||
<sect3 id="adv_bignum.h-usage">
|
||||
<title>External provided Functions</title>
|
||||
<title>Provided Functions</title>
|
||||
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
@@ -212,43 +264,127 @@ port_deny_multiple(0x378,3);
|
||||
<paramdef>Driver *<parameter>drvthis</parameter></paramdef>
|
||||
<paramdef>int <parameter>x</parameter></paramdef>
|
||||
<paramdef>int <parameter>num</parameter></paramdef>
|
||||
<paramdef>int <parameter>height</parameter></paramdef>
|
||||
<paramdef>int <parameter>offset</parameter></paramdef>
|
||||
<paramdef>int <parameter>do_init</parameter></paramdef>
|
||||
<paramdef>int <parameter>customchars</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
|
||||
<para>
|
||||
The main thing the driver has to do is to call this function from its <function>num()</function>
|
||||
function.
|
||||
function with the parameters described below.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Where <parameter>num</parameter> is the number (legal: <literal>0</literal> - <literal>9</literal>,
|
||||
and <literal>:</literal>)
|
||||
to be written, <parameter>height</parameter> the display's height in characters and
|
||||
<parameter>customchars</parameter> the number of available custom characters.
|
||||
</para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>drvthis</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
the pointer pointing to the Driver structure passed to thea driver's
|
||||
<function>num()</function> function.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>x</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
the horizontal position of the top-left corner of the big-number
|
||||
(the big-numbers don't have a y position).
|
||||
The placing of the characters is done by the client, so the driver only has to forward
|
||||
the position to the lib. The bignumlib has no influence on the placing of the characters.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>num</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
the number (legal: <literal>0</literal> - <literal>9</literal>,
|
||||
and <literal>:</literal>) to be written.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>offset</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
the character position where the user-defineable characters start
|
||||
(usually <literal>0</literal>).
|
||||
The user-defineable characters (if any) are then expected to be at the character positions
|
||||
<replaceable>offset</replaceable><literal>+0</literal>,
|
||||
<replaceable>offset</replaceable><literal>+1</literal>,
|
||||
<replaceable>offset</replaceable><literal>+2</literal>, ...
|
||||
<replaceable>offset</replaceable><literal>+</literal>
|
||||
<function>get_free_chars()</function><literal>-1</literal>
|
||||
and <replaceable>offset</replaceable><literal>+</literal>
|
||||
<function>get_free_chars()</function><literal>-1</literal> is required to be less than
|
||||
<literal>32</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>do_init</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
if not <literal>0</literal>, lib_adv_bignum will set the
|
||||
custom characters of the display for the big-numbers.
|
||||
</para>
|
||||
<para>
|
||||
The driver has to check if the custom-characters have to be set or if it is
|
||||
already done and tell it to the lib (using the <parameter>do_init</parameter> parameter).
|
||||
The common way is to use variable called <replaceable>p->ccmode</replaceable> or similar.
|
||||
In the different drivers there are some differences in the naming and handling of this variable.
|
||||
So the responsibility of checking and setting is left to the driver.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
<example id="lib_adv_bignum-example">
|
||||
<title>Calling <function>lib_adv_bignum()</function></title>
|
||||
|
||||
<programlisting>
|
||||
<emphasis>#include "adv_bignum.h"</emphasis>
|
||||
|
||||
MODULE_EXPORT void
|
||||
myDriver_num( Driver * drvthis, int x, int num )
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
int do_init = 0;
|
||||
|
||||
if (p->ccmode != CCMODE_BIGNUM){ // Are the custom-characters set up correctly? If not:
|
||||
do_init = 1; // Lib_adv_bignum has to set the custom-characters.
|
||||
p->ccmode = CCMODE_BIGNUM; // Switch custom-charactermode to bignum.
|
||||
}
|
||||
|
||||
// Lib_adv_bignum does everything needed to show the big-numbers.
|
||||
<emphasis>lib_adv_bignum(drvthis, x, num, 0, do_init);</emphasis>
|
||||
}
|
||||
</programlisting>
|
||||
|
||||
</example>
|
||||
|
||||
<para>
|
||||
<parameter>x</parameter> is the x position of the top-left corner of the big-number
|
||||
(the big-numbers don't have a y position).
|
||||
The placing of the characters is done by the client, so the driver only has to forward
|
||||
the position to the lib. The bignumlib has no influence on the placing of the characters.
|
||||
All that's left to do is to add <filename>libbignum.a</filename> to the libs and
|
||||
<filename>adv_bignum.h</filename> sources of your driver in the <filename>Makefile</filename>
|
||||
(or the file that generates the
|
||||
<filename>Makefile</filename>).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
If <parameter>do_init</parameter> is not <literal>0</literal> lib_bignum will set the
|
||||
custom characters of the display for the big-numbers.
|
||||
</para>
|
||||
<example id="adv_bignum.h-Makefile.am-example">
|
||||
<title>Enabling adv_bignum support in <filename>Makefile.am</filename></title>
|
||||
|
||||
<para>
|
||||
The driver has to check if the custom-characters have to be set or if it is
|
||||
already done and tell it to the lib (using the <parameter>do_init</parameter> parameter).
|
||||
The common way is to use variable called <replaceable>p->ccmode</replaceable> or similar.
|
||||
In the different drivers there are some differences in the naming and handling of this variable.
|
||||
So the responsibility of checking and setting is left at the driver.
|
||||
</para>
|
||||
<programlisting>
|
||||
myDriver_LDADD: libLCD.a <emphasis>libbignum.a</emphasis>
|
||||
|
||||
myDriver_SOURCES: lcd.h lcd_lib.h myDriver.c myDriver.h report.h <emphasis>adv_bignum.h</emphasis>
|
||||
</programlisting>
|
||||
|
||||
</example>
|
||||
|
||||
</sect3>
|
||||
|
||||
@@ -256,13 +392,16 @@ port_deny_multiple(0x378,3);
|
||||
<title>Internal Structure and Functions</title>
|
||||
|
||||
<para>
|
||||
The only function of <function>lib_adv_bignum()</function> is to determine the best
|
||||
display-dependent big-number function for the given display parameters, and to call it.
|
||||
The only purpose of <function>lib_adv_bignum()</function> is to determine the best
|
||||
display-dependent big-number function, based upon the values of the driver's
|
||||
<function>height()</function> and <function>get_free_chars()</function> functions,
|
||||
and call it.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The display-dependent functions are named <function>adv_bignum_num_N_M()</function>.
|
||||
Where <replaceable>N</replaceable> is the display-height in lines and <replaceable>M</replaceable>
|
||||
The display-dependent functions are named
|
||||
<function>adv_bignum_num_<replaceable>N_M</replaceable>()</function>,
|
||||
where <replaceable>N</replaceable> is the display's height in lines and <replaceable>M</replaceable>
|
||||
the number of used user-defineable characters.
|
||||
The bits of the user-characters are stored in <replaceable>static char bignum</replaceable>
|
||||
(take a look at the source and you will see what I mean). (On a display with a
|
||||
@@ -273,8 +412,8 @@ port_deny_multiple(0x378,3);
|
||||
</para>
|
||||
|
||||
<para>
|
||||
If user-characters have to be set the driver's <function>set_char()</function> function
|
||||
will be called once for every user-character.
|
||||
If user-defineable characters have to be set, the driver's <function>set_char()</function> function
|
||||
will be called once for every user-idefneable character.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
@@ -285,47 +424,6 @@ port_deny_multiple(0x378,3);
|
||||
|
||||
</sect3>
|
||||
|
||||
<sect3 id="adv_bignum.h-example">
|
||||
<title>Example:</title>
|
||||
|
||||
<para>
|
||||
Calling the <function>lib_adv_bignum()</function> from a drivers_num function.
|
||||
(from <filename>serialVFD.c</filename>):
|
||||
</para>
|
||||
<screen>
|
||||
|
||||
MODULE_EXPORT void
|
||||
serialVFD_num( Driver * drvthis, int x, int num )
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
int do_init = 0;
|
||||
|
||||
if (p->ccmode != CCMODE_BIGNUM){ // Are the custom-characters set up correctly? If not:
|
||||
do_init = 1; // Lib_adv_bignum has to set the custom-characters.
|
||||
p->ccmode = CCMODE_BIGNUM; // Switch custom-charactermode to bignum.
|
||||
}
|
||||
// Lib_adv_bignum does everything needed to show the big-numbers.
|
||||
lib_adv_bignum(drvthis, x, num, p->height, do_init, p->customchars);
|
||||
}
|
||||
|
||||
</screen>
|
||||
|
||||
<para>
|
||||
All that's left to do is to include the header-file
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
#include "adv_bignum.h"
|
||||
</screen>
|
||||
|
||||
<para>
|
||||
and to add <filename>libbignum.a</filename> to the libs and <filename>adv_bignum.h</filename>
|
||||
sources of your driver in the <filename>Makefile</filename> (or the file that generates the
|
||||
<filename>Makefile</filename>).
|
||||
</para>
|
||||
|
||||
</sect3>
|
||||
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
|
||||
@@ -696,7 +696,7 @@ int do_init = 0;
|
||||
}
|
||||
|
||||
// Lib_adv_bignum does everything needed to show the bignumbers.
|
||||
lib_adv_bignum(drvthis, x, num, do_init, NUM_CCs);
|
||||
lib_adv_bignum(drvthis, x, num, 0, do_init);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -784,7 +784,7 @@ int do_init = 0;
|
||||
}
|
||||
|
||||
// Lib_adv_bignum does everything needed to show the bignumbers.
|
||||
lib_adv_bignum(drvthis, x, num, do_init, NUM_CCs);
|
||||
lib_adv_bignum(drvthis, x, num, 0, do_init);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -951,7 +951,7 @@ int do_init = 0;
|
||||
}
|
||||
|
||||
// Lib_adv_bignum does everything needed to show the bignumbers.
|
||||
lib_adv_bignum(drvthis, x, num, do_init, NUM_CCs);
|
||||
lib_adv_bignum(drvthis, x, num, 0, do_init);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -778,7 +778,7 @@ int do_init = 0;
|
||||
}
|
||||
|
||||
// Lib_adv_bignum does everything needed to show the bignumbers.
|
||||
lib_adv_bignum(drvthis, x, num, do_init, NUM_CCs);
|
||||
lib_adv_bignum(drvthis, x, num, 0, do_init);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1129,7 +1129,7 @@ MtxOrb_num (Driver *drvthis, int x, int num)
|
||||
}
|
||||
|
||||
// Lib_adv_bignum does everything needed to show the bignumbers.
|
||||
lib_adv_bignum(drvthis, x, num, do_init, NUM_CCs);
|
||||
lib_adv_bignum(drvthis, x, num, 0, do_init);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+99
-76
@@ -28,19 +28,23 @@
|
||||
cellwidth == 5 (also with 6, but with gaps)
|
||||
cellheight == 7 or 8
|
||||
needed functions:
|
||||
drvthis->set_char (only if the display has customcharacters)
|
||||
drvthis->chr
|
||||
customcharacters (if available) at char 0, 1, 2, ..... ,n
|
||||
drvthis->get_free_chars()
|
||||
drvthis->set_char() [only if get_free_chars() returns a value > 0]
|
||||
drvthis->chr()
|
||||
drvthis->height()
|
||||
customcharacters (if available) at char offset+0, offset+1, ..., offset+get_free_chars()-1
|
||||
|
||||
USAGE:
|
||||
|
||||
Just call lib_adv_bignum(drvthis, x, num, height, do_init, customchars)
|
||||
from drvthis->num.
|
||||
Just call lib_adv_bignum(drvthis, x, num, offset, do_init)
|
||||
from drvthis->num().
|
||||
The library does everything needed to show bignumbers EXCEPT checking or
|
||||
setting the CCMODE variable. The driver has to do this (see serialVFD.c
|
||||
for details).
|
||||
|
||||
Example: Call of the lib_adv_bignum from a drivers_num function :
|
||||
Example: Call of the lib_adv_bignum from a driver's num function:
|
||||
|
||||
#include "adv_bignum.h"
|
||||
|
||||
MODULE_EXPORT void
|
||||
serialVFD_num(Driver *drvthis, int x, int num)
|
||||
@@ -53,7 +57,7 @@
|
||||
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, 0, do_init);
|
||||
}
|
||||
|
||||
*/
|
||||
@@ -78,17 +82,17 @@
|
||||
|
||||
|
||||
|
||||
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);
|
||||
static void adv_bignum_num_2_5 (Driver *drvthis, int x, int num, int height, int do_init);
|
||||
static void adv_bignum_num_2_28 (Driver *drvthis, int x, int num, int height, int do_init);
|
||||
static void adv_bignum_num_2_0(Driver *drvthis, int x, int num, int height, int offset, int do_init);
|
||||
static void adv_bignum_num_2_1(Driver *drvthis, int x, int num, int height, int offset, int do_init);
|
||||
static void adv_bignum_num_2_2(Driver *drvthis, int x, int num, int height, int offset, int do_init);
|
||||
static void adv_bignum_num_2_5(Driver *drvthis, int x, int num, int height, int offset, int do_init);
|
||||
static void adv_bignum_num_2_28(Driver *drvthis, int x, int num, int height, int offset, int do_init);
|
||||
|
||||
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_num_4_0(Driver *drvthis, int x, int num, int height, int offset, int do_init);
|
||||
static void adv_bignum_num_4_3(Driver *drvthis, int x, int num, int height, int offset, int do_init);
|
||||
static void adv_bignum_num_4_8(Driver *drvthis, int x, int num, int height, int offset, int do_init);
|
||||
|
||||
static void adv_bignum_write_num (Driver *drvthis, char write_num_map[][4][3], int x, int num, int height);
|
||||
static void adv_bignum_write_num(Driver *drvthis, char num_map[][4][3], int x, int num, int height, int offset);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -96,59 +100,78 @@ static void adv_bignum_write_num (Driver *drvthis, char write_num_map[][4][3], 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 do_init, int customchars)
|
||||
lib_adv_bignum(Driver *drvthis, int x, int num, int offset, int do_init)
|
||||
{
|
||||
int height = drvthis->height(drvthis);
|
||||
int customchars = drvthis->get_free_chars(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
|
||||
adv_bignum_num_2_0 (drvthis, x, num, height, do_init);
|
||||
}
|
||||
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
|
||||
adv_bignum_num_2_2 (drvthis, x, num, height, do_init);
|
||||
}
|
||||
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
|
||||
adv_bignum_num_2_28 (drvthis, x, num, height, do_init);
|
||||
}
|
||||
break;
|
||||
case 4: // 4 lines
|
||||
if (customchars == 0) { // 4 lines and customchars < 3
|
||||
adv_bignum_num_4_0 (drvthis, x, num, height, do_init);
|
||||
}
|
||||
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;
|
||||
if (height >= 4) {
|
||||
height = 4; // not ideal: we always start at the 1st line
|
||||
|
||||
if (customchars == 0) { // 4 lines and customchars < 3
|
||||
adv_bignum_num_4_0 (drvthis, x, num, height, offset, do_init);
|
||||
}
|
||||
else if (customchars < 8) { // 4 lines and customchars < 8
|
||||
adv_bignum_num_4_3 (drvthis, x, num, height, offset, do_init);
|
||||
}
|
||||
else { // 4 lines and customchars >= 8
|
||||
adv_bignum_num_4_8 (drvthis, x, num, height, offset, do_init);
|
||||
}
|
||||
}
|
||||
else if (height >= 2) {
|
||||
height = 2; // do 3 -line displays really exist?
|
||||
|
||||
if (customchars == 0) { // 2 lines and customchars = 0
|
||||
adv_bignum_num_2_0 (drvthis, x, num, height, offset, do_init);
|
||||
}
|
||||
else if (customchars == 1) { // 2 lines and customchars = 1
|
||||
adv_bignum_num_2_1 (drvthis, x, num, height, offset, do_init);
|
||||
}
|
||||
else if (customchars < 5) { // 2 lines and customchars = 2 ... 4
|
||||
adv_bignum_num_2_2 (drvthis, x, num, height, offset, do_init);
|
||||
}
|
||||
else if (customchars < 28) { // 2 lines and customchars = 5 ... 27
|
||||
adv_bignum_num_2_5 (drvthis, x, num, height, offset, do_init);
|
||||
}
|
||||
else { // 2 lines and customchars >= 28
|
||||
adv_bignum_num_2_28 (drvthis, x, num, height, offset, do_init);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 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][3], int x, int num, int height)
|
||||
static void adv_bignum_write_num(Driver *drvthis, char num_map[][4][3], int x, int num, int height, int offset)
|
||||
{
|
||||
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]);
|
||||
if (num == 10) { // ":" is only 1 character wide.
|
||||
unsigned char c = num_map[num][y][0];
|
||||
|
||||
// increase c by offset if it is a user-defined character
|
||||
// Note: this is a bit of a kludge,
|
||||
// we'd better check for c < offset+get_free_chars()
|
||||
if (c < ' ')
|
||||
c += offset;
|
||||
|
||||
drvthis->chr(drvthis, x, y+1, c);
|
||||
}
|
||||
else {
|
||||
for (dx = 0; dx < 3; dx++)
|
||||
drvthis->chr(drvthis, x + dx, y+1, write_num_map[num][y][dx]);
|
||||
for (dx = 0; dx < 3; dx++) {
|
||||
unsigned char c = num_map[num][y][dx];
|
||||
|
||||
// increase c by offset if it is a user-defined character
|
||||
// Note: this is a bit of a kludge,
|
||||
// we'd better check for c < offset+get_free_chars()
|
||||
if (c < ' ')
|
||||
c += offset;
|
||||
|
||||
drvthis->chr(drvthis, x + dx, y+1, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +189,7 @@ static void adv_bignum_write_num (Driver *drvthis, char write_num_map[][4][3], i
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This function is called for a 2 line display without custom characters.
|
||||
// (pretty ugly looking)
|
||||
static void adv_bignum_num_2_0 (Driver *drvthis, int x, int num, int height, int do_init)
|
||||
static void adv_bignum_num_2_0(Driver *drvthis, int x, int num, int height, int offset, int do_init)
|
||||
{
|
||||
static char num_map[][4][3] = {
|
||||
{ /* 0 */
|
||||
@@ -226,7 +249,7 @@ static void adv_bignum_num_2_0 (Driver *drvthis, int x, int num, int height, int
|
||||
" " }
|
||||
}; // 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, offset); // write the number
|
||||
|
||||
}
|
||||
|
||||
@@ -234,7 +257,7 @@ static void adv_bignum_num_2_0 (Driver *drvthis, int x, int num, int height, int
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This function is usable for a 2 line display with 1 or more custom characters.
|
||||
// (not a beauty, but useable)
|
||||
static void adv_bignum_num_2_1 (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 offset, int do_init)
|
||||
{
|
||||
static char num_map[][4][3] = {
|
||||
{ /* 0 */
|
||||
@@ -306,10 +329,10 @@ static void adv_bignum_num_2_1 (Driver *drvthis, int x, int num, int height, int
|
||||
b_______,
|
||||
b_______, }
|
||||
};
|
||||
drvthis->set_char (drvthis, 0, bignum[0]); // put the customcharacter into the display
|
||||
drvthis->set_char(drvthis, offset+0, bignum[0]); // put the customcharacter into the display
|
||||
}
|
||||
|
||||
adv_bignum_write_num (drvthis, num_map, x, num, height); // write the number
|
||||
adv_bignum_write_num(drvthis, num_map, x, num, height, offset); // write the number
|
||||
|
||||
}
|
||||
|
||||
@@ -317,7 +340,7 @@ static void adv_bignum_num_2_1 (Driver *drvthis, int x, int num, int height, int
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This function is usable for a 2 line display with 2 or more custom characters.
|
||||
// (o.k.)
|
||||
static void adv_bignum_num_2_2 (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 offset, int do_init)
|
||||
{
|
||||
static char num_map[][4][3] ={
|
||||
{ /* 0 */
|
||||
@@ -400,18 +423,18 @@ static void adv_bignum_num_2_2 (Driver *drvthis, int x, int num, int height, int
|
||||
};
|
||||
int i;
|
||||
for (i = 0; i < 2; i++) { // put the customcharacters into the display
|
||||
drvthis->set_char (drvthis, i, bignum[i]);
|
||||
drvthis->set_char(drvthis, offset+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, offset); // write the number
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This function is usable for a 2 line display with 5 or more custom characters.
|
||||
// (nice bignumbers)
|
||||
static void adv_bignum_num_2_5 (Driver *drvthis, int x, int num, int height, int do_init)
|
||||
static void adv_bignum_num_2_5(Driver *drvthis, int x, int num, int height, int offset, int do_init)
|
||||
{
|
||||
static char num_map[][4][3] =
|
||||
{{{3 ,0 ,2}, /*0*/
|
||||
@@ -510,18 +533,18 @@ static void adv_bignum_num_2_5 (Driver *drvthis, int x, int num, int height, int
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 5 ; i++) { // put the customcharacters into the display
|
||||
drvthis->set_char (drvthis, i, bignum[i]);
|
||||
drvthis->set_char(drvthis, offset+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, offset); // write the number
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This function is usable for a 2 line display with 28 or more custom characters.
|
||||
// (Wow, allmost graphical)
|
||||
static void adv_bignum_num_2_28 (Driver *drvthis, int x, int num, int height, int do_init)
|
||||
static void adv_bignum_num_2_28(Driver *drvthis, int x, int num, int height, int offset, int do_init)
|
||||
{
|
||||
static char num_map[][4][3] =
|
||||
{{{15 ,6 ,2}, /*0*/
|
||||
@@ -827,18 +850,18 @@ static void adv_bignum_num_2_28 (Driver *drvthis, int x, int num, int height, in
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 28 ; i++) { // put the customcharacters into the display
|
||||
drvthis->set_char (drvthis, i, bignum[i]);
|
||||
drvthis->set_char(drvthis, offset+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, offset); // write the number
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This function is usable for a 4 line display without custom characters.
|
||||
// (o.k.)
|
||||
static void adv_bignum_num_4_0 (Driver *drvthis, int x, int num, int height, int do_init)
|
||||
static void adv_bignum_num_4_0(Driver *drvthis, int x, int num, int height, int offset, int do_init)
|
||||
{
|
||||
/* Ugly code extracted by David GLAUDE from lcdm001.c ;)*/
|
||||
/* Moved to driver.c by Joris Robijn */
|
||||
@@ -901,14 +924,14 @@ static char num_map[][4][3] = {
|
||||
" " }
|
||||
}; // 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, offset); // write the number
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 void adv_bignum_num_4_3(Driver *drvthis, int x, int num, int height, int offset, int do_init)
|
||||
{
|
||||
static char num_map[][4][3] =
|
||||
{{{3 ,1 ,3}, /*0*/
|
||||
@@ -989,18 +1012,18 @@ static char num_map[][4][3] =
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++) { // put the customcharacters into the display
|
||||
drvthis->set_char(drvthis, i+1, bignum[i]);
|
||||
drvthis->set_char(drvthis, offset+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, offset); // 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 void adv_bignum_num_4_8(Driver *drvthis, int x, int num, int height, int offset, int do_init)
|
||||
{
|
||||
static char num_map[][4][3] = {
|
||||
{ /* 0: */
|
||||
@@ -1138,9 +1161,9 @@ static char num_map[][4][3] = {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 8 ; i++) { // put the customcharacters into the display
|
||||
drvthis->set_char(drvthis, i, bignum[i]);
|
||||
drvthis->set_char(drvthis, offset+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, offset); // write the number
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
#define b_XXXXXX 0x3F
|
||||
|
||||
|
||||
void lib_adv_bignum (Driver *drvthis, int x, int num, int do_init, int customchars);
|
||||
void lib_adv_bignum(Driver *drvthis, int x, int num, int offset, int do_init);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -712,7 +712,7 @@ HD44780_num (Driver *drvthis, int x, int num)
|
||||
}
|
||||
|
||||
// Lib_adv_bignum does everything needed to show the bignumbers.
|
||||
lib_adv_bignum(drvthis, x, num, do_init, NUM_CCs);
|
||||
lib_adv_bignum(drvthis, x, num, 0, do_init);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -505,7 +505,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, do_init, p->customchars);
|
||||
lib_adv_bignum(drvthis, x, num, 0, do_init);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -458,7 +458,7 @@ tyan_lcdm_num (Driver * drvthis, int x, int num)
|
||||
}
|
||||
|
||||
// Lib_adv_bignum does everything needed to show the bignumbers.
|
||||
lib_adv_bignum(drvthis, x, num, do_init, NUM_CCs);
|
||||
lib_adv_bignum(drvthis, x, num, 0, do_init);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user