wolframore:
what's autodiscovery? wow you guys have fancy libraries. 
I don't use that term, at least not in the way Paul__B has used it, in reference to the pin mappings.
The hd44780 library uses the term "auto discovery" in reference to the i2c address not the pin mappings.
for the pin mappings it will use terms like "auto detection", "auto configuration", or "self configuration".
(i2c address of the device and the pin mapping configuration are distinctly separate things)
more below
If you look at my post #11, it explains that a library must know 3 things when controlling an LCD using a PCF8574 based backpack.
- I2C address
- how the eight PCF8574 i/o pins are wired up to the LCD and the backlight control circuit
- the active level of the PCF8574 output pin connected to the backlight circuit needed to turn the backlight on.
If that information is incorrect, the LCD device will not work properly.
This is touched on in the hd44780 included documenation and the wiki:
The library you are using requires that all the information be configured manually through the constructor:
LiquidCrystal_I2C lcd(0x3F,2,1,0,4,5,6,7,3,POSITIVE);
While not particularly difficult to determine, get any of those wrong and it won't work.
The popular LiquidCrystal_I2C library which is available through the IDE library manager is simpler:
LiquidCrystal_I2C lcd(0x3F,16, 2);
But the reason it is simpler is the other 9 configuration parameters are hard coded.
That may or may not work with your particular backpack.
The hd44780_I2Cexp i/o class has the ability to determine the i2c address and figure the pin mappings for you.
Discovering the i2c address is easy. (auto i2c address discovery)
The library simply looks through the i2c addresses of the 16 known PCF8574 address until it finds one. It is a little more complicated than that as more than one lcd can be used.
The real magic and tough part is figuring out the other 9 parameters. (auto configuration or self configuration)
The probing is actually more involved and even more tricky than what Paul__B has outlined.
There are actually 2 parts to the auto configuration
- determining the pin mappings between the PCF8574 and the LCD and the backlight circuit
- determining the backlight circuit pin active level needed to turn on the backlight
While the actual final code itself to do this is pretty small and not very complicated,
determining the pin mappings is actually pretty complicated, it involves knowing intimate details of how the PCF8574 i/o pins work along with the LCD pins (data and control pins) and how they work & behave when driven and/or read.
It is more than just playing with the r/w pin.
Determining the active level is actually strait forward once you take into consideration how the PCF8574 i/o pin works and how it interacts with the waste leakage current through the transistor.
But depending on the backlight circuit design is not possible to detect the backlight active level 100% of the time because there are a few different designs that all look / behave the same way but use different active levels.
There are two cases (they are separate and different) where the active level will be incorrectly determined:
- A poor/bad backlight circuit design
There are some bakpacks that have improperly wired up the transistor. It "works" but not really..... as it isn't properly using the transistor.
- an FET is used.
There are few backpack that use an FET. While this is actually a better design than using a transistor, it is not possible to detect and/or differentiate this from the transistor design that requires a different active level.
In either of these cases of backpack design, the auto detection logic will get the active level backwards.
The library is still able to talk to the LCD, as pin mapping are still likely to have been determined correctly.
It is just that the backlight is in the wrong state so the backlight will off by default and will turn on only when commanded to turn off.
This can make the LCD appear to be dead if it is an LCD that has white text on a dark background.
The auto configuration code is the result of me believing for a couple of years that it could be done, then finally sitting down and carefully analyzing things for a few weeks and testing on many different backpack designs to get it all working reliably.
--- bill