hd44780/ftdi: Fix a bug in ftdi_HD44780_backlight() and add backlight

switching capability for 4bit mode. Document the different BL line level
and a small switching circuit for it.
This commit is contained in:
mmdolze
2012-01-02 09:22:30 +00:00
parent 6336c6c99e
commit 69a6f74c76
3 changed files with 61 additions and 7 deletions
+1
View File
@@ -23,6 +23,7 @@ v0.5dev (ongoing development)
* picolcd: Use libusb-1.0 asynchronous transfers to fix missed keys (M. Jones)
* sed1520: Make it work without using an external inverter
* lis driver: Make the last pixel row work (add lastline option parsing)
* hd44780/ftdi: Fix error in setting backlight and add backlight for 4bit mode
v0.5.5
+ sed1330 driver: Add support for HG25504 (L. Lagendijk)
+41
View File
@@ -1872,6 +1872,39 @@ The wiring of the control lines can optionally be reconfigured,
please look at the driver source if you really need that.
</para>
<note><para>
The backlight line is driven high when the backlight is <literal>on</literal>.
Therefore the standard backlight circuit (<xref linkend="hd44780-connections-backlight.circuit"/>)
will not work. Use the following instead.
</para></note>
<figure id="hd44780-ftdi-backlight">
<title>hd44780/ftdi: Backlight Wiring</title>
<screen>
<![CDATA[
O 5V
|
+--------o 15 backlight
+--------o 16 GND backlight
|
small resistor .-.
10 - 47 ohm | |
depending on | |
display '-'
|
|c
___ b |/
BL pin o------------|___|-------------|
4k7 |\
BC547 |e
|
=== GND
]]>
</screen>
</figure>
<para>
Alternatively you can use a single channel FTDI FT245BM USB &lt;-&gt; parallel
FIFO chip and use the display in its 4 bit mode.
@@ -1948,6 +1981,13 @@ FIFO chip and use the display in its 4 bit mode.
<entry>RW</entry>
<entry>5</entry>
</row>
<row>
<entry>D7</entry>
<entry>18</entry>
<entry></entry>
<entry>BL</entry>
<entry>Backlight (optional)</entry>
</row>
</tbody>
</tgroup>
</table>
@@ -1967,6 +2007,7 @@ ftdi_mode=4
ftdi_line_EN=0x10
ftdi_line_RS=0x20
ftdi_line_RW=0x40
ftdi_line_backlight=0x80
]]>
</screen>
</example>
+19 -7
View File
@@ -6,12 +6,13 @@
wiring example:
FTDI chip: D0 D1 D2 D3 D4 D5 D6 D7
| | | | | | | |
HD44780: D4 D5 D6 D7 EN RS RW n/c
HD44780: D4 D5 D6 D7 EN RS RW BL
in LCDd.conf we then need to define
ftdi_line_EN=0x10
ftdi_line_RS=0x20
ftdi_line_RW=0x40
ftdi_line_backlight=0x80
RW of your display can either be connected to D6 or GND.
\endverbatim
@@ -197,8 +198,9 @@ ftdi_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char fla
unsigned char buf[4];
unsigned char portControl = 0;
portControl = 0x00 | p->backlight_bit;
if (flags == RS_DATA) {
portControl = p->ftdi_line_RS;
portControl |= p->ftdi_line_RS;
}
buf[0] = ((ch >> 4) & 0x0F) | portControl | p->ftdi_line_EN;
@@ -228,18 +230,28 @@ ftdi_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char fla
void
ftdi_HD44780_backlight(PrivateData *p, unsigned char state)
{
unsigned char buf[1];
int f;
p->backlight_bit = state ? p->ftdi_line_backlight : 0;
buf[0] = p->backlight_bit;
if (p->ftdi_mode == 8) {
int f;
p->backlight_bit = state ? p->ftdi_line_backlight : 0;
f = ftdi_write_data(&p->ftdic2, &state, 1);
f = ftdi_write_data(&p->ftdic2, buf, 1);
if (f < 0) {
p->hd44780_functions->drv_report(RPT_ERR, "failed to write: %d (%s). Exiting",
f, ftdi_get_error_string(&p->ftdic2));
exit(-1);
}
}
else {
f = ftdi_write_data(&p->ftdic, buf, 1);
if (f < 0) {
p->hd44780_functions->drv_report(RPT_ERR, "failed to write: %d (%s). Exiting",
f, ftdi_get_error_string(&p->ftdic));
exit(-1);
}
}
}