Hello,
I have come up with a way to display variables on the TFT. This is a work around, but it is a start.
When you look at the Serial.print lines, you notice that a string is required. What I did was break the string down into 3 parts (stringStart, convertedVariable, stringEnd) and inserted a float variable that was converted into a charArray. I modified part of the MeTFT file as the demo. Save a copy of MeTFT.ino, then Copy/Paste the code below to the top (text) section, leaving the graphics alone.
Also, take a look at the Ref link for details on the conversion function.
Good Luck
Mike
P.S. I have a couple of non-related comments in the code.
//create some variables - line 1(string), pi(float), mypi(charArray), line3(string)
String line1 = “DS24(0,1,‘Size 24 - hello world’,4);”;
//DS[12 | 16 | 24 | 32 | 48 | 64](pxFromLeft, pxFromTop, ‘string’, color), DS48 appears to be emphasized.
float pi = 3.14159;
char mypi[10];
String line3 = “DS48(1,140,'PI=”; //this is the start of line3’s string
void setup()
{
Serial.begin(9600);
}
void loop()
{
//Ref. http://www.arduino-hacks.com/float-to-string-float-to-character-array-arduino/
dtostrf(pi, 6, 5, mypi);
line3.concat(mypi); //append mypi(charArray) to the end of line3
line3.concat("’,1);"); //append the closing parameters to line3
Serial.print(“CLS(0);”); // clear the screen with c color
Serial.print(“DR0;”);// the screen displays in upright way
Serial.print(line1); // display hello world with 32 dot matrix at the position of coordinate (0, 1)
Serial.println(line3);// display pi in 48 dot matrix at the position of coordinate (1, 140)
delay(3000);// wait