Scrolling Text on Ringo Display

I can easily program the Arduino 16x2 LCD to scroll text, but can’t figure out the mp.function() to scroll text on the 160x128 Ringo display.

I can display text with my choice of text size, text font, and color. I can also put the text anywhere I want on the display, but after trying a bunch of Arduino/c/c++ coding approaches, I can’t get text to scroll on the Ringo display.

Help please. Stuck in the house trying to stay well. Hope all you people are doing the same. Stay safe.

Hey Kent,

Glad to see you’re doing some interesting things during these hard times! :slight_smile:

What type of scrolling do you really want? Do you want something like when you get a really long message so that you can scroll your screen using the joystick or do you want to have autoscroll?

Ringo library doesn’t have the function to scroll. That scrolling motion you can see in different apps (messages, phone…) has been written for those specific apps.
I would suggest going through some of those apps codes to get a better understanding on how it works.

Apps’ source codes can be found here.

If you get stuck in the code (which is really easy because the code itself is not simple) contact me with the little more specific questions so we’ll sort it all out. :smiley:

Cheers,
Robert

Thank you Robert. Now I don’t feel like so much of a dummy. I am looking for an mp. function like lcd.autoscroll(); or lcd.scrollDisplayLeft(); From what you say those functions are not available.

I will look through the apps. code, and I am sure that I will get lost, but that is OK because I will learn a little more.

Look at this program:

https://community.circuitmess.com/t/heres-one-for-the-mathematically-curious-not-a-game/3062/9

Specifically look near the end inside the print loop where mp.display.scroll() is called. Smooth scrolling is a tad too slow, but scrolling text up a line at a time works fine. The text is not saved, so it’s not possible to scroll backward, but at least it will give you an idea.

Don’t forget mp.display.pushSprite() to render the display to the lcd screen.

Thanks Frank. I will give those a look.

