HD44780 update:
- howto updated - input pin readout reversed - 4bit and serialLpt init timing modified
This commit is contained in:
+21
-10
@@ -11,6 +11,7 @@ parallel port:
|
|||||||
- 8-bit (winamp style)
|
- 8-bit (winamp style)
|
||||||
- extended 8-bit (LCD + LED bargraph)
|
- extended 8-bit (LCD + LED bargraph)
|
||||||
- serial LPT
|
- 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
|
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
|
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:
|
functions anymore. The wiring looks like this:
|
||||||
|
|
||||||
O 5V
|
O 5V
|
||||||
___ |
|
___ |
|
||||||
+---|___|--------+
|
+---|___|---+
|
||||||
LPT Sub-D connector | 4k7 |
|
LPT Sub-D connector | 4k7 |
|
||||||
| |e
|
| |e
|
||||||
| ___ b |/
|
___ | b |/
|
||||||
BL pin o---------------+---|___|------|
|
BL pin o------------|___|---+---------|
|
||||||
330E |\
|
1k |\
|
||||||
bc327 |c
|
bc327 |c
|
||||||
| LCD connector
|
| LCD connector
|
||||||
|
|
|
|
||||||
@@ -219,7 +220,7 @@ LPT Sub-D connector | 4k7 |
|
|||||||
|
|
|
|
||||||
=== GND
|
=== 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:
|
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
|
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 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 current through the LEDs. Therefor you should then add a resistor after
|
||||||
the transistor of 10 ohm.
|
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
|
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
|
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
|
=== 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
|
1.5.1 Keypad
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
|||||||
@@ -260,6 +260,10 @@ unsigned char lcdstat_HD44780_readkeypad (PrivateData *p, unsigned int YData)
|
|||||||
// Put port back into idle state for backlight
|
// Put port back into idle state for backlight
|
||||||
port_out (p->port, p->backlight_bit);
|
port_out (p->port, p->backlight_bit);
|
||||||
|
|
||||||
// And convert value back.
|
// And convert value back (MSB first).
|
||||||
return ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) ) & ~p->stuckinputs;
|
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 */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,6 +169,10 @@ unsigned char lcdtime_HD44780_readkeypad (PrivateData *p, unsigned int YData)
|
|||||||
port_out (p->port, p->backlight_bit ^ OUTMASK);
|
port_out (p->port, p->backlight_bit ^ OUTMASK);
|
||||||
sem_signal (semid);
|
sem_signal (semid);
|
||||||
|
|
||||||
// And convert value back.
|
// And convert value back (MSB first).
|
||||||
return ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) ) & ~p->stuckinputs;
|
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 */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,10 @@ hd_init_serialLpt (Driver *drvthis)
|
|||||||
hd44780_functions->uPause (p, 5000);
|
hd44780_functions->uPause (p, 5000);
|
||||||
|
|
||||||
shiftreg (p, enableLines, 3);
|
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);
|
shiftreg (p, enableLines, 2);
|
||||||
hd44780_functions->uPause (p, 100);
|
hd44780_functions->uPause (p, 100);
|
||||||
@@ -168,7 +171,14 @@ unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
|
|||||||
p->hd44780_functions->uPause (p, 1);
|
p->hd44780_functions->uPause (p, 1);
|
||||||
|
|
||||||
readval = ~ port_in (p->port + 1) ^ INMASK;
|
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 ) {
|
if( inputs_zero == 0 ) {
|
||||||
// No keys were pressed
|
// No keys were pressed
|
||||||
@@ -192,7 +202,14 @@ unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
|
|||||||
if( !scancode ) {
|
if( !scancode ) {
|
||||||
// Read input line(s)
|
// Read input line(s)
|
||||||
readval = ~ port_in (p->port + 1) ^ INMASK;
|
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 ) {
|
if( keybits != inputs_zero ) {
|
||||||
shiftingbit = 1;
|
shiftingbit = 1;
|
||||||
for (shiftcount=0; shiftcount<KEYPAD_MAXX && !scancode; shiftcount++) {
|
for (shiftcount=0; shiftcount<KEYPAD_MAXX && !scancode; shiftcount++) {
|
||||||
|
|||||||
@@ -186,6 +186,10 @@ unsigned char lcdwinamp_HD44780_readkeypad (PrivateData *p, unsigned int YData)
|
|||||||
// Set output back to idle state for backlight
|
// Set output back to idle state for backlight
|
||||||
port_out (p->port + 2, p->backlight_bit ^ OUTMASK );
|
port_out (p->port + 2, p->backlight_bit ^ OUTMASK );
|
||||||
|
|
||||||
// And convert value back.
|
// And convert value back (MSB first).
|
||||||
return ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) ) & ~p->stuckinputs;
|
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
@@ -23,21 +23,23 @@
|
|||||||
/* Output data
|
/* Output data
|
||||||
* Write to baseaddress+0
|
* Write to baseaddress+0
|
||||||
*/
|
*/
|
||||||
// Straight-forward use, no defines needed for this...
|
/* Straight-forward use, no defines needed for this... */
|
||||||
|
|
||||||
|
|
||||||
/* Control output lines
|
/* Control output lines
|
||||||
* Write to baseaddress+2
|
* Write to baseaddress+2
|
||||||
*/
|
*/
|
||||||
#define nSTRB 0x01 /* negative logic */
|
#define nSTRB 0x01 /* pin 1; negative logic */
|
||||||
#define STRB 0x01
|
#define STRB 0x01
|
||||||
#define nLF 0x02
|
#define nLF 0x02 /* pin 14 */
|
||||||
#define LF 0x02
|
#define LF 0x02
|
||||||
#define INIT 0x04 /* the only positive logic output line */
|
#define INIT 0x04 /* pin 16; the only positive logic output line */
|
||||||
#define nSEL 0x08
|
#define nSEL 0x08 /* pin 17 */
|
||||||
#define SEL 0x08
|
#define SEL 0x08
|
||||||
#define ENIRQ 0x10 /* Enable IRQ via ACK line */
|
#define ENIRQ 0x10 /* Enable IRQ via ACK line (don't enable this without
|
||||||
#define ENBI 0x20 /* Enable bi-directional port */
|
* 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 */
|
#define OUTMASK 0x0B /* SEL, LF and STRB are hardware inverted */
|
||||||
/* Use this mask only for the control output lines */
|
/* Use this mask only for the control output lines */
|
||||||
@@ -47,13 +49,13 @@
|
|||||||
/* Control input lines
|
/* Control input lines
|
||||||
* Read from baseaddress+1
|
* Read from baseaddress+1
|
||||||
*/
|
*/
|
||||||
#define nFAULT 0x08
|
#define nFAULT 0x08 /* pin 15 */
|
||||||
#define FAULT 0x08
|
#define FAULT 0x08
|
||||||
#define SELIN 0x10
|
#define SELIN 0x10 /* pin 13 */
|
||||||
#define PAPEREND 0x20
|
#define PAPEREND 0x20 /* pin 12 */
|
||||||
#define nACK 0x40
|
#define nACK 0x40 /* pin 10 */
|
||||||
#define ACK 0x40
|
#define ACK 0x40
|
||||||
#define BUSY 0x80
|
#define BUSY 0x80 /* pin 11 */
|
||||||
#define IRQ 0x02
|
#define IRQ 0x02
|
||||||
|
|
||||||
#define INMASK 0x84 /* BUSY input and the IRQ indicator are inverted */
|
#define INMASK 0x84 /* BUSY input and the IRQ indicator are inverted */
|
||||||
|
|||||||
Reference in New Issue
Block a user