I would need to convert a decimal number that is calculated by Arduino (eg 1,1234) on the display ... i only get the number 1 without the values after the dot ...
I tried and tried but I can not do it ...
Kindly can you help me?
just multiply with
- 10 for one decimal
- 100 for two decimals
- 1000 for three decimals
- 10000 for four decimals
Thanks a lot for the answer...
So if I understand well I have to do:
number=number*10000 //for 4 decimals
1.12345 * 10000 =11234.5 as float and 11234 as integer
and we know, from 11234 the most right 4 numbers are always the decimal part ...
Okay, tonight I try and let you know ...
thank you so much
You might also use the sprintf() function in C/C++ to convert whatever decimal (or binary or hex) number into a formatted text string with a defined number of decimals and even optional left padding. Then, you might send that text string from your MCU to the Nextion.
Thank you all for the help ...
The solution to the "problem":
myNextion.setComponentText ("MainPage.t1", String (number, 3));
Where ,3 indicates the digits after zero