Modified the HD44780 driver to work with keypad.

This commit is contained in:
robijn
2001-10-05 15:05:59 +00:00
parent d8daf2bf6f
commit 50cdea1134
+205 -15
View File
@@ -21,8 +21,15 @@ HD44780 driver.
1. Connections
--------------
1.1 Power
----------
1.1 Common connections for all connectiontypes
-----------------------------------------------
No matter what connectiontype you choose, you will always need some
connections. They are explaned here.
1.1.1 Power
------------
All variants use the same method of obtaining power. i.e., for each LCD:
@@ -31,11 +38,22 @@ All variants use the same method of obtaining power. i.e., for each LCD:
2 +5V
3 Vadj (contrast)
Getting the supply voltage:
Use a floppy supply connector, get it from the game port, take some
diodes and a capacitor and get it from the port's data lines, get it
from the keyboard connector or whatever you like. Be safe to avoid
a short circuit. Most non-backlit displays only need 3mA at 5V!
WARNING: Always double check your power connection, your display probably
wont survive a reversely connected supply !
There are several ways to get 5V:
- Connect to a 5V line intented for disk drives (the red wire is 5V, black
is GND).
- Get it from a joystick port (pin 1 and 9 are 5V, 4, 5 and 12 are GND).
It seems that some soundcards can use these lines for communication, so
if you want to use this first check wether it really gives a 'clean' 5V.
- If you don't have a backlight, you can sometimes get the needed mA's from
the LPT port itself. Connect a few diodes from the data pins to a
capacitor and you have the 5V. If it's strong enough is another question...
- Get it from the keyboard connector. I do not recommend to use this with a
backlight, as the keyboard connector is often protected with a fuse of
100mA or 200mA.
Connecting the contrast adjusting pin (Vadj.):
@@ -47,6 +65,110 @@ Connecting the contrast adjusting pin (Vadj.):
|
Vadj.
1.1.2 Keypad
-------------
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
--------------------
If you connect a key like sketched below, then you can only connect one key
per input pin. It is a simple solution if you need only few keys.
+ 5V
|
|
-
| | 10k
| |
-
|
+-----------o input (X)
|
|
o
\
o
|
|
=== GND
By default, the following keystrokes are generated by the different keys:
X0 A
X1 B
X2 C
X3 D
X4 E
You should modify and recompile the driver to get other keystrokes.
1.1.2.2 Matrix keys
--------------------
Using a matrix, we can connect much more keys. To simplify the drawing here,
we replace all switches with an @ symbol:
X line
|
|
Y line ---+---------
| | |
o | = --@--
\ | |
o |
| |
+---+
|
|
We connect the matrix of keys like this:
Y0 o---|<---@--@--@
| | |
Y1 o---|<---@--@--@
| | |
Y2 o---|<---@--@--@
| | |
Y3 o---|<---@--@--@ + 5V
| | | |
diodes | | | ___ |
1N4148 +----------|___|---+
| | | ___ |
| +-------|___|---+
| | | ___ |
| | +----|___|---+ resistors 22k
| | |
o o o
X0 X1 X2
As you can see, you need 1 resistor per X line, and 1 diode per Y line.
Lcdproc will presume that you have a keypad with a layout like a telephone
connected, with X and Y lines connected as show. To be more precise, it
assumes this:
X0 X1 X2 X3
Y0 1 2 3 A
Y1 4 5 6 B
Y2 7 8 9 C
Y3 * 0 # D
If you only need 10 keys, leave the rest away. However, the lcdproc menu is
controlled by the keystrokes A to D. You should modify and recompile the
driver to get an other keypad layout.
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.
1.2 4-bit
----------
@@ -76,9 +198,30 @@ displays four to seven use:
INIT (16) EN6
SEL (17) EN7
The optional keypad can be connected as follows:
1.3 8-bit
----------
printer port keypad
D0 (2) Y0
D1 (3) Y1
D2 (4) Y2
D3 (5) Y3
D4 (6) Y4
D5 (7) Y5
nSTRB (1) Y6
nLF (14) Y7
INIT (16) Y8
nSEL (17) Y9
nACK (10) X0
BUSY (11) X1
PAPEREND (12) X2
SELIN (13) X3
nFAULT (15) X4
1.3 8-bit "Winamp"
-------------------
This type of connection should work with winamp.
@@ -97,13 +240,36 @@ This type of connection should work with winamp.
INIT (16) RS (4)
nSEL (17) EN2 (6 - LCD 2) (optional)
If you only want one display, wire nLF (pin 14) to nRW of your LCD.
N.B. I haven't tried using winamp while having the third LCD connected
to this line.
If you want the display to work with the Winamp plugin, wire nLF (pin 14)
to nRW of your LCD. You can then use the plugin in bidirectional mode (wich
is much faster). With 3 connected LCDs this is not possible.
Note from Benjamin: I haven't tried using winamp while having the third LCD
connected to this line.
The optional keypad can be connected as follows:
printer port keypad
D0 (2) Y0
D1 (3) Y1
D2 (4) Y2
D3 (5) Y3
D4 (6) Y4
D5 (7) Y5
D6 (8) Y6
D7 (9) Y7
nLF (14) Y8
INIT (16) Y9
nACK (10) X0
BUSY (11) X1
PAPEREND (12) X2
SELIN (13) X3
nFAULT (15) X4
1.4 Extended 8-bit
-------------------
1.4 Extended 8-bit "lcdtime"
-----------------------------
This is originally based on "lcdtime" (by Benjamin Tse
<blt@ComPorts.com>) and allows you to combine the LCD with a LED
@@ -134,6 +300,27 @@ The LCD connections are:
See the lcdtime tar-ball (above) for full details of the bargraph
connections.
The optional keypad can be connected as follows:
printer port keypad
D0 (2) Y0
D1 (3) Y1
D2 (4) Y2
D3 (5) Y3
D4 (6) Y4
D5 (7) Y5
D6 (8) Y6
D7 (9) Y7
nSTRB (1) Y8
nSEL (17) Y9
nACK (10) X0
BUSY (11) X1
PAPEREND (12) X2
SELIN (13) X3
nFAULT (15) X4
1.5 Serial LPT
---------------
@@ -143,6 +330,8 @@ HD44780. Suitable for high noise, long connections. Designed by
Andrew McMeikan <andrewm@engineer.com>. Refer to
http://members.xoom.com/andrewmuck for details of the connections.
Note from Joris: I still need to add keypad stuff here
2. Compiling
------------
@@ -160,8 +349,9 @@ Keep in mind the following points.
- When specifying the lcd size, do so before the -d argument.
- Arguments that need to be passed to the driver should be in quotes after
the -d HD44780 arguments.
- Use the "-e" argument for extended interfaces (e.g. >= 3 displays as
- Use the "-e" argument for extended interfaces (e.g. 3 or more displays as
indicated by "optional" connections above).
- Use "-k" to enable the keypad code.
EXAMPLES: