I am trying to display temperature data from my DH22 sensor. I have a command to display the text onto the LCD that shows Deg.F = by using this line-
showtemperatureXY(50,200, 1, &FreeSans12pt7b, "Deg. F = ");
This works fine, but how do I display the actual temperature data? it is in the form of an int type. and the variable is stored in t .
if I use showtemperatureXY(80,200, 1, &FreeSans12pt7b, t); nothing is displayed after the "Deg. F ="
Thanks
Do you think it might be useful to show where this "show temperature" comes from?
I assume it's a call to this function -
void showtemperatureXY(int x, int y, int sz, const GFXfont *f, const char *msg)
{
tft.setFont(f);
tft.setCursor(x, y);
tft.setTextColor(TFT_GREEN);
tft.setTextSize(sz);
tft.print(msg);
}
I use the same function to display the words "Deg. F =" and that works fine. Now I'm just trying to display the actual value next to the equal sign.
OK, so that function expects a char pointer as it's last argument. You can't pass it an integer if it wants a char pointer.
It's looking for a string (lower case s not the String class).
Your options are to overload that function with another version that takes an integer as the last argument
OR
create a string out of your integer and pass that to the function. The itoa function comes to mind.
Thank you so much. I will try that