seeed studio TFT passing variables

im trying to pass a string to a function in the tft library, but im using a variable to pass the string and it gives me the error :

START_MENU_ino:284: error: no matching function for call to 'TFT::drawString(String&, int, int, int, int)'

C:\ARDUINO\libraries\TFT_Touch_Shield_libraries/TFT.h:172: note: candidates are: void TFT::drawString(char*, unsigned int, unsigned int, unsigned int, unsigned int)

my code looks like this :

void Confirm_Menu(String tmpWord){

Tft.drawString("The Pin Number You Entered Is:",30,30,2,YELLOW);
Tft.drawString(tmpWord,50,50,4,GREEN); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<***
Tft.drawString("Do You Want To Use This Number?",30,100,2,YELLOW);
mkbutton(30,150,50,75,3);
mkbutton(30,225,50,75,3);
Tft.drawString("YES",50,50,2,GREEN);
Tft.drawString("NO",50,50,2,RED);
}

if I just send a word inside of "" it works just fine but as a variable it fails...?

what am I doing wrong here?
:frowning:

this is the seeedstudio tft v 1.0

don't use String.

The information is in the error message. It helpfully tells you what the parameter list types are, for the function it thinks you are trying to use. Your first parameter is a String&, and it wants a char*

Ugh... Strings... the spawn of Satan!

if you use UTFT library:

TFT.fillScr(229,229,229); //general back
TFT.loadBitmap(113, 72, 94, 80, init_g); //image or logo with 94x80 size
TFT.setFont(BigFont);
TFT.setBackColor(229,229,229); //font back color
TFT.setColor(69, 69, 69); //font color
TFT.print(str, CENTER, 160); // string and position

I understand that but is a word with in quotation marks not a string?

for intance "12345abcde" << is this not a string?

because i cant write tft.drawString("some words in quotations") and it works perfect.

now i am vb.net normally but i had to learn C for the arduino. so i am slightly noob but i have always thought a string was anything with in quotaions so what do i not under stand

There are strings, and there are Strings. Strings (with a capital S) are an instance of the String class. strings (lower-case S) are "C strings", or null-terminated character arrays (char *).

Anything in "..." is a string, not a String.

well thats odd but ok, so how do i turn "1234" into a string i can then pass to my function?

const char *mystring = "1234";
Tft.drawString(mystring, 30, 30, 2, YELLOW);

Or, if you want it more variable:

char mystring[10]; // Space for 9 characters + null termination
sprintf(mystring, "%d", 1234);
Tft.drawString(mystring, 30, 30, 2, YELLOW);

ok but it needs to be changable dynamicly as well anythoughts on that? :astonished:

The second example does just that. It starts with an "empty" string that can take up to 9 characters, then the number "1234" is placed into it. You can place other things in it too, as many times as you like, as long as you don't exceed the 9 character (or whatever you set it to when creating the variable) limit.

majenko:
...
Or, if you want it more variable:

char mystring[10]; // Space for 9 characters + null termination

sprintf(mystring, "%d", 1234);
Tft.drawString(mystring, 30, 30, 2, YELLOW);

Exactly... but this is more efficient :

char mystring[10]; // Space for 9 characters + null termination
mystring[0]='\0';

int x = 1234;


itoa (x,mystring,10); 

Tft.drawString(mystring, 30, 30, 2, YELLOW);

font...
http://www.cplusplus.com/reference/cstdlib/itoa/

Except itoa is non-standard. If you want your code to be even remotely portable you won't use itoa.

OK well ill give all this a try and see what works for me. I appreciate all the help

Any one know a good book on arduino programming?