Trouble with fonts, and with displaying floating point numbers in LVGL project

Hi George, I store the temperature as an integer so 254 is 25.4
You could do this in your code:
int sensVal = temperature * 10; // sets the int sensVal to 10 times the temperature
lv_label_set_text_fmt(label1, "Temp: %d.%d",sensVal/10, sensVal-(sensVal/10*10));

This uses the trimming and prioritisation of integer maths to your advantage and give you the result you want.

1 Like