Skip to content

Commit 54b4c76

Browse files
committed
Update trellis accessors for debugging
1 parent 60499d9 commit 54b4c76

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

adafruit_neotrellis/multitrellis.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,17 @@ def color(self, x, y, color):
131131
pad = self._key_pads[y][x]
132132
pad.pixels[pad.key_index(x, y)] = color
133133

134+
@property
135+
def data_pending(self) -> bool:
136+
for py in range(self._rows):
137+
for px in range(self._cols):
138+
available = self._trelli[py][px].count
139+
if available > 0:
140+
return True
141+
return False
142+
134143
def sync(self):
135144
"""Read all trellis boards in the matrix and call any callbacks"""
136-
for _n in range(self._rows):
137-
for _m in range(self._cols):
138-
139-
_t = self._trelli[_n][_m]
140-
_t.sync()
145+
for py in range(self._rows):
146+
for px in range(self._cols):
147+
self._trelli[py][px].sync()

adafruit_neotrellis/neotrellis.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ def sync(self):
113113
):
114114
self.callbacks[evt.number](evt)
115115

116+
def local_key_index(self, x, y):
117+
return int(y * self.width + x)
118+
116119
def key_index(self, x, y):
117120
return int((y - self.y_base) * self.width + (x - self.x_base))
118121

0 commit comments

Comments
 (0)