[Lcdproc] I2C-LCD with 2 enable lines

Stefan Herdler herdler@gmx.de
Wed Nov 15 20:32:02 2006


Hi,
Carsten Tschense wrote:
> 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... ;)
>   
At the first glance looks almost like what I would have tried.

I'm not an HD44780-expert but doesn't showing the "initial HD44780 
message" mean the init() function has been completed successfully?
So the i2c_HD44780_senddata() has to be o.k. too (at least if the 
displayID is 0).
> Suggestions?
>
>   
- Compile with debug information  (./configure --enable-debug ), run in 
foreground and post the output of LCDd.


cheers
Stefan