[Lcdproc] [patch] KS0073 charmap (with selector)

Matteo Pillon matteo.pillon@email.it
Thu Aug 10 10:14:01 2006


--s2ZSL+KKDSLx8OML
Content-Type: multipart/mixed; boundary="X1bOJ3K7DJ5YkBrT"
Content-Disposition: inline


--X1bOJ3K7DJ5YkBrT
Content-Type: text/plain; charset=iso-8859-15
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi,

I have an Electronic Assembly EADIP204B-4NLW KS0073 based display
without a standard hd44780 charset and I wanted to make a patch in
order to support the whole charset. This charset is richer than the
hd44780's, it has the most common used accented letters of iso-8859-1
and many prebuilt icons.
I think this charset is common to all ks0073, but as I'm not sure, I
preferred to name it "ea_ks0073".
All the details are in hd44780-charmap.h, I also added some
documentation (documenting also new parameters of the serial driver).

Bye.

--=20
 * Pillon Matteo

--X1bOJ3K7DJ5YkBrT
Content-Type: text/plain; charset=iso-8859-15
Content-Disposition: attachment; filename="lcdproc_hd44780-charmap.patch"
Content-Transfer-Encoding: quoted-printable

diff -r -u lcdproc-orig/docs/lcdproc-user/drivers/hd44780.docbook lcdproc/d=
ocs/lcdproc-user/drivers/hd44780.docbook
--- lcdproc-orig/docs/lcdproc-user/drivers/hd44780.docbook	2006-04-13 16:57=
:11.000000000 +0200
+++ lcdproc/docs/lcdproc-user/drivers/hd44780.docbook	2006-08-09 21:53:42.0=
00000000 +0200
@@ -1598,6 +1598,19 @@
=20
 <varlistentry>
   <term>
+    <command>Device=3D</command>
+    <arg choice=3D"plain"><replaceable>DEVICE</replaceable></arg>
+  </term>
+  <listitem><para>
+    If you are using a serial connection, you must
+    set this parameter to the device your lcd is connected to. For
+    example, if it's connected to the first serial port, you have to
+    set Device to /dev/ttyS0. The default value is /dev/lcd.
+  </para></listitem>
+</varlistentry>
+
+<varlistentry>
+  <term>
     <command>ConnectionType=3D</command>
     <arg choice=3D"plain">
     <group choice=3D"req">
@@ -1680,6 +1693,37 @@
=20
 <varlistentry>
   <term>
+    <command>Bitrate=3D</command>
+    <arg choice=3D"plain"><replaceable>BITRATE</replaceable></arg>
+  </term>
+  <listitem><para>
+      For a serial connection, set to the serial port bitrate. To use
+      the default value for the chosen interface, just set to 0.
+  </para></listitem>
+</varlistentry>
+
+<varlistentry>
+  <term>
+    <command>Charmap=3D</command>
+    <arg choice=3D"plain">
+    <group choice=3D"req">
+      <arg choice=3D"plain"><literal><emphasis>hd44780_default</emphasis><=
/literal></arg>
+      <arg choice=3D"plain"><literal>ea_ks0073</literal></arg>
+    </group>
+    </arg>
+  </term>
+  <listitem><para>
+      You need to set this parameter only if you don't have a standard
+      hd44780 display. ea_ks0073 is the charmap for Electronic
+      Assembly's KS0073 based displays. These devices have a richer
+      charset, including many icons and many more characters of the
+      ISO-8859-1 than standard hd44780s. Refer to hd44780-charset.h
+      for more informations.
+  </para></listitem>
+</varlistentry>
+
+<varlistentry>
+  <term>
     <command>Keypad=3D</command>
     <arg choice=3D"plain">
     <group choice=3D"req">
diff -r -u lcdproc-orig/server/drivers/hd44780.c lcdproc/server/drivers/hd4=
4780.c
--- lcdproc-orig/server/drivers/hd44780.c	2006-04-27 17:01:51.000000000 +02=
00
+++ lcdproc/server/drivers/hd44780.c	2006-08-07 18:21:45.000000000 +0200
@@ -27,6 +27,9 @@
  *
  * Modified October 2001 to read the configfile.
  *
