Go Down

Topic: 'POSITIVE' was not declared in this scope error LCD Display 2004a (Read 5265 times) previous topic - next topic

ZinggJM

No that is not your main error.
You main error is what I said in post #7

I gave you everything you need to get something up and working in post #7.
It comes down to 3 basic options:
- Switch to using the LiquidCrystal_I2C library that is available in the IDE library manger
This library may or may not work with your backpack, even if you tell it your correct i2c address.

- Install fm's newLiquidCrystal properly.
You must read the instructions for installation as using the zip import isn't the proper way to install it.
https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home
Then you must make sure that the i2c address and pin mappings you put in the constructor are correct.
If you get any of that information incorrect, it will not work.

- Install my hd44780 library using the IDE library manager.
You can be up and running in literally less than 1 minute.
It figures out all the i2c and pin configuration information for you.
It even includes a diagnostic sketch to help detect issues.


The choice is obviously yours, but if you want the easiest and quickest way to get the LCD & backpack up and working, I'd suggest that you take the advice I offered back in post #7.

--- bill

Hello Bill

I took my 2004A out of the storage drawer it was waiting to be used, to try to get experience with.
I had used a I2C 2x16 LCD some time ago, with the LiquidCrystal_I2C library.
I had used I2C_scan then, so my start was easy.

The Hello Word example of LiquidCrystal_I2C runs fine, with the parameters 0x27,20,4.

Then I wanted to try an example of hd44780. I had installed the library previously, and it is kept up to date. But no "Hello World" to start with. Which example should I start with?

I tried some, but it complained about missing configuration. I might surely find out, but reporting here is easier.

Maybe a separate forum section should be dedicated to LCDs. My focus was on EPDs and TFTs so far.
I did not guess that the "section for LDC" is the whole Arduino Displays section.

Jean-Marc
No personal message please; any question may be useful for other users. Use code tags for code. Make links clickable with URL tags. Provide links to the product in question.

ZinggJM

Aha, I found an example to take:

C:\Users\...\Documents\Arduino\libraries\hd44780\examples\OtherLibraries\LiquidCrystal_I2C\hd44780examples\LCDlibTest

this was not obvious for me.

The moving graphics bar graph even looks like colored, but this seems to be an artifact.

Jean-Marc
No personal message please; any question may be useful for other users. Use code tags for code. Make links clickable with URL tags. Provide links to the product in question.

bperrybap

Aha, I found an example to take:

C:\Users\...\Documents\Arduino\libraries\hd44780\examples\OtherLibraries\LiquidCrystal_I2C\hd44780examples\LCDlibTest

this was not obvious for me.

While that is "an example" it is the wrong example if you want to try the hd44780 hd44780_I2Cexp i/o class.
That example is using the LiquidCrystal_I2C library not the hd44780 library and the  hd44780_I2Cexp i/o class.
You should read the information & documentation on the github repository.
There are many readme files that describe the examples.
They automatically come up in the browser as you click down into the various example directories in the repository.

If you want to try/test the hd44780 library on your backpack, you need to run examples for the hd44780_I2Cexp i/o class.

And the first example to run is the I2CexpDiag sketch which runs a full diagnostic on the i2c bus and the LCD memory.

--- bill

cowpunch

This worked for me:

It's actually a very common error reported here. A bit of searching never hurts. I believe you're the second to report it this week.

I suspect the problem is you're using the wrong library. There are multiple libraries named "LiquidCrystal_I2C". Luckily for you the URL of the correct library is right there in the comments. So try this:

If you still have an error then do this:

When you encounter an error you'll see a button on the right side of the orange bar "Copy error messages". Click that button. Paste the error in a message here using code tags.

enjoyneering

try to use my library. it's much faster than others - https://github.com/enjoyneering/LiquidCrystal_I2C

bperrybap

try to use my library. it's much faster than others - https://github.com/enjoyneering/LiquidCrystal_I2C
It isn't faster from what I've seen.
From my testing your library is quite a bit slower than others.

When using a 16Mhz  AVR board like an UNO and the default 100kHz i2c clock:

The IDE bundled LiquidCrystal_I2C library v1.1.2 transfers a byte to the LCD display in 1455us
My hd44780 library v0.9.4 (hd44780_I2Cexp i/o class) transfers a byte to the LCD display in 549us

You LiquidCrystal_I2C library v1.2.0 transfers a byte to the LCD display in 7381us

Your library is 5x slower than the IDE bundled LiquidCrystal_I2C library
and is a bit over 13x slower than my hd44780 library using the hd44780_I2Cexp i/o class.

That is quite a bit slower than other libraries.

--- bill

enjoyneering

Wow. You've made quite a library. Challenge accepted. :) I'll try to make my faster.

floresta

Haven't you guys heard about 'alternative facts'?  

Don

bperrybap

Haven't you guys heard about 'alternative facts'? 
Sure. Not sure I understand the reference here.

Perhaps a reference to the claim made in post #19 that was obviously false.....

--- bill

enjoyneering

Tweaked my library. Time to transfers a byte to the LCD:


- my LiquidCrystal_I2C v1.2.1 does it in 1088us, ATmega328 16MHz,  i2c 100KHz
                                                                       902us,   STM32          72MHz,  i2c 100KHz
                                                                       854us,   ESP8266       80MHz, i2c 100KHz

- Bill's hd44780 v0.9.4                              552us,   ATmega328 16MHz,   i2c 100KHz


But my code uses less global memory 436 bytes vs 477 bytes.

I've used my sketch SpeedTest.ino to test both libraries

So far my library 1.3x times faster than IDE bundled LiquidCrystal_I2C library v1.1.2, but still 1.97x times slower then Bill's.

I have not yet gave-up. Stay tuned.

enjoyneering

Hi,

Manged to get 1056us from LiquidCrystal_I2C v1.2.2 , ATmega328 16MHz, i2c 100KHz

Bill's hd44780 v1.0.0  ~500us,  ATmega328 16MHz, i2c 100KHz

But my code uses 5010 byte of storage & 456 bytes of dynamic memory.
Bill's code uses 6924 byte of storage & 540 bytes dynamic memory.


I've used my sketch SpeedTest.ino to test both libraries.

enjoyneering

Hi.

The further speed improving uses a lot of memory. So I decided to stop. Bill won. His memory monster is the fastest.

bperrybap

Hi.

The further speed improving uses a lot of memory. So I decided to stop. Bill won. His memory monster is the fastest.
Just as an FYI, the hd44780 library and i/o classes have not been optimized yet.
I have looked closely enough to know know of many  areas that can be optimized but wanted to wait until after the 1.0 release.
Two main things cause the hd44780_I2Cexp code to be larger than other implementations. Auto detection and virtual functions.
The recent versions of the gnu compiler removed the ability to have the linker remove virtual functions that are never referenced.
I know how to work around this but it is a big effort.
This will reduce the code by about 1.5 to 1.8k for simple/small sketches that don't reference some of the more advanced capabilities such as reads from the LCD.
virtual functions also consume RAM. That RAM will also be freed up in the new library design.
My plan is to put this in a future 2.x release that uses C++ templates rather than C++ virtual functions to avoid the virtual function overhead.
Once that is done, the hd44780 code will be smaller and faster and use less RAM than it currently does so its flash and RAM usage should be closer to other implementations. And if not using auto detection, it should be close to parity.

--- bill

Go Up