diff --git a/adafruit_neotrellis/multitrellis.py b/adafruit_neotrellis/multitrellis.py index 8354543..17fa8ad 100644 --- a/adafruit_neotrellis/multitrellis.py +++ b/adafruit_neotrellis/multitrellis.py @@ -123,6 +123,13 @@ def set_callback(self, x: int, y: int, function: CallbackType): pad = self._key_pads[y][x] pad.callbacks[pad.key_index(x, y)] = function + + def get_callback(self, x: int, y: int) -> Optional[CallbackType]: + """Get a callback function for when an event for the key at index x, y + (measured from the top lefthand corner) is detected.""" + pad = self._key_pads[y][x] + return pad.callbacks[pad.key_index(x, y)] + def color(self, x: int, y: int, color: PixelType): """Set the color of the pixel at index x, y measured from the top lefthand corner of the matrix""" diff --git a/adafruit_neotrellis/neotrellis.py b/adafruit_neotrellis/neotrellis.py index 5fd173b..0e83c83 100755 --- a/adafruit_neotrellis/neotrellis.py +++ b/adafruit_neotrellis/neotrellis.py @@ -91,7 +91,7 @@ def __init__(self, i2c_bus, interrupt=False, self.callbacks = [None] * _NEO_TRELLIS_NUM_KEYS self.pixels = NeoPixel(self, _NEO_TRELLIS_NEOPIX_PIN, _NEO_TRELLIS_NUM_KEYS) - def activate_key(self, key, edge, enable=True): + def activate_key(self, key: int, edge: int, enable: bool = True): """Activate or deactivate a key on the trellis. Key is the key number from 0 to 16. Edge specifies what edge to register an event on and can be NeoTrellis.EDGE_FALLING or NeoTrellis.EDGE_RISING. enable should be set