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++;
}
}
sterretje:
Just curious, which Arduino are you using?
Just a small comment, are you sure that 10 is the tab character
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.