+ * Modified August 2006 by Pillon Matteo <matteo.pillon@email.it> to
+ * allow user selecting charmaps
+ *
  * Moved the delay timing code by Charles Steinkuehler to timing.h.
  * Guillaume Filion <gfk@logidac.com>, December 2001
  *
@@ -284,6 +287,28 @@
 		}
 	}
=20
+	// Get configured charmap
+	char conf_charmap[MAX_CHARMAP_NAME_LENGHT];
+
+	strncpy(conf_charmap, drvthis->config_get_string(drvthis->name, "charmap"=
, 0, "hd44780_default"), MAX_CHARMAP_NAME_LENGHT);
+	conf_charmap[MAX_CHARMAP_NAME_LENGHT-1]=3D'\0';
+	p->charmap=3D0;
+	for (i=3D0; i<(sizeof(available_charmaps)/sizeof(struct charmap)); i++) {
+		if (strcasecmp(conf_charmap, available_charmaps[i].name) =3D=3D 0) {
+			p->charmap=3Di;
+			break;
+		}
+	}
+	if (p->charmap !=3D i) {
+		report(RPT_ERR, "%s: Charmap %s is unknown", drvthis->name, conf_charmap=
);
+		report(RPT_ERR, "%s: Available charmaps:", drvthis->name);
+		for (i=3D0; i<(sizeof(available_charmaps)/sizeof(struct charmap)); i++) {
+			report(RPT_ERR, " %s", available_charmaps[i].name);
+		}
+		return -1;
+	}
+	report(RPT_INFO, "%s: Using %s charmap", drvthis->name, available_charmap=
s[p->charmap].name);
+
 	// Output latch state - init to a non-valid value
 	p->output_state =3D 999999;
=20
@@ -475,7 +500,7 @@
 					drawing =3D 1;
 					HD44780_position(drvthis,x,y);
 				}
-				p->hd44780_functions->senddata (p, p->spanList[y], RS_DATA, HD44780_ch=
armap[(unsigned char)ch]);
+				p->hd44780_functions->senddata (p, p->spanList[y], RS_DATA, available_=
charmaps[p->charmap].charmap[(unsigned char)ch]);
 				p->hd44780_functions->uPause (p, 40);  // Minimum exec time for all co=
mmands
 				p->lcd_contents[(y*wid)+x] =3D ch;
 				count++;
