How to create an LCD buffer with a constant stream of data?

I'm trying modify TinyBasic to output to an LCD, which would require a data buffer to scroll the text vertically. The problem is I can't figure out how to create one! All of the examples I've found have a set String to print. In my case, the method "writeToLCD" receives a constant stream of bytes to write to the screen. How would I create a reliable data buffer in this situation? In case you're wondering, I'm using an arduino Uno with a 16x4 alphanumaric LCD.

Here's the code I have so far:

int row = 0;
int col = 0;
byte screen[15][1];
static void writeToLcd(byte c) {
    // If the incoming byte is a carriage return.
    if(c ==  13) {
      col = 0;
      row++;
      lcd.setCursor(col,row);
    } 
    // If the incoming byte is tab.
    else if(c == 10) {
      lcd.write("");
    } 
    // Every other character.
    else {
      lcd.write(c);
      col++;
    }
}

The problem is I can't figure out how to create one!

An array of strings (lowercase s) or pointers to them would be one answer.

Put the incoming data into the array then to scroll through the buffer just change the array index.

Just curious, which Arduino are you using?

Just a small comment, are you sure that 10 is the tab character :wink:

And why do you use numbers for characters? Tab is '\t', newline is '\n' etc.

sterretje:
Just curious, which Arduino are you using?

Just a small comment, are you sure that 10 is the tab character :wink:

And why do you use numbers for characters? Tab is '\t', newline is '\n' etc.

I'm using the Arduino Uno. I forgot to update the comment from "VT," which is what I originally thought it was, to "LF." Also, I'm using ASCII decimals because that's the data type that TinyBasic sends it. It would be extremely hard to fundamentally change the code of TinyBasic.

x27:
Also, I'm using ASCII decimals because that's the data type that TinyBasic sends it. It would be extremely hard to fundamentally change the code of TinyBasic.

You don't have to change anything at the TinyBasic side.

The below demonstrates that '\t' and the number 9 are the same thing. Same for e.g. newline etc.

void setup()
{
  char c1 = '\t';
  char c2 = 9;

  Serial.begin(57600);
  Serial.write(c1); Serial.println(c1, HEX);
  Serial.write(c2); Serial.println(c2, HEX);
}

void loop()
{
}

Output

	9
	9

There is a in front of each 9.

I suggest that you try it in your code.

// Edit
Wikipedia Escape sequences in C has a table with the relevant escape codes.