try to fix
This commit is contained in:
parent
175695d512
commit
b75b306726
|
@ -30,7 +30,6 @@ class GPIOPin(Actuator):
|
|||
|
||||
def enable(self, enable=True):
|
||||
GPIO.output(self.pin, self.onstate) if enable else self.disable()
|
||||
|
||||
|
||||
def disable(self):
|
||||
GPIO.output(self.pin, self.offstate)
|
||||
|
|
|
@ -175,7 +175,7 @@ class State():
|
|||
return None
|
||||
|
||||
def phase_time(self, arg=None):
|
||||
return (self.now() - self.envdata['current-phase-loadtime'])
|
||||
return (self.now() - self.envdata.get('current-phase-loadtime', 0))
|
||||
|
||||
def loadphase(self, phaseidx):
|
||||
phase = self.recipe.phases[phaseidx]
|
||||
|
|
12
sensors.py
12
sensors.py
|
@ -4,6 +4,9 @@ from collections import deque
|
|||
import re
|
||||
from os.path import exists
|
||||
|
||||
import RPi.GPIO as GPIO
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
|
||||
# TODO client: add a way to disable live plotting? server: stop
|
||||
# sending data periodically to everybody!
|
||||
|
||||
|
@ -21,6 +24,14 @@ class Sensor():
|
|||
return (perf_counter(),
|
||||
int((random() * (1-self.auto) + self.prevval * self.auto) * 100) / 100)
|
||||
|
||||
class GPIOState(Sensor):
|
||||
def __init__(self, pin, transform=lambda x: 1-x):
|
||||
self.pin = pin
|
||||
self.transform = transform
|
||||
|
||||
def read(self):
|
||||
return self.transform(GPIO.input(self.pin))
|
||||
|
||||
class Temperature1W(Sensor):
|
||||
def __init__(self, address):
|
||||
self.measure = 'Temperature'
|
||||
|
@ -61,6 +72,7 @@ class Sensors():
|
|||
self.available_sensors = {
|
||||
'T_ext': Temperature1W('28-06214252b671'),
|
||||
'T_food': Temperature1W('28-062142531e5a'),
|
||||
'heater': GPIOState(22),
|
||||
}
|
||||
|
||||
def list(self):
|
||||
|
|
Loading…
Reference in New Issue