From 0ab1cb0878e8da5956c2c2c6145b1a398b739dcd Mon Sep 17 00:00:00 2001 From: Michael Horne Date: Sun, 7 Mar 2021 16:39:48 +0000 Subject: [PATCH 1/2] Add Pimoroni 11x7 LED Matrix Breakout --- README.rst | 2 +- adafruit_is31fl3731.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 912d2ba..bada9ef 100644 --- a/README.rst +++ b/README.rst @@ -23,7 +23,7 @@ This driver supports the following hardware: * `Pimoroni 17x7 Scroll pHAT HD `_ * `Pimoroni 28x3 (r,g,b) Led Shim `_ * `Pimoroni Keybow 2040 with 4x4 matrix of RGB LEDs `_ - +* `Pimoroni 11x7 LED Matrix Breakout `_ Dependencies ============= diff --git a/adafruit_is31fl3731.py b/adafruit_is31fl3731.py index bc1a1c3..83b4030 100644 --- a/adafruit_is31fl3731.py +++ b/adafruit_is31fl3731.py @@ -28,6 +28,9 @@ * Pimoroni Keybow 2040 _ +* Pimoroni 11x7 Matrix + + **Software and Dependencies:** * Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards: @@ -398,6 +401,27 @@ def pixel_addr(x, y): y = y - 8 return x * 16 + y +class Matrix11x7(Matrix): + width = 11 + height = 7 + + def __init__(self, i2c, address=0x75): + super().__init__(i2c, address) + + @staticmethod + def pixel_addr(x, y): + mapping = [ + 6, 22, 38, 54, 70, 86, 14, 30, 46, 62, 78, + 5, 21, 37, 53, 69, 85, 13, 29, 45, 61, 77, + 4, 20, 36, 52, 68, 84, 12, 28, 44, 60, 76, + 3, 19, 35, 51, 67, 83, 11, 27, 43, 59, 75, + 2, 18, 34, 50, 66, 82, 10, 26, 42, 58, 74, + 1, 17, 33, 49, 65, 81, 9, 25, 41, 57, 73, + 0, 16, 32, 48, 64, 80, 8, 24, 40, 56, 72 + ] + + y = Matrix11x7.height - 1 - y + return mapping[(y * Matrix11x7.width) + x] class LedShim(Matrix): """Supports the LED SHIM by Pimoroni""" From 702fa04e14cb01559429555078cc360ac2f894dc Mon Sep 17 00:00:00 2001 From: Michael Horne Date: Mon, 8 Mar 2021 07:36:04 +0000 Subject: [PATCH 2/2] Add support from Pimoroni 11x7 LED Matrix Breakout. Run through Black and Pylint --- adafruit_is31fl3731.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/adafruit_is31fl3731.py b/adafruit_is31fl3731.py index 83b4030..98a3b17 100644 --- a/adafruit_is31fl3731.py +++ b/adafruit_is31fl3731.py @@ -401,7 +401,10 @@ def pixel_addr(x, y): y = y - 8 return x * 16 + y + class Matrix11x7(Matrix): + """Supports the 11x7 LED Matrix Breakout by Pimoroni""" + width = 11 height = 7 @@ -410,18 +413,13 @@ def __init__(self, i2c, address=0x75): @staticmethod def pixel_addr(x, y): - mapping = [ - 6, 22, 38, 54, 70, 86, 14, 30, 46, 62, 78, - 5, 21, 37, 53, 69, 85, 13, 29, 45, 61, 77, - 4, 20, 36, 52, 68, 84, 12, 28, 44, 60, 76, - 3, 19, 35, 51, 67, 83, 11, 27, 43, 59, 75, - 2, 18, 34, 50, 66, 82, 10, 26, 42, 58, 74, - 1, 17, 33, 49, 65, 81, 9, 25, 41, 57, 73, - 0, 16, 32, 48, 64, 80, 8, 24, 40, 56, 72 - ] + """Translate an x,y coordinate to a pixel index.""" + if x <= 5: + r = x * 16 + y + else: + r = (x - 5) * 16 + y - 8 + return r - y = Matrix11x7.height - 1 - y - return mapping[(y * Matrix11x7.width) + x] class LedShim(Matrix): """Supports the LED SHIM by Pimoroni"""