├── README.md
├── docs
└── lcdproc-user
│ └── drivers
│ └── hd44780.docbook
├── hd44780.so
└── server
└── drivers
├── hd44780-i2c.c
└── hd44780-low.h
/README.md:
--------------------------------------------------------------------------------
1 | # README #
2 |
3 | Update to lcdproc i2c to allow the pin configurations to be specified via LCDd.conf.
4 |
5 | # alternative wiring example #
6 |
7 |
8 | ```
9 |
10 | PCF8574AP: P0 P1 P2 P3 P4 P5 P6 P7
11 | | | | | | | | |
12 | HD44780: RS RW EN BL D4 D5 D6 D7
13 |
14 | ```
15 |
16 | LCDd.conf
17 |
18 | ```
19 | ## Hitachi HD44780 driver ##
20 | [HD44780]
21 | ConnectionType=i2c
22 | Device=/dev/i2c-1
23 | Port=0x27
24 | Backlight=yes
25 | Size=20x4
26 | DelayBus=false
27 | DelayMult=1
28 | Keypad=no
29 | Speed=0
30 | i2c_line_RS=0x01
31 | i2c_line_RW=0x02
32 | i2c_line_EN=0x04
33 | i2c_line_BL=0x08
34 | i2c_line_D4=0x10
35 | i2c_line_D5=0x20
36 | i2c_line_D6=0x40
37 | i2c_line_D7=0x80
38 | Backlight=yes
39 | BacklightInvert=yes
40 | ```
41 |
42 | The Backlight Invert is used if a 0 turns the backlight on, and 1 turns it off, i.e. PNP
43 | transistor
44 |
45 | See discussion here:
46 | http://sourceforge.net/p/lcdproc/discussion/312/thread/00298b2f/
47 |
48 |
49 | Added compiled hd44780.so - save to:
50 | /usr/lib/lcdproc/hd44780.so
51 |
--------------------------------------------------------------------------------
/docs/lcdproc-user/drivers/hd44780.docbook:
--------------------------------------------------------------------------------
1 |
2 | The HD44780 Driver
3 |
4 |
5 | The HD44780 has become the de-facto standard of alphanumeric character displays.
6 | Although the original Hitachi HD44780 is long out of production, its command
7 | set has survived in a variety of (fully or nearly) compatible LCD, VFD and
8 | even OLED displays sold by a broad range of manufacturers all over the world.
9 | To name only a few: KS0066, KS0070, KS0076, LC7985, NT3881, SED1278, ST7066 ...
10 |
11 |
12 |
13 | The command set of these displays, which sometimes are advertised as being
14 | "industry standards compatible", is thus the workhorse of controllers for
15 | displays ranging from 8x1 to 20x4 or 40x2 characters.
16 | There are even displays with larger dimensions sporting two controllers,
17 | one for each half of the display.
18 |
19 |
20 |
21 | The HD44780 driver supports various ways of connecting HD44780 devices
22 | to your system.
23 | Each of these different ways is called a connection type
24 | of the driver.
25 |
26 |
27 |
28 | Depending on the connection type and the display connected, the driver supports
29 | various special features.
30 |
31 | Input keys
32 | Software controllable brightness / backlight
33 | Software controllable contrast
34 | multiple displays / multi-controller displays
35 |
36 |
37 |
38 |
39 | The following table lists the available connection types, sorted by the kind
40 | of connection (parallel port, serial port, USB, I2C, SPI or others).
41 |
42 |
43 |
44 |
186 |
187 |
188 |
189 |
190 | If you suspect the table above to be outdated, you might want to have a look at
191 | server/drivers/hd44780-drivers.h in LCDproc's
192 | source directory which contains the actual translation code.
193 |
194 |
195 |
196 |
197 |
198 |
199 | Connections
200 |
201 |
202 | Common connections for all connection types
203 |
204 |
205 | No matter what connection type you choose, you will always need some
206 | connections. They are explained here.
207 |
208 |
209 |
210 | Power
211 |
212 |
213 | All variants use the same method of obtaining power. i.e., for each LCD:
214 |
215 |
216 |
250 |
251 |
252 |
253 | Always double check your power connection, your display will probably
254 | not survive a reversely connected supply !
255 |
256 |
257 |
258 |
259 | There are several ways to get 5V:
260 |
261 |
262 |
263 |
264 | Connect to a 5V line intended for disk drives (the red wire is 5V,
265 | black is GND).
266 |
267 |
268 | Get it from the VCC and GND pins of an USB connector.
269 | For the USB connection types this is done automatically, as the circuits
270 | used there automatically power the LCD.
271 |
272 |
273 | Get it from a joystick port (pin 1 and 9 are 5V, 4, 5 and 12 are GND).
274 | It seems that some soundcards can use these lines for communication,
275 | so if you want to use this first check whether it really gives a 'clean' 5V.
276 |
277 |
278 | If you don't have a backlight, you can sometimes get the needed mA's
279 | from the LPT port itself. Connect a few diodes from the data pins to
280 | a capacitor and you have the 5V. If it's strong enough is another question...
281 |
282 |
283 | Get it from the keyboard connector. I do not recommend to use this with
284 | a backlight, as the keyboard connector is often protected with a fuse
285 | of 100mA or 200mA.
286 |
287 |
288 |
289 |
290 | HD44780: Connecting the contrast adjusting pin (VLC)
291 |
292 |
303 |
304 |
305 |
306 |
307 |
308 |
309 | Keypad
310 |
311 |
312 | You can connect a keypad with most connection types. The maximum supported
313 | number of keys differs per type. There are several ways to connect the keys
314 | to the input pins.
315 |
316 |
317 |
318 | Direct Keys
319 |
320 |
321 | If you connect a key like sketched below, then you can only connect one key
322 | per input pin. It is a simple solution if you need only few keys.
323 |
324 |
325 |
326 | HD44780: Direct Keys
327 |
328 |
349 |
350 |
351 |
352 |
353 | By default, the following keystrokes are generated by the different keys:
354 |
355 |
388 |
389 | You can change the mapping using the
390 | KeyDirect_NUM
391 | configuration option, where NUM
392 | is the subscript to the X in the table above.
393 |
394 |
395 |
396 |
397 |
398 | Matrix Keys
399 |
400 |
401 | Using a matrix, we can connect much more keys. To simplify the drawing here,
402 | we replace all switches with an @ symbol:
403 |
404 |
405 |
406 | HD44780: Single Matrix Key
407 |
408 |
424 |
425 |
426 |
427 |
428 | We connect the matrix of keys like this:
429 |
430 |
431 |
432 | HD44780: Complete Key Matrix
433 |
434 |
455 |
456 |
457 |
458 |
459 | As you can see, you need 1 resistor per X line, and 1 diode per Y line.
460 | By default, lcdproc will presume that you have a keypad with a layout
461 | like a telephone connected, with X and Y lines connected as show.
462 | To be more precise, it assumes this mapping:
463 |
464 |
465 |
512 |
513 |
514 | This mapping can be changed using the
515 | KeyMatrix_X_Y
516 | configuration option, where X and
517 | Y are the subscripts to the respective axes above.
518 |
519 |
520 |
521 | If you only need e.g. 10 keys, leave the rest away.
522 | You should modify and recompile the
523 | driver to get an other keypad layout.
524 |
525 |
526 |
527 | You can buy arrays of keys that are connected like this in the electronics
528 | shop. They usually call it a matrix keypad. To hook it to lcdproc, you
529 | would only need to add the resistors and diodes.
530 |
531 |
532 |
533 | If you want to use just one return line, for example with the serialLpt
534 | wiring, it looks (completely drawn) like this:
535 |
536 |
537 |
538 | HD44780: One Return Line
539 |
540 |
558 |
559 |
560 |
561 |
562 |
563 | If the driver generates keypresses without that you actually press a key,
564 | it might be that the unconnected input lines are picking up
565 | electromagnetic waves from the air. In that case connect the unconnected
566 | input lines (pin 10, 11, 12, 13 and 15 of the LPT) to VCC = 5V.
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 | Backlight
576 |
577 |
578 | A small extension allows you to switch the backlight of the display on
579 | and off. At the moment only the 4bit and winamp
580 | connection types support this.
581 | The extension uses one output pin, you cannot use that pin for other
582 | functions anymore. The wiring looks like this:
583 |
584 |
585 |
586 | HD44780: Backlight Wiring
587 |
588 |
620 |
621 |
622 |
623 |
624 |
625 | Sometimes the backlight connections are not on the 'main' connector, but on
626 | the side. If that is the case, there is usually NO RESISTOR present to limit
627 | the current through the LEDs. Therefore you should then add a resistor after
628 | the transistor of about 10 ohm (see display documentation).
629 |
630 |
631 |
632 |
633 |
634 | If you want the backlight to light a bit while it is "switched off", you can
635 | add a resistor bypassing the transistor from e to c, with a value of, say
636 | 47ohm or 22ohm. (My 4x20 has an internal resistor of 6ohm, so with 47 ohm
637 | extra it lights at only 1/9th. I like this. Joris.)
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 | 4bit
647 |
648 |
649 | This wiring is originally based on "lcdtext" (by Matthias Prinke).
650 |
651 |
652 |
747 |
748 |
749 |
750 | The RW (pin 5) line of the display decides whether the display receives data from the
751 | LPT port, or whether it sends data to the LPT port: if grounded it receives, if High or connected
752 | to nothing at all it "sends" (i.e., will not work as intended). So, if you are not sure that
753 | you need it otherwise, then connect it to GND. This certainly applies if you have only one display.
754 |
755 |
756 | Theoretically this wiring sends the data over twice as slow as the
757 | winamp or ext8bit wirings, because it only sends 4 bits at a time.
758 |
759 |
760 |
761 |
762 | The 4bit connection type supports more than one display connected
763 | to the same parallel port.
764 | If you want to connect more than one display, then wire the all the displays to the
765 | parallel port according to the scheme above with the exception of the EN
766 | (pin 6) line of the LCDs.
767 |
768 |
769 |
770 | For the second and further displays, you can find the wiring for the EN
771 | (pin 6) line in the table below.
772 |
773 |
774 |
1094 |
1095 |
1096 | (*) on the RW line of the display: this line decides whether the display receives data from the
1097 | LPT port, or whether it sends data to the LPT port: if grounded it receives, if High or connected
1098 | to nothing at all it "sends" (i.e., will not work as intended). So, if you are not sure that
1099 | you need it otherwise, then connect it to GND. This certainly applies if you have only one display.
1100 |
1101 |
1102 |
1103 | If you want the display to work with the Winamp plugin, wire nLF (pin 14)
1104 | to RW of your LCD. You can then use the plugin in bidirectional mode (which
1105 | is much faster). With 3 connected LCDs this is not possible.
1106 | Note from Benjamin: I haven't tried using winamp while having the third LCD
1107 | connected to this line.
1108 |
1109 |
1110 |
1111 | The optional keypad can be connected as follows:
1112 |
1113 |
1114 |
1214 |
1215 |
1216 | The optional backlight wiring should be connected to nSEL, pin 17.
1217 |
1218 |
1219 |
1220 |
1221 |
1222 | 8bit "lcdtime"
1223 |
1224 |
1225 | This is originally based on "lcdtime" (by Benjamin Tse
1226 | blt@ComPorts.com) and allows you to combine the LCD with a LED
1227 | bargraph. The LCD is driven by LCDproc and the LEDs by another program
1228 | such as portato. Further details can be obtained from:
1229 |
1230 |
1231 |
1232 |
1233 |
1234 |
1235 |
1236 |
1237 |
1238 |
1239 |
1240 |
1241 |
1242 |
1243 |
1244 | The LCD connections are:
1245 |
1246 |
1247 |
1356 |
1357 |
1358 | (*) on the RW line of the display: this line decides whether the display receives data from the
1359 | LPT port, or whether it sends data to the LPT port: if grounded it receives, if High or connected
1360 | to nothing at all it "sends" (i.e., will not work as intended). So, if you are not sure that
1361 | you need it otherwise, then connect it to GND.
1362 |
1363 |
1364 |
1365 | See the lcdtime tar-ball (above) for full details of the bargraph
1366 | connections.
1367 |
1368 |
1369 |
1370 | The optional keypad can be connected as follows:
1371 |
1372 |
1373 |
1485 |
1486 |
1487 | The backlight wiring should be attached to nSEL, pin 17. Because the portato
1488 | program (mentioned above) also uses this pin to control the bargraph, you
1489 | cannot use the backlight control together with the bargraph.
1490 |
1491 |
1492 |
1493 |
1494 |
1495 | Serial LPT
1496 |
1497 |
1498 | This interface uses a handful of wires to interface to the
1499 | HD44780. Suitable for high noise, long connections. Designed by
1500 | Andrew McMeikan andrewm@engineer.com.
1501 |
1502 |
1503 |
1504 | I (Joris) have extended this driver and the wiring a bit. It now supports
1505 | keys again (it had earlier supported keys, but some time did not).
1506 |
1507 |
1508 |
1509 | Further I have extended the driver and the wiring to be able to run
1510 | using 2 instead of 3 output pins. That's even one less pin ! :)
1511 |
1512 |
1513 |
1514 | Of course the use of fewer lines than the other wirings can not stay
1515 | without drawbacks. In this case the simplicity of the long feeding wires
1516 | is compensated by some intelligence in the decoding of the data. If you
1517 | have no experience with the soldering iron, I do not recommend to build
1518 | this wiring.
1519 |
1520 |
1521 |
1522 | OK, so here is the wiring. First of the 'simple' 3 wires version. IC1 is
1523 | the shift register, a 4094. Do not forget to connect the 5V to pin 16 and
1524 | GND to pin 8 of the IC.
1525 |
1526 |
1527 |
1528 | HD44780: Serial LPT wiring ('simple')
1529 |
1530 |
1579 |
1580 |
1581 |
1582 |
1583 | The second possible wiring is with 2 output lines. This one is a bit more
1584 | complex. If you do not understand the schematic, do not build it.
1585 |
1586 |
1587 |
1588 | HD44780: Serial LPT wiring ('complex')
1589 |
1590 | o----|R Q6|--------------------o Y7
1611 | | 22k | |/ | |13
1612 | | --- IC1 | Q7|---+ +--o 5 RW
1613 | | --- | | | 5V |
1614 | | |100p ----------- | O ===
1615 | | | | |
1616 | | === | .-.
1617 | | | | |22k
1618 | +--------------------------------------+ | |
1619 | | '-'
1620 | | ___ 11|\ 10 | 5|\ 6
1621 | +--|___|--+----| >o-------------------||-----+----| >o--o 6 EN
1622 | 22k | |/ 22p |/
1623 | --- IC1 IC1
1624 | ---
1625 | |22p
1626 | | IC1=74HCT14 (6x Schmitt trigger inverter)
1627 | ===
1628 |
1629 |
1630 | 5V O--+-------+------+------+-----------------------+-----o 2 VCC
1631 | | | | | 13|\ 12 |
1632 | | | | +---| >o- |
1633 | |100n O 14 O 14 |/ .-.
1634 | --- IC1 IC2 | |<---o 3 Vlcd
1635 | --- O 7 O 7 1|\ 2 3|\ 4 | |10k
1636 | | | | +--| >o- +--| >o- '-'
1637 | GND | | | | |/ | |/ |
1638 | 18..25 o------+-------+------+-------+----------+-----+-----+-----o 1 GND
1639 | |
1640 | === GND
1641 |
1642 | ]]>
1643 |
1644 |
1645 |
1646 |
1647 | Serial LPT Keypad
1648 |
1649 |
1650 |
1651 | To understand this part of the serialLpt documentation, you also need to
1652 | read the keypad section in this document.
1653 |
1654 |
1655 |
1656 |
1657 | serialLpt wiring supports a keypad. The 3 wires version supports
1658 | 8 keys, or if you use multiple return lines up to 8 x 5 = 40 lines. The
1659 | 2 wires version supports 7 keys, or with multiple return lines
1660 | 7 x 5 = 35 keys.
1661 |
1662 |
1663 |
1715 |
1716 |
1717 | On lines longer than, say a meter, you should buffer the return line(s).
1718 | If you only have 1 return line, you can buffer it with two remaining
1719 | buffers from the 74HCT14:
1720 |
1721 |
1722 |
1723 | HD44780: Serial LPT - Keypad return lines buffered
1724 |
1725 | o------| >o---|___|---+---o input pin on LPT port
1729 | return |/ |/ 220E |
1730 | IC1 IC1 ---
1731 | --- 1nF
1732 | |
1733 | ===
1734 |
1735 | ]]>
1736 |
1737 |
1738 |
1739 |
1740 |
1741 |
1742 | Serial LPT Backlight
1743 |
1744 |
1745 | Also a backlight is supported. You will also need a port from the 74HCT14 for
1746 | that. The BL output below should be connected to the BL input in the
1747 | backlight section
1748 |
1749 |
1750 |
1751 | HD44780: Serial LPT - Backlight extra circuit
1752 |
1753 | o----o BL output
1757 | LPT-D3 470k | |/
1758 | --- IC1
1759 | ---
1760 | |100nF
1761 | |
1762 | ===
1763 |
1764 | ]]>
1765 |
1766 |
1767 |
1768 |
1769 |
1770 |
1771 |
1772 |
1773 | spi
1774 |
1775 |
1776 | This connection type drives a LCD in serial mode (supported on Hitachi HD66712,
1777 | Samsung KS0073 and KS0074 (and clones) controllers) connected to some Linux
1778 | SPI device.
1779 |
1780 |
1781 | This connection type is currently only supported on Linux. It is strongly
1782 | recommended to use a SPI implementation with hardware support, e.g. on the
1783 | Raspberry Pi.
1784 |
1785 |
1786 | As the SPI communication to the display cannot drive a backlight switch, this
1787 | connection type features a BacklightDevice option
1788 | that can use a GPIO pin exposed via sysfs (see eLinux GPIO).
1789 |
1790 |
1791 |
1792 |
1793 |
1794 | FTDI FT2232D USB chip "ftdi"
1795 |
1796 |
1797 | You can use a FTDI FT2232D dual channel USB <-> parallel FIFO chip
1798 | to connect a display via the USB bus. The chip is switched to bitbang mode
1799 | and drives both channels as outputs to control the display in 8bit mode.
1800 |
1801 |
1802 |
1911 |
1912 |
1913 | You can configure the USB vendor/product ID in LCDd.conf.
1914 | The wiring of the control lines can optionally be reconfigured,
1915 | please look at the driver source if you really need that.
1916 |
1917 |
1918 |
1919 | The backlight line is driven high when the backlight is on.
1920 | Therefore the standard backlight circuit ()
1921 | will not work. Use the following instead.
1922 |
1923 |
1924 |
1925 | hd44780/ftdi: Backlight Wiring
1926 |
1927 |
1947 |
1948 |
1949 |
1950 |
1951 |
1952 | Alternatively you can use a single channel FTDI FT245BM USB <-> parallel
1953 | FIFO chip and use the display in its 4 bit mode.
1954 |
1955 |
1956 |
2037 |
2038 |
2039 | The following special configuration settings are required to use a single
2040 | channel FTDI FIFO chip:
2041 |
2042 |
2043 |
2044 | HD44780: Configuration for FTDI 4bit
2045 |
2046 |
2055 |
2056 |
2057 |
2058 |
2059 |
2060 |
2061 |
2062 | LIS2 USB device "lis2"
2063 |
2064 |
2065 | LIS2 from VLSystem ()
2066 | is a full featured USB VFD module with four channel fan controls.
2067 | This device can be accessed as a serial device with the help of the kernel
2068 | module ftdi_sio.ko that maps the USB port to a serial port
2069 | (e.g. /dev/ttyUSBx).
2070 |
2071 |
2072 |
2073 |
2074 |
2075 | MPlay Blast USB device "mplay"
2076 |
2077 |
2078 | MPlay Blast from VLSystem ()
2079 | is a full featured USB VFD module with two channel fan controls and
2080 | two channel temperature sensors.
2081 | This device can be accessed as a serial device with the help of the kernel
2082 | module ftdi_sio.ko that maps the USB port to a serial port
2083 | (e.g. /dev/ttyUSBx).
2084 |
2085 |
2086 |
2087 |
2088 |
2089 | LCD on Serial panel device "los-panel"
2090 |
2091 | The LoS-Panel is a DIY device built using an Atmel ATtiny2313 and
2092 | supports the following features:
2093 |
2094 | Drives displays with one controller.
2095 | Switchable backlight.
2096 | One 4x4 matrix keypad and 4 direct keys.
2097 |
2098 |
2099 |
2100 |
2101 |
2102 | The direct keys are reported as a fifth column of a matrix keypad to LCDd.
2103 |
2104 |
2105 | Column and rows are reported reverse (column 1 / row 1 is in the lower
2106 | right corner) to LCDd which expects (1/1) to be the upper left corner.
2107 | You have to take this into account when configuring keys.
2108 |
2109 |
2110 |
2111 |
2112 | See
2113 | for more information on this device.
2114 |
2115 |
2116 |
2117 |
2118 |
2119 | VDR LCD serial device "vdr-lcd"
2120 |
2121 |
2122 | … to be documented …
2123 |
2124 |
2125 |
2126 | Please address Matteo Pillon for further information.
2127 |
2128 |
2129 |
2130 |
2131 |
2132 | VDR-Wakeup module "vdr-wakeup"
2133 |
2134 |
2135 | The VDR-Wake module by Frank Jepsen is a serial IO extension module for the
2136 | famous Linux-based VDR that allows to connect an LCD to it and supports LCDproc.
2137 |
2138 |
2139 |
2140 | See
2141 | (German) for more information on VDR-Wakeup.
2142 |
2143 |
2144 |
2145 |
2146 |
2147 | Pertelian X2040 "pertelian"
2148 |
2149 |
2150 | The Pertelian X2040 includes an HD44780 display with enclosure and USB
2151 | connection.
2152 |
2153 | In order to work with LCDproc in Linux you need
2154 | the usbserial.ko and ftdi_sio.ko
2155 | kernel modules loaded. The display will then be available on a
2156 | serial port /dev/ttyUSBx.
2157 |
2158 |
2159 |
2160 | See the
2161 |
2162 | X4020 product page for more information.
2163 |
2164 |
2165 |
2166 |
2167 |
2168 |
2169 | PIC-an-LCD serial device "picanlcd"
2170 |
2171 |
2172 | The PIC-an-LCD module is also supported. It is not connected to the LPT port
2173 | but to a serial port, which saves you from a lot of potential problems.
2174 | To use it, specify the device to which you have connected the module in the
2175 | config file with the Device setting.
2176 | The default is /dev/lcd.
2177 | It does not support a keypad nor backlight switching.
2178 |
2179 |
2180 |
2181 |
2182 | As of 2012 these devices are not sold anymore. Search the Internet Archive for
2183 | a copy of if you need
2184 | the manual.
2185 |
2186 |
2187 |
2188 |
2189 |
2190 |
2191 | LCD serializer device "lcdserializer"
2192 |
2193 |
2194 | LCD serializer connection is technically the same as PIC-an-LCD with the same advantages,
2195 | it uses the serial port making things really simple.
2196 | Unlike PIC-an-LCD
2197 | LCD serializer
2198 | is not a commercial product. it's just a project found digging on the net and freely available.
2199 | You have all the tools and the code to build it yourself and to customize the behaviour of the device.
2200 |
2201 |
2202 |
2203 | What you need
2204 |
2205 |
2206 |
2207 | Some electronic knowledge and familiarity with the soldering iron
2208 | A PIC16F84 (I used PIC16F84A) or PIC16C54
2209 | JDM PIC programmer
2210 | gputils and picprog installed on your GNU/Linux box
2211 |
2212 |
2213 |
2214 |
2215 |
2216 | Burning the PIC
2217 |
2218 |
2219 | First, you need to download the ASM source for your PIC and then make the hex:
2220 |
2221 |
2222 |
2223 | $gpasm lcd16f84_custom.asm
2224 |
2225 |
2226 |
2227 | Now the binary is ready to be flashed to the PIC.
2228 | Connect the programmer with the PIC installed and issue the following command to see it burning ;-):
2229 |
2230 |
2231 |
2232 | $picprog --erase --burn --input lcd16f84.hex --pic /dev/ttyS0
2233 |
2234 |
2235 |
2236 |
2237 |
2238 | Running lcdproc
2239 |
2240 |
2241 | It's time to build the operating circuit,
2242 | remember this driver uses a baud rate of 9600, so JP2 need to be closed.
2243 |
2244 |
2245 |
2246 | Now power on the board. You should see OK on the LCD screen.
2247 | Otherwise double-check all the connections.
2248 |
2249 |
2250 |
2251 | Change LCDd.conf to include the following statements in the [hd44780] section:
2252 |
2253 |
2254 |
2255 | ConnectionType=lcdserializer
2256 | Device=/dev/ttyS0
2257 |
2258 |
2259 |
2260 | Finally, start the daemon and relax watching lcdproc running.
2261 |
2262 |
2263 |
2264 |
2265 |
2266 |
2267 | BWCT USB LCD module "bwctusb"
2268 |
2269 |
2270 | The BWCT USB LCD module, sold by Bernd Walter Computing Technology
2271 | () is a little board
2272 | that can be piggy-packed to a HD44780 display and connects that to USB.
2273 |
2274 |
2275 |
2276 | The board, driven by the bwctusb connection type,
2277 | does neither support a keypad for input, nor more than one single-controller
2278 | display, nor does it allow setting the backlight or brightness.
2279 | But you can set the display's contrast using software
2280 | (see the Contrast configuration parameter).
2281 |
2282 |
2283 |
2284 | Special configuration options
2285 |
2286 |
2287 | If there is more than one BWCT USB module connected to the system,
2288 | the SerialNumber configuration parameter allows
2289 | selecting which display is used in LCDd.
2290 |
2291 |
2292 |
2293 |
2294 |
2295 |
2296 |
2297 |
2298 | Till Harbaum's "lcd2usb"
2299 |
2300 |
2301 | LCD2USB
2302 | is a cheap but powerful do-it-yourself interface to connect HD44780
2303 | based displays via USB, consisting of easily available parts only.
2304 | The device supports software adjustable contrast and backlight
2305 | as well as dual controller displays (required for 4*27 and 4*40).
2306 |
2307 |
2308 |
2309 | It is based upon an Atmel AVR Mega8 CPU with a pure software implementation
2310 | of the USB protocol for the Atmel AVR microcontroller series.
2311 |
2312 |
2313 |
2314 | The whole interface incl. the hardware layout is under a GPL like license.
2315 | This means that you can take these schematics and use it as a basis
2316 | for your own interface e.g. for a graphic LCD.
2317 |
2318 |
2319 |
2320 | Two keys can be connected to the LCD2USB interface board.
2321 | They can generate three key events that can be mapped to key names using
2322 | the DirectKey_1 to DirectKey_3 commands:
2323 | one for each key and the third if the keys are pressed simultaneously.
2324 | With this 3-key setup, menus can be used (see example below).
2325 |
2326 |
2327 |
2328 | This driver supports the original LCD2USB interface board as described above
2329 | as well as compatible devices like those sold by Lcdmod Kit
2330 | or those developed by Malte Pöggel.
2331 |
2332 |
2333 |
2334 | Special configuration options
2335 |
2336 |
2337 | Besides the standard configuration options for hd44780 displays, the
2338 | lcd2usb connection type supports three additional options:
2339 | Contrast to set the display's contrast,
2340 | Brightness to set the display's brightness when the backlight is switched on and
2341 | OffBrightness to set the display's brightness when is backlight is switched off.
2342 | All three options expect a number in the range from 0 to 1000.
2343 |
2344 |
2345 |
2346 | HD44780: Configuration for LCD2USB
2347 |
2348 |
2366 |
2367 |
2368 |
2369 |
2370 |
2371 | In order to make the lcd2usb connection type work with a 2-controller display
2372 | you may need to set the vSpan config option accordingly.
2373 |
2374 |
2375 |
2376 |
2377 |
2378 |
2379 |
2380 | Dick Streefland's "USBtiny"
2381 |
2382 |
2383 | USBtiny
2384 | is a software implementation of the USB low-speed protocol for
2385 | the Atmel ATtiny microcontrollers. It is also the name of a 'reference
2386 | circuit' using the ATtiny2313.
2387 |
2388 |
2389 |
2390 | The reference circuit features an IR receiver for remote controls and a LCD.
2391 | Due to hardware limitations of the ATtiny2313 the LCD does not have switchable
2392 | backlight, adjustable contrast, any keys, nor does it support displays with
2393 | more than one controller. If you want these features and do not require the
2394 | IR receiver we recommend to take a look at the LCD2USB
2395 | device.
2396 |
2397 |
2398 |
2399 |
2400 | LCDproc does not make use of the IR receiver. 3rd party software is required
2401 | to make it do anything, e.g. LIRC.
2402 |
2403 |
2404 |
2405 |
2406 |
2407 |
2408 |
2409 | USS-720 USB-to-IEEE 1284 Bridge (Belkin F5U002) "uss720"
2410 |
2411 |
2412 | The USS-720 USB-to-IEEE 1284 Bridge is a fully featured USB to parallel chip that is used
2413 | in most (but not all) Belkin F5U002 USB Parallel Printer Adapters. Because these adapters are
2414 | inexpensive and readily available on the second-hand market, they provide an excellent solution
2415 | for users who want to experiment with a parallel port but only have USB ports on their computers.
2416 |
2417 |
2418 |
2419 | Because the chip acts as a parallel port, the driver maintains the same features and wiring as
2420 | the 8-bit "winamp" driver. However, because most USB Parallel Printer Adapters use a centronics
2421 | printer connector, be sure to convert the pin numbering of the parallel port pins in the "winamp"
2422 | wiring to the pin numbering of the centronics port. Many tables are available on the internet
2423 | that illustrate how the pin numbering differs between the two.
2424 |
2425 |
2426 |
2427 | Special configuration options
2428 |
2429 |
2430 | Because several manufacturers used the USS720 chip in their USB Parallel Printer Adapters, the
2431 | VendorID and ProductID options are configurable in the
2432 | LCDd.conf file.
2433 |
2434 |
2435 |
2436 |
2437 | Not all Belkin F5U002 USB Parallel Printer Adapters used the USS720 chip. Look for the dark grey
2438 | adapters with the removable USB cable for best results.
2439 |
2440 |
2441 |
2442 |
2443 |
2444 |
2445 |
2446 |
2447 |
2448 | I2C with Port-Expander
2449 |
2450 |
2451 | If you have an I2C port available that is supported by your kernel
2452 | (through /dev/i2c*), you can add a I2C
2453 | port expander there (PCF8574P in this example).
2454 |
2455 |
2456 |
2457 | HD44780: PCF8574P port expander on I2C bus
2458 |
2459 |
2500 |
2501 |
2502 |
2503 |
2504 | Configuration
2505 |
2506 |
2507 | HD44780: Configuration for I2C with port expander
2508 |
2509 |
2530 |
2531 |
2532 |
2533 |
2534 | If your port expander has different wiring you can re-assign the pins in the config file
2535 |
2536 |
2537 |
2538 | HD44780: Configuration for I2C with port expander
2539 | Alternative Wiring
2540 |
2541 |
2546 |
2547 |
2548 |
2549 |
2550 | HD44780: Configuration for I2C with port expander
2551 | alternative config
2552 |
2553 |
2575 |
2576 |
2577 |
2578 |
2579 | The Device configuration setting denotes the device file
2580 | of your I2C bus (here /dev/i2c-0).
2581 | You have to load the kernel standard module i2c-dev.ko and
2582 | the bus driver, but no I2C
2583 | chip modules (e.g. pcf8574.ko)!
2584 |
2585 |
2586 |
2587 | The Port config option contains the I2C
2588 | address of the I2C port expander
2589 | (here 0x20, the PCF8574 from the example above, with all address bits set to 0).
2590 |
2591 | Bit 8 of the address (normally 0 in I2C addresses)
2592 | has a special meaning:
2593 | It tells the driver to treat the device as PCA9554 or similar,
2594 | a device that needs a 2-byte command, and it will be stripped
2595 | off the address.
2596 |
2597 |
2598 |
2599 | HD44780: Examples of I2C port expander addresses
2600 |
2601 |
2602 |
2603 | Port value
2604 | Meaning
2605 |
2606 |
2607 |
2608 |
2609 | 0x20…0x27
2610 | PCF8574 with A[012]=0…7
2611 |
2612 |
2613 | 0x38…0x3f
2614 | PCF8574A with A[012]=0…7
2615 |
2616 |
2617 | 0xa0…0xa7
2618 | PCA9554 with A[012]=0…7
2619 |
2620 |
2621 | 0xa0…0xa7
2622 | PCA9554A with A[012]=0…7
2623 |
2624 |
2625 |
2626 |
2627 |
2628 |
2629 |
2630 |
2631 |
2632 |
2633 | ethlcd Device
2634 |
2635 |
2636 | The ethlcd () device is simply
2637 | an LCD display driven by an ATmega microcontroller, controlled and powered by
2638 | "home-made" Power over Ethernet. The hardware and software are open source.
2639 |
2640 |
2641 | Features
2642 | ethernet connection using ENC28J60 ethernet controller
2643 | Power over Ethernet (data and power using single UTP cable)
2644 | Atmel's ATmega168 microcontroller
2645 | 6 buttons (MENU, UP, DOWN, LEFT, RIGHT, ENTER)
2646 | backlight control in three states: ON, Night-Mode (partialy ON) and OFF
2647 | beeper
2648 | device act as a TCP server - LCDproc driver is connecting to device just by creating
2649 | a TCP socket - no need to PC-side additional hardware besides NIC
2650 |
2651 |
2652 |
2653 |
2654 | HD44780: ethlcd - block diagram
2655 |
2656 | | ethernet |<========+------> PC running
2667 | | | | | | | controller | | | LCDproc
2668 | | | | | | | | | |
2669 | | |_________| |___________| |____________| | |
2670 | | | | |
2671 | | | | |
2672 | | beeper | |
2673 | |_____________________________________________________| |
2674 | ethlcd AC Adapter
2675 |
2676 | ]]>
2677 |
2678 |
2679 |
2680 |
2681 | The device is "visible" to LCDproc just like any other HD44780 device. The difference
2682 | is the wiring - instead of connecting the display directly to PC (via serial/parallel/usb port),
2683 | it is connected via ethernet and the communication is done over TCP connection.
2684 | The main feature is - that to power and control the LCD is needed single UTP cable.
2685 | To use the driver, specify the device IP address or hostname, on which the ethlcd device
2686 | is accessible by setting in config file the Device value.
2687 | The default is ethlcd.
2688 |
2689 |
2690 |
2691 |
2692 |
2693 | USBLCD adapter
2694 |
2695 |
2696 | The USBLCD adapter from Adams IT Services ()
2697 | is a small interface board which allows you to connect an alphanumerical display
2698 | module based on the HD44780 or compatible controller to the USB. The display
2699 | will be powered by the USB. It features a switchable backlight (on or off) and
2700 | can be used with 16x2, 16x4 or 20x4 displays.
2701 |
2702 |
2703 |
2704 | The usblcd connection type communicates with a kernel
2705 | driver by using a device file /dev/usb/lcdx.
2706 | The kernel driver providing this device currently only exists for Linux kernels
2707 | newer than 2.4.20-pre7.
2708 |
2709 |
2710 |
2711 |
2712 | As of 2007 these device are not sold anymore. This driver has been ported from
2713 | lcdproc 0.4.5 to support existing users.
2714 |
2715 |
2716 |
2717 |
2718 |
2719 | USB-4-all controller
2720 |
2721 |
2722 | The USB-4-all controller board from Sprut ()
2723 | is a small interface board which allows you to connect different hardware to the USB.
2724 | The subdriver for LCDproc supports dual HD44780 displays and a 4x4 keypad as well as
2725 | software adjustable contrast and brightness (backlight).
2726 |
2727 |
2728 |
2894 |
2895 |
2896 |
2897 | HD44780: USB-4-all brightness control
2898 |
2899 | LCD 15 (+ Backlight)
2914 |
2915 | +---> LCD 16 (- Backlight)
2916 | |
2917 | === GND
2918 | ]]>
2919 |
2920 |
2921 |
2922 |
2923 | HD44780: USB-4-all contrast control
2924 |
2925 | LCD 3 (Contrast)
2934 | |c 680R |
2935 | ___ b |/ |+
2936 | RC2 o------|___|------| npn --- 10uF
2937 | 22k |\ ---
2938 | |e |
2939 | | |
2940 | | |
2941 | === === GND
2942 | ]]>
2943 |
2944 |
2945 |
2946 |
2947 |
2948 |
2949 |
2950 | Raspberry Pi
2951 |
2952 | This connection type supports a LCD connected to the GPIO header P1 on
2953 | a Raspberry Pi. Displays with one or two controllers are supported.
2954 |
2955 | It supports a switchable backlight connected to pin P1-11 by default. Use
2956 | the switch circuit as described in .
2957 |
2958 |
2959 | The signal level on the GPIO pins is 3.3 V and they are said not to
2960 | be 5 V tolerant. Therefore the R/W pin of the display must
2961 | be wired to GND to prevent 5V logic appearing on the GPIO
2962 | pins. For the same reason the backlight cicuit from must not be
2964 | used.
2965 | Powering a LCD that uses 5 V from pin P1-02 will work. Powering a
2966 | LCD from 3.3 V (pin P1-01) will only work if it is designed for 3.3 V
2967 | operation.
2968 |
2969 |
2970 |
3058 |
3059 | GPIO07 and GPIO08 used for RS and EN signal are also used by the SPI
3060 | bus. If you loaded the SPI driver you will need to assign them to a different
3061 | GPIO, e.g. GPIO04 and GPIO22.
3062 |
3063 | When using a display with two controllers the vspan
3064 | option has to be configured as well (e.g. vspan=2,2 for a
3065 | 40x4 display).
3066 |
3067 |
3068 | Special Raspberry Pi configuration options
3069 |
3070 | This connection driver can be configured to use other pins than the
3071 | one described in the table
3072 | above. Using the pin_<LCD pin name>
3073 | configuration option, any LCD pin can be assigned
3074 | to any GPIO pin.
3075 |
3076 |
3077 | The values for the pin_<LCD pin name>
3078 | configuration option are the number part from the
3079 | GPIO signal name, not the pin number from the header connector! To find
3080 | out which signal is routed to which connector pin refer to the RPi Low-level peripherals
3082 | description.
3083 |
3084 |
3085 | The connection driver contains a check for possible signal names. You
3086 | will receive an error message if you try to assign a pin to a signal that is
3087 | not available on connector P1 or P5.
3088 |
3089 |
3090 | HD44780: Alternate configuration for Raspberry Pi GPIO pins
3091 |
3092 |
3107 |
3108 |
3109 |
3110 |
3111 |
3112 |
3113 |
3114 | Adafruit Pi Plate
3115 |
3116 |
3117 | The Adafruit RGB Positive 16x2 LCD+Keypad for Raspberry Pi (aka Pi Plate,
3118 | see ()) combines
3119 | a 16x2 Character LCD, up to 3 backlight pins AND 5 keypad pins using only
3120 | the two I2C pins on the Rasperry Pi.
3121 |
3122 |
3123 |
3124 | Note that this connection type drives all RGB pins of the backlight at the
3125 | same time, resulting in a white backlight. You will need to modify the
3126 | source code if you want to have some other color.
3127 |
3128 |
3129 |
3130 | HD44780: Configuration example for Pi Plate connection type
3131 |
3132 |
3147 |
3148 |
3149 |
3150 |
3151 |
3152 |
3153 | PiFace Control and Display
3154 |
3155 |
3156 | The PiFace Control and Display for Raspberry Pi
3157 | from OpenLX SP Ltd combines a 16x2 Character LCD and navigation buttons using
3158 | the SPI bus on the Rasperry Pi.
3159 |
3160 |
3161 |
3162 |
3163 | The PiFace Control and Display features a IR receiver, which LCDproc does not
3164 | make use of. You have to setup and use LIRC for that. See
3165 |
3166 | Setting up PiFace Control And Display to use a remote.
3167 |
3168 |
3169 |
3170 |
3171 | HD44780: Configuration example for PiFace Control and Display connection type
3172 |
3173 |
3190 |
3191 |
3192 |
3193 |
3194 |
3195 |
3196 |
3197 |
3198 |
3199 | Compiling
3200 |
3201 |
3202 | Make sure that the HD44780 files are built when you run ./configure.
3203 | This can be done by specifying or by including
3204 | hd44780 in the list of enabled drivers
3205 | (e.g. ).
3206 |
3207 |
3208 |
3209 |
3210 |
3211 |
3212 |
3213 | Configuration in LCDd.conf
3214 |
3215 |
3216 | [hd44780]
3217 |
3218 |
3219 |
3220 |
3221 | Port =
3222 | PORT
3223 |
3224 |
3225 | For parallel connections, specify the address of the parallel port the LCD is connected to.
3226 | Common values for PORT are 0x278,
3227 | 0x378 and 0x3BC.
3228 | If not given, the default is 0x378.
3229 |
3230 | For I2C connection types this sets the slave
3231 | address.
3232 |
3233 |
3234 |
3235 |
3236 |
3237 | Device =
3238 | DEVICE
3239 |
3240 |
3241 | If you are using a serial or I2C connection,
3242 | you need to set this parameter to the device your LCD is connected to.
3243 | For example, if the display is connected to the first serial port,
3244 | you have to set it to /dev/ttyS0.
3245 | The default value is /dev/lcd.
3246 |
3247 |
3248 |
3249 |
3250 |
3251 | ConnectionType =
3252 | {
3253 |
3254 | 4bit |
3255 | 8bit |
3256 | serialLpt |
3257 | winamp |
3258 | picanlcd |
3259 | lcdserializer |
3260 | los-panel |
3261 | vdr-lcd |
3262 | vdr-wakeup |
3263 | pertelian |
3264 | lis2 |
3265 | mplay |
3266 | usblcd |
3267 | bwctusb |
3268 | lcd2usb |
3269 | usbtiny |
3270 | uss720 |
3271 | usb4all |
3272 | ftdi |
3273 | i2c |
3274 | piplate |
3275 | spi |
3276 | pifacecad |
3277 | ethlcd |
3278 | raspberrypi
3279 | }
3280 |
3281 |
3282 |
3283 | Select the type of the wiring / display connection. See also
3284 | ().
3285 |
3286 |
3287 |
3288 |
3289 |
3290 |
3291 | Speed =
3292 | BITRATE
3293 |
3294 |
3295 | For a serial connection, set to the serial port bitrate. To use
3296 | the default value for the chosen interface, just set to 0.
3297 |
3298 |
3299 |
3300 |
3301 |
3302 | CharMap =
3303 | {
3304 | hd44780_default |
3305 | hd44780_euro |
3306 | ea_ks0073 |
3307 | sed12780f_0b |
3308 | hd44780_koi8_r |
3309 | hd44780_cp1251 |
3310 | hd44780_8859_5 |
3311 | upd16314 |
3312 | none
3313 | }
3314 |
3315 |
3316 |
3317 | Set the character mapping depending on the display you have:
3318 |
3319 |
3320 | The default, hd44780_default, is for "classic"
3321 | HD44780 displays.
3322 |
3323 |
3324 | hd44780_euro is for displays with a ROM mask
3325 | supporting the european charset (ROM code A02).
3326 |
3327 |
3328 | ea_ks0073 is the charmap for Electronic
3329 | Assembly's KS0073 based displays. These devices have a richer
3330 | charset, including many icons and many more characters of the
3331 | ISO-8859-1 than standard HD44780s.
3332 |
3333 |
3334 | sed12780f_0b is for some SED 1278 displays.
3335 |
3336 |
3337 | The none charmap does not translate any characters.
3338 | It displays the characters the display controllers actually has
3339 | stored in its CGROM for that position instead. This setting is
3340 | intended for debugging purpose.
3341 |
3342 |
3343 | You only need to set this parameter if you have a non-standard
3344 | HD44780 display or charmap.
3345 |
3346 |
3347 | If LCDproc was configured with '--enable-extra-charmaps' option the
3348 | following character mappings are available, too:
3349 |
3350 |
3351 | hd44780_koi8_r maps input from a client in
3352 | Russian KOI8-R to displays with a ROM mask supporting the european
3353 | charset (ROM code A02).
3354 |
3355 |
3356 | hd44780_cp1251 maps input from a client in
3357 | Russian CP1251 (Windows-1251) to displays with a ROM mask supporting
3358 | the european charset (ROM code A02).
3359 |
3360 |
3361 | hd44780_8859_5 maps input from a client in
3362 | Russian ISO 8859-5 to displays with a ROM mask supporting the european
3363 | charset (ROM code A02).
3364 |
3365 |
3366 | upd16314 is for displays with a Nec uPD16314
3367 | vacuum fluorescent display (VFD) controller with ROM code 002
3368 | character set. If your display has ROM code 001 character set you
3369 | may use the hd44780_euro charmap instead.
3370 |
3371 |
3372 |
3373 |
3374 |
3375 | See server/drivers/hd44780-charset.h
3376 | in LCDproc's source directory for the actual
3377 | mappings.
3378 |
3379 |
3380 |
3381 |
3382 |
3383 |
3384 |
3385 | Keypad = ¶meters.yesnodef;
3386 |
3387 |
3388 | Tell whether you have a keypad connected.
3389 | You may also need to configure the keypad layout further on in this file.
3390 |
3391 |
3392 |
3393 |
3394 |
3395 | Brightness =
3396 | BRIGHTNESS
3397 |
3398 |
3399 | Set the initial brightness when the backlight is on
3400 | for the lcd2usb connection type.
3401 | Legal values are 0 - 1000,
3402 | with 800 being the default.
3403 |
3404 |
3405 |
3406 |
3407 |
3408 | OffBrightness =
3409 | BRIGHTNESS
3410 |
3411 |
3412 | Set the initial off-brightness, i.e. the brightness when the backlight is off,
3413 | for the lcd2usb connection type.
3414 | The legal range is 0 - 1000.
3415 | If not given, it defaults to 300.
3416 |
3417 |
3418 |
3419 |
3420 |
3421 | Contrast =
3422 | CONTRAST
3423 |
3424 |
3425 | Set the initial contrast for the bwctusb and
3426 | lcd2usb connection types.
3427 | Legal values for CONTRAST are
3428 | 0 - 1000.
3429 | If not given, it defaults to 500 which may
3430 | be too low or too high for the selected connection type.
3431 | So, if the screen is blank or dark, please try playing with
3432 | the contrast a bit.
3433 |
3434 |
3435 |
3436 |
3437 |
3438 | Backlight = ¶meters.yesnodef;
3439 |
3440 |
3441 | Specify if you have a switchable backlight.
3442 |
3443 |
3444 |
3445 |
3446 |
3447 | OutputPort = ¶meters.yesnodef;
3448 |
3449 |
3450 | Tell if you have the additional output port ("bargraph") and you want to
3451 | be able to control it with the lcdproc OUTPUT command.
3452 |
3453 |
3454 |
3455 |
3456 |
3457 | Lastline = ¶meters.yesdefno;
3458 |
3459 |
3460 | Specifies whether the lowest pixel line of a character is pixel addressable
3461 | or if it controls an underline effect.
3462 | The default is yes, meaning a pixel addressable last pixel line.
3463 |
3464 |
3465 |
3466 |
3467 |
3468 | Size = ¶meters.size;
3469 |
3470 |
3471 | Specifies the size of the LCD.
3472 | Default: 20x4
3473 | In case of multiple combined displays, this should be the total size.
3474 |
3475 |
3476 |
3477 |
3478 |
3479 | vSpan =
3480 |
3481 | HEIGHT
3482 | ,…
3483 |
3484 |
3485 |
3486 | The "vertical span" when using the driver with multi-controller displays
3487 | or with multiple displays that are treated as a single virtual display.
3488 | It is a comma separated list of the heights of each display.
3489 | In multi-controller displays it lists the number of lines each controller
3490 | is responsible for.
3491 |
3492 |
3493 | E.g. vSpan=2,2,1 means you have three physical displays, the first
3494 | two having two lines each, and the third having one line, that together form
3495 | a virtual display that is 5 lines high.
3496 |
3497 |
3498 | The sum of the HEIGHTs must match the total height
3499 | given in Size=.
3500 |
3501 |
3502 |
3503 |
3504 |
3505 | ExtendedMode = ¶meters.yesnodef;
3506 |
3507 |
3508 | If you have a KS0073 or an other 'almost HD44780-compatible', set this
3509 | flag to get into extended,4-line linear addressing mode.
3510 |
3511 |
3512 |
3513 |
3514 |
3515 | LineAddress =
3516 | ADDR
3517 |
3518 |
3519 | If the next line of your display doesn't start 0x20 higher in
3520 | DDRAM you can override the default value of the ExtendedMode with this parameter.
3521 |
3522 |
3523 |
3524 |
3525 |
3526 | DelayMult =
3527 | DELAY
3528 |
3529 |
3530 | If your display is slow and cannot keep up with the flow of data from
3531 | LCDd, garbage can appear on the LCDd. Set this delay multiplier to
3532 | 2 or 4 to increase the delays.
3533 | The default is 1 for a non-multiplied delay.
3534 |
3535 |
3536 |
3537 |
3538 |
3539 | DelayBus = ¶meters.yesdefno;
3540 |
3541 |
3542 | You can reduce the inserted delays by setting this to no.
3543 | On fast PCs it is possible your LCD does not respond correctly.
3544 | Default: yes.
3545 |
3546 |
3547 |
3548 |
3549 |
3550 | KeepAliveDisplay =
3551 | SECONDS
3552 |
3553 |
3554 | Some displays (e.g. vdr-wakeup) need a message from the driver to
3555 | indicate that it is still alive.
3556 | When set to a value greater than 0 the character in the
3557 | upper left corner is updated every SECONDS seconds.
3558 | The default 0 does not cause any extra updates.
3559 |
3560 |
3561 |
3562 |
3563 |
3564 | RefreshDisplay =
3565 | SECONDS
3566 |
3567 |
3568 | If you experience occasional garbage on your display you can use this
3569 | option as workaround. If set to a value greater than 0 it forces a
3570 | full screen refresh every SECONDS seconds.
3571 | Default: 0.
3572 |
3573 |
3574 |
3575 |
3576 |
3577 | KeyDirect_NUM =
3578 | KEY
3579 |
3580 |
3581 | KeyMatrix_X_Y =
3582 | KEY
3583 |
3584 |
3585 |
3586 | If you have a keypad you can assign keystrings to the keys.
3587 | See the keypad section
3588 | for used terms and the section on the specific connection type how to
3589 | wire it.
3590 |
3591 |
3592 | To map, for example, the directly connected key 4
3593 | to the string Enter, use KeyDirect_4=Enter.
3594 | For matrix keys use the X and
3595 | Y coordinates of the key;
3596 | e.g. KeyMatrix_1_3=Enter.
3597 |
3598 |
3599 |
3600 |
3601 |
3602 |
3603 | VendorID =
3604 | VENDORID
3605 |
3606 |
3607 | USB vendor ID to look for in certain USB connection types.
3608 | When using an FTDI chip with connection type ftdi, the default value is
3609 | 0x4003.
3610 | When using a USS720 chip with connection type uss720, the default value is
3611 | 0x1293.
3612 |
3613 |
3614 |
3615 |
3616 |
3617 | ProductID =
3618 | PRODUCTID
3619 |
3620 |
3621 | USB product ID to look for in certain USB connection types.
3622 | When using an FTDI chip with connection type ftdi, the default value is
3623 | 0x6001.
3624 | When using a USS720 chip with connection type uss720, the default value is
3625 | 0x0002.
3626 |
3627 |
3628 |
3629 |
3630 |
3631 | SerialNumber =
3632 | SERIALNO
3633 |
3634 |
3635 | Serial number of the USB device to look for with
3636 | connection type bwctusb.
3637 | If not given, the first BWCT USB module found will be used.
3638 |
3639 |
3640 |
3641 |
3642 |
3643 |
3644 |
3645 |
3646 |
3647 |
3648 | Miscellanea
3649 |
3650 |
3651 | This text has originally been taken from a message by Bill Farrow
3652 | bfarrow@arrow.bsee.swin.edu.au.
3653 |
3654 |
3655 |
3656 | Updated February 2000, Benjamin Tse blt@ComPorts.com
3657 |
3658 |
3659 |
3660 | Updated October 2001, Joris Robijn joris@robijn.net
3661 |
3662 |
3663 |
3664 | Converted to Docbook March 2002, Rene Wagner reenoo@gmx.de
3665 |
3666 |
3667 |
3668 | Updated April 2002, Rene Wagner reenoo@gmx.de
3669 |
3670 |
3671 |
3672 | Updated and extended April 2006 to November 2007, Peter Marschall peter@adpm.de
3673 |
3674 |
3675 |
3676 |
3677 |
3678 |
--------------------------------------------------------------------------------
/hd44780.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilberforce/lcdproc/3753e21c231113daf008059dcfb3c5ae705753ea/hd44780.so
--------------------------------------------------------------------------------
/server/drivers/hd44780-i2c.c:
--------------------------------------------------------------------------------
1 | /** \file server/drivers/hd44780-i2c.c
2 | * \c i2c connection type of \c hd44780 driver for Hitachi HD44780 based LCD displays.
3 | *
4 | * The LCD is operated in its 4 bit-mode to be connected to the 8 bit-port
5 | * of a single PCF8574(A) or PCA9554(A) that is accessed by the server via the i2c bus.
6 | */
7 |
8 | /* Copyright (c) 2005 Matthias Goebl
9 | * 2000, 1999, 1995 Benjamin Tse
10 | * 2001 Joris Robijn
11 | * 1999 Andrew McMeikan
12 | * 1998 Richard Rognlie
13 | * 1997 Matthias Prinke
14 | *
15 | * The connections are:
16 | * PCF8574AP Bit LCD
17 | * P0 (4) 0x01 D4 (11)
18 | * P1 (5) 0x02 D5 (12)
19 | * P2 (6) 0x04 D6 (13)
20 | * P3 (7) 0x08 D7 (14)
21 | * P4 (9) 0x10 RS (4)
22 | * P5 (10) 0x20 RW (5)
23 | * P6 (11) 0x40 EN (6)
24 | * P7 (12) 0x80 /backlight (optional, active-low)
25 | *
26 | * Configuration:
27 | \verbatim
28 | alternative wiring example:
29 | PCF8574AP: P0 P1 P2 P3 P4 P5 P6 P7
30 | | | | | | | | |
31 | HD44780: RS RW EN BL D4 D5 D6 D7
32 |
33 | in LCDd.conf we then need to define
34 | i2c_line_RS=0x01
35 | i2c_line_RW=0x02
36 | i2c_line_EN=0x04
37 | i2c_line_BL=0x80
38 | i2c_line_D4=0x10
39 | i2c_line_D5=0x20
40 | i2c_line_D6=0x40
41 | i2c_line_D7=0x80
42 | Backlight=yes
43 | BacklightInvert=yes
44 |
45 | The Backlight Invert is used if a 0 turns the backlight on, and 1 turns it off, i.e. npn transistor
46 | \endverbatim
47 |
48 | *
49 | * Configuration:
50 | * device=/dev/i2c-0 # the device file of the i2c bus
51 | * port=0x20 # the i2c address of the i2c port expander
52 | *
53 | * Attention: Bit 8 of the address given in port is special:
54 | * It tells the driver to treat the device as PCA9554 or similar,
55 | * a device that needs a 2-byte command, and it will be stripped
56 | * off the address.
57 | * So we have:
58 | * port=0x20..0x27 PCF8574 with A[012]=0..7
59 | * port=0x38..0x3f PCF8574A with A[012]=0..7
60 | * port=0xa0..0xa7 PCA9554 with A[012]=0..7
61 | * port=0xa0..0xa7 PCA9554A with A[012]=0..7
62 | *
63 | * When using this driver, DON'T load the i2c chip module (e.g. pcf8574),
64 | * you only need the i2c bus driver module!
65 | *
66 | *
67 | * Based mostly on the hd44780-4bit module, see there for a complete history.
68 | * Suggestions for PCA9554 support from Tonu Samuel .
69 | *
70 | * This file is released under the GNU General Public License. Refer to the
71 | * COPYING file distributed with this package.
72 | */
73 |
74 | #include "hd44780-i2c.h"
75 | #include "hd44780-low.h"
76 |
77 | #include "report.h"
78 | #ifdef HAVE_CONFIG_H
79 | # include "config.h"
80 | #endif
81 | #include
82 | #include
83 | #include
84 | #include
85 | #include
86 | #include
87 |
88 | #ifdef HAVE_DEV_IICBUS_IIC_H
89 | #include
90 | #else /* HAVE_LINUX_I2C_DEV_H */
91 | #include
92 | /* I2C_SLAVE is missing in linux/i2c-dev.h from kernel headers of 2.4.x kernels */
93 | #ifndef I2C_SLAVE
94 | #define I2C_SLAVE 0x0703 /* Change slave address */
95 | #endif
96 | #endif
97 |
98 |
99 | // Generally, any function that accesses the LCD control lines needs to be
100 | // implemented separately for each HW design. This is typically (but not
101 | // restricted to):
102 | // HD44780_senddata
103 | // HD44780_readkeypad
104 |
105 | void i2c_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
106 | void i2c_HD44780_backlight(PrivateData *p, unsigned char state);
107 | void i2c_HD44780_close(PrivateData *p);
108 |
109 | #define RS 0x10
110 | #define RW 0x20
111 | #define EN 0x40
112 | #define BL 0x80
113 | #define D4 0x01
114 | #define D5 0x02
115 | #define D6 0x04
116 | #define D7 0x08
117 | #define BL_INVERT 0
118 | // note that the above bits are all meant for the data port of PCF8574
119 |
120 | #define I2C_ADDR_MASK 0x7f
121 | #define I2C_PCAX_MASK 0x80
122 |
123 | static void
124 | i2c_out(PrivateData *p, unsigned char val)
125 | {
126 | char data[2];
127 | int datalen;
128 | static int no_more_errormsgs=0;
129 | #ifdef HAVE_DEV_IICBUS_IIC_H
130 | struct iiccmd cmd;
131 | bzero(&cmd, sizeof(cmd));
132 | #endif
133 |
134 | if (p->port & I2C_PCAX_MASK) { // we have a PCA9554 or similar, that needs a 2-byte command
135 | data[0]=1; // command: read/write output port register
136 | data[1]=val;
137 | datalen=2;
138 | } else { // we have a PCF8574 or similar, that needs a 1-byte command
139 | data[0]=val;
140 | datalen=1;
141 | }
142 |
143 | #ifdef HAVE_DEV_IICBUS_IIC_H
144 | cmd.slave = (p->port & I2C_ADDR_MASK) << 1;
145 | cmd.last = 1;
146 | cmd.count = datalen;
147 | cmd.buf = data;
148 |
149 | if (ioctl(p->fd, I2CWRITE, &cmd) < 0) {
150 | #else /* HAVE_LINUX_I2C_DEV_H */
151 | if (write(p->fd,data,datalen) != datalen) {
152 | #endif
153 | p->hd44780_functions->drv_report(no_more_errormsgs?RPT_DEBUG:RPT_ERR, "HD44780: I2C: i2c write data %u to address 0x%02X failed: %s",
154 | val, p->port & I2C_ADDR_MASK, strerror(errno));
155 | no_more_errormsgs=1;
156 | }
157 | }
158 |
159 | #define DEFAULT_DEVICE "/dev/i2c-0"
160 |
161 |
162 | /**
163 | * Initialize the driver.
164 | * \param drvthis Pointer to driver structure.
165 | * \retval 0 Success.
166 | * \retval -1 Error.
167 | */
168 | int
169 | hd_init_i2c(Driver *drvthis)
170 | {
171 | PrivateData *p = (PrivateData*) drvthis->private_data;
172 | HD44780_functions *hd44780_functions = p->hd44780_functions;
173 |
174 | p->i2c_backlight_invert = drvthis->config_get_bool(drvthis->name, "BacklightInvert", 0, BL_INVERT);
175 | p->i2c_line_RS = drvthis->config_get_int(drvthis->name, "i2c_line_RS", 0, RS);
176 | p->i2c_line_RW = drvthis->config_get_int(drvthis->name, "i2c_line_RW", 0, RW);
177 | p->i2c_line_EN = drvthis->config_get_int(drvthis->name, "i2c_line_EN", 0, EN);
178 | p->i2c_line_BL = drvthis->config_get_int(drvthis->name, "i2c_line_BL", 0, BL);
179 | p->i2c_line_D4 = drvthis->config_get_int(drvthis->name, "i2c_line_D4", 0, D4);
180 | p->i2c_line_D5 = drvthis->config_get_int(drvthis->name, "i2c_line_D5", 0, D5);
181 | p->i2c_line_D6 = drvthis->config_get_int(drvthis->name, "i2c_line_D6", 0, D6);
182 | p->i2c_line_D7 = drvthis->config_get_int(drvthis->name, "i2c_line_D7", 0, D7);
183 |
184 | report(RPT_INFO, "HD44780: I2C: Init using D4 and D5, and or'd lines, invert", p->i2c_line_RS);
185 | report(RPT_INFO, "HD44780: I2C: Pin RS mapped to 0x%02X", p->i2c_line_RS);
186 | report(RPT_INFO, "HD44780: I2C: Pin RW mapped to 0x%02X", p->i2c_line_RW);
187 | report(RPT_INFO, "HD44780: I2C: Pin EN mapped to 0x%02X", p->i2c_line_EN);
188 | report(RPT_INFO, "HD44780: I2C: Pin BL mapped to 0x%02X", p->i2c_line_BL);
189 | report(RPT_INFO, "HD44780: I2C: Pin D4 mapped to 0x%02X", p->i2c_line_D4);
190 | report(RPT_INFO, "HD44780: I2C: Pin D5 mapped to 0x%02X", p->i2c_line_D5);
191 | report(RPT_INFO, "HD44780: I2C: Pin D6 mapped to 0x%02X", p->i2c_line_D6);
192 | report(RPT_INFO, "HD44780: I2C: Pin D7 mapped to 0x%02X", p->i2c_line_D7);
193 | report(RPT_INFO, "HD44780: I2C: Invert Backlight %d", p->i2c_backlight_invert);
194 |
195 | char device[256] = DEFAULT_DEVICE;
196 | #ifdef HAVE_DEV_IICBUS_IIC_H
197 | struct iiccmd cmd;
198 | bzero(&cmd, sizeof(cmd));
199 | #endif
200 |
201 | p->backlight_bit = p->i2c_line_BL;
202 |
203 | /* READ CONFIG FILE */
204 |
205 | /* Get serial device to use */
206 | strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(device));
207 | device[sizeof(device)-1] = '\0';
208 | report(RPT_INFO,"HD44780: I2C: Using device '%s' and address 0x%02X for a %s",
209 | device, p->port & I2C_ADDR_MASK, (p->port & I2C_PCAX_MASK) ? "PCA9554(A)" : "PCF8574(A)");
210 |
211 | // Open the I2C device
212 | p->fd = open(device, O_RDWR);
213 | if (p->fd < 0) {
214 | report(RPT_ERR, "HD44780: I2C: open i2c device '%s' failed: %s", device, strerror(errno));
215 | return(-1);
216 | }
217 |
218 | // Set I2C address
219 | #ifdef HAVE_DEV_IICBUS_IIC_H
220 | cmd.slave = (p->port & I2C_ADDR_MASK) << 1;
221 | cmd.last = 0;
222 | cmd.count = 0;
223 | if (ioctl(p->fd, I2CRSTCARD, &cmd) < 0) {
224 | report(RPT_ERR, "HD44780: I2C: reset bus failed: %s", strerror(errno));
225 | return -1;
226 | }
227 | if (ioctl(p->fd, I2CSTART, &cmd) < 0) {
228 | report(RPT_ERR, "HD44780: I2C: set address to 0x%02X: %s", p->port & I2C_ADDR_MASK, strerror(errno));
229 | return -1;
230 | }
231 | #else /* HAVE_LINUX_I2C_DEV_H */
232 | if (ioctl(p->fd,I2C_SLAVE, p->port & I2C_ADDR_MASK) < 0) {
233 | report(RPT_ERR, "HD44780: I2C: set address to '%i': %s", p->port & I2C_ADDR_MASK, strerror(errno));
234 | return(-1);
235 | }
236 | #endif
237 |
238 | if (p->port & I2C_PCAX_MASK) { // we have a PCA9554 or similar, that needs special config
239 | char data[2];
240 | data[0] = 2; // command: set polarity inversion
241 | data[1] = 0; // -> no polarity inversion
242 | if (write(p->fd,data,2) != 2) {
243 | report(RPT_ERR, "HD44780: I2C: i2c set polarity inversion failed: %s", strerror(errno));
244 | }
245 | data[0] = 3; // command: set output direction
246 | data[1] = 0; // -> all pins are outputs
247 | if (write(p->fd,data,2) != 2) {
248 | report(RPT_ERR, "HD44780: I2C: i2c set output direction failed: %s", strerror(errno));
249 | }
250 | }
251 |
252 | hd44780_functions->senddata = i2c_HD44780_senddata;
253 | hd44780_functions->backlight = i2c_HD44780_backlight;
254 | hd44780_functions->close = i2c_HD44780_close;
255 |
256 | // powerup the lcd now
257 | /* We'll now send 0x03 a couple of times,
258 | * which is in fact (FUNCSET | IF_8BIT) >> 4
259 | */
260 | i2c_out(p, p->i2c_line_D4 | p->i2c_line_D5);
261 | if (p->delayBus)
262 | hd44780_functions->uPause(p, 1);
263 |
264 | i2c_out(p, p->i2c_line_EN | p->i2c_line_D4 | p->i2c_line_D5);
265 | if (p->delayBus)
266 | hd44780_functions->uPause(p, 1);
267 | i2c_out(p, p->i2c_line_D4 | p->i2c_line_D5);
268 | hd44780_functions->uPause(p, 15000);
269 |
270 | i2c_out(p, p->i2c_line_EN | p->i2c_line_D4 | p->i2c_line_D5);
271 | if (p->delayBus)
272 | hd44780_functions->uPause(p, 1);
273 | i2c_out(p, p->i2c_line_D4 | p->i2c_line_D5);
274 | hd44780_functions->uPause(p, 5000);
275 |
276 | i2c_out(p, p->i2c_line_EN | p->i2c_line_D4 | p->i2c_line_D5);
277 | if (p->delayBus)
278 | hd44780_functions->uPause(p, 1);
279 | i2c_out(p, p->i2c_line_D4 | p->i2c_line_D5);
280 | hd44780_functions->uPause(p, 100);
281 |
282 | i2c_out(p, p->i2c_line_EN | p->i2c_line_D4 | p->i2c_line_D5);
283 | if (p->delayBus)
284 | hd44780_functions->uPause(p, 1);
285 | i2c_out(p, p->i2c_line_D4 | p->i2c_line_D5);
286 | hd44780_functions->uPause(p, 100);
287 |
288 | // now in 8-bit mode... set 4-bit mode
289 | /*
290 | OLD (FUNCSET | IF_4BIT) >> 4 0x02
291 | ALT (FUNCSET | IF_4BIT) 0x20
292 | */
293 | i2c_out(p, p->i2c_line_D5);
294 | if (p->delayBus)
295 | hd44780_functions->uPause(p, 1);
296 |
297 | i2c_out(p, p->i2c_line_EN | p->i2c_line_D5);
298 | if (p->delayBus)
299 | hd44780_functions->uPause(p, 1);
300 | i2c_out(p, p->i2c_line_D5);
301 | hd44780_functions->uPause(p, 100);
302 |
303 | // Set up two-line, small character (5x8) mode
304 | hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | IF_4BIT | TWOLINE | SMALLCHAR);
305 | hd44780_functions->uPause(p, 40);
306 |
307 | common_init(p, IF_4BIT);
308 |
309 | return 0;
310 | }
311 |
312 | void
313 | i2c_HD44780_close(PrivateData *p) {
314 | if (p->fd >= 0) {
315 | #ifdef HAVE_DEV_IICBUS_IIC_H
316 | ioctl(p->fd, I2CSTOP);
317 | #endif
318 | close(p->fd);
319 | }
320 | }
321 |
322 |
323 | /**
324 | * Send data or commands to the display.
325 | * \param p Pointer to driver's private data structure.
326 | * \param displayID ID of the display (or 0 for all) to send data to.
327 | * \param flags Defines whether to end a command or data.
328 | * \param ch The value to send.
329 | */
330 | void
331 | i2c_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
332 | {
333 | unsigned char portControl = 0;
334 | unsigned char h=0;
335 | unsigned char l=0;
336 | if( ch & 0x80 ) h |= p->i2c_line_D7;
337 | if( ch & 0x40 ) h |= p->i2c_line_D6;
338 | if( ch & 0x20 ) h |= p->i2c_line_D5;
339 | if( ch & 0x10 ) h |= p->i2c_line_D4;
340 | if( ch & 0x08 ) l |= p->i2c_line_D7;
341 | if( ch & 0x04 ) l |= p->i2c_line_D6;
342 | if( ch & 0x02 ) l |= p->i2c_line_D5;
343 | if( ch & 0x01 ) l |= p->i2c_line_D4;
344 | if (flags == RS_INSTR)
345 | portControl = 0;
346 | else //if (flags == RS_DATA)
347 | portControl = p->i2c_line_RS;
348 |
349 | portControl |= p->backlight_bit;
350 |
351 | i2c_out(p, portControl | h);
352 | if (p->delayBus)
353 | p->hd44780_functions->uPause(p, 1);
354 | i2c_out(p, p->i2c_line_EN | portControl | h);
355 | if (p->delayBus)
356 | p->hd44780_functions->uPause(p, 1);
357 | i2c_out(p, portControl | h);
358 |
359 | i2c_out(p, portControl | l);
360 | if (p->delayBus)
361 | p->hd44780_functions->uPause(p, 1);
362 | i2c_out(p, p->i2c_line_EN | portControl | l);
363 | if (p->delayBus)
364 | p->hd44780_functions->uPause(p, 1);
365 | i2c_out(p, portControl | l);
366 | }
367 |
368 |
369 | /**
370 | * Turn display backlight on or off.
371 | * \param p Pointer to driver's private data structure.
372 | * \param state New backlight status.
373 | */
374 | void i2c_HD44780_backlight(PrivateData *p, unsigned char state)
375 | {
376 | if ( p->i2c_backlight_invert == 0 )
377 | p->backlight_bit = ((!p->have_backlight||state) ? 0 : p->i2c_line_BL);
378 | else // Inverted backlight - npn transistor
379 | p->backlight_bit = ((p->have_backlight && state) ? p->i2c_line_BL : 0);
380 | i2c_out(p, p->backlight_bit);
381 | }
382 |
--------------------------------------------------------------------------------
/server/drivers/hd44780-low.h:
--------------------------------------------------------------------------------
1 | /** \file server/drivers/hd44780-low.h
2 | * Interface to low level code to export from hd44780.c to "lower" hardware
3 | * implementation dependent files.
4 | */
5 |
6 | #ifndef HD_LOW_H
7 | #define HD_LOW_H
8 |
9 | #ifdef HAVE_CONFIG_H
10 | # include "config.h"
11 | #endif
12 |
13 | #ifdef HAVE_LIBUSB
14 | # include
15 | #endif
16 |
17 | #if TIME_WITH_SYS_TIME
18 | # include
19 | # include
20 | #else
21 | # if HAVE_SYS_TIME_H
22 | # include
23 | # else
24 | # include
25 | # endif
26 | #endif
27 |
28 | #ifdef HAVE_LIBFTDI
29 | # include
30 | #endif
31 |
32 | /** \name Symbolic names for connection types
33 | *@{*/
34 | #define HD44780_CT_UNKNOWN 0
35 | #define HD44780_CT_4BIT 1
36 | #define HD44780_CT_8BIT 2
37 | #define HD44780_CT_SERIALLPT 3
38 | #define HD44780_CT_WINAMP 4
39 | #define HD44780_CT_PICANLCD 5
40 | #define HD44780_CT_LCDSERIALIZER 6
41 | #define HD44780_CT_LOS_PANEL 7
42 | #define HD44780_CT_VDR_LCD 8
43 | #define HD44780_CT_VDR_WAKEUP 9
44 | #define HD44780_CT_PERTELIAN 10
45 | #define HD44780_CT_LIS2 11
46 | #define HD44780_CT_MPLAY 12
47 | #define HD44780_CT_BWCTUSB 13
48 | #define HD44780_CT_LCD2USB 14
49 | #define HD44780_CT_FTDI 15
50 | #define HD44780_CT_I2C 16
51 | #define HD44780_CT_ETHLCD 17
52 | #define HD44780_CT_USS720 18
53 | #define HD44780_CT_USBLCD 19
54 | #define HD44780_CT_USBTINY 20
55 | #define HD44780_CT_USB4ALL 21
56 | #define HD44780_CT_RASPBERRYPI 22
57 | #define HD44780_CT_PIPLATE 23
58 | #define HD44780_CT_SPI 24
59 | #define HD44780_CT_PIFACECAD 25
60 | /**@}*/
61 |
62 | /** \name Symbolic names for interface types
63 | *@{*/
64 | #define IF_TYPE_UNKNOWN 0
65 | #define IF_TYPE_PARPORT 1
66 | #define IF_TYPE_SERIAL 2
67 | #define IF_TYPE_USB 3
68 | #define IF_TYPE_I2C 4
69 | #define IF_TYPE_TCP 5
70 | #define IF_TYPE_SPI 6
71 | /**@}*/
72 |
73 | /** \name Symbolic default values
74 | *@{*/
75 | #define DEFAULT_CONTRAST 800
76 | #define DEFAULT_BRIGHTNESS 800
77 | #define DEFAULT_OFFBRIGHTNESS 300
78 | /**@}*/
79 |
80 | /** \name Maximum sizes of the keypad
81 | *@{*/
82 | /* DO NOT CHANGE THESE VALUES, unless you change the functions too! */
83 | #define KEYPAD_MAXX 5
84 | #define KEYPAD_MAXY 11
85 | /**@}*/
86 |
87 | /** number of custom characters */
88 | #define NUM_CCs 8
89 |
90 | /**
91 | * One entry of the custom character cache consists of 8 bytes of cache data
92 | * and a clean flag.
93 | */
94 | typedef struct cgram_cache {
95 | unsigned char cache[LCD_DEFAULT_CELLHEIGHT];
96 | int clean;
97 | } CGram;
98 |
99 |
100 | /**
101 | * Provides necessary data to initialize a connection type (sub-driver).
102 | */
103 | typedef struct ConnectionMapping {
104 | /** Name (string) of connection type as used in LCDd.conf */
105 | char *name;
106 | /** Registered number of connection type, see above */
107 | int connectiontype;
108 | /** Numeric type (serial, parallel, etc), see above */
109 | int if_type;
110 | /** Pointer to connection type's initialization function */
111 | int (*init_fn) (Driver *drvthis);
112 | } ConnectionMapping;
113 |
114 |
115 | /**
116 | * Transmit buffer. This structure provides a generic transmit buffer for
117 | * collecting command or data bytes before sending them to the display. The
118 | * connection driver is responsible for allocating memory and resetting
119 | * \c use_count. \c type may also be driver dependent.
120 | */
121 | typedef struct tx_buffer_t {
122 | unsigned char *buffer; /**< Pointer to buffer */
123 | int type; /**< Data or Command indicator */
124 | int use_count; /**< Number of currently used bytes */
125 | } tx_buffer;
126 |
127 |
128 | /** private data for the \c hd44780 driver */
129 | typedef struct hd44780_private_data {
130 | /* parallel connection types */
131 | unsigned int port; /**< parallel port */
132 |
133 | /* serial connection types */
134 | int fd; /**< file handle to serial device */
135 | int serial_type; /**< type of device for hd44780-serial */
136 |
137 | #ifdef HAVE_LIBUSB
138 | /* libusb-based connection types */
139 | usb_dev_handle *usbHandle; /**< USB device handle */
140 | int usbIndex; /**< USB interface index */
141 | int usbMode; /**< USB write mode (bulk or interrupt)*/
142 | int usbEpOut; /**< USB Endpoint Out */
143 | int usbEpIn; /**< USB Endpoint In */
144 | tx_buffer rx_buf; /**< Input buffer */
145 | #endif
146 |
147 | #ifdef HAVE_LIBFTDI
148 | /* libftdi-based connection types */
149 | struct ftdi_context ftdic, ftdic2;
150 |
151 | int ftdi_mode;
152 | int ftdi_line_RS;
153 | int ftdi_line_RW;
154 | int ftdi_line_EN;
155 | int ftdi_line_backlight;
156 | #endif
157 |
158 | #ifdef HAVE_I2C
159 | /* libi2c-based connection types */
160 |
161 | int i2c_backlight_invert;
162 | int i2c_line_RS;
163 | int i2c_line_RW;
164 | int i2c_line_EN;
165 | int i2c_line_BL;
166 | int i2c_line_D4;
167 | int i2c_line_D5;
168 | int i2c_line_D6;
169 | int i2c_line_D7;
170 |
171 | #endif
172 |
173 | #ifdef WITH_ETHLCD
174 | int sock; /**< socket for TCP devices */
175 | #endif
176 | #ifdef WITH_RASPBERRYPI
177 | struct rpi_gpio_map *rpi_gpio; /**< GPIO pin mapping for Raspberry Pi */
178 | #endif
179 |
180 | int charmap; /**< index of currently used charmap */
181 |
182 | int width, height; /**< size of display (characters) */
183 | int cellwidth, cellheight; /**< size a one cell (pixels) */
184 |
185 | unsigned char *framebuf; /**< the framebuffer */
186 | unsigned char *backingstore; /**< buffer for incremental updates */
187 |
188 | CGram cc[NUM_CCs]; /**< the custom character cache */
189 | CGmode ccmode; /**< character mode of the current screen */
190 |
191 | /* Connection type data */
192 | int connectiontype;
193 | struct hwDependentFns *hd44780_functions;
194 |
195 | /** \name Screens spanning several display
196 | *@{*/
197 | /**
198 | * \c spanlist is an array which stores the number of the display a
199 | * line is shown own. (disp=spanList[line])
200 | */
201 | int *spanList;
202 | int numLines; /**< total number of lines for screen */
203 |
204 | /**
205 | * \c dispVOffset is an array that stores for each display its offset
206 | * aka start line within the (virtual) screen. Use this to determine
207 | * the vertical positioning on a given display.
208 | */
209 | int *dispVOffset;
210 | int numDisplays; /**< total number of displays */
211 |
212 | /** Array storing the vertical size of each display. */
213 | int *dispSizes;
214 | /**@}*/
215 |
216 | /** \name Display features
217 | *@{*/
218 | char have_keypad;
219 | char have_backlight;
220 | char have_output;
221 | /**@}*/
222 |
223 | char ext_mode; /**< use extended mode on some weird controllers */
224 | int line_address; /**< address of the next line in extended mode */
225 |
226 | int delayMult; /**< Delay multiplier for slow displays */
227 | char delayBus; /**< Delay if data is sent too fast over LPT port */
228 |
229 | /**
230 | * lastline controls the use of the last line, if pixel addressable
231 | * (true, default) or underline effect (false). To avoid the
232 | * underline effect, last line is always zeroed for whatever
233 | * redefined character.
234 | */
235 | char lastline;
236 |
237 | /** \name Keypad
238 | *@{*/
239 | /**
240 | * keyMapDirect contains an array of strings (ASCII-codes) that
241 | * should be generated when a directly connected key is pressed (not
242 | * in matrix).
243 | */
244 | char *keyMapDirect[KEYPAD_MAXX];
245 |
246 | /**
247 | * keyMapMatrix contains an array with arrays of strings
248 | * (ASCII-codes) that should be generated when a key in the matrix is
249 | * pressed.
250 | */
251 | char *keyMapMatrix[KEYPAD_MAXY][KEYPAD_MAXX];
252 |
253 | char *pressed_key; /**< The last pressed key */
254 | int pressed_key_repetitions; /**< Number of repeated key presses */
255 | struct timeval pressed_key_time;/**< Time the key was pressed first */
256 | int stuckinputs; /**< Value on the parallel port input if no keys are pressed */
257 | /**@}*/
258 |
259 | int backlight_bit; /**< shorthand for the value of the BL bit if it is set */
260 |
261 | /** \name Forced screen updates
262 | *@{*/
263 | time_t nextrefresh; /**< Time when the next refresh is due. */
264 | int refreshdisplay; /**< Seconds after which a complete display update is forced. */
265 | /**@}*/
266 |
267 | /** \name Keepalive
268 | *@{*/
269 | time_t nextkeepalive; /**< Time the next keep-alive is due. */
270 | int keepalivedisplay; /**< Refresh upper left char every \c keepalivedisplay seconds. */
271 | /**@}*/
272 |
273 | int output_state; /**< most recently output to the output port */
274 |
275 | /** \name Contrast and brightness
276 | *@{*/
277 | int contrast; /**< Contrast value (range 0 - 1000) */
278 | int brightness; /**< Brightness when backlight is "on" (range 0 - 1000) */
279 | int offbrightness; /**< Brightness when backlight is "off" (range 0 - 1000) */
280 | int backlightstate; /**< Saves the last backlight state (on/off) */
281 | /**@}*/
282 |
283 | /** Output buffer to collect command or data bytes */
284 | tx_buffer tx_buf;
285 | } PrivateData;
286 |
287 |
288 | /** Structure holding pointers to HD44780 specific functions */
289 | typedef struct hwDependentFns {
290 | /** Wait for some micro seconds.
291 | * \param p pointer to private date structure
292 | * \param usecs micro seconds to wait
293 | */
294 | void (*uPause) (PrivateData *p, int usecs);
295 |
296 | /** \name Report and debug helper: set by global hd44780 init */
297 | /**@{*/
298 | void (*drv_report) (const int level, const char *format,... /* args */ );
299 | void (*drv_debug) (const int level, const char *format,... /* args */ );
300 | /**@}*/
301 |
302 | /** Send a single byte of data to the LCD.
303 | * \param p pointer to private date structure
304 | * \param dispID display to send data to (0 = all displays)
305 | * \param flags data or instruction command (RS_DATA | RS_INSTR)
306 | * \param ch character to display or instruction value
307 | */
308 | void (*senddata) (PrivateData *p, unsigned char dispID, unsigned char flags, unsigned char ch);
309 |
310 | /**
311 | * Flush data to the display. To be used by sub-drivers that queue from
312 | * senddata internally.
313 | */
314 | void (*flush) (PrivateData *p);
315 |
316 | /** Switch the backlight on or off
317 | * \param p pointer to private date structure
318 | * \param state to be or not to be on
319 | */
320 | void (*backlight) (PrivateData *p, unsigned char state);
321 |
322 | /** Set the contrast
323 | * \param p pointer to private date structure
324 | * \param value new value to be set
325 | */
326 | void (*set_contrast) (PrivateData *p, unsigned char value);
327 |
328 | /** Read the keypad
329 | * \param p pointer to private date structure
330 | * \param Ydata Up to 11 bits that should be put on the Y side
331 | * of the matrix.
332 | * \return Up to 5 bits that are read out on the X side of the matrix.
333 | */
334 | unsigned char (*readkeypad) (PrivateData *p, unsigned int Ydata);
335 |
336 | /** Scan the keypad and return a scancode.
337 | * \param p pointer to private date structure
338 | * \return Y-value in the high nibble and X-value in the low nibble.
339 | *
340 | * \note A sub-driver should either implement \c readkeypad or
341 | * override \c scankeypad.
342 | */
343 | unsigned char (*scankeypad) (PrivateData *p);
344 |
345 | /** Output "data" to output latch if there is one.
346 | * \param p pointer to private date structure
347 | * \param data Value to put on the output latch (up to 32 bit)
348 | */
349 | void (*output) (PrivateData *p, int data);
350 |
351 | /** Close the interface on shutdown */
352 | void (*close) (PrivateData *p);
353 | } HD44780_functions;
354 |
355 |
356 | /* Prototypes */
357 | void common_init(PrivateData *p, unsigned char if_bit);
358 |
359 |
360 | /* commands for senddata */
361 | #define RS_DATA 0x00
362 | #define RS_INSTR 0x01
363 |
364 | /** \name ---------------- The HD44780 Instruction Set -------------------- */
365 | /**@{*/
366 | /*
367 | * The instruction set below is for the original HD44780 and compatibel and
368 | * those that support extended function registers (like the KS0073). For
369 | * extended function registers two instruction sets exist but we assume
370 | * "instruction set 2" below.
371 | *
372 | * Note: RE=0 means EXTREG bit has not been set, RE=1 means EXTREG has been
373 | * set. The term 'RE' is used in the datasheets so I use it here as well.
374 | */
375 |
376 | /** Clear display */
377 | #define CLEAR 0x01
378 |
379 | /** Return home */
380 | #define HOMECURSOR 0x02
381 |
382 | /** Entry mode set */
383 | #define ENTRYMODE 0x04
384 | #define E_MOVERIGHT 0x02
385 | #define E_MOVELEFT 0x00
386 | #define EDGESCROLL 0x01
387 | #define NOSCROLL 0x00
388 |
389 | /** Display on/off control (RE=0) */
390 | #define ONOFFCTRL 0x08
391 | #define DISPON 0x04
392 | #define DISPOFF 0x00
393 | #define CURSORON 0x02
394 | #define CURSOROFF 0x00
395 | #define CURSORBLINK 0x01
396 | #define CURSORNOBLINK 0x00
397 |
398 | /** Extended function set (RE=1) */
399 | #define EXTMODESET 0x08
400 | #define FONT6WIDE 0x04
401 | #define FONT5WIDE 0x00
402 | #define INVCURSOR 0x02
403 | #define FOURLINE 0x01 /**< If not set, ONELINE or TWOLINE is used */
404 |
405 | /** Cursor or display shift (RE=0) */
406 | #define CURSORSHIFT 0x10
407 | #define SCROLLDISP 0x08
408 | #define MOVECURSOR 0x00
409 | #define MOVERIGHT 0x04
410 | #define MOVELEFT 0x00
411 |
412 | /** Shift or scroll enable (RE=1) */
413 | #define HSCROLLEN 0x10
414 |
415 | /** Function set (RE=0) */
416 | #define FUNCSET 0x20
417 | #define IF_8BIT 0x10
418 | #define IF_4BIT 0x00
419 | #define TWOLINE 0x08
420 | #define ONELINE 0x00
421 | #define LARGECHAR 0x04 /**< 5x11 characters */
422 | #define SMALLCHAR 0x00 /**< 5x8 characters */
423 | #define EXTREG 0x04 /**< Select ext. registers (Yes, the same bits) */
424 | #define SEGBLINK 0x02 /**< CGRAM/SEGRAM blink, only if RE=1 */
425 |
426 | /** Set CGRAM address (RE=0) */
427 | #define SETCHAR 0x40
428 |
429 | /** Set SEGRAM address (RE=1) */
430 | #define SETSEG 0x40
431 |
432 | /** Set DDRAM address (RE=0) */
433 | #define POSITION 0x80
434 |
435 | /** Set scroll quantity (RE=1) */
436 | #define HSCROLLAMOUNT 0x80
437 |
438 | /** Default Lineaddress in 4 line mode (RE=1) */
439 | #define LADDR 0x20
440 |
441 | /**@}*/
442 | #endif
443 |
--------------------------------------------------------------------------------