New LiquidCrystal library - LCD library

fm,
I think some of the confusion/mis-interpretation could be coming from the wiki home page:
https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home
The examples on that page do not show using the backlight support functions in the library.
They use standard arduino core calls to control arduino pins for backlight control.
Also, the other i2c backpacks out there are wired differently than EXTRAIO
(I've seen 3 different pin wirings - all different from EXTRAIO) and when they support
s/w backlight control, they use a 8574 output bit rather than depend on a separate
Arduino pin for backlight control.

As a suggestion, I think what would could help would be a couple of things:

  • update the examples to better show the constructor parameters.
  • update the examples to use the backlight control functions
  • update the constructors to have an overloaded pin parameter for backlight control
    that can specify either a interface pin or a Arduino pin.
    (but so far I haven't seen any other lcd i2c board other than EXTRAIO that would need to
    use an Arduino pin for backlight control)

After seeing all the confusion about constructors not only for things like i2c and SR device layers
but for the standard LiquidCrystal library, I'd recommend using const int parameters
in all the examples to show what the parameters are.
And in the examples, show all the parameters rather than
the simplified constructors like the i2c one with just the address that use the defaults.
i.e. don't show examples that use a builtin/default pin wiring.
I think many users are really struggling with the i2c constructor because they simply
don't realize that even with i2c that there is a pin configuration/wiring that must still
be specified when a hd44780 is hooked up to a PCF8574.

For example here is what it would be for a MJKDZ i2c backpack that I have:
(different wiring than EXTRAIO)

#include <Wire.h>
#include <LiquidCrystal_I2C>
const int i2c_addr = 0x27;
const int i2c_en = 4; // 8574 output bit wired to LCD EN
const int i2c_rw = 5; // 8574 output bit wired to LCD RW
const int i2c_rs = 6; // 8574 output bit wired to LCD RS
const int i2c_d4 = 0; // 8574 output bit wired to LCD D4
const int i2c_d5 = 1; // 8574 output bit wired to LCD D5
const int i2c_d6 = 2; // 8574 output bit wired to LCD D6
const int i2c_d7 = 3; // 8574 output bit wired to LCD D7
const int i2c_bl = 7; // use number for output bit and LCD_ARDIUNO_PIN(arduino_pin#) for arduino pin
const int i2c_blpol = NEGATIVE; // backlight polarity

LiquidCrystal_I2C lcd(i2c_addr, i2c_en, i2c_rw, i2c_rs, i2c_d4, i2c_d5, i2c_d6, i2c_d7, i2c_bl, i2c_blpol);

This allows users to see the parameters as well as easily modify them for their application.

As I outlined in issue #27, it would be useful to also (at least for EXTRAIO) to add in an overload
for the backlight pin/bit parameter and update code to deal with it.
That way users could specify either an interface pin/bit or an Arduino pin for backlight control.
For example, this would be the example for the EXTRAIO board:
[ Assuming an overloading macro of LCD_ARDUINO_PIN() ]

#include <Wire.h>
#include <LiquidCrystal_I2C>
const int i2c_addr = 0x27;
const int i2c_en = 6; // 8574 output bit wired to LCD EN
const int i2c_rw = 5; // 8574 output bit wired to LCD RW
const int i2c_rs = 4; // 8574 output bit wired to LCD RS
const int i2c_d4 = 0; // 8574 output bit wired to LCD D4
const int i2c_d5 = 1; // 8574 output bit wired to LCD D5
const int i2c_d6 = 2; // 8574 output bit wired to LCD D6
const int i2c_d7 = 3; // 8574 output bit wired to LCD D7
const int i2c_bl = LCD_ARDUINO_PIN(13);  // arduino pin 13 for backlight control
const int i2c_blpol = POSITIVE; // backlight polarity

LiquidCrystal_I2C lcd(i2c_addr, i2c_en, i2c_rw, i2c_rs, i2c_d4, i2c_d5, i2c_d6, i2c_d7, i2c_bl, i2c_blpol);

This type of initalization example would also be useful for the other interfaces well.
For example this would be an example for many of the lcd keypads out there.

// Include the Liquid Crystal library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
const int lcd_rs = 8; // Arduino pin wired to LCD RS
const int lcd_en = 9; // Arduino pin wired to LCD EN
const int lcd_d4 = 4; // Arduino pin wired to LCD D4
const int lcd_d5 = 5; // Arduino pin wired to LCD D5
const int lcd_d6 = 6; // Arduino pin wired to LCD D6
const int lcd_d7 = 7; // Arduino pin wired to LCD D7
const int lcd_bl = 10; // Arduino pin used for backlight control
const int lcd_blpol = POSITIVE; // backlight polarity

#ifdef BACKLIGHT_ON // check for new library being used
LiquidCrystal lcd( lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_bl, lcd_blpol); // new constructor with backlight support
#else
LiquidCrystal lcd( lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7); // old style constructor w/o backlight
#endif

While these examples are a bit verbose, I think they might help users better understand how to modify
the parameters for their device.

I'll be happy to work with you make this happen if you want to move in this direction.
We can discuss off line.

BTW, I'll be getting and adafruit LCD backpack soon.
That board uses a MCP23008 instead of a PCF8574
so I'll be doing a MCP23008 device layer for it.
This is another area of confusion for some users in that some have
PCF8574 based boards, and some have MCP23008 and yet to them it is just "I2C".
Compounding this is the vendors supply libraries called "LiquidCrystal_I2C".
So some LiquidCrystal_I2C libraries out there are not for PCF8574 based chips.
My plan is to create a MCP23008 i2c device layer I'm just not sure what to call it.
Any suggestions?