Skip to content

Commit e77fed2

Browse files
committed
use the cpu temperature if sensor is not present.
1 parent ffb8f9b commit e77fed2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

PyPortal_User_Interface/code.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import time
22
import board
3+
import microcontroller
34
import displayio
45
import busio
56
from analogio import AnalogIn
@@ -338,11 +339,11 @@ def switch_view(what_view):
338339

339340
if adt: # Only if we have the temperature sensor
340341
tempC = round(adt.temperature)
341-
tempF = tempC * 1.8 + 32
342-
sensor_data.text = 'Touch: {}\nLight: {}\n Temp: {}°F'.format(touch, light, tempF)
342+
else: # No temperature sensor
343+
tempC = round(microcontroller.cpu.temperature)
343344

344-
else: # No temperature sensor on Titano and Pynt
345-
sensor_data.text = 'Touch: {}\nLight: {}'.format(touch, light)
345+
tempF = tempC * 1.8 + 32
346+
sensor_data.text = 'Touch: {}\nLight: {}\n Temp: {}°F'.format(touch, light, tempF)
346347

347348
# ------------- Handle Button Press Detection ------------- #
348349
if touch: # Only do this if the screen is touched

0 commit comments

Comments
 (0)