Temp Display

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
angusgr
Freetronics Staff
Freetronics Staff
Posts:853
Joined:Tue Apr 09, 2013 11:19 pm
Location:Melbourne, Australia
Contact:
Re: Temp Display

Post by angusgr » Fri Sep 18, 2015 6:31 am

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

Post Reply