RA8875 sumotoy library, serial terminal, need help

Status
Not open for further replies.

joey120373

Well-known member
Hardware: buyDisplay 800x480 RA8875 tft
And, at the moment a T4 running at 150Mhz.
Using HW SPI for display and IIC for cap touch interface.

I am in the early stages of getting a GUI up and running on this display and so far it’s been relatively pain free. I’ve got multiple screens or pegs that pop up and the touch screen works great.

But I’m having real issues wrapping my head around the hardware scroll feature. It’s not well documented on the library wiki. As far as I can tell, I define a window, then call a scroll function with direction and number of pixells to scroll. But it doesn’t seem to work exactly like I would want. And, as it seems to wrap the window, It’s not exactly what I need, but I could live with that if it’s all I can get.

What I want is a simple serial terminal, that loos and acts similar to hyper-term, or similar. When a serial stream is fed into the teensy buffer, it will display it on the TFT.

That’s easy, what I can’t seem to do is get the screen to scroll when the data being printed reaches the bottom of the screen. Depending on the font scale I use, I can get 15 or 30 lines of data on the screen ( in landscape orientation ) , using the small default code gets me the 30
Lines but text is too small, setting the font scale to 1 gives nice readable text but cuts the available lines in half. What I would really like is for the data lines to start moving up once the print function hits the last available line ( basically set cursor is : tft.height() - tft.getFontHeight )

Or even have it start printing on the bottom “line” and scroll up from there, either way would be ok. Don’t really care what happens to the data once it has left the screen, though it would be nice to be able to use the touch screen to scroll through it, though inrealize there are limits to how much data could be saved.

I am basically a hobbies level tinkerer, and my programming skills are not great, so I was hoping someone could give me some pointers, or even a bit of general code that might get me on the right track.
I have see. Some YouTube videos of people using the mcufreind.kbv library on a much smaller tft, with a uno, and getting exactly the results I am hoping for, but no descriptions or links. I’m hoping that since a lowly uno driving an ilixxxx can do it, there is hope for a teensy and the RA8875 combo.

At the moment I am on my phone so cannot post code, however i can do that once I get back to my computer if that might help.

I do have the scroll function working with some static text that’s printed, then scrolled, as a cute animation, but once I try to print, then scroll, it just doesn’t work for me.


Thanks
Joe
 
Kurt, thanks for the quick response. As far as I know I am using the RA8875 library that was bundled in with teensyloader, I don’t remember the exact version at the moment but I will post that ASAP.
IIRC, it’s been less that 4 months since I updated TL. I will get that info and post a bit of code as soon as I can.

Also, somehow I missed the huge thread on the T4 and sumotoy library, if you think this thread should be moved there feel free.
 
Ok, back at my computer for a few min.

Teensy Loader 1.51 beta 1
Library RA8875 version=0.7.11
Ardiono version 1.8.12
Teensy4

Code:
  #include <SPI.h>
  #include <RA8875.h>

  #define RA8875_CS 10 //any digital pin
  #define RA8875_RESET 8//any pin or 255 to disable it!


  RA8875 tft = RA8875(RA8875_CS, RA8875_RESET); //Teensy

  uint16_t x = 1;
  uint16_t y = 16;// or just use tft.getFontHeigth
  void setup(){
  
    tft.begin(RA8875_800x480);
    tft.fillWindow(RA8875_BLACK);
    tft.setScrollWindow(0, 799, 0, 479 );//have tried (0,800,0,480) no help
    tft.setCursor(0,tft.height()-tft.getFontHeight());
  }

  void loop(){
    tft.print("x = "), // for some reason, it wont print when x = 2 or 3 
    tft.print(x),
    tft.print("   "),
    tft.print("Scroll number = ");
    tft.println(y);
    tft.scroll(0, y);

    x=x+1;

    y=y+16; // if this is commented out, scroll does not work
    delay(200);
  }


This is not the code as it is as i am trying to use it in my sketch, but its similar, in my sketch, "x" would be a '\n' terminated string from the serial port, and "y" would be incremented by 16 every time a new line was received.

