1
0
Fork 0
wasp-os/wasp/drivers/signal.py
2020-01-30 21:46:35 +00:00

23 lines
520 B
Python

class Signal(object):
'''Simplified Signal class
Note: The normal C implementation isn't working for the NRF port
'''
def __init__(self, pin, invert=False):
self.pin = pin
self.invert = invert
def __call__(self, v=None):
return self.value(v)
def value(self, v=None):
if v == None:
return self.invert ^ self.pin.value()
self.pin.value(self.invert ^ bool(v))
def on(self):
self.value(1)
def off(self):
self.value(0)