diff -r -u lcdproc-orig/server/drivers/hd44780-charmap.h lcdproc/server/dri=
vers/hd44780-charmap.h
--- lcdproc-orig/server/drivers/hd44780-charmap.h	2005-06-05 00:07:38.00000=
0000 +0200
+++ lcdproc/server/drivers/hd44780-charmap.h	2006-08-09 19:43:53.000000000 =
+0200
@@ -1,14 +1,21 @@
 /*
  * Character mapping for HD44780 devices by Mark Haemmerling <mail@markh.d=
e>.
  *
- * Translates ISO 8859-1 to HD44780 charset.
- * HD44780 charset reference: http://markh.de/hd44780-charset.png
+ * Translates ISO 8859-1 to any HD44780 charset.
  *
- * Initial table taken from lcd.o Linux kernel driver by
- * Nils Faerber <nilsf@users.sourceforge.net>. Thanks!
+ * Charmap selector (C) 2006 Pillon Matteo <matteo.pillon@email.it>
  *
  * This file is released under the GNU General Public License.
  * Refer to the COPYING file distributed with this package.
+ */
+
+/*
+ * HD44780 table
+ *
+ * Initial table taken from lcd.o Linux kernel driver by
+ * Nils Faerber <nilsf@users.sourceforge.net>. Thanks!
+ *
+ * HD44780 charset reference: http://markh.de/hd44780-charset.png
  *
  * The following translations are being performed:
  * - map umlaut accent characters to the corresponding umlaut characters
@@ -65,3 +72,81 @@
   111, 110, 111, 111, 111, 111, 239, 253,
    48, 117, 117, 117, 245, 121, 240, 255
 };
+
+/*
+ * Electronic Assembly's KS0073 based LCDs table
+ * http://www.lcd-module.de/eng/pdf/doma/dip204-4e.pdf
+ *
+ * This map is more similar to a ISO-8859-15, but with fractions from
+ * ISO-8859-1 (0xBC, 0xBD).
+ *
+ * ~ (126) is mapped to right arrow, even though it exists, for
+ * compatibility with some clients. 127 is left arrow.
+ *
+ * There's no backtick, substituded with '.
+ *
+ * | is substituted with another similar charachter as the code is
+ * used by some serial drivers.
+ *
+ * Charset of the display offers a nice set of icons, they are mapped
+ * from 128 to 159. I mapped these intervals to, in order: 16-28,
+ * 140-151, 180-182, 187, 207, 222, 224.
+ *
+ * (C) 2006 Pillon Matteo <matteo.pillon@email.it>
+ *
+ */
+
+const unsigned char EA_KS0073_charmap[] =3D {
+  /* #0 */
+    0,   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 */
+   32,  33,  34,  35,  36,  37,  38,  39,
+   40,  41,  42,  43,  44,  45,  46,  47,
+   48,  49,  50,  51,  52,  53,  54,  55,
+   56,  57,  58,  59,  60,  61,  62,  63,
+  /* #64 */
+   64,  65,  66,  67,  68,  69,  70,  71,
+   72,  73,  74,  75,  76,  77,  78,  79,
+   80,  81,  82,  83,  84,  85,  86,  87,
+   88,  89,  90, 250, 251, 252,  29, 196,
+  /* #96 */
+   39,  97,  98,  99, 100, 101, 102, 103,
+  104, 105, 106, 107, 108, 109, 110, 111,
+  112, 113, 114, 115, 116, 117, 118, 119,
+  120, 121, 122, 253, 218, 255, 223, 225,
+  /* #128 */
+   16,  17,  18,  19,  20,  21,  22,  23,
+   24,  25,  26,  27,  28, 140, 141, 142,
+  143, 144, 145, 146, 147, 148, 149, 150,
+  151, 180, 181, 182, 187, 207, 222, 224,
+  /* #160 */
+  160,  64, 177, 161,  36, 163, 243,  95,
+  248,  67, 170,  20, 172, 173,  82, 175,
+  128, 140, 130, 131, 249, 143, 182, 221,
+  244, 129, 128,  21, 139, 138, 190,  96,
+  /* #192 */
+  174, 226, 174, 174,  91, 174, 188, 169,
+  197, 191, 198,  69,  73,  73,  73,  73,
+   68,  93, 168, 228, 236,  79,  92, 120,
+  171, 238, 229, 238,  94, 230, 178, 190,
+  /* #224 */
+  127, 231, 175, 175, 123, 175, 189, 200,
+  164, 165, 199, 101, 167, 232, 105, 105,
+  111, 125, 168, 233, 237, 111, 124,  58,
+  172, 166, 234, 239, 126, 235, 178, 255
+};
+
+#define MAX_CHARMAP_NAME_LENGHT 16
+
+struct charmap {
+	char name[MAX_CHARMAP_NAME_LENGHT];
+	const unsigned char *charmap;
+};
+
+const struct charmap available_charmaps[] =3D {
+	{"hd44780_default", HD44780_charmap},
+	{"ea_ks0073", EA_KS0073_charmap}
+};
diff -r -u lcdproc-orig/server/drivers/hd44780-low.h lcdproc/server/drivers=
/hd44780-low.h
--- lcdproc-orig/server/drivers/hd44780-low.h	2006-07-16 12:20:55.000000000=
 +0200
+++ lcdproc/server/drivers/hd44780-low.h	2006-08-05 20:13:03.000000000 +0200
@@ -55,6 +55,8 @@
=20
 	int fd; /* for picanlcd connection type */
=20
+	int charmap;
+
 	int width, height;
 	int cellwidth, cellheight;
=20

--X1bOJ3K7DJ5YkBrT--

--s2ZSL+KKDSLx8OML
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (GNU/Linux)

iD8DBQFE2wcidF6kRp1ZHz0RAljcAKCx/od+uChncp1wBkQzxFA/stqhZgCfQdlU
JxPZ7xMleMQ4+w0aXZqbIiI=
=4C7I
-----END PGP SIGNATURE-----

--s2ZSL+KKDSLx8OML--