How do you properly convert values into String so as to display on the TFT LCD?

TFTscreen.text(" ", 0, 30);
TFTscreen.text("ADC bits: ", 0, 40);
String recordVal = String((meta->recordEightBits ? 8 : 10));
recordVal.toCharArray(recordPrintout, 4);
TFTscreen.text(recordPrintout, 0, 50);
TFTscreen.text("ADC clock kHz: ", 0, 60 );
String adcfreqVal = (String)(meta->adcFrequency/1000);
adcfreqVal.toCharArray(adcfreqPrintout, 4);
TFTscreen.text(adcfreqPrintout, 0, 70);
TFTscreen.text("Sample Rate: ", 0, 80);
String samplerateVal = (String)(sampleRate);
samplerateVal.toCharArray(sampleratePrintout, 4);
TFTscreen.text(sampleratePrintout, 0, 90);
TFTscreen.text("Sample interval usec: ", 0, 100);
String srVal = (String)(1000000.0/sampleRate, 4);
srVal.toCharArray(srPrintout, 4);
TFTscreen.text(srPrintout, 0, 110);

Hi guys, the above is part of the code that I'm trying to figure out. The program works properly on the serial monitor but my goal is to display them on the TFT LCD instead. I understand that I have to first store the value into a string and then convert string content to a char array. However, the TFT LCD is only printing out the sentences and not the data. :~ I believe I am doing it wrongly, therefore, could any kind souls help me out? Thank you!

kitkadbury:
The program works properly on the serial monitor but my goal is to display them on the TFT LCD instead.

I believe I am doing it wrongly

You are probably right

You should be able to print on LCD everything you can print on the serial monitor, and in more or less the same way. The only difference is in the placement. There should be no need to convert values to strings.

Something like

float data
data = 12.34

Serial,print("data= ");
Serial.println(data):
TFTscreen.txt("data= ",0,0);
TFTscreen.txt(data,0,10);

I'm not familiar with this LCD but there should be something to this effect included in the library it uses. The TFT code I use has a command printNum i.e. it distiguishes between text and numeric data. Yours may be similar.

I tried adding the dtostrf() function. The LCD managed to display the values but it worked only for that one time. Does not print out values anymore.

float eightbitsRecord = meta->recordEightBits ? 8 : 10;

String recordVal = dtostrf(eightbitsRecord, 7, 4, recordPrintout);

recordVal.toCharArray(recordPrintout, 10);

What library are you using for the LCD ?

And, further to that, state the objective, post the code, and describe the LCD.
I don't think you should have to suffer from anything to do with strings of any sort and, if you insist on doing so, you deserve all the grief you get. You should be able to print in the simple manner I described above. The only time I have ever had to use the dtostrf() function is when I was feeding data to alien software on an alien device.
I don't think it's likely, but if your LCD library really demands that you take this route, looking for an alternative library written by somebody more competent would be a good idea.