try it, for me it wont print lines 2 an 3, it skips to 4, then prints a few lines, skips afew, then the scroll window appears to move, i also get weird artifacts on the lcd every so often.
 
I should add that i don't intend for it to scroll on forever, i will add limits on how many lines get scrolled before the counter "y" in this case, gets reset.

the intended serial stream ( to be read and displayed ) has a packet terminating string, and the packets are usually less than or equal to 16 lines of ~ 16 chars,

however, sometimes they will be shorter or longer. And the point of this tool is to act as a terminal when the packets are not right, so being able to see everything is important.
 
You have the option of deleting the old or you can simply install the @mjs513 version into your <Arduino sketches folder>/libraries/RA8875 directory and by the library rules it should be brought in instead of the Teensyduino verison..

Note: The Teensyduino version I think is a version of this same one, I just don't remember if more fixes were put in since Paul grabbed it.
 
Most everything ive tested looks and acts pretty much the same with the @mjs513 library, i just cut the old RA8875 lib out of the teensy libraries folder and put it on my desktop for now, so im assuming after re-starting arduino that ints using that file now . The code i posted earlier acts the same, however i do notice that the colors now seem deeper, the RA8875_GRAYSCALE is now noticeably darker, not sure if its just my eyes playing tricks on me but it just looks better, colors seem deeper.
Was something changed with the colors?
 
Ok, back at my computer for a few min.

Teensy Loader 1.51 beta 1
Library RA8875 version=0.7.11
Ardiono version 1.8.12
Teensy4

Code:
  #include <SPI.h>
  #include <RA8875.h>

  #define RA8875_CS 10 //any digital pin
  #define RA8875_RESET 8//any pin or 255 to disable it!


  RA8875 tft = RA8875(RA8875_CS, RA8875_RESET); //Teensy

  uint16_t x = 1;
  uint16_t y = 16;// or just use tft.getFontHeigth
  void setup(){
  
    tft.begin(RA8875_800x480);
    tft.fillWindow(RA8875_BLACK);
    tft.setScrollWindow(0, 799, 0, 479 );//have tried (0,800,0,480) no help
    tft.setCursor(0,tft.height()-tft.getFontHeight());
  }

  void loop(){
    tft.print("x = "), // for some reason, it wont print when x = 2 or 3 
    tft.print(x),
    tft.print("   "),
    tft.print("Scroll number = ");
    tft.println(y);
    tft.scroll(0, y);

    x=x+1;

    y=y+16; // if this is commented out, scroll does not work
    delay(200);
  }


This is not the code as it is as i am trying to use it in my sketch, but its similar, in my sketch, "x" would be a '\n' terminated string from the serial port, and "y" would be incremented by 16 every time a new line was received.

try it, for me it wont print lines 2 an 3, it skips to 4, then prints a few lines, skips afew, then the scroll window appears to move, i also get weird artifacts on the lcd every so often.
Try commenting out the setCursor seems to do what you want without skipping but I am still getting these blips on the right side of the screen for some reason. Why to both - have no idea yet.
 
I will try that when I get home this afternoon, thank you. I notice another forum member, his forum handle escapes me at the moment, has got scrolling working well, even with large fonts, on this display. He has been posting in the RA8875 thread I need to look close at his code but if I understand correctly, he is using layers and 8 bit color . I would be fine with this approach as well.
The set cursor I had in there because on my project screen, the window that I create to display the data is on the right hand side, so I have to offset the y coordinates. Maybe I should see if cursor offset would work instead, or I can move the screen to the window to the left hand side. I have tried setting an active window, but if iirc it didn’t work, the println returned the cursor to the zero y.

Thanks !
 
mjs513, Thanks for that, It does seem to cure some of the issues. I am still getting those odd artifacts a blip or small screen shift at the top, seems to repeat at a constant interval.

I would have never guessed that using a setCursor in the set up would hijack the scroll function, and i am wondering how to get around that.

in this example, its not a big deal, but in my GUI code, i use the set cursor command everywhere.

I will continue playing with this little sketch to see if i can make any more sense of it.

thanks again.
Joe
 
