Help Create Vertical Scroll on LCD using Char

I am attempting to create a function for an LCD screen that will allow the display of the latest set of information on the top and then show the "history of values" below by reassigning them.s. Very time the function is called it should "shift" all the information down on placed the newest item on the top.

This is my attempt at doing this. The first time the function is called everything displays as expected. However each subsequent call does not shift the data. SO i believe the issue is with how i am reassigning the Char array.

//sample data
char dataline1[] = "11 11 11 1 1 1 1\r\n";
char dataline2[] = "2 22 2 22 2 2 222\r\n";
char dataline3[] = "33 33 33  33 33\r\n";
char dataline4[] = "444 44 4 4 44 44\r\n";
char dataline5[] = "55 55  55 555 5\r\n";
char dataline6[] = "66 66 6 6 66 6 6 66 6\r\n";
char dataline7[] = "77 77 777  777 777\r\n";
char dataline8[] = "8 88 888 888 8 888\r\n";
char dataline9[] = "9 9 9 9 9  9 9 9 99\r\n";
char dataline10[] = "10101010101010\r\n";
char dataline11[] = "11 11 11 11 11 11 \r\n";
char dataline12[] = "12 12 12 12 12 12 12\r\n";
char dataline13[] = "13 13 13  13 13 \r\n";

void displayResultsTable(){
	tft.fillScreen(ILI9341_BLUE);
	tft.setCursor(0, 0);
	tft.setTextColor(ILI9341_WHITE);
	tft.setTextSize(2);
	String Stringdataline0;
	Stringdataline0 = String(FwRed);
	Stringdataline0 +=", ";
	Stringdataline0 +=String(FwBlue);
	Stringdataline0 +=", ";
	Stringdataline0 +=String(FwGreen);
	Stringdataline0 +="\r\n";
	char dataline0[25];
	Stringdataline0.toCharArray(dataline0,25);

	char* LCDstring_table[] = {dataline0, dataline1, dataline2, dataline3, dataline4, dataline5, dataline6, dataline7, dataline8, dataline9, dataline10, dataline11, dataline12, dataline13};

	for (int i = 0; i < 14; i++){
		String table_buffer = LCDstring_table[i]; 
		tft.print(table_buffer);
	}
	
	dataline13[25] = dataline12[25];
	dataline12[25] = dataline11[25];
	dataline11[25] = dataline10[25];
	dataline10[25] = dataline9[25];
	dataline9[25] = dataline8[25];
	dataline8[25] = dataline7[25];
	dataline7[25] = dataline6[25];
	dataline6[25] = dataline5[25];
	dataline5[25] = dataline4[25];	
	dataline4[25] = dataline3[25];
	dataline3[25] = dataline2[25];
	dataline2[25] = dataline1[25];
	dataline1[25] = dataline0[25];

}
	String Stringdataline0;
	Stringdataline0 = String(FwRed);
	Stringdataline0 +=", ";
	Stringdataline0 +=String(FwBlue);
	Stringdataline0 +=", ";
	Stringdataline0 +=String(FwGreen);
	Stringdataline0 +="\r\n";

You do not need to piss away resources using the class at all. So, stop it.

sprintf() will populate the char away.

	char* LCDstring_table[] = {dataline0, dataline1, dataline2, dataline3, dataline4, dataline5, dataline6, dataline7, dataline8, dataline9, dataline10, dataline11, dataline12, dataline13};

Why is the array local to the function? It goes away at then end of the function.

		String table_buffer = LCDstring_table[i];

Useless crap. If the library you are using can't handle a string, get a decent library.

Here is a code which scrolls the data up.
Hope you can modify it to push the data down.
Have fun.

   char* LCDstring_table[] = {dataline0, dataline1, dataline2, dataline3, dataline4, dataline5, dataline6, dataline7, dataline8, dataline9, dataline10, dataline11, dataline12, dataline13};
    int iIndex = 0;
    for (int j = 0; j != 14; j++) {
      lcd_i2c.clear(); // print(LCDstring_table[i]);
      for (int i = 0; i != 4; i++) {
        //String table_buffer = LCDstring_table[i];
        lcd_i2c.setCursor(0,i);
        lcd_i2c.print(LCDstring_table[i + iIndex]);
        delay(DELAY);
      }
      iIndex++;
    }

