Page 2 of 2

Re: Temp Display

Posted: Fri Sep 18, 2015 6:31 am
by angusgr
ledsarecool wrote: When the temperature is 21.00 or 21.10 or 21.20 ect.
It will only show the first digit after the decimal point.
How can i print 1 decimal place also?
Hi ledsarecool,

To display a single decimal place instead of two decimal places, replace this line:

Code: Select all

snprintf(str2_buf, 20, "%d.%d" , (int)t, (int)(t*100)-(int)t*100);  // string with degree C
With this line:

Code: Select all

snprintf(str2_buf, 20, "%d.%d" , (int)t, (int)(t*10)-(int)t*10);  // string with degree C
Angus