I have played around some with layers, but to work if you have one of the 800x... displays you have to restrict your code to 8 bit colors.

I don't remember doing scrolling, but I did do a picture embed program with multiple images and would load one and then switch to it's layer while the next is loading into the other layer.
 
try this:

Code:
  #include <SPI.h>
  #include <RA8875.h>

  #define RA8875_CS 10 //any digital pin
  #define RA8875_RESET 8//any pin or 255 to disable it!


  RA8875 tft = RA8875(RA8875_CS, RA8875_RESET); //Teensy

  uint32_t x = 1;
  int y = 0;// or just use tft.getFontHeigth
  uint32_t font_lines = 0;
  uint32_t Lines_remaining = 0;
  uint32_t Agent_Smith = 0;
  uint32_t his_clone = 0;
  void setup(){
  
    tft.begin(RA8875_800x480);
    tft.fillWindow(RA8875_BLACK);
    
    tft.setTextColor(RA8875_WHITE,RA8875_BLACK);
    tft.setFontScale(1);
    y = tft.getFontHeight();
    font_lines = tft.height()/tft.getFontHeight();
    Agent_Smith = tft.height()-tft.getFontHeight();
    his_clone = Agent_Smith;
    //tft.setCursor(0,tft.height()-tft.getFontHeight());
    //tft.setActiveWindow(0,799,0,479);
    tft.setScrollWindow(0, 799, 0, 479 );//have tried (0,800,0,480) no help
  }

  void loop(){
    
    //tft.scroll(0,0);
    tft.print("x = "), 
    tft.print(x),
    tft.print("   "),
    tft.print("y = ");
    tft.print(y);
    tft.println("    ");
    if ( y == Agent_Smith ){
      tft.print("....................The MATRIX has You  ");
      tft.println(x/font_lines);
      Agent_Smith = Agent_Smith + his_clone;
    }


    
    tft.scroll(0,y);
    x=x+1;
    y = y+tft.getFontHeight();
    delay(500);
  }



it sort of works but no really, as near as I can tell, when the scroll argument (y in this case) equals the tft height or a multiple there of, it glitches.
 
interestingly, if i run the same code as above, but comment out the " tft.setScrollWindow(0, 799, 0, 479 );"
to dissable scrolling, it has basically the same glitch.

once the text hits the last "line" of the screen, in this case, with this font size, it would be the 16th line printed , there is a delay, and the text starts printing again
at the top of the screen, however, line 16 is not printed, line 17 is.

Its as if there is more space on the y axis, ant the missing 16th line is being printed off screen.
 
@joey120373, @KurtE, @mjs513 - I am not sure if this what you are looking for but I had a minimal terminal display working with an Adafruit RA8875 display adapter. The line scrolling function was modeled after an old Arduino sketch that I cannot even find now. It worked well with the T3.x. Not tested on the T4.
It only scrolls lines bottom up but with mod's could do more. This was using the latest version of Sumotoy's RA8875 library available at that time.

Here is the link:
https://github.com/wwatson4506/RA8875_3.X_Terminal.

More info in the readme.
Hopefully this may help:)
 
WWatson, thanks, I will give that a try, out to dinner at the moment.

@kurt and mjs513, after posting that last bit of code, I tried a few different layer commands, either in the set up or out, nothing worked, but writing to layer 2 resulted in nothing showing up on the screen.

Talking of writing to one layer while displaying another, I’m wondering if I should try alternating layers between print updates...... I’m also not sure how exactly the layers functuin works.... but maybe write to layer on, scroll on layer 2, print layer 2 and scroll on layer 1, repeat.....

I’ll try that but first I need to dive into the example code and get a better understanding of what is going on and how to use it.

I also have not tried scrolling with a font yet, just because usually included fonts need to be blacked out, and that adds an extra layer of complication.

I’ve also tried saving the strings I’m receiving in a buffer, and then reprinting those once the screen fil up, but getting the buffer set up as a ring buffer and trying to shift through it correctly and then print... basically gets me down a rabbit hole the farther I go, I know there is a way to do it like that but I’m just no where near that level.
 
