Hello,
I'm new in C programming (used to use Delphi). I want to change the text of a button using a variable
int red_value = 255;
void setup{
do some other stuff
b_red.initButton(&tft, 40, 40, 60, 40, WHITE, RED, BLACK, "255", 2);
b_red.drawButton;
}
void loop
do some stuff
red_value= getRed();
b_red.initButton(&tft,40,40,60,40,WHITE, RED, BLACK,red_value, 2);
b_red.drawButton;
do other stuff
Lets say that getRed returns "145" then i get some very strange signs in the button but not "145".
I looked in the refernece to change the int into a ASCII string, but cannot find it. Is there a function in C that convert this? In Delphi it is simple X= str(red_value).
Thanks for the help
I just want the result of a funtion (let's say int red=145, but I need to have "145") into the InitButton function who requires an ASCII string? In Delphi this is a minor detail. In C(Arduino) it is hopeless complicated.
Jacques_verl:
I just want the result of a funtion (let's say int red=145, but I need to have "145") into the InitButton function who requires an ASCII string? In Delphi this is a minor detail. In C(Arduino) it is hopeless complicated.
Too bad. Have you noticed that you're coding a machine that has less memory than some calculators? You're using a library, so any accusations of complexity should maybe fall on the authors of the library. Did you pay or contribute anything to the library, or to the Arduino project? Probably not.
If you know of a simpler way of programming an Arduino, there is nothing stopping you from doing it. It's fully open source hardware and software.
Since you didn't post the source for 'getRed()' how are we supposed to guess why it doesn't work?
There is a string data type in arduino. Have a look to the sample sketches in arduino IDE under string.
An alternative is to use a characters array or pointer.
char mychars[] = “145”;
Or
String mystring =“145”;
Or
Char* mystring =“145”;
Jacques_verl:
Hello,
I'm new in C programming (used to use Delphi). I want to change the text of a button using a variable
int red_value = 255;
void setup{
do some other stuff
b_red.initButton(&tft, 40, 40, 60, 40, WHITE, RED, BLACK, "255", 2);
b_red.drawButton;
}
void loop
do some stuff
red_value= getRed();
b_red.initButton(&tft,40,40,60,40,WHITE, RED, BLACK,red_value, 2);
b_red.drawButton;
do other stuff
Lets say that getRed returns "145" then i get some very strange signs in the button but not "145".
I looked in the refernece to change the int into a ASCII string, but cannot find it. Is there a function in C that convert this? In Delphi it is simple X= str(red_value).
Thanks for the help
I believe you want to do this:
string myString= String(red_value);