Tft.text not working

hello,
i'm tring to display a text on my arduino esplora but it return me this error.

C:\Users\Public\sketch pubblici\inventario_papi3.ino\inventario_papi3.ino.ino: In function 'void printSelN(int, unsigned int, String)':
inventario_papi3.ino:70:52: error: no matching function for call to 'TFT::text(String&, int, int)'
   EsploraTFT.text(s, 5 * 6 * dTxt, 64 - (10 * dTxt));
                                                    ^
In file included from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\libraries\TFT\src/TFT.h:36:0,
                 from C:\Users\Public\sketch pubblici\inventario_papi3.ino\inventario_papi3.ino.ino:5:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\libraries\TFT\src/utility/Adafruit_GFX.h:174:2: note: candidate: void Adafruit_GFX::text(const char*, int16_t, int16_t)
  text(const char * text, int16_t x, int16_t y),
  ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\libraries\TFT\src/utility/Adafruit_GFX.h:174:2: note:   no known conversion for argument 1 from 'String' to 'const char*'
Più di una libreria trovata per "Keyboard.h"
Usata: C:\Users\matti\Desktop\arduino\libraries\Keyboard
Non usata: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\libraries\Keyboard
Più di una libreria trovata per "Mouse.h"
Usata: C:\Users\matti\Desktop\arduino\libraries\Mouse
Non usata: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\libraries\Mouse
Uso la libreria Keyboard alla versione 1.0.4 nella cartella: C:\Users\matti\Desktop\arduino\libraries\Keyboard 
Uso la libreria HID alla versione 1.0 nella cartella: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\HID 
Uso la libreria Mouse alla versione 1.0.1 nella cartella: C:\Users\matti\Desktop\arduino\libraries\Mouse 
Uso la libreria Esplora alla versione 1.0.4 nella cartella: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\libraries\Esplora 
Uso la libreria TFT alla versione 1.0.6 nella cartella: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\libraries\TFT 
Uso la libreria SPI alla versione 1.0 nella cartella: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI 
exit status 1
no matching function for call to 'TFT::text(String&, int, int)'
Trovata libreria non valida in C:\Users\matti\Desktop\arduino\libraries\2020_07_26-Fishino-Libs-Firmware_8.0.x: Nessun header file (.h) trovato in C:\Users\matti\Desktop\arduino\libraries\2020_07_26-Fishino-Libs-Firmware_8.0.x

here's the code

void printSelN(int n, unsigned int pos, String f) {
  String s = n + f;
  pos++;
  EsploraTFT.setTextSize(dTxt);
  EsploraTFT.text(s, 5 * 6 * dTxt, 64 - (10 * dTxt));
}

Post a complete code.

Post complete code. Posting snippets just makes it harder for people to help you because then they have to guess, which just wastes everyone's time.

I think the error message is pretty clear. There's no such method in the class.

Were you possibly looking for something like

EsploraTFT.setCursor(5 * 6 * dTxt, 64 - (10 * dTxt));
EsploraTFT.print(s);
1 Like

.text() doesn't take a String as the first argument, it takes a const char *

You can use the .c_str() method on your String to get the underlying char *

EsploraTFT.text(s.c_str(), 5 * 6 * dTxt, 64 - (10 * dTxt));

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