fix for import problems with MAX31855
This commit is contained in:
parent
082d422013
commit
26fcbd48b4
17
oven.py
17
oven.py
@ -2,6 +2,13 @@ import threading,time,random,datetime,logging
|
|||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
try:
|
||||||
|
from max31855 import MAX31855, MAX31855Error
|
||||||
|
sensor_dummy = False
|
||||||
|
except ImportError:
|
||||||
|
log.warning("Could not initialize temperature sensor, using dummy values!")
|
||||||
|
sensor_dummy = True
|
||||||
|
|
||||||
class Oven (threading.Thread):
|
class Oven (threading.Thread):
|
||||||
STATE_IDLE = "IDLE"
|
STATE_IDLE = "IDLE"
|
||||||
STATE_RUNNING = "RUNNING"
|
STATE_RUNNING = "RUNNING"
|
||||||
@ -58,12 +65,6 @@ class Oven (threading.Thread):
|
|||||||
return state
|
return state
|
||||||
|
|
||||||
class TempSensor(threading.Thread):
|
class TempSensor(threading.Thread):
|
||||||
try:
|
|
||||||
from max31855 import MAX31855, MAX31855Error
|
|
||||||
dummy = False
|
|
||||||
except ImportError:
|
|
||||||
log.warning("Could not initialize temperature sensor, using dummy values!")
|
|
||||||
dummy = True
|
|
||||||
|
|
||||||
def __init__(self,oven):
|
def __init__(self,oven):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
@ -72,7 +73,7 @@ class TempSensor(threading.Thread):
|
|||||||
self.temperature = 0
|
self.temperature = 0
|
||||||
self.oven = oven
|
self.oven = oven
|
||||||
|
|
||||||
if not TempSensor.dummy:
|
if not sensor_dummy:
|
||||||
cs_pin = 27
|
cs_pin = 27
|
||||||
clock_pin = 22
|
clock_pin = 22
|
||||||
data_pin = 17
|
data_pin = 17
|
||||||
@ -82,7 +83,7 @@ class TempSensor(threading.Thread):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while True:
|
while True:
|
||||||
if not TempSensor.dummy:
|
if not sensor_dummy:
|
||||||
self.temperature = self.thermocouple.get()
|
self.temperature = self.thermocouple.get()
|
||||||
else:
|
else:
|
||||||
time_delta = (20.0 - self.temperature)/40
|
time_delta = (20.0 - self.temperature)/40
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user