Update docstring

This commit is contained in:
arofarn 2021-06-27 18:35:32 +02:00
parent 5a16f94881
commit 77e83be0b6

View File

@ -6,7 +6,8 @@
`trellism4_extended` `trellism4_extended`
================================================================================ ================================================================================
CircuitPython library to extended Adafruit NeotrellisM4 board with two Neotrellis seesaw boards (or more !). CircuitPython library to extended Adafruit NeotrellisM4 board with two Neotrellis seesaw
boards (or more !).
* Author(s): arofarn * Author(s): arofarn
@ -28,8 +29,6 @@ Implementation Notes
""" """
# imports
__version__ = "0.0.0-auto.0" __version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/arofarn/CircuitPython_TrellisM4_extended.git" __repo__ = "https://github.com/arofarn/CircuitPython_TrellisM4_extended.git"
@ -160,7 +159,12 @@ class _TrellisKeypad:
class NeoTrellisM4: class NeoTrellisM4:
"""Driver for the Adafruit NeoTrellis.""" """Driver for the Adafruit NeoTrellis.
:param left_part : if None (or ommitted) the class create a
neotrellis.multitrellis-compatible object for the right half of the
TrellisM4 board. Else for the left part.
"""
EDGE_HIGH = const(0) EDGE_HIGH = const(0)
EDGE_LOW = const(1) EDGE_LOW = const(1)
@ -188,15 +192,15 @@ class NeoTrellisM4:
@property @property
def interrupt_enabled(self): def interrupt_enabled(self):
"""Only for compatibility with neotrellis module """Only for compatibility with neotrellis module:
interrupts are disable on trellis M4 keypad""" Interrupts are disable on trellis M4 keypad"""
return False return False
# pylint: disable=unused-argument, no-self-use # pylint: disable=unused-argument, no-self-use
@interrupt_enabled.setter @interrupt_enabled.setter
def interrupt_enabled(self, value): def interrupt_enabled(self, value):
"""Only for compatibility with neotrellis module """Only for compatibility with neotrellis module:
interrupts are disable on trellis M4 keypad Interrupts are disable on trellis M4 keypad
""" """
print("Warning: no interrupt with Trellis M4 keypad (method does nothing)") print("Warning: no interrupt with Trellis M4 keypad (method does nothing)")
# pylint: enable=unused-argument, no-self-use # pylint: enable=unused-argument, no-self-use
@ -217,8 +221,11 @@ class NeoTrellisM4:
# pylint: enable=unused-argument, no-self-use # pylint: enable=unused-argument, no-self-use
def set_event(self, key, edge, enable): def set_event(self, key, edge, enable):
"""Set event on a key """Control which kinds of events are set
""" :param int key: The key number
:param int edge: The type of event
:param bool enable: True to enable the event, False to disable it"""
if enable not in (True, False): if enable not in (True, False):
raise ValueError("event enable must be True or False") raise ValueError("event enable must be True or False")
if edge > 3 or edge < 0: if edge > 3 or edge < 0:
@ -231,14 +238,16 @@ class NeoTrellisM4:
self._events[key] = self._events[key] & (0xF ^ (1 << edge)) self._events[key] = self._events[key] & (0xF ^ (1 << edge))
def read_keypad(self, num): def read_keypad(self, num):
"""Give the n events in the keypad buffer """Read data from the keypad
""" :param int num: The number of bytes to read"""
while num > len(self._current_events): while num > len(self._current_events):
self._current_events.append(0xFF) self._current_events.append(0xFF)
return self._current_events[:num] return self._current_events[:num]
def _read_keypad(self): def _read_keypad(self):
"""Read keypad and update _key_edges and _current_events""" """Read keypad and update _key_edges and _current_events
"""
pressed = set(self.keypad.pressed_keys) pressed = set(self.keypad.pressed_keys)
#default : not pressed => EDGE_HIGH #default : not pressed => EDGE_HIGH
self._key_edges = [self.EDGE_HIGH] * _NEO_TRELLIS_NUM_KEYS self._key_edges = [self.EDGE_HIGH] * _NEO_TRELLIS_NUM_KEYS
@ -259,11 +268,13 @@ class NeoTrellisM4:
def activate_key(self, key, edge, enable=True): def activate_key(self, key, edge, enable=True):
"""Activate or deactivate a key on the trellis. Key is the key number from """Activate or deactivate a key on the trellis.
0 to 15. Edge specifies what edge to register an event on and can be
NeoTrellis.EDGE_FALLING or NeoTrellis.EDGE_RISING. enable should be set : param key : key number from 0 to 16.
to True if the event is to be enabled, or False if the event is to be : param edge : specifies what edge to register an event on and can be
disabled. NeoTrellis.EDGE_FALLING or NeoTrellis.EDGE_RISING.
: param enable : should be set to True if the event is to be enabled,
or False if the event is to be disabled.
""" """
self.set_event(key, edge, enable) self.set_event(key, edge, enable)