My LCD cursor is not working normally.
I'm using a 16x4 LCD.
The problem is that the first and second lines are well written, but the third and fourth lines
has a blank space on the left.
Im write my code based on correcting this third and fourth line using the lcd.setCursor (-4,2); lcd.setCursor (-4.3) and everything was going fine, until I needed to use the lcd.scrollDisplayRight() function. That's when I saw I was in trouble.
This is the problem with LCD. The third and fourth line using the lcd.setCursor (0,2); lcd.setCursor (0.3) but is writing like lcd.setCursor (4,2); lcd.setCursor (4.3)
I didn't try, as we have more than 1000 libraries available for LCD. I don't know which ones it is. I can't say which driver for my LCD either. I just know my driver is HD44780 because I saw it in the datasheet.
Have you tips for finding a library?
This was a common problem with the Arduino LiquidCrystal library several several years ago but has long since been resolved.
The I2C library that you are using is probably based on one of those ancient versions of the Arduino library. You should really consider switching to Bill Perry's HD44780 library as mentioned previously.
Yes, the LiquidCrystal_I2C library (at least the one in the IDE library manager) is broken for 16x4 displays. There is no way to work around this without fixing the library code.
The hd44780 library does not have this issue.
I will also mention that scrollDisplayRight() may not work the way you think it does.
All this function does is offset the location where lines on the display map to memory so everything on the display (all lines) will shift
It is all but useless on anything but a 1 line display.
I would recommend that you switch to the hd44780 library and use the hd44780_I2Cexp i/o class.
The hd44780 library is actively maintained, is faster and some additional capabilities not found any any other hd44780 type library.
It is available in the IDE library manager, and includes lots of documenation.
If you want to read about it before you install you can start on the hd44780 github page.
--- bill
For the gory details:
Background of LIquidCrystal_I2C library.
The history of the "LiquidCrystal_I2C" library goes back more 10 years to about Sept of 2009.
It was original created by Mario H from the LiquidCrystal library at that point in time.
Remember, back then there was no IDE library manager. You could not even import a library in zip format so the LiquidCrystal_I2C library was copied and posted on many places around the net. And some of those copies have since been modified with updates and minor bug fixes so there are now many "silent" forks out there all with the same name.
6 years ago a guy named Marco Schwartz put a copy he obtained that was last touched by a guy named Frank de Brabander on github to set it up for using the new networked based IDE library manager.
It was definitely an improvement to have it available in the IDE library manager.
Unfortunately Marco didn't have the technical skills to maintain it.
There have been a few updates done since Marco created the github repository but there have also been and are still some issues with the repository - like incorrect tagging for the IDE library manager get some of the fixes. And the code is behind in some updates related to cursor positioning.
The LiquidCrystal_I2C library became such a mess along with what I felt was a need for a "plug and play" solution for these types of LCDs that I created the hd44780 library back in 2016
In late 2018 Marco wanted to re-assign the LiquidCrystal_I2C repository to someone that could properly maintain it.
Marco asked if I would do it, I didn't want to take it on.
Eventually a guy named John Rickman took it over. Which I originally thought would be a good thing as I thought some needed fixes (that were pretty trivial to get resolved) could finally get fixed.
However, that's when, IMO, things went downhill and became much worse for this library.
John, has made a wreck of the library. He first moved the "active" repository over to gitlab and changed the name. This was a deal breaker since it would mean that that the IDE library manager would not longer be able to have access to it.
Then he tried to change the license from LGPL to Apachie.
I stepped in an called him out on it. He finally agreed that he couldn't change the license but his solution was to delete the repository from gitlab.
Unfortunately, Marco ended up handing the github repository over to a person that hijacked it then abandoned it.
At this point Rickman no longer responds to my emails.
So as of right now, there is a LiquidCrystal_I2C library in the IDE library manager but it has issues, is no longer supported, and there is no way to get it updated.
Guys, today I tested this hd44780 library needed above. In fact I no longer need to use
** lcd.SetCursor (-4.2); (-4.3) ** to fix the space problem. But this library has the same error as the previous with the scroll function.
I don't know if is my configuration is the correct, but is working.
If you think the display as shown in the 3rd photo is incorrect then there is a misunderstanding how the limited LCD memory is mapped to the LCD display particularly when combined with the right/left shift instructions.
BTW, I think noasca's sample sketch code is pretty goofy.
I think it makes things even more confusing when certain numbers/characters as skipped.
i.e. why leave out '3's ?
The display shown in the 3 images where you did two shifts is as to be expected given the way the LCD memory is mapped to the display on a 16x4 display.
Like I said the shift right/left instruction capabilities of a hd44780 display are not that useful on displays larger than 1 line.
I would recommend having a read on how the LCD memory addressing/mapping works.
You can find a link to a web page with detailed information on this in the documentation included in the hd44780 library.
Bring up the Documentation sketch in the hd44780 library examples, and in the comments of the sketch, click on the link referenced by:
hd44780 internal RAM addressing:
It will link to a web pages that explains how the hd44780 internal memory is mapped to the physical LCD display for various geometries.
You are free to have your own opinion and believe anything you want; however, in this case, it isn't how the LCD h/w actually works.
Hang on their partner.
I think if YOU read the datasheet, and fully understood it, then you would realize that this is not a library issue/problem but rather an expected behavior given the limitations in the hd44780 chipset h/w.
i.e. the way it is working is exactly as expected given the way the hd44780 h/w works when combined with the hd44780 shift right/left instructions on a 16x4 display.
But the real problem is expecting the LCD to work in a way that is not the way the hardware actually works.
These chipsets were designed more than 40 years ago and have very limited RAM so they can't do what you wanting given that limited RAM.
It isn't so much a problem but rather a misunderstanding as to how the LCD h/w works.
Like I've said a few times, the shift right/left instructions are pretty much unusable on anything but a 1 line display.
I'm trying to make a screen animation program. It's actually a kind of oscilloscope with this type of 16x4 screen.
I tried to use the Scroll tool, but seeing that it doesn't work, I abandoned the idea.
Let me tell you. When I used <LiquidCrystal_I2C.h> The spacing between each lap on the screen was the ratio of 4 empty spaces on the third and fourth lines. In the library "hd44780-master" you indicated for download the number goes up to 6 empty spaces after the first scroll, after the second lap the text goes back to normal and so on.
But I don't deny that this library is much more efficient in relation to not having to use (-4,*) in Set.Cursor, besides being faster than the IDE's native one.
I'm not criticizing the Library, in fact, I would never do that. It's like someone complaining because someone else is helping you, it doesn't make sense
Your 16x4 display only needs 64 bytes of SRAM memory if you want to keep a copy of the image in a buffer.
You can scroll, rotate, or otherwise manipulate the buffer very easily. Then blit the 64 bytes to the LCD in one go.
Controllers like ST7920 can display graphics as well as text.
You can produce more professional images, graphs, text than with a HD44780 character display.
That (hd44780-master) isn't anything anyone recommended.
You should be installing the hd44780 library using the IDE library manager network install capabilities.
I highly recommend that you DO NOT download a zip of the repository and then install it manually or use the zip image install capabiality in the IDE.
There are github zip image structure issues with the Arduino IDE.
Not only is it more work to do your own download but unless you take a few additional steps you will end up with an improperly named directory in your IDE libraries directory which can cause problems when doing updates in the future.
Use the IDE library manager to locate the library and then to automatically do the download and install.
The instructions on the hd44780 github page explain how to install the library using the IDE library manager and even warns against using zip installs unless using a VERY old version of the IDE.
NOTE:
If you end up with a directory name hd44780-master, you did something wrong.
3 The hd44780-master library is more efficient than arduino's native <LiquidCrystal_I2C.h> and fixes the bug of writing 4 columns ahead of the third and fourth lines.
Is possible manipulate the text directly from arduino
Thanks for everything. Don't stress, you're good people but I'm Brazilian and it's difficult to translate because sometimes the text comes out as offensive. I apologize to everyone, I'm new here and I don't want to be arrogant with you who always help me