Slow memcpy or memmove, see the video here and look at the last part of the video.
https://www.youtube.com/watch?v=hIfnh6LuMp4&feature=youtu.be
void printandscroll_layer_1() {
static char line1[43];
static char line2[43];
static char line3[43];
static char line4[43];
static char line5[43];
static char line6[43];
static char line7[43];
static char line8[43];
static char line9[43];
static char line10[43];
static char line11[43];
static uint16_t curs; // Cursor position at bottom line
static int8_t x; // current X co-ordinate
static uint8_t last_space; // location of latest space character
if (ch == ' ') last_space = x; // Keep track of word spaces in order to avoid breaking up words
if (x == 43) // End of line. Scroll everything up one line
{
tft.setTextColor(RA8875_BLACK); // Clear all lines by reprinting in BLACK
tft.setCursor(10, 25);
tft.print(line9);
tft.setCursor(10, 75);
tft.print(line8);
tft.setCursor(10, 125);
tft.print(line7);
tft.setCursor(10, 175);
tft.print(line6);
tft.setCursor(10, 225);
tft.print(line5);
tft.setCursor(10, 275);
tft.print(line4);
tft.setCursor(10, 325);
tft.print(line3);
tft.setCursor(10, 375);
tft.print(line2);
tft.setCursor(10, 430);
tft.print(line1);
memcpy(line11, line10, 42);
memcpy(line10, line9, 42);
memcpy(line9, line8, 42);
memcpy(line8, line7, 42);
memcpy(line7, line6, 42);
memcpy(line6, line5, 42);
memcpy(line5, line4, 42); // Shift all lines up
memcpy(line4, line3, 42);
memcpy(line3, line2, 42);
if (last_space == 0) last_space = 42; // Special case, no space in line1
memcpy(line2, line1, last_space);
line2[last_space] = '\0'; // Terminate string
tft.setTextColor(RA8875_WHITE);
tft.setCursor(10, 25);
tft.print(line9);
tft.setCursor(10, 75);
tft.print(line8);
tft.setCursor(10, 125);
tft.print(line7);
tft.setCursor(10, 175);
tft.print(line6);
tft.setCursor(10, 225); // and print data
tft.print(line5);
tft.setCursor(10, 275);
tft.print(line4);
tft.setCursor(10, 325);
tft.print(line3);
tft.setCursor(10, 375);
tft.print(line2);
tft.setTextColor(RA8875_GREEN);
tft.setCursor(0, 430); // Set cursor at beginning of first (lowest) line
if (last_space == 42) // Special case, no space in line1, therefore nothing to print
{
tft.fillRect(0, 430, 800, 33, RA8875_BLACK);
line1[0] = '\0';
x = 0;
curs = 0;
}
else // Move beginning of unfinished word to front of line
{
x = 42 - (last_space + 1); // Get length of text we want to move to front
memmove(line1, &line1[last_space], x);
line1[x] = '\0'; // Terminate end of string
tft.fillRect(0, 430, 800, 32, RA8875_BLACK); // Clear line
tft.setCursor(0, 430);
tft.print(line1); // Print the moved word-fragment
curs = x * 18 + 18; // + 18 // And move cursor accordingly
line1[x++] = ch; // Print to string
tft.print(ch);
}
last_space = 0;
}
else // Print new character to string and TFT, one char at a time
{
tft.setTextColor(RA8875_GREEN); // Set GREEN as text Colour
tft.setCursor(curs, 430);
line1[x++] = ch;
tft.println(ch);
curs = curs + 16; //space between characters
}
}
https://www.youtube.com/watch?v=hIfnh6LuMp4&feature=youtu.be
void printandscroll_layer_1() {
static char line1[43];
static char line2[43];
static char line3[43];
static char line4[43];
static char line5[43];
static char line6[43];
static char line7[43];
static char line8[43];
static char line9[43];
static char line10[43];
static char line11[43];
static uint16_t curs; // Cursor position at bottom line
static int8_t x; // current X co-ordinate
static uint8_t last_space; // location of latest space character
if (ch == ' ') last_space = x; // Keep track of word spaces in order to avoid breaking up words
if (x == 43) // End of line. Scroll everything up one line
{
tft.setTextColor(RA8875_BLACK); // Clear all lines by reprinting in BLACK
tft.setCursor(10, 25);
tft.print(line9);
tft.setCursor(10, 75);
tft.print(line8);
tft.setCursor(10, 125);
tft.print(line7);
tft.setCursor(10, 175);
tft.print(line6);
tft.setCursor(10, 225);
tft.print(line5);
tft.setCursor(10, 275);
tft.print(line4);
tft.setCursor(10, 325);
tft.print(line3);
tft.setCursor(10, 375);
tft.print(line2);
tft.setCursor(10, 430);
tft.print(line1);
memcpy(line11, line10, 42);
memcpy(line10, line9, 42);
memcpy(line9, line8, 42);
memcpy(line8, line7, 42);
memcpy(line7, line6, 42);
memcpy(line6, line5, 42);
memcpy(line5, line4, 42); // Shift all lines up
memcpy(line4, line3, 42);
memcpy(line3, line2, 42);
if (last_space == 0) last_space = 42; // Special case, no space in line1
memcpy(line2, line1, last_space);
line2[last_space] = '\0'; // Terminate string
tft.setTextColor(RA8875_WHITE);
tft.setCursor(10, 25);
tft.print(line9);
tft.setCursor(10, 75);
tft.print(line8);
tft.setCursor(10, 125);
tft.print(line7);
tft.setCursor(10, 175);
tft.print(line6);
tft.setCursor(10, 225); // and print data
tft.print(line5);
tft.setCursor(10, 275);
tft.print(line4);
tft.setCursor(10, 325);
tft.print(line3);
tft.setCursor(10, 375);
tft.print(line2);
tft.setTextColor(RA8875_GREEN);
tft.setCursor(0, 430); // Set cursor at beginning of first (lowest) line
if (last_space == 42) // Special case, no space in line1, therefore nothing to print
{
tft.fillRect(0, 430, 800, 33, RA8875_BLACK);
line1[0] = '\0';
x = 0;
curs = 0;
}
else // Move beginning of unfinished word to front of line
{
x = 42 - (last_space + 1); // Get length of text we want to move to front
memmove(line1, &line1[last_space], x);
line1[x] = '\0'; // Terminate end of string
tft.fillRect(0, 430, 800, 32, RA8875_BLACK); // Clear line
tft.setCursor(0, 430);
tft.print(line1); // Print the moved word-fragment
curs = x * 18 + 18; // + 18 // And move cursor accordingly
line1[x++] = ch; // Print to string
tft.print(ch);
}
last_space = 0;
}
else // Print new character to string and TFT, one char at a time
{
tft.setTextColor(RA8875_GREEN); // Set GREEN as text Colour
tft.setCursor(curs, 430);
line1[x++] = ch;
tft.println(ch);
curs = curs + 16; //space between characters
}
}