-
Notifications
You must be signed in to change notification settings - Fork 1
/
guiphidgets.py
38 lines (31 loc) · 1.04 KB
/
guiphidgets.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#Add Phidgets Library
from Phidget22.Phidget import *
from Phidget22.Devices.TemperatureSensor import *
from gpiozero import Button
from guizero import App, Text, PushButton
#Required for sleep statement
import time
#Create
temperatureSensor = TemperatureSensor()
btn = Button(2)
app = App(title="Dashboard")
#Open
temperatureSensor.openWaitForAttachment(1000)
# Get Temperature Function
def getTemp():
#Set Temperature Variable
showTemp = str(temperatureSensor.getTemperature()) + " °C"
# Print on GUI
message.value = showTemp
# Print for Debugging in console comment later
print(" Temperature: " + showTemp )
def convertTemp():
convertTemp = (temperatureSensor.getTemperature() * 1.8) + 32
showTemp = str(convertTemp) + " °F"
message.value = showTemp
# When button is pressed get temperature
btn.when_pressed = getTemp
message = Text(app)
button = PushButton(app, text="Get Temperature", command=getTemp)
button2 = PushButton(app, text="Convert Temperature to Fahrenheit", command=convertTemp)
app.display()