Frank, I remember playing with your Pi program and getting a vertical scroll. I am working with it again, at your suggestion, and with a big 1 second delay, I got the CircuitMess -Ringo logon (from mp.begin(1):wink: to slowly scroll horizontally off screen to the left. Now I need to get your code further modified to let me scroll my own line of text horizontally starting at the LCD column and row that I designate. For my needs, I should probably use smooth scrolling instead of a delay, since I want slow. Making progress. Much Thanks.

Frank, I got rid of the logo by switching to mp.begin(0); and was able to get my word to scroll like I want, and in the text size and font that I want. Still don’t have the text in the position on the screen that I want, but I am ninety percent there. I will be able to fix the positioning if I understand the arguments for:

mp.display.pushSprite(10, 10);
mp.display.scroll(10);
mp.display.setCursor(0, mp.display.height() -8);

Hopefully these functions are close to C/C++ functions and I will be able to figure them out.
Trial and error got me pretty far, but I want to know what argument values to use rather than just experimenting.

I also want the text to continue scrolling so I guess I need a for loop - right?

Really happy I have scrolling text on Ringo. I want to use it as part of another little program I am fooling with.

So:

mp.display.pushSprite(10,10);
means push the display to the TFT screen offset down 10 pixels and to the right 10 pixels. Normally, one would use 0,0 to push the full display to the full screen.

mp.display.scroll(10);
is equivalent to mp.display.scroll(10,0), which means move all the display pixels to the right by 10 pixels.

mp.display.setCursor(0,mp.display.height()-8);
means set the cursor (where the next operation will take place on the display) to the leftmost pixel of the 7th row of pixels from the bottom row (or the 8th row of pixels from one row below the bottom row).

Note that “MAKERphone::display” is of type TFT_eSprite (sort of a pixel map, or pixmap in the Linux/X world), so you can see all the function definitions and implementations in the files TFT_eSPI.h and TFT_eSPI.cpp which are source files in the MAKERphone library. The comments above each member function pretty much tell you what the arguments do.

Good luck.

@kfixman The cleanest and the fastest way to do any kind of scrolling is through the for loop. For example, you write something like this:

for(int i = 0; i < 160; i++){
mp.display.fillScreen(TFT_BLACK);
mp.display.setCursor(i, 40);
mp.display.print(“My text!”);
mp.display.pushSprite(0,0);
}

This is the general and the simplest idea - of course, there are many other ways you can do any kind of scrolling, but it’s important here to understand how all of this works.

Like Frank said, you’re actually drawing a picture on this 160x128 canvas, but the picture itself won’t change until you push it onto the screen.

Using the for loop in combination with the millis() function you can fine-tune this so you get the desired speed of the text and refresh rate of your screen.

Also, watch out for that fillScreen() function - you want to clear everything before starting a new “painting”, otherwise you’ll just get this text printed out multiple times.

Now if you want to do real scrolling like in programs that “saves” the info that was on the screen before, that is a bit more work.

Stay in touch and keep us updated on your progress! :smiley:
Robert

Thanks guys. That’s plenty to work with, and should keep me out of the local bar. Oh yea I forgot, I can’t do that anyway.

1 Like

I pretty much have the text where I want it and the scrolling is OK, however the scrolled word jumps down a line at the end of each cycle before it jumps back to the chosen starting point. I want it to stay in the same line throughout the scroll. I have tried various things, but can’t figure it out.

#include <MAKERphone.h>

MAKERphone mp;

void setup()

{

mp.begin(0);

 }

void loop() {

for(int i = 0; i < 160; i++){
mp.display.fillScreen(TFT_BLACK);
mp.display.setCursor(i, 50);
mp.display.setTextColor(TFT_BLUE);
mp.display.setTextFont(2);
mp.display.setTextSize(2);
mp.display.print(“RINGO”);
mp.display.pushSprite(0, 0);

 delay(100);

}

 }

When you set the cursor to pixels near the end of the screen, the text you print will continue on the next line (such is the way print works).

Try:
mp.display.setTextWrap(false)
before your loop to override this.

So just to suggest how you might figure things like this out on your own, here is how I found the setTextWrap() function.

First I looked in TFT_eSPI.h to see where print() came from. Turns out that class TFT_eSPI is derived from base class Print, but then I found that it had a member function write() that was commented: “Used by print class to print text to cursor position”.

I then looked in TFT_eSPI.cpp at the TFT_eSPI::write() member function and saw that whether it moved down to the next line or not (when at the end of a line) was controlled by a flag called textwrapX. I searched for textwrapX and saw that it was initialized to true, but could be modified by the setTextWrap() member function. By setting it to false using that function, the text would simpy be written off the end of the display. Not quite sure what that does, as the drawChar() function is rather complex, but at least it shouldn’t go to the next line.

Experiment with this to see what happens. The whole idea of having text scroll off the right side and magically appear on the left may not be supported by the library. It’s all yours to explore and add capability if you see fit.

First, Although the text does continue on the next line. It only starts on the next line and then jumps up to the original line.

If I reduce the pixels in the second argument of the for loop function to 65 (i <65;) instead of the end of the screen at 160, I get a fairly good one line scroll.

Frank, here is the problem I have with your suggestion - when you first mentioned looking at the TFT_eSPI.h and TFT_eSPI.cpp source files, I looked everywhere for the function definitions and implementation that you referenced. I could not find them. I looked in the MAKERphone library and even tried google. Had a little luck, but not enough to provide any useful info. So please guide me to the location of this information.

I will try the suggestions you gave me, and do more research when I find the info you referenced.

Frank, the setTextWrap function works and I thank you. I have the scrolling the way I want it now with the end of screen 160 in the for loop as it should be.

Very interested in studying the source files you gave me, once I am able to access them.

The library is here:
https://github.com/CircuitMess/CircuitMess-Ringo

TFT_eSPI.h and TFT_eSPI.cpp are in the library - look in the src/TFT_eSPI directory. If you open TFT_eSPI.cpp in any text or code editor and search for TFT_eSPI::setCursor, you will find the function (which is pretty simple) and a comment directly above it describing the function and its arguments. Likewise you can search for TFT_eSPI::setTextWrap. Now if you try to search for TFT_eSPI.print or TFT_eSPI.pushSprite, you won’t find them because pushSprite is part of class eSprite which is another class derived from TFT_eSPI, so in this case, search for TFT_eSprite::pushSprite. To find print(), you need to look in TFT_eSPI.h and see that class TFT_eSPI is derived from base class Print, which is where the print() function is; but you really don’t need to go find the Print class because it defers to it’s virtual member function write() to do the actual work, and since TFT_eSPI provides a write() function, that is what does the printing. So you see it’s pretty convoluted to try to learn this way. Circuitmess folks really need to DOCUMENT the library API by class and member functions of each class; but though they’ve been promising to do that, it has yet to happen. So this hunting through the source files to figure out what each function of each class does is the next best thing. It’s a great learning experience but certainly can be frustrating.

Thank you so much Frank for your patience. I will follow your tutorial. Only been at this for a couple of months, so I really appreciate your help.

Frank, I find nothing that I can explore in the location you gave me.

When you go to that page, you click on the blue word “src” which takes you to the src directory. Then click on the blue word "TFT_eSPI, which takes you to the src/TFT_eSPI directory. Then click on the blue word “TFT_eSPI.cpp” if you want to see the source for TFT_eSPI.cpp (the implementation of classes TFT_eSPI and TFT_eSprite) or click on the underlined word “TFT_eSPI.h” if you want to see the source for TFT_eSPI.h (the specification of classes TFT_eSPI and TFT_eSprite). Since “display” is defined in MAKERphone.h (which can be found one directory level back) to be of type TFT_eSprite, these two files tell you everything you can possibly find out (lacking real documentation, i.e.: man pages) about the display member functions, which will be all the member functions of classes TFT_eSPI and TFT_eSprite plus all the member functions of base class Print from which class TFT_eSPI is derived (for those functions you would have to look elsewhere, probably in an Arduino library that defines class Print). In addition to the member functions, there may be public data members, flags/counts and such, that provide additional information for display (I haven’t gone hunting for these.)

If clicking your way through this directory structure is not working for you, I have no idea what the problem is, because all the project directories on GitHub are structured this way, and that is the normal way to explore a GitHub directory.