Skip to content

Commit 8d75f10

Browse files
authored
rounding temperature as last operation
To avoid loosing precision the rounding should take place after the conversion from Centigrade to Fahrenheit. I also believe that this conversion is present in one or some CP library, so it could be reused. WARNING: code not tested (well I compared the math on another board)
1 parent ae29f01 commit 8d75f10

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

PyPortal_User_Interface/code.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,11 @@ def switch_view(what_view):
338338
light = light_sensor.value
339339

340340
if adt: # Only if we have the temperature sensor
341-
tempC = round(adt.temperature)
341+
tempC = adt.temperature
342342
else: # No temperature sensor
343-
tempC = round(microcontroller.cpu.temperature)
343+
tempC = microcontroller.cpu.temperature
344344

345-
tempF = tempC * 1.8 + 32
345+
tempF = round(tempC * 1.8 + 32)
346346
sensor_data.text = 'Touch: {}\nLight: {}\n Temp: {}°F'.format(touch, light, tempF)
347347

348348
# ------------- Handle Button Press Detection ------------- #

0 commit comments

Comments
 (0)