MajicDesigns / MD_DS3231

DS3231 Real Time Clock Library
GNU Lesser General Public License v2.1
30 stars 11 forks source link

Suggestion: return temperature as int #11

Open wolfbert opened 4 years ago

wolfbert commented 4 years ago

Hi, playing around with the library I noticed that the temperature is returned as a float (as in other DS3231 libraries). If the method is used, this pulls in floating point code that would otherwise be unneeded.

The datasheet lists the temperature accuracy as +/-3° Celsius @ 3.3V, yet the temperature is internally represented in units of 0.25°. Given that, wouldn't it make sense to integer divide by 4/round and return an int8_t? In a small example, this resulted in upwards of 800 bytes less flash memory. The tradeoff is that tiny trends would only be detectable after a change of 0.5°, and that the interface would not totally show the internal status of the chip.

Not a big deal, given that the temperature method will probably not be widely used, just my 2 cents.

Edit: Such a version could be provided by means of an additional configuration switch ENABLE_*.