TLDR
I want to scroll words >16 letters in their entirety from right to left across the TFT display. The word will NOT be able to fit on the screen because of how big the letters are.
There is a constraint that anything scrolled off the left edge of the screen will loop back to the right side automatically.
My issue is %100 on the software side, and is irrelevant to the hardware being used. Here is what I am working with:
RA8875 driver chip (Adafruit)
7” 400x800px diagonal TFT display (Adafruit)
Sumotoy RA8875 library
Arduino Mega 2560
Windows 11 PC
Here is what I’m trying to do: Scroll a string of text (variable length) onto the TFT display from right to left (marquee style), and continue scrolling until the whole word disappears off the left side of the screen.
The problem: The display only fits about 5 letters of the font size I desire. When anything scrolls past the leftmost edge of the screen, it wraps around to the right side of the screen and continues scrolling left. This is problematic because the first (5) letters of a (10) letter word will loopback before the entire word has scrolled, overlapping the rest of the word.
My progress so far: The letters scroll onto the display smoothly from right to left, but I can only scroll words (5) letters or less. Before the letters loop back. I am experimenting with using layering techniques in combination with black rectangles that act as “concealing curtains,” covering up the first (5) letters as they loop back from the right side to make room for the next (5) letters as they scroll from R to L.
I will post pictures and illustrations of this soon.
If any part of this is unclear please ask me a question, or request additional info.
Does anyone have an idea for a possible solution?
Any advice, direction, code, help, or discussion all greatly appreciated.
The library scrolls as well as static displays. You can scroll from either direction.
#include <LG_Matrix_Print.h>
const int scrollRateMs = 40;
const int segments = 4;
LG_Matrix_Print lmd(segments, CSLED);
// somewhere in setup()
lmd.setEnabled(true);
lmd.setIntensity(MatrixBright); // 0 = low, 15 = high
// somewhere in loop()
//
// Let LED matrix running until eom
//
if (!lmd.updateTicker()) lmd.stopTicker(); //Stop at end
// When you want to scroll a message
waitTicker( F("My scrolling message that goes on ...") );
// ==================================================
//
// Spin hard letting ticker run
//
void waitTicker(String Msg)
{
lmd.ticker(Msg, scrollRateMs);
//
while (lmd.updateTicker())
{ ; }
//
}
[code]
#include <SPI.h>
#include <RA8875.h>
#include "fonts/antiultra.c" //The font I'll be using (a very unusual and barely readable custom font)
#define RA8875_CS 10
#define RA8875_RESET 9
RA8875 tft = RA8875(RA8875_CS, RA8875_RESET);
char text[] = ("flypdx");
void setup()
{
Serial.begin(9600);
Serial.println("RA8875 start"); //Ignore
tft.begin(RA8875_800x480);
tft.displayOn(true);
tft.GPIOX(true); //Nothing shows on the screen if this line isn't here.
tft.setActiveWindow(0, tft.width(), 0, tft.height());
tft.setScrollWindow(0, tft.width() - 1, 0, tft.height());
tft.useLayers(true);
/*
///////////////////////////////////////////////////////////////////////////////////////////////////////
Font Setup (I am not looking to use a dot matrix display because it matters to me how the letters look)
///////////////////////////////////////////////////////////////////////////////////////////////////////
*/
tft.setFont(&antiultra);
tft.setFontScale(2, 3);
tft.setTextColor(RA8875_WHITE);
tft.clearMemory();
/*
//////////////////////////////////////////////////////////////
Writes the text to the display, and evenly spaces the letters
//////////////////////////////////////////////////////////////
*/
for (int a = 0; a < 800; a += 120) {
tft.setCursor(a, 100);
tft.writeTo(L2);
tft.write(text[a / 120]);
}
}
void loop()
{
/*
////////////////////////////////////////////////////////////////////////////////////////////////////////
The length of the text I want to write to the display in pixels (didn't end up using this in the sketch)
////////////////////////////////////////////////////////////////////////////////////////////////////////
*/
// int Len = (strlen(text) * 128) + 128;
/*
//////////////////////////////////////////
Reveal, and scroll text from right to left
//////////////////////////////////////////
*/
tft.layerEffect(AND);
/* What this does:
basically, the RA8875 driver chip gives you (2) layers to write things on,
there are a few layer effects you can use to change how the layers interact wand display.
The "AND" layer FX only shows pixels where both layers share "RA8875_WHITE" (white colored pixels) at the same location.
This is being used to show/hide portions of the screen as demonstrated below.
*/
for (int b = 0; b < tft.width() - 1; b++) {
tft.writeTo(L1);
tft.drawFastVLine(800 - b, 0, tft.height(), RA8875_WHITE);
tft.setScrollMode(LAYER2ONLY);
tft.writeTo(L2);
tft.scroll(b, 0);
delay(7);
}
/*
/////////////////////////////////////////////////////////////
Re-draw text once it reaches the leftmost edge of the display
/////////////////////////////////////////////////////////////
*/
for (int a = 0; a < 800; a += 120) {
tft.setCursor(a, 100);
tft.writeTo(L2);
tft.write(text[a / 120]);
}
/*
/////////////////////////////////////////////////////////////////////////////////////////////////
Scroll text out of view from right to left, conceal the text as it loops back from the right side
/////////////////////////////////////////////////////////////////////////////////////////////////
*/
tft.setScrollMode(LAYER2ONLY);
for (int c = 0; c < tft.width() - 1; c++) {
tft.writeTo(L1);
tft.drawFastVLine(800 - c, 0, tft.height(), RA8875_BLACK);
tft.scroll(c, 0);
delay(7);
}
}
[/code]
Yes. Or you need a representation of the message, like the entire message in characters, and then a means of rendering a sliding window portion of that message to the screen.
Like a 50 character buffer, and at any time you dispaly a number of them that fit on the screen, say the 7 characters starting at character number 13.
Place spaces at the end of the character array so the last, say, q0 characters are simply blank and look to push off the last of the printing characters.
Word. I for one would find it easier to see and deal with if you would temporarily just use a regular font of the same size. Just an idea - I don't make heads or tails out of your custom font. But I will say it looks interesting and probably even more so in motion.