Go Down

Topic: New Liquid Crystal library vs LiquidCrystal_I2C-1.1.2 (Read 181 times) previous topic - next topic

fluxia

I am learning about LCD menus and adapted some examples from the libraries to work with my LCD 1602.
 I have noticed that in order to use the New Liquid Crystal library instead of the LiquidCrystal_I2C-1.1.2 (this was the first one I used), I have to change the way I initialize the LCD:

instead of:
Code: [Select]
LiquidCrystal_I2C lcd(0x27, 16, 2);

I have to use:
Code: [Select]
#define I2C_ADDR    0x27
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

LiquidCrystal_I2C  lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin); 


and in the setup(), instead of:
Code: [Select]
  lcd.init();                     
  lcd.backlight();


I need to use:
Code: [Select]
  lcd.begin(16, 2);                             
  lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
  lcd.setBacklight(HIGH);


I find it odd that a new library makes things more complicated, so I am sure I am missing something...?

Paul__B

If you are using the I2C version of the library, then you would be using that with a backpack connected to the I2C pins A4 and A5.  And you would be extremely lucky if that worked at all since there are a number of different I2C backpacks which use different wiring and port addresses.  Or did you already realise that?

Your second version specifies all of the important parameters instead of taking a wager that your present backpack actually does match the library default.

You are however advised to forget those older libraries, and use bperrybap, Bill's HD44780 library which can be automatically installed using the library manager in the IDE and has a test program which will figure out all the settings for you.

fluxia

Thank you Paul and yes I am using an I2C  i/o exapander backpack. I have connected it to my arduino uno A4 (SDA) and A5 (SCL) pins. Initially I found it strange that it would work this way but it does, so that puzzled me  a bit. i am only trying out staff to learn.

Thanks for your advice about the HD44780 library, I have downloaded and as you said it is very easy to use: the examples work fine without any change. I have just had a quick look at the documentation and it looks like it support most functions of the liquidcrystal library. I hope that this means I can use my liquidmenu library with it. I will try as soon as I can.

fluxia

It appears that the liquid menu library is not working with the hd44780 library...

when I call

Code: [Select]
LiquidMenu menu(lcd);

I get an error: no matching function for call to 'LiquidMenu::LiquidMenu(hd44780_I2Cexp&)'

the syntax for this function is :

LiquidMenu::LiquidMenu   (   DisplayClass &    liquidCrystal, uint8_t    startingScreen = 1 )   

Parameters
&liquidCrystal   - pointer to the DisplayClass object
startingScreen   - the number of the screen that will be shown first

I had previously declared the LCD object
Code: [Select]
hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip

fluxia

Since I have not been able to use the liquid menu library with the hd44780 library I wanted to ask if anyone can recommend a menu library that would work with the hd44780.


bperrybap

Unfortunately, that library makes some assumptions about i/o classes and uses a config file rather than auto detect or polymorphism to automate things.
You will need to go in an edit LiquidMenu.h to use the hd44780 header files and object class name.
i.e.: at line 52
Code: [Select]

#if I2C
#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>
#define DisplayClass hd44780_I2Cexp



--- bill

Go Up