fixup
This commit is contained in:
parent
bd96ca95a6
commit
7cfbb3f56b
12
sensors.py
12
sensors.py
|
@ -28,15 +28,13 @@ class GPIOState(Sensor):
|
||||||
def __init__(self, pin, transform=lambda x: 1-x):
|
def __init__(self, pin, transform=lambda x: 1-x):
|
||||||
self.pin = pin
|
self.pin = pin
|
||||||
self.transform = transform
|
self.transform = transform
|
||||||
|
|
||||||
self.value = GPIO.input(self.pin)
|
|
||||||
self.update_time()
|
|
||||||
|
|
||||||
def update_time(self):
|
|
||||||
self.time = perf_counter()
|
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
self.value = GPIO.input(self.pin)
|
try:
|
||||||
|
self.value = GPIO.input(self.pin)
|
||||||
|
except:
|
||||||
|
self.value = None
|
||||||
|
self.time = perf_counter()
|
||||||
|
|
||||||
return (self.time, self.transform(self.value))
|
return (self.time, self.transform(self.value))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue