I am not newbie but having a problem with part of my project.
Part of project needs long text to be scrolled between margins, with delay of one second.
Tried with LiquuidCrystal commands but no progress.
I made something but it is interestly large (22% on UNO) and wondering is there some other approach or is there some way to minimize memory allocation?
@Eric_Baas, thank you for replying but scrollDisplayleft scrolling Display and everything on LCD left and right which isnt acceptable. It needs to move only one line.
@Paul__B... Will check in the morning.
This what I wrote is working but 22% of memory...?!?! And on second loop when text needs to move left to right, last character prints in right-to-left direction before anything in second loop. Make me very angry because of this.
Thanx all for reading...
Go on. 16x2 is pretty small. You can just manipulate the text in an SRAM buffer. Then print the buffer in the normal way.
Yes, the hardware can scroll left and right quite nicely for both lines on a 16x2
It does not work so well on a 20x4
There is no way for the hardware to scroll a single line.
I am sure that you can do your SRAM manipulations with String methods. But String methods make my head hurt.
@David... I am not familiar that hard with sram and string. My project is fairly simple like what you have saw...
Can you please suggest some example?
And is there solution gor my code to need less memory?
Thank you.
If you have a buffer that is big enough to hold the long message e.g.
char buf[40]; //big enough
strcpy(buf, " Loading with transporter inside");
for (int i = 0; i < 16; i++) {
lcd.setCursor(0, 1); //print on second line
lcd.print(buf + i); //start printing at different point in the message
delay(1000); //so we see it happen slowly.
}
Yes, it is always going to cost you SRAM memory for the buffer. But you can use PSTR() to keep any fixed messages in Flash. Then use strcpy_P() to copy to your buffer.
And of course you can put the scroll_one_line_left() as a generalised function. i.e. use it for any message of any length and any pixel position.
I am sure that the hd44780 library has examples that move stuff around the screen in software. I suggest that you run every hd44780 library example. See what tips you might pick up.
Other than being easier to configure and a bit faster to get the characters to the display, the hd44780 library won't help for this type of application.
Horizontal shifting must all be done in the application when using a 20x4 display since all the RAM is mapped to characters on the display.