Add rounded output to TMP006 temperature output

This commit is contained in:
Aadi Desai 2022-03-02 10:53:45 +00:00
parent 444bc1c719
commit 36eecf3a00
No known key found for this signature in database
GPG key ID: CFFFE425830EF4D9

View file

@ -35,6 +35,7 @@ class TMP006:
@property
def temperature(self) -> float:
"""Measured temperature in degrees Celsius, to 2 decimel places"""
Vobj = self.vObject()
Tdie = self.tAmbient()
# Values for Calculations
@ -55,7 +56,7 @@ class TMP006:
# Calculate object temperature in Kelvin
Tobj = (Tdie**4 + (fVobj / S)) ** 0.25
# Convert from Kelvin to Celsius
return Tobj - 273.15
return round(Tobj - 273.15, 2)
@property
def active(self) -> bool: