HD44780 update:

- howto updated
- input pin readout reversed
- 4bit and serialLpt init timing modified
This commit is contained in:
robijn
2002-02-22 01:13:24 +00:00
parent fc92898174
commit b3e1506ffa
6 changed files with 73 additions and 31 deletions
+21 -10
View File
@@ -11,6 +11,7 @@ parallel port:
- 8-bit (winamp style)
- extended 8-bit (LCD + LED bargraph)
- serial LPT
And supports a PIC-an-LCD connected to a serial port.
The driver also lets you use multiple displays as a single virtual
display. For example, a 4, 2 and 1 line display can be used to form a
@@ -203,13 +204,13 @@ this. The extension uses one output pin, you cannot use that pin for other
functions anymore. The wiring looks like this:
O 5V
___ |
+---|___|--------+
LPT Sub-D connector | 4k7 |
| |e
| ___ b |/
BL pin o---------------+---|___|------|
330E |\
___ |
+---|___|---+
LPT Sub-D connector | 4k7 |
| |e
___ | b |/
BL pin o------------|___|---+---------|
1k |\
bc327 |c
| LCD connector
|
@@ -219,7 +220,7 @@ LPT Sub-D connector | 4k7 |
|
=== GND
Note: 4k7 means 4,7 kohm and 330E means 330 ohm.
Note: 4k7 means 4,7 kohm.
The BC327 transistor has the following connections:
_____
@@ -233,8 +234,8 @@ The BC327 transistor has the following connections:
Sometimes the backlight connections are not on the 'main' connector, but on
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.
the current through the LEDs. Therefor you should then add a resistor after
the transistor of about 10 ohm (see display documentation).
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
@@ -534,6 +535,16 @@ complex. If you do not understand the schematic, do not build it.
=== GND
1.6 PIC-an-LCD serial device "picanlcd"
----------------------------------------
The PIC-an-LCD module is also supported. It is not connected to the LPT port
but to a serial port, which saves you from a lot of potential problems.
To use it, specify the device to which you have connected the module in the
config file with the Device= setting. The default is /dev/lcd.
It does not support a keypad nor backlight switching.
1.5.1 Keypad
------------
+6 -2
View File
@@ -260,6 +260,10 @@ unsigned char lcdstat_HD44780_readkeypad (PrivateData *p, unsigned int YData)
// Put port back into idle state for backlight
port_out (p->port, p->backlight_bit);
// And convert value back.
return ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) ) & ~p->stuckinputs;
// And convert value back (MSB first).
return (((readval & FAULT) / FAULT <<4) | /* pin 15 */
((readval & SELIN) / SELIN <<3) | /* pin 13 */
((readval & PAPEREND) / PAPEREND <<2) | /* pin 12 */
((readval & BUSY) / BUSY <<1) | /* pin 11 */
((readval & ACK) / ACK )) & ~p->stuckinputs; /* pin 10 */
}
+6 -2
View File
@@ -169,6 +169,10 @@ unsigned char lcdtime_HD44780_readkeypad (PrivateData *p, unsigned int YData)
port_out (p->port, p->backlight_bit ^ OUTMASK);
sem_signal (semid);
// And convert value back.
return ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) ) & ~p->stuckinputs;
// And convert value back (MSB first).
return (((readval & FAULT) / FAULT <<4) | /* pin 15 */
((readval & SELIN) / SELIN <<3) | /* pin 13 */
((readval & PAPEREND) / PAPEREND <<2) | /* pin 12 */
((readval & BUSY) / BUSY <<1) | /* pin 11 */
((readval & ACK) / ACK )) & ~p->stuckinputs; /* pin 10 */
}
+20 -3
View File
@@ -97,7 +97,10 @@ hd_init_serialLpt (Driver *drvthis)
hd44780_functions->uPause (p, 5000);
shiftreg (p, enableLines, 3);
hd44780_functions->uPause (p, 150);
hd44780_functions->uPause (p, 100);
shiftreg (p, enableLines, 3);
hd44780_functions->uPause (p, 100);
shiftreg (p, enableLines, 2);
hd44780_functions->uPause (p, 100);
@@ -168,7 +171,14 @@ unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
p->hd44780_functions->uPause (p, 1);
readval = ~ port_in (p->port + 1) ^ INMASK;
inputs_zero = ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) );
// And convert value back (MSB first).
inputs_zero = (((readval & FAULT) / FAULT <<4) | /* pin 15 */
((readval & SELIN) / SELIN <<3) | /* pin 13 */
((readval & PAPEREND) / PAPEREND <<2) | /* pin 12 */
((readval & BUSY) / BUSY <<1) | /* pin 11 */
((readval & ACK) / ACK )); /* pin 10 */
if( inputs_zero == 0 ) {
// No keys were pressed
@@ -192,7 +202,14 @@ unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
if( !scancode ) {
// Read input line(s)
readval = ~ port_in (p->port + 1) ^ INMASK;
keybits = ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) );
// And convert value back (MSB first).
keybits = (((readval & FAULT) / FAULT <<4) | /* pin 15 */
((readval & SELIN) / SELIN <<3) | /* pin 13 */
((readval & PAPEREND) / PAPEREND <<2) | /* pin 12 */
((readval & BUSY) / BUSY <<1) | /* pin 11 */
((readval & ACK) / ACK )); /* pin 10 */
if( keybits != inputs_zero ) {
shiftingbit = 1;
for (shiftcount=0; shiftcount<KEYPAD_MAXX && !scancode; shiftcount++) {
+6 -2
View File
@@ -186,6 +186,10 @@ unsigned char lcdwinamp_HD44780_readkeypad (PrivateData *p, unsigned int YData)
// Set output back to idle state for backlight
port_out (p->port + 2, p->backlight_bit ^ OUTMASK );
// And convert value back.
return ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) ) & ~p->stuckinputs;
// And convert value back (MSB first).
return (((readval & FAULT) / FAULT <<4) | /* pin 15 */
((readval & SELIN) / SELIN <<3) | /* pin 13 */
((readval & PAPEREND) / PAPEREND <<2) | /* pin 12 */
((readval & BUSY) / BUSY <<1) | /* pin 11 */
((readval & ACK) / ACK )) & ~p->stuckinputs; /* pin 10 */
}
+14 -12
View File
@@ -23,21 +23,23 @@
/* Output data
* Write to baseaddress+0
*/
// Straight-forward use, no defines needed for this...
/* Straight-forward use, no defines needed for this... */
/* Control output lines
* Write to baseaddress+2
*/
#define nSTRB 0x01 /* negative logic */
#define nSTRB 0x01 /* pin 1; negative logic */
#define STRB 0x01
#define nLF 0x02
#define nLF 0x02 /* pin 14 */
#define LF 0x02
#define INIT 0x04 /* the only positive logic output line */
#define nSEL 0x08
#define INIT 0x04 /* pin 16; the only positive logic output line */
#define nSEL 0x08 /* pin 17 */
#define SEL 0x08
#define ENIRQ 0x10 /* Enable IRQ via ACK line */
#define ENBI 0x20 /* Enable bi-directional port */
#define ENIRQ 0x10 /* Enable IRQ via ACK line (don't enable this without
* setting up interrupt stuff too) */
#define ENBI 0x20 /* Enable bi-directional port (is nice to play with!
* I first didn't know a SPP could do this) */
#define OUTMASK 0x0B /* SEL, LF and STRB are hardware inverted */
/* Use this mask only for the control output lines */
@@ -47,13 +49,13 @@
/* Control input lines
* Read from baseaddress+1
*/
#define nFAULT 0x08
#define nFAULT 0x08 /* pin 15 */
#define FAULT 0x08
#define SELIN 0x10
#define PAPEREND 0x20
#define nACK 0x40
#define SELIN 0x10 /* pin 13 */
#define PAPEREND 0x20 /* pin 12 */
#define nACK 0x40 /* pin 10 */
#define ACK 0x40
#define BUSY 0x80
#define BUSY 0x80 /* pin 11 */
#define IRQ 0x02
#define INMASK 0x84 /* BUSY input and the IRQ indicator are inverted */