Please forgive the horrible grammar and spelling, on my phone, and my thumbs are fat, eyes are bad and auto correct hates me for some reason.
 
WWatson, thanks, I will give that a try, out to dinner at the moment.

@kurt and mjs513, after posting that last bit of code, I tried a few different layer commands, either in the set up or out, nothing worked, but writing to layer 2 resulted in nothing showing up on the screen.

Talking of writing to one layer while displaying another, I’m wondering if I should try alternating layers between print updates...... I’m also not sure how exactly the layers functuin works.... but maybe write to layer on, scroll on layer 2, print layer 2 and scroll on layer 1, repeat.....

I’ll try that but first I need to dive into the example code and get a better understanding of what is going on and how to use it.

I also have not tried scrolling with a font yet, just because usually included fonts need to be blacked out, and that adds an extra layer of complication.

I’ve also tried saving the strings I’m receiving in a buffer, and then reprinting those once the screen fil up, but getting the buffer set up as a ring buffer and trying to shift through it correctly and then print... basically gets me down a rabbit hole the farther I go, I know there is a way to do it like that but I’m just no where near that level.

Please remember that this is not the latest version of the RA8875 library. It is meant as a reference to modify @mjs523's version:)
By the the way I have problems talking online with my skill levels to:)
 
Please remember that this is not the latest version of the RA8875 library. It is meant as a reference to modify @mjs523's version
By the the way I have problems talking online with my skill levels to

I will still give it a shot, however if that means digging through the .h and .cpp files to figure out what functions and arguments to make Im afraid my skill
set will let me down. Same applies to modifying a library, Ill give it a go but im just not at that level Im afraid.
 
Arduino: 1.8.12 (Windows 10), TD: 1.51-beta1, Board: "Teensy 4.0, Serial, 150 MHz, Fast, US English"

In file included from C:\Users\joey1\Documents\Arduino\my_RA8875_scroll_testing_not_great\my_RA8875_scroll_testing_not_great.ino:3:0:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\RA8875_3.X_Terminal/RA8875.h:149:33: fatal error: _utility/RA8875Font.h: No such file or directory

compilation terminated.

Error compiling for board Teensy 4.0.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Just tried compiling with the _Terminal library, and gave me that error, ill keep working on it but this is where ill probably have to beg for some more help.

Thanks guys
 
no luck, i did try replacing just the .H and .CPP files inside the RA_8875_t4 folder but get the same compiler error. I tried compiling it it the T3 as well and got the same error.


_utility/RA8875Font.h:

Im guessing that this /\ is missing from one the _t3_Terminal .H or .CPP files?
 
no luck, i did try replacing just the .H and .CPP files inside the RA_8875_t4 folder but get the same compiler error. I tried compiling it it the T3 as well and got the same error.


_utility/RA8875Font.h:

Im guessing that this /\ is missing from one the _t3_Terminal .H or .CPP files?

I'm sorry if I have mislead you. My version of the RA8875 library is an older version. It is NOT current. It is strictly meant as a reference to modify mjs513's current RA8875 library to accomplish the scrolling functions you want. It most likely will not compile without error. The functions in my old version of the library will have to to be adapted for use with the new library. It is meant for reference only. Unfortunately my RA8875 display is dead. But this was working with an older version of Arduino and Teensyduino. I cannot perform the task of adapting it.
 
Well, I tried a different approach using the BTE
Function, my thought being, print value at 0,0
Then, when a new value comes in, copy that block at 0,0 move it down, . Took a bit to figure out the arguments, but not too bad. So I thought, I’ll copy a block that is the length of the text, and the height of the lcd, minus the very bottom “line”. However, what that did was fill the entire column with 16 lines of the copied block!
that was run in the setup?!
I still have not fully figured out the function arguments though, the first 4 have to do with x any y coordinates if the block to be copied, the 5th and 6th arguments are the x and y for where to put the copied block, the seventh and eighth argument I cannot figure out, they appear to do nothing, I can enter all kinds of numbers but doesn’t seem to do anything. Maybe they are for transparency ? The last argument is Boolean, and just sets the background of the copied block to transparent or not I think.
 
Status
Not open for further replies.
Back
Top