[Lcdproc] I2C-LCD with 2 enable lines

Carsten Tschense carsten@michaeli-gymnasium.de
Mon Nov 13 17:14:02 2006


Hi,
I already tried modifying the code and I ended up with this, which
displays the initial HD44780-message and then crashes:

--- lcdproc-0.5.0/server/drivers/hd44780-i2c.c.old      2006-04-07
16:54:29.000000000 +0200
+++ lcdproc-0.5.0/server/drivers/hd44780-i2c.c  2006-11-13
15:50:37.000000000 +0100
@@ -72,12 +72,12 @@
 // HD44780_readkeypad

 void i2c_HD44780_senddata (PrivateData *p, unsigned char displayID,
unsigned char flags, unsigned char ch);
-void i2c_HD44780_backlight (PrivateData *p, unsigned char state);
+// void i2c_HD44780_backlight (PrivateData *p, unsigned char state);

 #define RS     0x10
 #define RW     0x20
-#define EN     0x40
-#define BL     0x80
+#define EN1    0x40
+#define EN2    0x80
 // note that the above bits are all meant for the data port of PCF8574

 #define I2C_ADDR_MASK 0x7f
@@ -113,9 +113,9 @@
        PrivateData *p = (PrivateData*) drvthis->private_data;
        HD44780_functions *hd44780_functions = p->hd44780_functions;

-       int enableLines = EN;
+       int enableLines = EN1 | EN2;
        char device[256] = DEFAULT_DEVICE;
-       p->backlight_bit = BL;
+       // p->backlight_bit = BL;

        /* READ CONFIG FILE */

@@ -154,7 +154,7 @@
        }

        hd44780_functions->senddata = i2c_HD44780_senddata;
-       hd44780_functions->backlight = i2c_HD44780_backlight;
+       hd44780_functions->backlight = NULL;
        hd44780_functions->scankeypad = NULL;

        // powerup the lcd now
@@ -221,9 +221,11 @@
        else //if (flags == RS_DATA)
                portControl = RS;

-       portControl |= p->backlight_bit;
-
-       enableLines = EN;
+       //portControl |= p->backlight_bit;
+
+       enableLines = EN1;
+       if (displayID == 0) enableLines = EN1 | EN2;
+               else if (displayID == 2) enableLines = EN2;

        i2c_out(p, portControl | h);
        if (p->delayBus)
@@ -242,9 +244,9 @@
        i2c_out(p, portControl | l);
 }

-void i2c_HD44780_backlight (PrivateData *p, unsigned char state)
+/*void i2c_HD44780_backlight (PrivateData *p, unsigned char state)
 {
        p->backlight_bit = ((!p->have_backlight||state) ? 0 : BL);

        i2c_out(p, p->backlight_bit);
-}
+}*/

Please don't laugh at me, I'm not saying I can code C... ;)
Suggestions?


Carsten

Markus Dolze schrieb:
> Hell again,
>
> I had a look at the i2c and winamp wiring driver. The part that distributes the data to the two controllers is in the hd44780 driver itself, not in the wiring driver.
>
> The i2c does only use one enable line. If you connect the display's second enable line to P7 pin on the part extender (without the connection to VCC of course!), you may modify the i2c_HD44780_senddata to use the DisplayID to talk to different controllers similar like the winamp wiring driver does.
>
> Regards
> Markus
>