summaryrefslogtreecommitdiff
path: root/wasp/drivers/signal.py
blob: 18ce8bff78e315fadb9ac92f8725ab05a5335ba1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)