Print string with the TFT.v2 library and a 2.4' ili9341 display

Hello,

I have been struggling to print strings with the TFT.v2 library.

What works:

#include <stdint.h>
#include <TFTv2.h>
#include <SPI.h>

void setup()
{
  TFT_BL_ON;    
  Tft.TFTinit();
}

void loop()
{
    Tft.drawString("Task complete!",0,0,2,WHITE);
    Tft.drawString("Task incomplete!",0,30,2,WHITE);
}

What I want to do:

#include <stdint.h>
#include <TFTv2.h>
#include <SPI.h>

String printString;
boolean taskComplete;

void setup()
{
  TFT_BL_ON;    
  Tft.TFTinit();
}

void loop()
{
  if(taskComplete == true)
  {
    printString = "Task complete!";
  }
  else
  {
    printString = "Task incomplete!";
  }
  Tft.drawString(printString,0,0,2,WHITE);
}

This is a simplified example. No matter what I do I get all sorts of errors or a blank screen.

Any help would be appreciated.

Since you included neither the errors you're seeing nor a link to the library you're using, I can only venture a SWAG.

If TFT.v2 is TFT Touch Shield v2.0, a quick glance at the TFTv2.h file in this deprecated library reveals that the drawString function expects a char * not a String.

1 Like

I apologize for the incomplete info. Your suggestion worked! Thank you!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.