Skip to content

Commit

Permalink
Update trellis accessors for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeharker committed Oct 24, 2024
1 parent 60499d9 commit 54b4c76
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
17 changes: 12 additions & 5 deletions adafruit_neotrellis/multitrellis.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,17 @@ def color(self, x, y, color):
pad = self._key_pads[y][x]
pad.pixels[pad.key_index(x, y)] = color

@property
def data_pending(self) -> bool:
for py in range(self._rows):
for px in range(self._cols):
available = self._trelli[py][px].count
if available > 0:
return True
return False

def sync(self):
"""Read all trellis boards in the matrix and call any callbacks"""
for _n in range(self._rows):
for _m in range(self._cols):

_t = self._trelli[_n][_m]
_t.sync()
for py in range(self._rows):
for px in range(self._cols):
self._trelli[py][px].sync()
3 changes: 3 additions & 0 deletions adafruit_neotrellis/neotrellis.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ def sync(self):
):
self.callbacks[evt.number](evt)

def local_key_index(self, x, y):
return int(y * self.width + x)

def key_index(self, x, y):
return int((y - self.y_base) * self.width + (x - self.x_base))

0 comments on commit 54b4c76

Please sign in to comment.