[riot-notifications] [RIOT-OS/RIOT] drivers/lm75: driver for the lm75 sensor and derivatives (#16678)

viktorbatista notifications at github.com
Fri Aug 13 10:58:44 CEST 2021


@viktorbatista commented on this pull request.



> +    /* this is required not to discard the leading zero and
+    * output a false result in the case the temperature is x.0625 */
+    if (dev->lm75_params.res->temp_mult > 1000 \
+         && temp % dev->lm75_params.res->temp_mult == 625) {

Because all variables used are integers, printing decimal values to the user must be done using the remainder operator. Also because reading the device temperature registers is done at the maximum resolution possible, in the TMP1075 sensor, in the event the temperature is something like x.0625ºC, the value of `temperature % 10000` would be just x.625, because the leftmost zero was discarded and a false value was printed to the user. Therefore, this was done so, in that single specific case, a zero will be added before the 625 to print the true value - which is x.0625.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16678#discussion_r688357947
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210813/33b7bd4e/attachment.htm>


More information about the notifications mailing list