Thanks for the help Paul and Vaclav.

I'm getting rid of strings all together. The library can handle char.

Vaclav, I dont see how this code works.

I have moved the array LCDstring_table out of the local function. How can I now reassign each char set withing the array appropriately to shift the data.? I get an syntax error when i recall the array to modify the values.

Vaclav, I dont see how this code works.

If you've read any of Vaclav's other nonsense, (oops, I meant replies), you'd know that there wasn't much chance of it working.

If lcd supports vertical scroll, you can make it work in hardware:

Got something working... however, I doubt this is the best way to do it and I am still "pissing away resources" :-[ I am not complete sure how to build "currentdata" without using strings...

char dataline0[25] = "0 00 0 0 0 00 0 0\r\n";
char dataline1[25] = "11 11 11 1 1 1 1\r\n";
char dataline2[25] = "2 22 2 22 2 2 222\r\n";
char dataline3[25] = "33 33 33  33 33\r\n";
char dataline4[25] = "444 44 4 4 44 44\r\n";
char dataline5[25] = "55 55  55 555 5\r\n";
char dataline6[25] = "66 66 6 6 66 6 6 66 6\r\n";
char dataline7[25] = "77 77 777  777 777\r\n";
char dataline8[25] = "8 88 888 888 8 888\r\n";
char dataline9[25] = "9 9 9 9 9  9 9 9 99\r\n";
char dataline10[25] = "10101010101010\r\n";
char dataline11[25] = "11 11 11 11 11 11 \r\n";
char dataline12[25] = "12 12 12 12 12 12 12\r\n";
char dataline13[25] = "13 13 13  13 13 \r\n";
char dataline14[25] = "14 14 14 14 14  14 14\r\n";
char* LCDstring_table[] = {dataline0, dataline1, dataline2, dataline3, dataline4, dataline5, dataline6, dataline7, dataline8, dataline9, dataline10, dataline11, dataline12, dataline13, dataline14};

void displayResultsTable(){
	tft.fillScreen(ILI9341_BLUE);
	tft.setCursor(0, 0);
	tft.setTextColor(ILI9341_WHITE);
	tft.setTextSize(2);

	String Stringdataline0;
	Stringdataline0 = String(FwRed);
	Stringdataline0 +=", ";
	Stringdataline0 +=String(FwBlue);
	Stringdataline0 +=", ";
	Stringdataline0 +=String(FwGreen);
	Stringdataline0 +="\r\n";
	char currentdata[25];
	Stringdataline0.toCharArray(currentdata,25);

	tft.print(currentdata);
	for (int i = 0; i <= 13; i++){
		tft.print(LCDstring_table[i]);
	}

	strcpy(dataline13,dataline12);
	strcpy(dataline12,dataline11);
	strcpy(dataline11,dataline10);
	strcpy(dataline10,dataline9);
	strcpy(dataline9,dataline8);
	strcpy(dataline8,dataline7);
	strcpy(dataline7,dataline6);
	strcpy(dataline6,dataline5);
	strcpy(dataline5,dataline4);
	strcpy(dataline4,dataline3);
	strcpy(dataline3,dataline2);
	strcpy(dataline2,dataline1);
	strcpy(dataline1,dataline0);
	strcpy(dataline0,currentdata);
}

I am not complete sure how to build "currentdata" without using strings...

You can't. You CAN do it without using Strings, though.

If FwRed, FwGreen, and FwBlue are ints, then

char currentdata[20];
sprintf(currentdata, "%d, %d, %d\r\n", FwRed, FwGreen, FwBlue);

If they are some other type, it can still be done. You need to post more of your code. Generally, the expected amount is ALL OF IT!

Thanks Paul, that line helped a ton. I found this link that was helpful in explaining what is taking place and use of sprintf.

http://www.cplusplus.com/reference/cstdio/sprintf/

PaulS:
You can't. You CAN do it without using Strings, though.

If FwRed, FwGreen, and FwBlue are ints, then

char currentdata[20];

sprintf(currentdata, "%d, %d, %d\r\n", FwRed, FwGreen, FwBlue);




If they are some other type, it can still be done. You need to post more of your code. Generally, the expected amount is ALL OF IT!