diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-05-14 20:39:14 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-05-14 20:39:14 (GMT) |
| commit | 9274d8cc2df1c40f96c8fc13eb3aec42fa792821 (patch) | |
| tree | a379f0596e7b416d7f7fae1de62db808232746ed /wasp | |
| parent | 880083977cb1de7714404d3b032fa0b6a090a7ca (diff) | |
drivers: signal: Finalize docstrings
Diffstat (limited to 'wasp')
| -rw-r--r-- | wasp/drivers/signal.py | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/wasp/drivers/signal.py b/wasp/drivers/signal.py index 974adb5..b72a218 100644 --- a/wasp/drivers/signal.py +++ b/wasp/drivers/signal.py @@ -1,26 +1,46 @@ # SPDX-License-Identifier: LGPL-3.0-or-later # Copyright (C) 2020 Daniel Thompson +"""Inverting pin wrapper +~~~~~~~~~~~~~~~~~~~~~~~~ +""" + class Signal(object): - '''Simplified Signal class + """Simplified Signal class + + .. note:: - Note: The normal C implementation isn't working for the NRF port - ''' + The normal C implementation of the Signal class used by MicroPython + doesn't work on the nRF family. This class provides a temporary + workaround until that can be addressed. + + .. automethod:: __init__ + """ def __init__(self, pin, invert=False): + """Create a Signal object by wrapping a pin.""" self.pin = pin self.invert = invert def __call__(self, v=None): + """Shortcut for :py:meth:`.value`""" return self.value(v) def value(self, v=None): + """Get or set the state of the signal. + + :param v: Value to set, defaults to None (which means get the signal + state instead. + :returns: The state of the signal if v is None, otherwise None. + """ if v == None: return self.invert ^ self.pin.value() self.pin.value(self.invert ^ bool(v)) def on(self): + """Activate the signal.""" self.value(1) def off(self): + """Deactivate the signal.""" self.value(0) |
