4747__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_neotrellis.git"
4848
4949from time import sleep
50- from typing import Callable , List , Optional
50+ from typing import Callable , List , Optional , TypeAlias
5151
5252from adafruit_seesaw .keypad import KeyEvent , Keypad , ResponseType
5353from adafruit_seesaw .neopixel import NeoPixel
6363_NEO_TRELLIS_NUM_KEYS = const (64 )
6464
6565
66- CallbackType = Callable [[KeyEvent ], None ]
66+ CallbackType : TypeAlias = Callable [[KeyEvent ], None ]
6767
6868
6969class NeoTrellis (Keypad ):
@@ -73,15 +73,18 @@ class NeoTrellis(Keypad):
7373 height : int
7474 x_base : int
7575 y_base : int
76+ pad_x : int
77+ pad_y : int
7678 interrupt_enabled : bool
7779 callbacks : List [Optional [CallbackType ]]
7880 pixels : NeoPixel
7981
80- def __init__ (self , i2c_bus , interrupt = False ,
81- addr = _NEO_TRELLIS_ADDR , drdy = None ,
82- width = _NEO_TRELLIS_NUM_COLS ,
83- height = _NEO_TRELLIS_NUM_ROWS ,
84- x_base = 0 , y_base = 0 ):
82+ def __init__ (self , i2c_bus , interrupt : bool = False ,
83+ addr : int = _NEO_TRELLIS_ADDR , drdy = None ,
84+ width : int = _NEO_TRELLIS_NUM_COLS ,
85+ height : int = _NEO_TRELLIS_NUM_ROWS ,
86+ x_base : int = 0 , y_base : int = 0 ,
87+ pad_x : int = 0 , pad_y : int = 0 ):
8588 super ().__init__ (i2c_bus , addr , drdy )
8689 self .width = width
8790 self .height = height
@@ -91,18 +94,21 @@ def __init__(self, i2c_bus, interrupt=False,
9194 self .callbacks = [None ] * _NEO_TRELLIS_NUM_KEYS
9295 self .pixels = NeoPixel (self , _NEO_TRELLIS_NEOPIX_PIN , _NEO_TRELLIS_NUM_KEYS )
9396
94- def activate_key (self , key : int , edge : int , enable : bool = True ):
97+ def activate_key (self , key : int , edge : int , enable : bool = True ) -> None :
9598 """Activate or deactivate a key on the trellis. Key is the key number from
9699 0 to 16. Edge specifies what edge to register an event on and can be
97100 NeoTrellis.EDGE_FALLING or NeoTrellis.EDGE_RISING. enable should be set
98101 to True if the event is to be enabled, or False if the event is to be
99102 disabled."""
100103 self .set_event (key , edge , enable )
101104
102- def clear (self ):
105+ def clear (self ) -> None :
103106 self .pixels .fill ((0 , 0 , 0 ))
104107
105- def sync (self ):
108+ def show (self ) -> None :
109+ self .pixels .show ()
110+
111+ def sync (self ) -> None :
106112 """read any events from the Trellis hardware and call associated
107113 callbacks"""
108114 available = self .count
@@ -120,9 +126,9 @@ def sync(self):
120126 ):
121127 callback (evt )
122128
123- def local_key_index (self , x , y ):
129+ def local_key_index (self , x , y ) -> int :
124130 return int (y * self .width + x )
125131
126- def key_index (self , x , y ):
132+ def key_index (self , x , y ) -> int :
127133 return int ((y - self .y_base ) * self .width + (x - self .x_base ))
128134
0 commit comments