HD44780 general:
- Removed 'long p' from keymap HD44780 serialLpt: - Backlight support - Updated documentation
This commit is contained in:
+64
-10
@@ -73,6 +73,7 @@ You can connect a keypad with all connection types. The maximum supported
|
||||
number of keys differs per type. There are several ways to connect the keys
|
||||
to the input pins.
|
||||
|
||||
|
||||
1.1.2.1 Direct keys
|
||||
--------------------
|
||||
|
||||
@@ -168,10 +169,29 @@ You can buy arrays of keys that are connected like this in the electronics
|
||||
shop. They usually call it a matrix keypad. To hook it to lcdproc, you
|
||||
would only need to add the resistors and diodes.
|
||||
|
||||
If you want to use just one return line, for example with the serialLpt
|
||||
wiring, it looks (completely drawn) like this:
|
||||
|
||||
O 5V
|
||||
|
|
||||
.-.
|
||||
| | 4k7 or 22k
|
||||
diodes | |
|
||||
1N4148 '-'
|
||||
___ |
|
||||
Y0 o---|<---o o---+
|
||||
___ |
|
||||
Y1 o---|<---o o---+
|
||||
___ |
|
||||
Y2 o---|<---o o---+
|
||||
___ |
|
||||
Y3 o---|<---o o---+----o return line
|
||||
|
||||
|
||||
If the driver generates keypresses without that you actually press a key,
|
||||
it might be that the unconnected input lines are picking up
|
||||
electromagnetic waves from the air. In that case connect the unconnected
|
||||
input lines (pin 10, 11, 12, 13 and 15 of the LPT) to VCC.
|
||||
electromagnetic waves from the air. In that case connect the unconnected
|
||||
input lines (pin 10, 11, 12, 13 and 15 of the LPT) to VCC = 5V.
|
||||
|
||||
|
||||
1.1.3 Backlight
|
||||
@@ -200,7 +220,7 @@ LPT Sub-D connector | 4k7 |
|
||||
=== GND
|
||||
|
||||
Note: 4k7 means 4,7 kohm and 330E means 330 ohm.
|
||||
The BC327 has the following connections:
|
||||
The BC327 transistor has the following connections:
|
||||
|
||||
_____
|
||||
| |
|
||||
@@ -216,6 +236,11 @@ the side. If that is the case, there is usually NO RESISTOR present to limit
|
||||
the current through the LEDs. Therefor you should add a resistor after
|
||||
the transistor of 10 ohm.
|
||||
|
||||
If you want the backlight to light a bit while it's switched 'off', you can
|
||||
add a resistor bypassing the transistor from e to c, with a value of, say
|
||||
47ohm or 22ohm. (My 4x20 has an internal resistor of 6ohm, so with 47 ohm
|
||||
extra it lights at only 1/9th. I like this. Joris.)
|
||||
|
||||
|
||||
1.2 4-bit
|
||||
----------
|
||||
@@ -387,11 +412,11 @@ cannot use the backlight control together with the bargraph.
|
||||
This interface uses a handful of wires to interface to the
|
||||
HD44780. Suitable for high noise, long connections. Designed by
|
||||
Andrew McMeikan <andrewm@engineer.com>. The original wiring and
|
||||
driver can be found at:
|
||||
driver can be found at:
|
||||
http://members.xoom.com/andrewmuck
|
||||
|
||||
I (Joris) have extended this driver and the wiring a bit. It now supports
|
||||
keys again (it had earlier supported keys, but some time did not).
|
||||
keys again (it had earlier supported keys, but some time did not).
|
||||
|
||||
Further I have extended the driver and the wiring to be able to run
|
||||
using 2 instead of 3 output pins. That's even one less pin ! :)
|
||||
@@ -400,7 +425,7 @@ Of course the use of fewer lines than the other wirings can not stay
|
||||
without drawbacks. In this case the simplicity of the long feeding wires
|
||||
is compensated by some intelligence in the decoding of the data. If you
|
||||
have no experience with the soldering iron, I do not recommend to build
|
||||
this wiring.
|
||||
this wiring.
|
||||
|
||||
OK, so here is the wiring. First of the 'simple' 3 wires version. IC1 is
|
||||
the shift register, a 4094. Do not forget to connect the 5V to pin 16 and
|
||||
@@ -508,7 +533,14 @@ complex. If you do not understand the schematic, do not build it.
|
||||
|
|
||||
=== GND
|
||||
|
||||
Also the serialLpt wiring supports a keypad. The 3 wires version supports
|
||||
|
||||
1.5.1 Keypad
|
||||
------------
|
||||
|
||||
To understand this part of the serialLpt documentation, you also need to
|
||||
read the keypad section in this document.
|
||||
|
||||
serialLpt wiring supports a keypad. The 3 wires version supports
|
||||
8 keys, or if you use multiple return lines up to 8 x 5 = 40 lines. The
|
||||
2 wires version supports 7 keys, or with multiple return lines
|
||||
7 x 5 = 35 keys.
|
||||
@@ -521,8 +553,30 @@ The return lines are the following:
|
||||
SELIN (13) X3
|
||||
nFAULT (15) X4
|
||||
|
||||
To understand some of this keypad documentation, do also read the keypad
|
||||
section in this document.
|
||||
On lines longer than, say a meter, you should buffer the return line(s).
|
||||
If you only have 1 return line, you can buffer it with two remaining
|
||||
buffers from the 74HCT14:
|
||||
|
||||
1|\ 2 13|\ 12 ___
|
||||
keypad o-----| >o------| >o---|___|---+---o input pin on LPT port
|
||||
return |/ |/ 220E |
|
||||
IC1 IC1 ---
|
||||
--- 1nF
|
||||
|
|
||||
===
|
||||
|
||||
Also a backlight is suported. You will also need a port from the 74HCT14 for
|
||||
that. The BL output below should be connected to the BL input in paragraph
|
||||
1.1.3.
|
||||
|
||||
___ 3|\ 4
|
||||
Data o-----|___|--+----| >o----o BL output
|
||||
LPT-D3 470k | |/
|
||||
--- IC1
|
||||
---
|
||||
|100nF
|
||||
|
|
||||
===
|
||||
|
||||
|
||||
2. Compiling
|
||||
@@ -544,7 +598,7 @@ Then as usual, start LCDd with the correct config file:
|
||||
for example.
|
||||
|
||||
If you want to override the driver selection in LCDd.conf then use:
|
||||
LCDd -c ./LCDd.conf -d HD44780
|
||||
LCDd -c ./LCDd.conf -d HD44780
|
||||
If you use this, the HD44780 driver will read the options from the config
|
||||
file.
|
||||
|
||||
|
||||
@@ -7,13 +7,21 @@
|
||||
* Initial table taken from lcd.o Linux kernel driver by
|
||||
* Nils Faerber <nilsf@users.sourceforge.net>. Thanks!
|
||||
*
|
||||
* Alternative mappings used:
|
||||
* #112 ("p") -> #240 (large "p"), orig. mapped -> #112
|
||||
* #113 ("q") -> #241 (large "q"), orig. mapped -> #113
|
||||
*
|
||||
* This file is released under the GNU General Public License. Refer to the
|
||||
* COPYING file distributed with this package.
|
||||
*
|
||||
*
|
||||
* Following translations are being performed:
|
||||
* - maps umlaut accent characters to the corresponding umlaut characters
|
||||
* - maps other accent characters to the characters without accents
|
||||
* - maps beta (=ringel-S), micro and Yen
|
||||
*
|
||||
* Alternative mappings:
|
||||
* - #112 ("p") -> #240 (large "p"), orig. mapped -> #112
|
||||
* - #113 ("q") -> #241 (large "q"), orig. mapped -> #113
|
||||
*
|
||||
* HD44780 misses backslash
|
||||
*
|
||||
*/
|
||||
|
||||
const char HD44780_charmap[]={
|
||||
@@ -44,7 +52,7 @@ const char HD44780_charmap[]={
|
||||
84, 85, 86, 87,
|
||||
88, 89, 90, 91,
|
||||
/* #92 */
|
||||
92, 93, 94, 95,
|
||||
47, 93, 94, 95,
|
||||
96, 97, 98, 99,
|
||||
100,101,102,103,
|
||||
104,105,106,107,
|
||||
@@ -63,7 +71,7 @@ const char HD44780_charmap[]={
|
||||
152,153,154,155,
|
||||
156,157,158,159,
|
||||
/* #160 */
|
||||
160, 33,236,163,
|
||||
160, 33,236,237,
|
||||
164, 92,124,167,
|
||||
34,169,170,171,
|
||||
172,173,174,175,
|
||||
|
||||
@@ -74,6 +74,7 @@ void shiftreg (unsigned char displayID, unsigned char r);
|
||||
#define EN2 32
|
||||
|
||||
static unsigned int lptPort;
|
||||
static char backlight_bit = 0;
|
||||
|
||||
// Initialisation
|
||||
int
|
||||
@@ -91,21 +92,21 @@ hd_init_serialLpt (HD44780_functions * hd44780_functions, lcd_logical_driver * d
|
||||
hd44780_functions->backlight = lcdserLpt_HD44780_backlight;
|
||||
hd44780_functions->scankeypad = lcdserLpt_HD44780_scankeypad;
|
||||
|
||||
// Clear the shiftregister
|
||||
rawshift (0);
|
||||
|
||||
// setup the lcd in 4 bit mode
|
||||
shiftreg (enableLines, 3);
|
||||
hd44780_functions->uPause (4100);
|
||||
hd44780_functions->uPause (15000);
|
||||
|
||||
shiftreg (enableLines, 3);
|
||||
hd44780_functions->uPause (5000);
|
||||
|
||||
shiftreg (enableLines, 3);
|
||||
hd44780_functions->uPause (100);
|
||||
|
||||
shiftreg (enableLines, 3);
|
||||
hd44780_functions->uPause (40);
|
||||
hd44780_functions->uPause (100);
|
||||
|
||||
shiftreg (enableLines, 2);
|
||||
hd44780_functions->uPause (40);
|
||||
hd44780_functions->uPause (100);
|
||||
|
||||
hd44780_functions->senddata (0, RS_INSTR, FUNCSET | IF_4BIT | TWOLINE | SMALLCHAR);
|
||||
|
||||
@@ -135,42 +136,59 @@ lcdserLpt_HD44780_senddata (unsigned char displayID, unsigned char flags, unsign
|
||||
|
||||
shiftreg (enableLines, portControl | h);
|
||||
shiftreg (enableLines, portControl | l);
|
||||
|
||||
// Restore line status for backlight
|
||||
port_out (lptPort, backlight_bit );
|
||||
}
|
||||
|
||||
void
|
||||
lcdserLpt_HD44780_backlight (unsigned char state)
|
||||
{
|
||||
// Store new state
|
||||
backlight_bit = (state?LCDDATA:0);
|
||||
|
||||
// Set line status for backlight
|
||||
port_out (lptPort, backlight_bit );
|
||||
}
|
||||
|
||||
unsigned char lcdserLpt_HD44780_scankeypad ()
|
||||
{
|
||||
// Unfortunately just bit shifting does not work with the 2 IC version...
|
||||
// Unfortunately just bit shifting does not work with the 2-wire version...
|
||||
|
||||
unsigned char keybits;
|
||||
unsigned int shiftcount;
|
||||
unsigned int shiftingbit;
|
||||
unsigned char readval, inputs_zero, r;
|
||||
unsigned char readval, inputs_zero;
|
||||
int i;
|
||||
unsigned int scancode = 0;
|
||||
|
||||
// While scanning the keypad, the 2-wire version executes the 0xFF
|
||||
// command. This command sets the cursor position, so it's harmless.
|
||||
// I could not prevent this, while staying compatible with both
|
||||
// wiring versions.
|
||||
|
||||
r = 0xFF; // This command will set the cursor position, so it's harmless
|
||||
// Clear the shiftregister, needed for 3-wire version
|
||||
rawshift(0);
|
||||
hd44780_functions->uPause (2);
|
||||
|
||||
readval = ~ port_in (lptPort + 1) ^ INMASK;
|
||||
inputs_zero = ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) );
|
||||
|
||||
if( inputs_zero == 0 ) {
|
||||
// No keys were pressed
|
||||
|
||||
// Restore line status for backlight.
|
||||
port_out (lptPort, backlight_bit );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Scan the keypad while sending the first half of the command (high nibble)
|
||||
for (i = 7; i >= 0; i--) { /* MSB first */
|
||||
port_out (lptPort, ((r >> i) & 1) * LCDDATA); /*set up data */
|
||||
port_out (lptPort, (((r >> i) & 1) * LCDDATA) | LCDCLOCK); /*rising edge of clock */
|
||||
for (i = 7; i >= 0; i--) { /* MSB first */
|
||||
port_out (lptPort, LCDDATA); /*set up data */
|
||||
port_out (lptPort, LCDDATA | LCDCLOCK); /*rising edge of clock */
|
||||
|
||||
hd44780_functions->uPause (2);
|
||||
|
||||
// Do keyscan too !
|
||||
if( !scancode ) {
|
||||
// Read input line(s)
|
||||
readval = ~ port_in (lptPort + 1) ^ INMASK;
|
||||
@@ -188,12 +206,18 @@ unsigned char lcdserLpt_HD44780_scankeypad ()
|
||||
}
|
||||
}
|
||||
|
||||
hd44780_functions->uPause (4);
|
||||
// Wait for 2-wire version to clear the latch...
|
||||
hd44780_functions->uPause (6);
|
||||
|
||||
// And again for the second half of the command (low nibble)
|
||||
rawshift (r);
|
||||
// And again for the second half of the command (low nibble).
|
||||
// Needed for 2-wire version.
|
||||
rawshift (0xFF);
|
||||
|
||||
hd44780_functions->uPause (4);
|
||||
// Wait for 2-wire version to clear the latch...
|
||||
hd44780_functions->uPause (6);
|
||||
|
||||
// Restore line status for backlight.
|
||||
port_out (lptPort, backlight_bit );
|
||||
|
||||
return scancode;
|
||||
}
|
||||
@@ -203,7 +227,6 @@ void
|
||||
rawshift (unsigned char r)
|
||||
{
|
||||
int i;
|
||||
// r |= 0x80; // just to make sure ...
|
||||
|
||||
for (i = 7; i >= 0; i--) { /* MSB first */
|
||||
port_out (lptPort, ((r >> i) & 1) * LCDDATA); /*set up data */
|
||||
@@ -215,9 +238,9 @@ rawshift (unsigned char r)
|
||||
void
|
||||
shiftreg (unsigned char enableLines, unsigned char r)
|
||||
{
|
||||
rawshift (r | 0x80); // highest bit always set to 1 for Clear for wiring with 2 ICs
|
||||
rawshift (r | 0x80); // highest bit always set to 1 for Clear for 2-wire version
|
||||
port_out (lptPort, enableLines); // latch it, to correct display
|
||||
hd44780_functions->uPause (1);
|
||||
port_out (lptPort, 0); // for wiring with 1 IC
|
||||
hd44780_functions->uPause (3);
|
||||
port_out (lptPort, 0); // for 3-wire version
|
||||
hd44780_functions->uPause (5); // wait for 2-wire version to clear the latch...
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user