Hi all.
The TFT_eSPI.h has: drawString(const char *string, int32_t x, int32_t y, uint8_t font), // Draw string using specified font number
and I have int count = 0; how to drawString my count instead of string?
count is any natural number.
like: drawString(count, int32_t x, int32_t y, uint8_t font), ?
Thanks
Adam
The function is expecting an ascii string stored in a char array. This is the normal way to handle strings in C.
There are a number of functions that can help. For a simple int variable itoa is probably appropriate. If you want to build more complex strings, then sprintf is your friend.
int count = 1;
char string[5]; // needs to be big enough to hold all digits and a null
sprintf(string, "%d", count);
drawString(string, x, y, font);
I thought so. But as I went looking for a link to give the OP about itoa I kept finding stuff that said to use sprintf instead for that reason. So I changed the answer. I didn't want to give an answer and then provide a link that said to do something else.