Skip to content

Commit

Permalink
Keybow 2040: Further tiny RGB speedup.
Browse files Browse the repository at this point in the history
Speed up RGB a little more by skipping the first 17 and last few unused elements.

Signed-off-by: Phil Howard <github@gadgetoid.com>
  • Loading branch information
Gadgetoid committed Jun 10, 2024
1 parent 82bc902 commit 9b94ff3
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions boards/pimoroni/keybow_2040/keybow_2040_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ class Keybow2040Leds(PixelBuf):
width = 16
height = 3

def __init__(
self,
size: int = 16 # Kept for backward compatibility
):
self.i2c = i2c = busio.I2C( board.SCL, board.SDA, frequency=400_000)
def __init__(self, size: int = 16): # Kept for backward compatibility
self.i2c = i2c = busio.I2C(board.SCL, board.SDA, frequency=400_000)
self.i2c_device = I2CDevice(i2c, 0x74)
self.out_buffer = bytearray(144)
self._pixels = 16
Expand Down Expand Up @@ -56,7 +53,7 @@ def _transmit(self, buffer):

# We only actually use 16 * 3 = 48 LEDs out of the 144 total
# but at 400KHz I2C it's cheaper just to write the whole lot
i2c.write(bytes([_COLOR_OFFSET]) + self.out_buffer)
i2c.write(bytes([_COLOR_OFFSET + 17]) + self.out_buffer[17:140])

# Set the newly written frame as the visible one
i2c.write(bytes([_BANK_ADDRESS, _CONFIG_BANK]))
Expand Down

0 comments on commit 9b94ff3

Please sign in to comment.