Add charmap for NEC uPD16314 (ROM code 002). Add a small charmap search

function and update hd44780 to use it. Make charmap selectable in imon driver.
This commit is contained in:
mmdolze
2011-02-10 23:07:04 +00:00
parent eaf74128c6
commit dfd486c55b
6 changed files with 154 additions and 28 deletions
+1
View File
@@ -20,6 +20,7 @@ v.0.5dev (ongoing development)
* Port remaining drivers to 0.5 API (glk, lcdm001, stv5730)
* Pyramid: Only send LED state changes, doxygen-ize
* sed1520: Make it work with 68-family style interface, convert to 0.5 API
* hd44780/imon: Add charmap for NEC uPD16314 and make it configurable
v0.5.4
* Update driver includes and LDFLAGS (fixed glk and bayrad binding error)
+13 -2
View File
@@ -502,7 +502,7 @@ Size=20x4
# Character map to to map ISO-8859-1 to the LCD's character set
# [default: hd44780_default; legal: hd44780_default, hd44780_euro,
# ea_ks0073, sed1278f_0b, hd44780_koi8_r ]
# ea_ks0073, sed1278f_0b, hd44780_koi8_r, upd16314 ]
CharMap=hd44780_default
# If your display is slow and cannot keep up with the flow of data from
@@ -573,7 +573,9 @@ Device=/dev/lcd0
# display dimensions
Size=16x2
# Character map to to map ISO-8859-1 to the displays character set.
# [default: none; legal: none, hd44780_euro, upd16314, hd44780_koi8_r]
CharMap=hd44780_euro
## Soundgraph iMON LCD ##
[imonlcd]
@@ -945,6 +947,15 @@ ConnectionType=classic
# Port where the LPT is. Usual values are 0x278, 0x378 and 0x3BC
Port=0x378
# Select the interface type (wiring) for the display. Supported values are
# 68 for 68-style connection (RESET level high) and 80 for 80-style connection
# (RESET level low). [legal: 68, 80; default: 80]
InterfaceType=68
# On fast machines it may be necessary to slow down transfer to the display.
# If this value is set to zero, delay is disabled. Any value greater than
# zero slows down each write by one microsecond. [legal: 0-1000; default 1]
DelayMult=0
## serial POS display driver ##
@@ -2853,6 +2853,7 @@ This can be done by specifying <option>--enable-drivers=all</option> or by inclu
<parameter><literal>ea_ks0073</literal></parameter> |
<parameter><literal>sed12780f_0b</literal></parameter> |
<parameter><literal>hd44780_koi8_r</literal></parameter> |
<parameter><literal>upd16314</literal></parameter> |
<parameter><literal>none</literal></parameter>
}
</term>
@@ -2881,6 +2882,12 @@ This can be done by specifying <option>--enable-drivers=all</option> or by inclu
Russian KOI8-R to displays with a ROM mask supporting the european
charset (ROM code A02).
</para></listitem>
<listitem><para>
<literal>upd16314</literal> is for displays with a Nec uPD16314
vacuum fluorescent display (VFD) controller with ROM code 002
character set. If your display has ROM code 001 character set you
may use the <literal>hd44780_euro</literal> charmap instead.
</para></listitem>
<listitem><para>
The <literal>none</literal> charmap does not translate any characters.
It displays the characters the display controllers actually has
+95 -11
View File
@@ -1,12 +1,13 @@
/** \file server/drivers/hd44780-charmap.h
* Character mapping for HD44780 devices.
* Character mapping for HD44780 devices. Translates ISO 8859-1 to known
* HD44780 (and compatible) ROM character sets.
*/
/* Character mapping for HD44780 devices by Mark Haemmerling <mail@markh.de>.
*
* Translates ISO 8859-1 to any HD44780 charset.
*
* Charmap selector (C) 2006 Pillon Matteo <matteo.pillon@email.it>
/*-
* Copyright (C) 2001 Mark Haemmerling <mail@markh.de>
* 2006 Pillon Matteo <matteo.pillon@email.it>
* 2007 Frank Jepsen <vdr_at_jepsennet.de>
* 2009-2011 Markus Dolze <bsdfan@nurfuerspam.de>
*
* This file is released under the GNU General Public License.
* Refer to the COPYING file distributed with this package.
@@ -235,7 +236,6 @@ const unsigned char EA_KS0073_charmap[] = {
/*
* Character mapping by Frank Jepsen <vdr_at_jepsennet.de>.
*
*/
const unsigned char SED1278F_0B_charmap[] = {
/* #0 */
@@ -329,18 +329,102 @@ const unsigned char HD44780_KOI8R_charmap[] = {
98, 142, 131, 139, 143, 140, 138, 141 /* Ь Ы З Ш Э Щ Ч Ъ */
};
/*
* Mapping table for NEC µ PD16314 controller. This is a VFD controller
* that understands the same command set as HD44780 driver and comes with (at
* least) one of two character sets in ROM:
*
* - ROM code 001 is the same charset as hd44780_euro.
* - ROM code 002 is the same charset as hd44780_default (with some additional
* characters in the otherwise unused areas.
*
* The table below is for ROM code 002 and identical to hd44780_default but
* takes advantage of some additional international characters.
*/
const unsigned char uPD16314_charmap[] = {
/* 00h - 1Fh : Control characters */
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,
/* 20h - 3Fh : Numbers and punctuation */
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,
/* 40h - 7Fh : Upper and lower-case letters */
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, 91, 140, 93, 94, 95,
96, 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, 123, 124, 125, 142, 127,
/* 80h - 9Fh : Control characters */
128, 129, 130, 131, 132, 133, 134, 135,
136, 137, 138, 139, 140, 141, 142, 143,
144, 145, 146, 147, 148, 149, 150, 151,
152, 153, 154, 155, 156, 157, 158, 159,
/* A0h - BFh : Special characters */
32, 33, 236, 146, 164, 92, 152, 143,
34, 169, 170, 171, 172, 173, 174, 175,
223, 177, 178, 179, 39, 228, 247, 165,
44, 185, 186, 187, 188, 189, 190, 63,
/* C0h - FFh : International characters */
129, 129, 65, 65, 128, 130, 144, 153,
69, 69, 69, 69, 73, 73, 73, 73,
68, 238, 79, 79, 79, 79, 134, 120,
136, 85, 85, 85, 138, 89, 240, 226,
97, 131, 97, 97, 225, 132, 145, 153,
101, 101, 101, 101, 105, 105, 105, 105,
111, 238, 111, 111, 111, 111, 135, 253,
137, 117, 117, 117, 139, 121, 240, 255
};
#define MAX_CHARMAP_NAME_LENGTH 16
struct charmap {
char name[MAX_CHARMAP_NAME_LENGTH];
const unsigned char *charmap;
char name[MAX_CHARMAP_NAME_LENGTH]; /**< Name of the mapping table */
const unsigned char *charmap; /**< Pointer to mapping table */
};
/** List of available character mappings. This list is sorted by relevance! */
const struct charmap available_charmaps[] = {
{ "none", none_charmap },
{ "hd44780_default", HD44780_charmap },
{ "hd44780_euro", HD44780_euro_charmap },
{ "hd44780_koi8_r", HD44780_KOI8R_charmap},
{ "ea_ks0073", EA_KS0073_charmap },
{ "sed1278f_0b", SED1278F_0B_charmap }
{ "sed1278f_0b", SED1278F_0B_charmap },
{ "upd16314", uPD16314_charmap },
{ "none", none_charmap }
};
/**
* Gets the index of the requested charmap entry in the list of available
* charmaps.
* \param req_charmap String containing the name of the requested charmap
* \return Index of charmap in available_charmaps array or -1 of not found.
*
* \note As long as available_charmaps[] is still small a simple search is
* fine. Should the list become larger (>10 entries) a better search
* algorithm (e.g. binary search) should be used.
*/
static int
charmap_get_index(const char * req_charmap)
{
int i;
if (req_charmap == NULL)
return -1;
for (i = 0; i < (sizeof(available_charmaps)/sizeof(struct charmap)); i++) {
if (strcasecmp(req_charmap, available_charmaps[i].name) == 0) {
return i;
}
}
return -1;
}
/* EOF */
+2 -8
View File
@@ -335,14 +335,8 @@ HD44780_init(Driver *drvthis)
/* Get configured charmap */
strncpy(conf_charmap, drvthis->config_get_string(drvthis->name, "charmap", 0, "hd44780_default"), MAX_CHARMAP_NAME_LENGTH);
conf_charmap[MAX_CHARMAP_NAME_LENGTH-1] = '\0';
p->charmap = 0;
for (i = 0; i < (sizeof(available_charmaps)/sizeof(struct charmap)); i++) {
if (strcasecmp(conf_charmap, available_charmaps[i].name) == 0) {
p->charmap = i;
break;
}
}
if (p->charmap != i) {
p->charmap = charmap_get_index(conf_charmap);
if (p->charmap == -1) {
report(RPT_ERR, "%s: Charmap %s is unknown", drvthis->name, conf_charmap);
report(RPT_ERR, "%s: Available charmaps:", drvthis->name);
for (i = 0; i < (sizeof(available_charmaps)/sizeof(struct charmap)); i++) {
+36 -7
View File
@@ -8,7 +8,7 @@
* from http://www.lirc.org/
*/
/*
/*-
* Driver for Soundgraph/Ahanix/Silverstone/Uneed/Accent iMON IR/VFD Module
*
* Copyright (c) 2004, Venky Raju <dev@venky.ws>, original author of
@@ -43,9 +43,8 @@
#include "lcd.h"
#include "lcd_lib.h"
#include "report.h"
#include "imon.h"
#include "hd44780-charmap.h"
// iMon reserves the first 8 locations for the
// special bargraph characters
@@ -105,8 +104,19 @@ typedef struct imon_private_data {
int width; /**< display width in characters */
int cellwidth; /**< character cell width */
int cellheight; /**< character cell height */
const unsigned char *charmap; /**< character mapping table */
} PrivateData;
/**
* NULL-terminated list of charmaps that can be used by this driver. This
* list is sorted by relevance. Most likely used entries first. */
static char * imon_charmaps[] = {
"none",
"hd44780_euro",
"hd44780_koi8_r",
"upd16314",
NULL
};
/**
* Initialize the driver.
@@ -118,8 +128,9 @@ MODULE_EXPORT int imon_init (Driver *drvthis)
{
PrivateData *p = NULL;
char buf[256];
int i;
// Alocate, initialize and store private p
/* Allocate, initialize and store private p */
p = (PrivateData *) calloc(1, sizeof(PrivateData));
if (p == NULL) {
report(RPT_ERR, "%s: failed to allocate private data", drvthis->name);
@@ -149,7 +160,6 @@ MODULE_EXPORT int imon_init (Driver *drvthis)
if ((p->imon_fd = open(buf, O_WRONLY)) < 0) {
report(RPT_ERR, "%s: ERROR opening %s (%s)", drvthis->name, buf, strerror(errno));
report(RPT_ERR, "%s: Did you load the iMON VFD kernel module?", drvthis->name);
report(RPT_ERR, "%s: More info in lcdproc/docs/README.imon", drvthis->name);
return -1;
}
@@ -172,6 +182,25 @@ MODULE_EXPORT int imon_init (Driver *drvthis)
}
memset(p->framebuf, ' ', p->width * p->height);
/* Load character mapping table */
p->charmap = NULL;
strncpy(buf, drvthis->config_get_string(drvthis->name, "Charmap", 0, "none"), sizeof(buf));
buf[sizeof(buf)-1] = '\0';
for (i = 0; imon_charmaps[i] != NULL; i++) {
if (strcasecmp(imon_charmaps[i], buf) == 0) {
int idx = charmap_get_index(buf);
if (idx != -1) {
p->charmap = available_charmaps[idx].charmap;
report(RPT_INFO, "%s: using %s charmap",
drvthis->name, available_charmaps[idx].name);
}
}
}
if (p->charmap == NULL) {
report(RPT_ERR, "%s: unable to load charmap: %s", drvthis->name, buf);
return -1;
}
report(RPT_DEBUG, "%s: init() done", drvthis->name);
return 0;
@@ -272,7 +301,7 @@ MODULE_EXPORT void imon_chr (Driver *drvthis, int x, int y, char c)
if ((x < 0) || (y < 0) || (x >= p->width) || (y >= p->height))
return;
p->framebuf[(y * p->width) + x] = c;
p->framebuf[(y * p->width) + x] = p->charmap[(unsigned char) c];
}
@@ -403,7 +432,7 @@ MODULE_EXPORT void imon_hbar (Driver *drvthis, int x, int y, int len, int promil
else if (pixels >= 1) {
/* write a partial block, albeit vertically... */
imon_chr(drvthis, x+pos, y, pixels * p->cellheight / p->cellwidth);
}
}
#else
if (pixels >= p->cellwidth * 3/4) {
/* write a "full" block to the screen... */