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
+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);
}
}
}