mariolukas / Watterott-CO2-Ampel-Plus-Firmware

Firmware for Watterott CO2 Ampel (Plus Version)
GNU General Public License v3.0
15 stars 13 forks source link

Use float for temperature in MQTT Message #14

Closed Jesse-Grass closed 3 years ago

Jesse-Grass commented 3 years ago

First gut hub submission, please excuse any inconvenience

reibuehl commented 3 years ago

Isn't sprintf(tempMessage, "%d.%02d", (int)temp, (int)(temp*100)%100); a little too complex?

Wouldn't sprintf(tempMessage, "%02d", temp); do exactly the same?

Jesse-Grass commented 3 years ago

Sadly sprintf() doesn't format floats on AVR platforms. So I use this little hack to get around this limitation.

reibuehl commented 3 years ago

Sadly sprintf() doesn't format floats on AVR platforms. So I use this little hack to get around this limitation.

Oh! I didn't know that... it just looked strange. Then go for it.