From d85fd576f50e5ca0e3db83d55b267a5bb3869867 Mon Sep 17 00:00:00 2001 From: David Glaude Date: Sun, 16 Aug 2020 15:03:02 +0200 Subject: [PATCH 01/14] Split library into package and adapt examples+doc --- README.rst | 8 +- adafruit_is31fl3731/CharlieBonnet.py | 64 +++++++++ adafruit_is31fl3731/CharlieWing.py | 69 +++++++++ adafruit_is31fl3731/LedShim.py | 132 +++++++++++++++++ adafruit_is31fl3731/ScrollPhatHD.py | 65 +++++++++ .../__init__.py | 136 ------------------ examples/is31fl3731_blink_example.py | 27 ++-- examples/is31fl3731_frame_example.py | 27 ++-- examples/is31fl3731_ledshim_rainbow.py | 4 +- examples/is31fl3731_pillow_animated_gif.py | 17 ++- examples/is31fl3731_pillow_marquee.py | 17 ++- examples/is31fl3731_pillow_numbers.py | 17 ++- examples/is31fl3731_simpletest.py | 26 ++-- examples/is31fl3731_text_example.py | 26 ++-- examples/is31fl3731_wave_example.py | 23 ++- 15 files changed, 460 insertions(+), 198 deletions(-) create mode 100644 adafruit_is31fl3731/CharlieBonnet.py create mode 100644 adafruit_is31fl3731/CharlieWing.py create mode 100644 adafruit_is31fl3731/LedShim.py create mode 100644 adafruit_is31fl3731/ScrollPhatHD.py rename adafruit_is31fl3731.py => adafruit_is31fl3731/__init__.py (79%) diff --git a/README.rst b/README.rst index 61fa057..91607a6 100644 --- a/README.rst +++ b/README.rst @@ -66,11 +66,11 @@ Matrix: .. code:: python - import adafruit_is31fl3731 + from adafruit_is31fl3731 import Matrix import board import busio with busio.I2C(board.SCL, board.SDA) as i2c: - display = adafruit_is31fl3731.Matrix(i2c) + display = Matrix(i2c) display.fill(127) @@ -78,11 +78,11 @@ Charlie Wing: .. code:: python - import adafruit_is31fl3731 + from adafruit_is31fl3731.CharlieWing import CharlieWing import board import busio with busio.I2C(board.SCL, board.SDA) as i2c: - display = adafruit_is31fl3731.CharlieWing(i2c) + display = CharlieWing(i2c) display.fill(127) # Turn off pixel 4,4, change its brightness and turn it back on diff --git a/adafruit_is31fl3731/CharlieBonnet.py b/adafruit_is31fl3731/CharlieBonnet.py new file mode 100644 index 0000000..17cab3a --- /dev/null +++ b/adafruit_is31fl3731/CharlieBonnet.py @@ -0,0 +1,64 @@ +# The MIT License (MIT) +# +# Copyright (c) 2017 Tony DiCola +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +""" +`adafruit_is31fl3731` +==================================================== + +CircuitPython driver for the IS31FL3731 charlieplex IC. + + +* Author(s): Tony DiCola, Melissa LeBlanc-Williams + +Implementation Notes +-------------------- + +**Hardware:** + +* `Adafruit 16x9 Charlieplexed PWM LED Matrix Driver - IS31FL3731 + `_ + +* `Adafruit 15x7 CharliePlex LED Matrix Display FeatherWings + `_ + +**Software and Dependencies:** + +* Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards: + https://github.com/adafruit/circuitpython/releases +""" + +# imports +from . import Matrix + + +class CharlieBonnet(Matrix): + """Supports the Charlieplexed bonnet""" + + width = 16 + height = 8 + + @staticmethod + def pixel_addr(x, y): + """Calulate the offset into the device array for x,y pixel""" + if x >= 8: + return (x - 6) * 16 - (y + 1) + return (x + 1) * 16 + (7 - y) diff --git a/adafruit_is31fl3731/CharlieWing.py b/adafruit_is31fl3731/CharlieWing.py new file mode 100644 index 0000000..13c50ef --- /dev/null +++ b/adafruit_is31fl3731/CharlieWing.py @@ -0,0 +1,69 @@ +# The MIT License (MIT) +# +# Copyright (c) 2017 Tony DiCola +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +""" +`adafruit_is31fl3731` +==================================================== + +CircuitPython driver for the IS31FL3731 charlieplex IC. + + +* Author(s): Tony DiCola, Melissa LeBlanc-Williams + +Implementation Notes +-------------------- + +**Hardware:** + +* `Adafruit 16x9 Charlieplexed PWM LED Matrix Driver - IS31FL3731 + `_ + +* `Adafruit 15x7 CharliePlex LED Matrix Display FeatherWings + `_ + +**Software and Dependencies:** + +* Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards: + https://github.com/adafruit/circuitpython/releases +""" + +# imports +from . import Matrix + + +class CharlieWing(Matrix): + """Supports the Charlieplexed feather wing + """ + + width = 15 + height = 7 + + @staticmethod + def pixel_addr(x, y): + """Calulate the offset into the device array for x,y pixel + """ + if x > 7: + x = 15 - x + y += 8 + else: + y = 7 - y + return x * 16 + y diff --git a/adafruit_is31fl3731/LedShim.py b/adafruit_is31fl3731/LedShim.py new file mode 100644 index 0000000..bdefd2e --- /dev/null +++ b/adafruit_is31fl3731/LedShim.py @@ -0,0 +1,132 @@ +# The MIT License (MIT) +# +# Copyright (c) 2017 Tony DiCola +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +""" +`adafruit_is31fl3731.LedShim` +==================================================== + +CircuitPython driver for the IS31FL3731 charlieplex IC. + + +* Author: David Glaude + +Implementation Notes +-------------------- + +**Hardware:** + +* `Pimoroni 28 RGB Led Shim + `_ + +**Software and Dependencies:** + +* Adafruit CircuitPython firmware: + https://github.com/adafruit/circuitpython/releases +""" + +# imports +from . import Matrix + + +class LedShim(Matrix): + """Supports the LED SHIM by Pimoroni""" + + width = 28 + height = 3 + + def __init__(self, i2c, address=0x75): + super().__init__(i2c, address) + + # pylint: disable-msg=too-many-arguments + def pixelrgb(self, x, r, g, b, blink=None, frame=None): + """ + Blink or brightness for x-pixel + + :param x: horizontal pixel position + :param r: red brightness value 0->255 + :param g: green brightness value 0->255 + :param b: blue brightness value 0->255 + :param blink: True to blink + :param frame: the frame to set the pixel + """ + super().pixel(x, 0, r, blink, frame) + super().pixel(x, 1, g, blink, frame) + super().pixel(x, 2, b, blink, frame) + + # pylint: disable=inconsistent-return-statements + # pylint: disable=too-many-return-statements + # pylint: disable=too-many-branches + + @staticmethod + def pixel_addr(x, y): + """Translate an x,y coordinate to a pixel index.""" + if y == 0: + if x < 7: + return 118 - x + if x < 15: + return 141 - x + if x < 21: + return 106 + x + if x == 21: + return 15 + return x - 14 + + if y == 1: + if x < 2: + return 69 - x + if x < 7: + return 86 - x + if x < 12: + return 28 - x + if x < 14: + return 45 - x + if x == 14: + return 47 + if x == 15: + return 41 + if x < 21: + return x + 9 + if x == 21: + return 95 + if x < 26: + return x + 67 + return x + 50 + + if x == 0: + return 85 + if x < 7: + return 102 - x + if x < 11: + return 44 - x + if x < 14: + return 61 - x + if x == 14: + return 63 + if x < 17: + return 42 + x + if x < 21: + return x + 25 + if x == 21: + return 111 + if x < 27: + return x + 83 + return 93 diff --git a/adafruit_is31fl3731/ScrollPhatHD.py b/adafruit_is31fl3731/ScrollPhatHD.py new file mode 100644 index 0000000..a72b9e7 --- /dev/null +++ b/adafruit_is31fl3731/ScrollPhatHD.py @@ -0,0 +1,65 @@ +# The MIT License (MIT) +# +# Copyright (c) 2017 Tony DiCola +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +""" +`adafruit_is31fl3731.ScrollPhatHD` +==================================================== + +CircuitPython driver for the Pimoroni 17x7 Scroll pHAT HD. + + +* Author: David Glaude + +Implementation Notes +-------------------- + +**Hardware:** + +* `Pimoroni 17x7 Scroll pHAT HD + `_ + +**Software and Dependencies:** + +* Adafruit CircuitPython firmware: + https://github.com/adafruit/circuitpython/releases +""" + +# imports +from . import Matrix + + +class ScrollPhatHD(Matrix): + """Supports the Scroll pHAT HD by Pimoroni""" + + width = 17 + height = 7 + + @staticmethod + def pixel_addr(x, y): + """Translate an x,y coordinate to a pixel index.""" + if x <= 8: + x = 8 - x + y = 6 - y + else: + x = x - 8 + y = y - 8 + return x * 16 + y diff --git a/adafruit_is31fl3731.py b/adafruit_is31fl3731/__init__.py similarity index 79% rename from adafruit_is31fl3731.py rename to adafruit_is31fl3731/__init__.py index b7c3e95..bf7b1c1 100644 --- a/adafruit_is31fl3731.py +++ b/adafruit_is31fl3731/__init__.py @@ -364,139 +364,3 @@ def image(self, img, blink=None, frame=None): for x in range(self.width): # yes this double loop is slow, for y in range(self.height): # but these displays are small! self.pixel(x, y, pixels[(x, y)], blink=blink, frame=frame) - - -class CharlieWing(Matrix): - """Supports the Charlieplexed feather wing - """ - - width = 15 - height = 7 - - @staticmethod - def pixel_addr(x, y): - """Calulate the offset into the device array for x,y pixel - """ - if x > 7: - x = 15 - x - y += 8 - else: - y = 7 - y - return x * 16 + y - - -class CharlieBonnet(Matrix): - """Supports the Charlieplexed bonnet""" - - width = 16 - height = 8 - - @staticmethod - def pixel_addr(x, y): - """Calulate the offset into the device array for x,y pixel""" - if x >= 8: - return (x - 6) * 16 - (y + 1) - return (x + 1) * 16 + (7 - y) - - -class ScrollPhatHD(Matrix): - """Supports the Scroll pHAT HD by Pimoroni""" - - width = 17 - height = 7 - - @staticmethod - def pixel_addr(x, y): - """Translate an x,y coordinate to a pixel index.""" - if x <= 8: - x = 8 - x - y = 6 - y - else: - x = x - 8 - y = y - 8 - return x * 16 + y - - -class LedShim(Matrix): - """Supports the LED SHIM by Pimoroni""" - - width = 28 - height = 3 - - def __init__(self, i2c, address=0x75): - super().__init__(i2c, address) - - # pylint: disable-msg=too-many-arguments - def pixelrgb(self, x, r, g, b, blink=None, frame=None): - """ - Blink or brightness for x-pixel - - :param x: horizontal pixel position - :param r: red brightness value 0->255 - :param g: green brightness value 0->255 - :param b: blue brightness value 0->255 - :param blink: True to blink - :param frame: the frame to set the pixel - """ - super().pixel(x, 0, r, blink, frame) - super().pixel(x, 1, g, blink, frame) - super().pixel(x, 2, b, blink, frame) - - # pylint: disable=inconsistent-return-statements - # pylint: disable=too-many-return-statements - # pylint: disable=too-many-branches - - @staticmethod - def pixel_addr(x, y): - """Translate an x,y coordinate to a pixel index.""" - if y == 0: - if x < 7: - return 118 - x - if x < 15: - return 141 - x - if x < 21: - return 106 + x - if x == 21: - return 15 - return x - 14 - - if y == 1: - if x < 2: - return 69 - x - if x < 7: - return 86 - x - if x < 12: - return 28 - x - if x < 14: - return 45 - x - if x == 14: - return 47 - if x == 15: - return 41 - if x < 21: - return x + 9 - if x == 21: - return 95 - if x < 26: - return x + 67 - return x + 50 - - if x == 0: - return 85 - if x < 7: - return 102 - x - if x < 11: - return 44 - x - if x < 14: - return 61 - x - if x == 14: - return 63 - if x < 17: - return 42 + x - if x < 21: - return x + 25 - if x == 21: - return 111 - if x < 27: - return x + 83 - return 93 diff --git a/examples/is31fl3731_blink_example.py b/examples/is31fl3731_blink_example.py index 5319879..2105a08 100644 --- a/examples/is31fl3731_blink_example.py +++ b/examples/is31fl3731_blink_example.py @@ -1,20 +1,29 @@ -import busio import board -import adafruit_is31fl3731 +import busio + +# uncomment next line if you are using Feather CharlieWing LED 15 x 7 +from adafruit_is31fl3731.CharlieWing import CharlieWing + +# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix +# from adafruit_is31fl3731 import Matrix +# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet +# from adafruit_is31fl3731.CharlieBonnet import CharlieBonnet +# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 +# from adafruit_is31fl3731.ScrollPhatHD import ScrollPhatHD i2c = busio.I2C(board.SCL, board.SDA) # array pattern in bits; top row-> bottom row, 8 bits in each row an_arrow = bytearray((0x08, 0x0C, 0xFE, 0xFF, 0xFE, 0x0C, 0x08, 0x00, 0x00)) -# initial display using Feather CharlieWing LED 15 x 7 -display = adafruit_is31fl3731.CharlieWing(i2c) +# uncomment next line if you are using Feather CharlieWing LED 15 x 7 +display = CharlieWing(i2c) # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = adafruit_is31fl3731.Matrix(i2c) -# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = adafruit_is31fl3731.CharlieBonnet(i2c) -# initial display using Pimoroni Scroll Phat HD LED 17 x 7 -# display = adafruit_is31fl3731.ScrollPhatHD(i2c) +# display = Matrix(i2c) +# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet +# display = CharlieBonnet(i2c) +# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 +# display = ScrollPhatHD(i2c) # first load the frame with the arrows; moves the an_arrow to the right in each # frame diff --git a/examples/is31fl3731_frame_example.py b/examples/is31fl3731_frame_example.py index b678daa..f9e14ac 100644 --- a/examples/is31fl3731_frame_example.py +++ b/examples/is31fl3731_frame_example.py @@ -1,21 +1,30 @@ import time import board import busio -import adafruit_is31fl3731 + +# uncomment next line if you are using Feather CharlieWing LED 15 x 7 +from adafruit_is31fl3731.CharlieWing import CharlieWing + +# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix +# from adafruit_is31fl3731 import Matrix +# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet +# from adafruit_is31fl3731.CharlieBonnet import CharlieBonnet +# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 +# from adafruit_is31fl3731.ScrollPhatHD import ScrollPhatHD i2c = busio.I2C(board.SCL, board.SDA) # arrow pattern in bits; top row-> bottom row, 8 bits in each row arrow = bytearray((0x08, 0x0C, 0xFE, 0xFF, 0xFE, 0x0C, 0x08, 0x00, 0x00)) -# initial display using Feather CharlieWing LED 15 x 7 -display = adafruit_is31fl3731.CharlieWing(i2c) -# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = adafruit_is31fl3731.Matrix(i2c) -# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = adafruit_is31fl3731.CharlieBonnet(i2c) -# initial display using Pimoroni Scroll Phat HD LED 17 x 7 -# display = adafruit_is31fl3731.ScrollPhatHD(i2c) +# uncomment next line if you are using Feather CharlieWing LED 15 x 7 +display = CharlieWing(i2c) +# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix +# display = Matrix(i2c) +# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet +# display = CharlieBonnet(i2c) +# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 +# display = ScrollPhatHD(i2c) # first load the frame with the arrows; moves the arrow to the right in each diff --git a/examples/is31fl3731_ledshim_rainbow.py b/examples/is31fl3731_ledshim_rainbow.py index 3d658b0..f23b5b3 100644 --- a/examples/is31fl3731_ledshim_rainbow.py +++ b/examples/is31fl3731_ledshim_rainbow.py @@ -1,12 +1,12 @@ import time import board import busio -import adafruit_is31fl3731 +from adafruit_is31fl3731.LedShim import LedShim i2c = busio.I2C(board.SCL, board.SDA) # initial display if you are using Pimoroni LED SHIM -display = adafruit_is31fl3731.LedShim(i2c) +display = LedShim(i2c) # This list 28 colors from a rainbow... rainbow = [ diff --git a/examples/is31fl3731_pillow_animated_gif.py b/examples/is31fl3731_pillow_animated_gif.py index dffbfc9..4183c54 100644 --- a/examples/is31fl3731_pillow_animated_gif.py +++ b/examples/is31fl3731_pillow_animated_gif.py @@ -15,14 +15,23 @@ import sys import board from PIL import Image -import adafruit_is31fl3731 + +# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix +# from adafruit_is31fl3731 import Matrix +# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet +from adafruit_is31fl3731.CharlieBonnet import CharlieBonnet + +# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 +# from adafruit_is31fl3731.ScrollPhatHD import ScrollPhatHD i2c = board.I2C() # uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = adafruit_is31fl3731.Matrix(i2c) -# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -display = adafruit_is31fl3731.CharlieBonnet(i2c) +# display = Matrix(i2c) +# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet +display = CharlieBonnet(i2c) +# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 +# display = ScrollPhatHD(i2c) # Open the gif if len(sys.argv) < 2: diff --git a/examples/is31fl3731_pillow_marquee.py b/examples/is31fl3731_pillow_marquee.py index 5b24b00..810c7db 100644 --- a/examples/is31fl3731_pillow_marquee.py +++ b/examples/is31fl3731_pillow_marquee.py @@ -10,7 +10,14 @@ import board from PIL import Image, ImageDraw, ImageFont -import adafruit_is31fl3731 + +# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix +# from adafruit_is31fl3731 import Matrix +# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet +from adafruit_is31fl3731.CharlieBonnet import CharlieBonnet + +# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 +# from adafruit_is31fl3731.ScrollPhatHD import ScrollPhatHD SCROLLING_TEXT = "You can display a personal message here..." BRIGHTNESS = 64 # Brightness can be between 0-255 @@ -18,9 +25,11 @@ i2c = board.I2C() # uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = adafruit_is31fl3731.Matrix(i2c) -# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -display = adafruit_is31fl3731.CharlieBonnet(i2c) +# display = Matrix(i2c) +# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet +display = CharlieBonnet(i2c) +# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 +# display = ScrollPhatHD(i2c) # Load a font font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 8) diff --git a/examples/is31fl3731_pillow_numbers.py b/examples/is31fl3731_pillow_numbers.py index 2f298c9..93b4c29 100644 --- a/examples/is31fl3731_pillow_numbers.py +++ b/examples/is31fl3731_pillow_numbers.py @@ -11,16 +11,25 @@ import board from PIL import Image, ImageDraw, ImageFont -import adafruit_is31fl3731 + +# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix +# from adafruit_is31fl3731 import Matrix +# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet +from adafruit_is31fl3731.CharlieBonnet import CharlieBonnet + +# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 +# from adafruit_is31fl3731.ScrollPhatHD import ScrollPhatHD BRIGHTNESS = 32 # Brightness can be between 0-255 i2c = board.I2C() # uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = adafruit_is31fl3731.Matrix(i2c) -# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -display = adafruit_is31fl3731.CharlieBonnet(i2c) +# display = Matrix(i2c) +# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet +display = CharlieBonnet(i2c) +# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 +# display = ScrollPhatHD(i2c) display.fill(0) diff --git a/examples/is31fl3731_simpletest.py b/examples/is31fl3731_simpletest.py index 221c8b3..333bdd2 100644 --- a/examples/is31fl3731_simpletest.py +++ b/examples/is31fl3731_simpletest.py @@ -1,20 +1,26 @@ import board import busio -import adafruit_is31fl3731 -i2c = busio.I2C(board.SCL, board.SDA) - -# initialize display using Feather CharlieWing LED 15 x 7 -display = adafruit_is31fl3731.CharlieWing(i2c) +# uncomment next line if you are using Feather CharlieWing LED 15 x 7 +from adafruit_is31fl3731.CharlieWing import CharlieWing # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = adafruit_is31fl3731.Matrix(i2c) - +# from adafruit_is31fl3731 import Matrix # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -# display = adafruit_is31fl3731.CharlieBonnet(i2c) +# from adafruit_is31fl3731.CharlieBonnet import CharlieBonnet +# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 +# from adafruit_is31fl3731.ScrollPhatHD import ScrollPhatHD -# initial display using Pimoroni Scroll Phat HD LED 17 x 7 -# display = adafruit_is31fl3731.ScrollPhatHD(i2c) +i2c = busio.I2C(board.SCL, board.SDA) + +# uncomment next line if you are using Feather CharlieWing LED 15 x 7 +display = CharlieWing(i2c) +# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix +# display = Matrix(i2c) +# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet +# display = CharlieBonnet(i2c) +# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 +# display = ScrollPhatHD(i2c) # draw a box on the display # first draw the top and bottom edges diff --git a/examples/is31fl3731_text_example.py b/examples/is31fl3731_text_example.py index e570176..ad5af92 100644 --- a/examples/is31fl3731_text_example.py +++ b/examples/is31fl3731_text_example.py @@ -1,19 +1,27 @@ import board import busio import adafruit_framebuf -import adafruit_is31fl3731 +# uncomment next line if you are using Feather CharlieWing LED 15 x 7 +# from adafruit_is31fl3731.CharlieWing import CharlieWing +# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix +# from adafruit_is31fl3731 import Matrix +# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet +from adafruit_is31fl3731.CharlieBonnet import CharlieBonnet + +# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 +# from adafruit_is31fl3731.ScrollPhatHD import ScrollPhatHD i2c = busio.I2C(board.SCL, board.SDA) -# initial display using Feather CharlieWing LED 15 x 7 -# display = adafruit_is31fl3731.CharlieWing(i2c) -# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = adafruit_is31fl3731.Matrix(i2c) -# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -display = adafruit_is31fl3731.CharlieBonnet(i2c) -# initial display using Pimoroni Scroll Phat HD LED 17 x 7 -# display = adafruit_is31fl3731.ScrollPhatHD(i2c) +# uncomment next line if you are using Feather CharlieWing LED 15 x 7 +# display = CharlieWing(i2c) +# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix +# display = Matrix(i2c) +# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet +display = CharlieBonnet(i2c) +# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 +# display = ScrollPhatHD(i2c) text_to_show = "Adafruit!!" diff --git a/examples/is31fl3731_wave_example.py b/examples/is31fl3731_wave_example.py index 332f0a5..57bf221 100644 --- a/examples/is31fl3731_wave_example.py +++ b/examples/is31fl3731_wave_example.py @@ -1,6 +1,15 @@ import board import busio -import adafruit_is31fl3731 + +# uncomment next line if you are using Feather CharlieWing LED 15 x 7 +from adafruit_is31fl3731.CharlieWing import CharlieWing + +# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix +# from adafruit_is31fl3731 import Matrix +# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet +# from adafruit_is31fl3731.CharlieBonnet import CharlieBonnet +# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 +# from adafruit_is31fl3731.ScrollPhatHD import ScrollPhatHD i2c = busio.I2C(board.SCL, board.SDA) @@ -33,14 +42,14 @@ frame = 0 -# initialize display using Feather CharlieWing LED 15 x 7 -display = adafruit_is31fl3731.CharlieWing(i2c) +# uncomment next line if you are using Feather CharlieWing LED 15 x 7 +display = CharlieWing(i2c) # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = adafruit_is31fl3731.Matrix(i2c) +# display = Matrix(i2c) # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -# display = adafruit_is31fl3731.CharlieBonnet(i2c) -# initial display using Pimoroni Scroll Phat HD LED 17 x 7 -# display = adafruit_is31fl3731.ScrollPhatHD(i2c) +# display = CharlieBonnet(i2c) +# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 +# display = ScrollPhatHD(i2c) while True: for incr in range(24): From c1166f02a50602c9eeea30254ed8bea2d2b69385 Mon Sep 17 00:00:00 2001 From: David Glaude Date: Wed, 19 Aug 2020 21:52:20 +0200 Subject: [PATCH 02/14] make library lowercase + remove the matrix singularity + adapt example --- adafruit_is31fl3731/__init__.py | 6 +- .../{CharlieBonnet.py => charlie_bonnet.py} | 4 +- .../{CharlieWing.py => charlie_wing.py} | 7 +-- .../{LedShim.py => led_shim.py} | 4 +- adafruit_is31fl3731/matrix.py | 61 +++++++++++++++++++ .../{ScrollPhatHD.py => scroll_phat_hd.py} | 4 +- examples/is31fl3731_blink_example.py | 17 ++---- examples/is31fl3731_frame_example.py | 17 ++---- examples/is31fl3731_ledshim_rainbow.py | 4 +- examples/is31fl3731_pillow_animated_gif.py | 14 ++--- examples/is31fl3731_pillow_marquee.py | 13 ++-- examples/is31fl3731_pillow_numbers.py | 13 ++-- examples/is31fl3731_simpletest.py | 17 ++---- examples/is31fl3731_text_example.py | 17 ++---- examples/is31fl3731_wave_example.py | 17 ++---- 15 files changed, 113 insertions(+), 102 deletions(-) rename adafruit_is31fl3731/{CharlieBonnet.py => charlie_bonnet.py} (97%) rename adafruit_is31fl3731/{CharlieWing.py => charlie_wing.py} (92%) rename adafruit_is31fl3731/{LedShim.py => led_shim.py} (98%) create mode 100644 adafruit_is31fl3731/matrix.py rename adafruit_is31fl3731/{ScrollPhatHD.py => scroll_phat_hd.py} (97%) diff --git a/adafruit_is31fl3731/__init__.py b/adafruit_is31fl3731/__init__.py index bf7b1c1..ef8c423 100644 --- a/adafruit_is31fl3731/__init__.py +++ b/adafruit_is31fl3731/__init__.py @@ -78,9 +78,10 @@ _COLOR_OFFSET = const(0x24) -class Matrix: +class IS31FL3731: """ - The Matrix class support the main function for driving the 16x9 matrix Display + The IS31FL3731 is an abstract class contain the main function related to this chip. + Each board needs to define width, height and pixel_addr. :param ~adafruit_bus_device.i2c_device i2c_device: the connected i2c bus i2c_device :param address: the device address; defaults to 0x74 @@ -298,6 +299,7 @@ def fill(self, color=None, blink=None, frame=None): for col in range(18): self._register(frame, _BLINK_OFFSET + col, data) + # This function must be replaced for each board @staticmethod def pixel_addr(x, y): """Calulate the offset into the device array for x,y pixel diff --git a/adafruit_is31fl3731/CharlieBonnet.py b/adafruit_is31fl3731/charlie_bonnet.py similarity index 97% rename from adafruit_is31fl3731/CharlieBonnet.py rename to adafruit_is31fl3731/charlie_bonnet.py index 17cab3a..2ea5c75 100644 --- a/adafruit_is31fl3731/CharlieBonnet.py +++ b/adafruit_is31fl3731/charlie_bonnet.py @@ -47,10 +47,10 @@ """ # imports -from . import Matrix +from . import IS31FL3731 -class CharlieBonnet(Matrix): +class CharlieBonnet(IS31FL3731): """Supports the Charlieplexed bonnet""" width = 16 diff --git a/adafruit_is31fl3731/CharlieWing.py b/adafruit_is31fl3731/charlie_wing.py similarity index 92% rename from adafruit_is31fl3731/CharlieWing.py rename to adafruit_is31fl3731/charlie_wing.py index 13c50ef..f87cd03 100644 --- a/adafruit_is31fl3731/CharlieWing.py +++ b/adafruit_is31fl3731/charlie_wing.py @@ -34,9 +34,6 @@ **Hardware:** -* `Adafruit 16x9 Charlieplexed PWM LED Matrix Driver - IS31FL3731 - `_ - * `Adafruit 15x7 CharliePlex LED Matrix Display FeatherWings `_ @@ -47,10 +44,10 @@ """ # imports -from . import Matrix +from . import IS31FL3731 -class CharlieWing(Matrix): +class CharlieWing(IS31FL3731): """Supports the Charlieplexed feather wing """ diff --git a/adafruit_is31fl3731/LedShim.py b/adafruit_is31fl3731/led_shim.py similarity index 98% rename from adafruit_is31fl3731/LedShim.py rename to adafruit_is31fl3731/led_shim.py index bdefd2e..fd483ed 100644 --- a/adafruit_is31fl3731/LedShim.py +++ b/adafruit_is31fl3731/led_shim.py @@ -44,10 +44,10 @@ """ # imports -from . import Matrix +from . import IS31FL3731 -class LedShim(Matrix): +class LedShim(IS31FL3731): """Supports the LED SHIM by Pimoroni""" width = 28 diff --git a/adafruit_is31fl3731/matrix.py b/adafruit_is31fl3731/matrix.py new file mode 100644 index 0000000..4a3e697 --- /dev/null +++ b/adafruit_is31fl3731/matrix.py @@ -0,0 +1,61 @@ +# The MIT License (MIT) +# +# Copyright (c) 2017 Tony DiCola +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +""" +`adafruit_is31fl3731` +==================================================== + +CircuitPython driver for the IS31FL3731 charlieplex IC. + + +* Author(s): Tony DiCola, Melissa LeBlanc-Williams + +Implementation Notes +-------------------- + +**Hardware:** + +* `Adafruit 16x9 Charlieplexed PWM LED Matrix Driver - IS31FL3731 + `_ + +**Software and Dependencies:** + +* Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards: + https://github.com/adafruit/circuitpython/releases +""" + +# imports +from . import IS31FL3731 + + +class Matrix(IS31FL3731): + """Supports the Charlieplexed feather wing + """ + + width = 16 + height = 9 + + @staticmethod + def pixel_addr(x, y): + """Calulate the offset into the device array for x,y pixel + """ + return x + y * 16 diff --git a/adafruit_is31fl3731/ScrollPhatHD.py b/adafruit_is31fl3731/scroll_phat_hd.py similarity index 97% rename from adafruit_is31fl3731/ScrollPhatHD.py rename to adafruit_is31fl3731/scroll_phat_hd.py index a72b9e7..5212673 100644 --- a/adafruit_is31fl3731/ScrollPhatHD.py +++ b/adafruit_is31fl3731/scroll_phat_hd.py @@ -44,10 +44,10 @@ """ # imports -from . import Matrix +from . import IS31FL3731 -class ScrollPhatHD(Matrix): +class ScrollPhatHD(IS31FL3731): """Supports the Scroll pHAT HD by Pimoroni""" width = 17 diff --git a/examples/is31fl3731_blink_example.py b/examples/is31fl3731_blink_example.py index 2105a08..b68c1e7 100644 --- a/examples/is31fl3731_blink_example.py +++ b/examples/is31fl3731_blink_example.py @@ -2,28 +2,21 @@ import busio # uncomment next line if you are using Feather CharlieWing LED 15 x 7 -from adafruit_is31fl3731.CharlieWing import CharlieWing +from adafruit_is31fl3731.charlie_wing import CharlieWing as Display # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# from adafruit_is31fl3731 import Matrix +# from adafruit_is31fl3731.matrix import Matrix as Display # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -# from adafruit_is31fl3731.CharlieBonnet import CharlieBonnet +# from adafruit_is31fl3731.charlie_bonnet import CharlieBonnet as Display # uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 -# from adafruit_is31fl3731.ScrollPhatHD import ScrollPhatHD +# from adafruit_is31fl3731.scroll_phat_hd import ScrollPhatHD as Display i2c = busio.I2C(board.SCL, board.SDA) # array pattern in bits; top row-> bottom row, 8 bits in each row an_arrow = bytearray((0x08, 0x0C, 0xFE, 0xFF, 0xFE, 0x0C, 0x08, 0x00, 0x00)) -# uncomment next line if you are using Feather CharlieWing LED 15 x 7 -display = CharlieWing(i2c) -# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = Matrix(i2c) -# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -# display = CharlieBonnet(i2c) -# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 -# display = ScrollPhatHD(i2c) +display = Display(i2c) # first load the frame with the arrows; moves the an_arrow to the right in each # frame diff --git a/examples/is31fl3731_frame_example.py b/examples/is31fl3731_frame_example.py index f9e14ac..c5a83fa 100644 --- a/examples/is31fl3731_frame_example.py +++ b/examples/is31fl3731_frame_example.py @@ -3,28 +3,21 @@ import busio # uncomment next line if you are using Feather CharlieWing LED 15 x 7 -from adafruit_is31fl3731.CharlieWing import CharlieWing +from adafruit_is31fl3731.charlie_wing import CharlieWing as Display # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# from adafruit_is31fl3731 import Matrix +# from adafruit_is31fl3731.matrix import Matrix as Display # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -# from adafruit_is31fl3731.CharlieBonnet import CharlieBonnet +# from adafruit_is31fl3731.charlie_bonnet import CharlieBonnet as Display # uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 -# from adafruit_is31fl3731.ScrollPhatHD import ScrollPhatHD +# from adafruit_is31fl3731.scroll_phat_hd import ScrollPhatHD as Display i2c = busio.I2C(board.SCL, board.SDA) # arrow pattern in bits; top row-> bottom row, 8 bits in each row arrow = bytearray((0x08, 0x0C, 0xFE, 0xFF, 0xFE, 0x0C, 0x08, 0x00, 0x00)) -# uncomment next line if you are using Feather CharlieWing LED 15 x 7 -display = CharlieWing(i2c) -# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = Matrix(i2c) -# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -# display = CharlieBonnet(i2c) -# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 -# display = ScrollPhatHD(i2c) +display = Display(i2c) # first load the frame with the arrows; moves the arrow to the right in each diff --git a/examples/is31fl3731_ledshim_rainbow.py b/examples/is31fl3731_ledshim_rainbow.py index f23b5b3..96bf330 100644 --- a/examples/is31fl3731_ledshim_rainbow.py +++ b/examples/is31fl3731_ledshim_rainbow.py @@ -1,12 +1,12 @@ import time import board import busio -from adafruit_is31fl3731.LedShim import LedShim +from adafruit_is31fl3731.led_shim import LedShim as Display i2c = busio.I2C(board.SCL, board.SDA) # initial display if you are using Pimoroni LED SHIM -display = LedShim(i2c) +display = Display(i2c) # This list 28 colors from a rainbow... rainbow = [ diff --git a/examples/is31fl3731_pillow_animated_gif.py b/examples/is31fl3731_pillow_animated_gif.py index 4183c54..d7f983d 100644 --- a/examples/is31fl3731_pillow_animated_gif.py +++ b/examples/is31fl3731_pillow_animated_gif.py @@ -17,21 +17,17 @@ from PIL import Image # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# from adafruit_is31fl3731 import Matrix +# from adafruit_is31fl3731.matrix import Matrix as Display # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -from adafruit_is31fl3731.CharlieBonnet import CharlieBonnet +from adafruit_is31fl3731.charlie_bonnet import CharlieBonnet as Display # uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 -# from adafruit_is31fl3731.ScrollPhatHD import ScrollPhatHD +# from adafruit_is31fl3731.scroll_phat_hd import ScrollPhatHD as Display i2c = board.I2C() -# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = Matrix(i2c) -# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -display = CharlieBonnet(i2c) -# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 -# display = ScrollPhatHD(i2c) +display = Display(i2c) + # Open the gif if len(sys.argv) < 2: diff --git a/examples/is31fl3731_pillow_marquee.py b/examples/is31fl3731_pillow_marquee.py index 810c7db..120f9fb 100644 --- a/examples/is31fl3731_pillow_marquee.py +++ b/examples/is31fl3731_pillow_marquee.py @@ -12,24 +12,19 @@ from PIL import Image, ImageDraw, ImageFont # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# from adafruit_is31fl3731 import Matrix +# from adafruit_is31fl3731.matrix import Matrix as Display # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -from adafruit_is31fl3731.CharlieBonnet import CharlieBonnet +from adafruit_is31fl3731.charlie_bonnet import CharlieBonnet as Display # uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 -# from adafruit_is31fl3731.ScrollPhatHD import ScrollPhatHD +# from adafruit_is31fl3731.scroll_phat_hd import ScrollPhatHD as Display SCROLLING_TEXT = "You can display a personal message here..." BRIGHTNESS = 64 # Brightness can be between 0-255 i2c = board.I2C() -# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = Matrix(i2c) -# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -display = CharlieBonnet(i2c) -# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 -# display = ScrollPhatHD(i2c) +display = Display(i2c) # Load a font font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 8) diff --git a/examples/is31fl3731_pillow_numbers.py b/examples/is31fl3731_pillow_numbers.py index 93b4c29..2383466 100644 --- a/examples/is31fl3731_pillow_numbers.py +++ b/examples/is31fl3731_pillow_numbers.py @@ -13,23 +13,18 @@ from PIL import Image, ImageDraw, ImageFont # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# from adafruit_is31fl3731 import Matrix +# from adafruit_is31fl3731.matrix import Matrix as Display # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -from adafruit_is31fl3731.CharlieBonnet import CharlieBonnet +from adafruit_is31fl3731.charlie_bonnet import CharlieBonnet as Display # uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 -# from adafruit_is31fl3731.ScrollPhatHD import ScrollPhatHD +# from adafruit_is31fl3731.scroll_phat_hd import ScrollPhatHD as Display BRIGHTNESS = 32 # Brightness can be between 0-255 i2c = board.I2C() -# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = Matrix(i2c) -# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -display = CharlieBonnet(i2c) -# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 -# display = ScrollPhatHD(i2c) +display = Display(i2c) display.fill(0) diff --git a/examples/is31fl3731_simpletest.py b/examples/is31fl3731_simpletest.py index 333bdd2..c7d0e80 100644 --- a/examples/is31fl3731_simpletest.py +++ b/examples/is31fl3731_simpletest.py @@ -2,25 +2,18 @@ import busio # uncomment next line if you are using Feather CharlieWing LED 15 x 7 -from adafruit_is31fl3731.CharlieWing import CharlieWing +from adafruit_is31fl3731.charlie_wing import CharlieWing as Display # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# from adafruit_is31fl3731 import Matrix +# from adafruit_is31fl3731.matrix import Matrix as Display # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -# from adafruit_is31fl3731.CharlieBonnet import CharlieBonnet +# from adafruit_is31fl3731.charlie_bonnet import CharlieBonnet as Display # uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 -# from adafruit_is31fl3731.ScrollPhatHD import ScrollPhatHD +# from adafruit_is31fl3731.scroll_phat_hd import ScrollPhatHD as Display i2c = busio.I2C(board.SCL, board.SDA) -# uncomment next line if you are using Feather CharlieWing LED 15 x 7 -display = CharlieWing(i2c) -# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = Matrix(i2c) -# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -# display = CharlieBonnet(i2c) -# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 -# display = ScrollPhatHD(i2c) +display = Display(i2c) # draw a box on the display # first draw the top and bottom edges diff --git a/examples/is31fl3731_text_example.py b/examples/is31fl3731_text_example.py index ad5af92..9eef0ec 100644 --- a/examples/is31fl3731_text_example.py +++ b/examples/is31fl3731_text_example.py @@ -3,25 +3,18 @@ import adafruit_framebuf # uncomment next line if you are using Feather CharlieWing LED 15 x 7 -# from adafruit_is31fl3731.CharlieWing import CharlieWing +# from adafruit_is31fl3731.charliewing import CharlieWing as Display # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# from adafruit_is31fl3731 import Matrix +# from adafruit_is31fl3731.matrix import Matrix as Display # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -from adafruit_is31fl3731.CharlieBonnet import CharlieBonnet +from adafruit_is31fl3731.charlie_bonnet import CharlieBonnet as Display # uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 -# from adafruit_is31fl3731.ScrollPhatHD import ScrollPhatHD +# from adafruit_is31fl3731.scroll_phat_hd import ScrollPhatHD as Display i2c = busio.I2C(board.SCL, board.SDA) -# uncomment next line if you are using Feather CharlieWing LED 15 x 7 -# display = CharlieWing(i2c) -# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = Matrix(i2c) -# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -display = CharlieBonnet(i2c) -# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 -# display = ScrollPhatHD(i2c) +display = Display(i2c) text_to_show = "Adafruit!!" diff --git a/examples/is31fl3731_wave_example.py b/examples/is31fl3731_wave_example.py index 57bf221..7647b58 100644 --- a/examples/is31fl3731_wave_example.py +++ b/examples/is31fl3731_wave_example.py @@ -2,14 +2,14 @@ import busio # uncomment next line if you are using Feather CharlieWing LED 15 x 7 -from adafruit_is31fl3731.CharlieWing import CharlieWing +from adafruit_is31fl3731.charlie_wing import CharlieWing as Display # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# from adafruit_is31fl3731 import Matrix +# from adafruit_is31fl3731.matrix import Matrix as Display # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -# from adafruit_is31fl3731.CharlieBonnet import CharlieBonnet +# from adafruit_is31fl3731.charlie_bonnet import CharlieBonnet as Display # uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 -# from adafruit_is31fl3731.ScrollPhatHD import ScrollPhatHD +# from adafruit_is31fl3731.scroll_phat_hd import ScrollPhatHD as Display i2c = busio.I2C(board.SCL, board.SDA) @@ -42,14 +42,7 @@ frame = 0 -# uncomment next line if you are using Feather CharlieWing LED 15 x 7 -display = CharlieWing(i2c) -# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = Matrix(i2c) -# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -# display = CharlieBonnet(i2c) -# uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 -# display = ScrollPhatHD(i2c) +display = Display(i2c) while True: for incr in range(24): From 85b2b642344f3b38abb5cb707911277b6e43c023 Mon Sep 17 00:00:00 2001 From: David Glaude Date: Thu, 20 Aug 2020 01:21:08 +0200 Subject: [PATCH 03/14] Update api.rst --- docs/api.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/api.rst b/docs/api.rst index 49effac..6a34fc9 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -3,3 +3,18 @@ .. automodule:: adafruit_is31fl3731 :members: + +.. automodule:: adafruit_is31fl3731.charlie_bonnet + :members: + +.. automodule:: adafruit_is31fl3731.charlie_wing + :members: + +.. automodule:: adafruit_is31fl3731.matrix + :members: + +.. automodule:: adafruit_is31fl3731.scroll_phat_hd + :members: + +.. automodule:: adafruit_is31fl3731.led_shim + :members: From f3f64458ef09607821a162ae13f61dad3f011e68 Mon Sep 17 00:00:00 2001 From: David Glaude Date: Thu, 20 Aug 2020 19:48:35 +0200 Subject: [PATCH 04/14] Update led_shim.py Dunno what I am doing... Let's see what Sphynx is saying. --- adafruit_is31fl3731/led_shim.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_is31fl3731/led_shim.py b/adafruit_is31fl3731/led_shim.py index fd483ed..ae6e799 100644 --- a/adafruit_is31fl3731/led_shim.py +++ b/adafruit_is31fl3731/led_shim.py @@ -21,7 +21,7 @@ # THE SOFTWARE. """ -`adafruit_is31fl3731.LedShim` +`adafruit_is31fl3731` ==================================================== CircuitPython driver for the IS31FL3731 charlieplex IC. From 684e8f629edf394b7bfb576deed69571223d66e0 Mon Sep 17 00:00:00 2001 From: David Glaude Date: Thu, 20 Aug 2020 19:48:55 +0200 Subject: [PATCH 05/14] Update scroll_phat_hd.py Dunno what I am doing... Let's see what Sphynx is saying. --- adafruit_is31fl3731/scroll_phat_hd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_is31fl3731/scroll_phat_hd.py b/adafruit_is31fl3731/scroll_phat_hd.py index 5212673..f15d661 100644 --- a/adafruit_is31fl3731/scroll_phat_hd.py +++ b/adafruit_is31fl3731/scroll_phat_hd.py @@ -21,7 +21,7 @@ # THE SOFTWARE. """ -`adafruit_is31fl3731.ScrollPhatHD` +`adafruit_is31fl3731` ==================================================== CircuitPython driver for the Pimoroni 17x7 Scroll pHAT HD. From a7ff4e57677098045b066dbb46b10029447ad49a Mon Sep 17 00:00:00 2001 From: David Glaude Date: Thu, 20 Aug 2020 22:03:39 +0200 Subject: [PATCH 06/14] Update README.rst Co-authored-by: Scott Shawcroft --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 91607a6..c4a352c 100644 --- a/README.rst +++ b/README.rst @@ -66,7 +66,7 @@ Matrix: .. code:: python - from adafruit_is31fl3731 import Matrix + from adafruit_is31fl3731.matrix import Matrix import board import busio with busio.I2C(board.SCL, board.SDA) as i2c: @@ -78,7 +78,7 @@ Charlie Wing: .. code:: python - from adafruit_is31fl3731.CharlieWing import CharlieWing + from adafruit_is31fl3731.charlie_wing import CharlieWing import board import busio with busio.I2C(board.SCL, board.SDA) as i2c: From 6270f09318ac1df552d6374e5d7ecc1fee4e4989 Mon Sep 17 00:00:00 2001 From: David Glaude Date: Fri, 21 Aug 2020 16:34:08 +0200 Subject: [PATCH 07/14] Ameliorate the rendering of the example despite black. --- examples/is31fl3731_wave_example.py | 30 ++++------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/examples/is31fl3731_wave_example.py b/examples/is31fl3731_wave_example.py index 7647b58..3b25a77 100644 --- a/examples/is31fl3731_wave_example.py +++ b/examples/is31fl3731_wave_example.py @@ -13,32 +13,10 @@ i2c = busio.I2C(board.SCL, board.SDA) -sweep = [ - 1, - 2, - 3, - 4, - 6, - 8, - 10, - 15, - 20, - 30, - 40, - 60, - 60, - 40, - 30, - 20, - 15, - 10, - 8, - 6, - 4, - 3, - 2, - 1, -] +# fmt: off +sweep = [ 1, 2, 3, 4, 6, 8, 10, 15, 20, 30, 40, 60, + 60, 40, 30, 20, 15, 10, 8, 6, 4, 3, 2, 1, ] +# fmt: on frame = 0 From cac8a774b73729041a483ce10aa9f15987f4020a Mon Sep 17 00:00:00 2001 From: David Glaude Date: Fri, 21 Aug 2020 16:48:34 +0200 Subject: [PATCH 08/14] Stoping black from putting a table on a line. --- examples/is31fl3731_ledshim_rainbow.py | 37 +++++++------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/examples/is31fl3731_ledshim_rainbow.py b/examples/is31fl3731_ledshim_rainbow.py index 96bf330..6d5bec5 100644 --- a/examples/is31fl3731_ledshim_rainbow.py +++ b/examples/is31fl3731_ledshim_rainbow.py @@ -8,37 +8,18 @@ # initial display if you are using Pimoroni LED SHIM display = Display(i2c) +# fmt: off # This list 28 colors from a rainbow... rainbow = [ - (255, 0, 0), - (255, 54, 0), - (255, 109, 0), - (255, 163, 0), - (255, 218, 0), - (236, 255, 0), - (182, 255, 0), - (127, 255, 0), - (72, 255, 0), - (18, 255, 0), - (0, 255, 36), - (0, 255, 91), - (0, 255, 145), - (0, 255, 200), - (0, 255, 255), - (0, 200, 255), - (0, 145, 255), - (0, 91, 255), - (0, 36, 255), - (18, 0, 255), - (72, 0, 255), - (127, 0, 255), - (182, 0, 255), - (236, 0, 255), - (255, 0, 218), - (255, 0, 163), - (255, 0, 109), - (255, 0, 54), + (255, 0, 0), (255, 54, 0), (255, 109, 0), (255, 163, 0), + (255, 218, 0), (236, 255, 0), (182, 255, 0), (127, 255, 0), + (72, 255, 0), (18, 255, 0), (0, 255, 36), (0, 255, 91), + (0, 255, 145), (0, 255, 200), (0, 255, 255), (0, 200, 255), + (0, 145, 255), (0, 91, 255), (0, 36, 255), (18, 0, 255), + (72, 0, 255), (127, 0, 255), (182, 0, 255), (236, 0, 255), + (255, 0, 218), (255, 0, 163), (255, 0, 109), (255, 0, 54), ] +# fmt: on for y in range(3): From 1440e4ffe8c3f4811aaf6a8438260e16e018947b Mon Sep 17 00:00:00 2001 From: David Glaude Date: Fri, 21 Aug 2020 16:50:14 +0200 Subject: [PATCH 09/14] Sorting and documenting all the example provided. --- docs/examples.rst | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/docs/examples.rst b/docs/examples.rst index 3c7e1f8..6c51f3d 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -7,9 +7,11 @@ Ensure your device works with this simple test. :caption: examples/is31fl3731_simpletest.py :linenos: -Other Examples +Matrix Examples --------------- +Other examples working on matrix display. + .. literalinclude:: ../examples/is31fl3731_blink_example.py :caption: examples/is31fl3731_blink_example.py :linenos: @@ -25,3 +27,31 @@ Other Examples .. literalinclude:: ../examples/is31fl3731_wave_example.py :caption: examples/is31fl3731_wave_example.py :linenos: + +Pillow Examples +--------------- + +Examples that utilize the Python Imaging Library (Pillow) for use on (Linux) +computers that are using CPython with Adafruit Blinka to support CircuitPython +libraries. CircuitPython does not support PIL/pillow (python imaging library)! + +.. literalinclude:: ../examples/is31fl3731_pillow_animated_gif.py + :caption: examples/is31fl3731_pillow_animated_gif.py + :linenos: + +.. literalinclude:: ../examples/is31fl3731_pillow_marquee.py + :caption: examples/is31fl3731_pillow_marquee.py + :linenos: + +.. literalinclude:: ../examples/is31fl3731_pillow_numbers.py + :caption: examples/is31fl3731_pillow_numbers.py + :linenos: + +Led Shim Example +---------------- + +Example that work on the RGB Led Shim. + +.. literalinclude:: ../examples/is31fl3731_ledshim_rainbow.py + :caption: examples/is31fl3731_ledshim_rainbow.py + :linenos: From 1a726c3426b4e556c88b44baf57d303d20097dd6 Mon Sep 17 00:00:00 2001 From: David Glaude Date: Fri, 21 Aug 2020 17:16:37 +0200 Subject: [PATCH 10/14] Adapt example to generate better documentation. --- adafruit_is31fl3731/__init__.py | 11 +++++++++++ adafruit_is31fl3731/charlie_bonnet.py | 8 +++----- adafruit_is31fl3731/charlie_wing.py | 2 +- adafruit_is31fl3731/led_shim.py | 2 +- adafruit_is31fl3731/matrix.py | 2 +- adafruit_is31fl3731/scroll_phat_hd.py | 2 +- 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/adafruit_is31fl3731/__init__.py b/adafruit_is31fl3731/__init__.py index ef8c423..0929626 100644 --- a/adafruit_is31fl3731/__init__.py +++ b/adafruit_is31fl3731/__init__.py @@ -26,6 +26,7 @@ CircuitPython driver for the IS31FL3731 charlieplex IC. +Base library. * Author(s): Tony DiCola, Melissa LeBlanc-Williams @@ -40,6 +41,16 @@ * `Adafruit 15x7 CharliePlex LED Matrix Display FeatherWings `_ +* `Adafruit 16x8 CharliePlex LED Matrix Bonnets + `_ + +* `Pimoroni 17x7 Scroll pHAT HD + `_ + +* `Pimoroni 28x3 (r,g,b) Led Shim + `_ + + **Software and Dependencies:** * Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards: diff --git a/adafruit_is31fl3731/charlie_bonnet.py b/adafruit_is31fl3731/charlie_bonnet.py index 2ea5c75..473d9ed 100644 --- a/adafruit_is31fl3731/charlie_bonnet.py +++ b/adafruit_is31fl3731/charlie_bonnet.py @@ -21,7 +21,7 @@ # THE SOFTWARE. """ -`adafruit_is31fl3731` +`adafruit_is31fl3731.charlie_bonnet` ==================================================== CircuitPython driver for the IS31FL3731 charlieplex IC. @@ -34,11 +34,9 @@ **Hardware:** -* `Adafruit 16x9 Charlieplexed PWM LED Matrix Driver - IS31FL3731 - `_ +* `Adafruit 16x8 CharliePlex LED Matrix Bonnets + `_ -* `Adafruit 15x7 CharliePlex LED Matrix Display FeatherWings - `_ **Software and Dependencies:** diff --git a/adafruit_is31fl3731/charlie_wing.py b/adafruit_is31fl3731/charlie_wing.py index f87cd03..1aa9055 100644 --- a/adafruit_is31fl3731/charlie_wing.py +++ b/adafruit_is31fl3731/charlie_wing.py @@ -21,7 +21,7 @@ # THE SOFTWARE. """ -`adafruit_is31fl3731` +`adafruit_is31fl3731.charlie_wing` ==================================================== CircuitPython driver for the IS31FL3731 charlieplex IC. diff --git a/adafruit_is31fl3731/led_shim.py b/adafruit_is31fl3731/led_shim.py index ae6e799..d1c6a85 100644 --- a/adafruit_is31fl3731/led_shim.py +++ b/adafruit_is31fl3731/led_shim.py @@ -21,7 +21,7 @@ # THE SOFTWARE. """ -`adafruit_is31fl3731` +`adafruit_is31fl3731.led_shim` ==================================================== CircuitPython driver for the IS31FL3731 charlieplex IC. diff --git a/adafruit_is31fl3731/matrix.py b/adafruit_is31fl3731/matrix.py index 4a3e697..92b7866 100644 --- a/adafruit_is31fl3731/matrix.py +++ b/adafruit_is31fl3731/matrix.py @@ -21,7 +21,7 @@ # THE SOFTWARE. """ -`adafruit_is31fl3731` +`adafruit_is31fl3731.matrix` ==================================================== CircuitPython driver for the IS31FL3731 charlieplex IC. diff --git a/adafruit_is31fl3731/scroll_phat_hd.py b/adafruit_is31fl3731/scroll_phat_hd.py index f15d661..e01fd78 100644 --- a/adafruit_is31fl3731/scroll_phat_hd.py +++ b/adafruit_is31fl3731/scroll_phat_hd.py @@ -21,7 +21,7 @@ # THE SOFTWARE. """ -`adafruit_is31fl3731` +`adafruit_is31fl3731.scroll_phat_hd` ==================================================== CircuitPython driver for the Pimoroni 17x7 Scroll pHAT HD. From 6766c5a568d4f8bad40339ee0886d72a34281322 Mon Sep 17 00:00:00 2001 From: David Glaude Date: Sun, 23 Aug 2020 10:21:13 +0200 Subject: [PATCH 11/14] Update setup.py This might make PyPi more happy (as seen in Adafruit_CircuitPython_LSM6DS). --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6204d76..8caa444 100644 --- a/setup.py +++ b/setup.py @@ -49,5 +49,5 @@ "breakout hardware micropython circuitpython", # You can just specify the packages manually here if your project is # simple. Or you can use find_packages(). - py_modules=["adafruit_is31fl3731"], + packages=["adafruit_is31fl3731"], ) From 90011177a4218aea561baa8cec2654475d6ca280 Mon Sep 17 00:00:00 2001 From: David Glaude Date: Mon, 24 Aug 2020 00:35:13 +0200 Subject: [PATCH 12/14] Update is31fl3731_text_example.py --- examples/is31fl3731_text_example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/is31fl3731_text_example.py b/examples/is31fl3731_text_example.py index 9eef0ec..9c945a0 100644 --- a/examples/is31fl3731_text_example.py +++ b/examples/is31fl3731_text_example.py @@ -3,7 +3,7 @@ import adafruit_framebuf # uncomment next line if you are using Feather CharlieWing LED 15 x 7 -# from adafruit_is31fl3731.charliewing import CharlieWing as Display +# from adafruit_is31fl3731.charlie_wing import CharlieWing as Display # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix # from adafruit_is31fl3731.matrix import Matrix as Display # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet From e1898cb4ba09c176094feb02237002e722b8d9bc Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Mon, 8 Mar 2021 09:11:05 -0800 Subject: [PATCH 13/14] Remove extraneous code and run pre-commit --- adafruit_is31fl3731/__init__.py | 135 ---------------------------- adafruit_is31fl3731/charlie_wing.py | 6 +- adafruit_is31fl3731/matrix.py | 6 +- adafruit_is31fl3731/matrix_11x7.py | 1 + 4 files changed, 5 insertions(+), 143 deletions(-) diff --git a/adafruit_is31fl3731/__init__.py b/adafruit_is31fl3731/__init__.py index c6c49e8..2d65f4e 100644 --- a/adafruit_is31fl3731/__init__.py +++ b/adafruit_is31fl3731/__init__.py @@ -364,138 +364,3 @@ def image(self, img, blink=None, frame=None): for x in range(self.width): # yes this double loop is slow, for y in range(self.height): # but these displays are small! self.pixel(x, y, pixels[(x, y)], blink=blink, frame=frame) -<<<<<<< HEAD:adafruit_is31fl3731.py - - -class CharlieWing(Matrix): - """Supports the Charlieplexed feather wing""" - - width = 15 - height = 7 - - @staticmethod - def pixel_addr(x, y): - """Calulate the offset into the device array for x,y pixel""" - if x > 7: - x = 15 - x - y += 8 - else: - y = 7 - y - return x * 16 + y - - -class CharlieBonnet(Matrix): - """Supports the Charlieplexed bonnet""" - - width = 16 - height = 8 - - @staticmethod - def pixel_addr(x, y): - """Calulate the offset into the device array for x,y pixel""" - if x >= 8: - return (x - 6) * 16 - (y + 1) - return (x + 1) * 16 + (7 - y) - - -class ScrollPhatHD(Matrix): - """Supports the Scroll pHAT HD by Pimoroni""" - - width = 17 - height = 7 - - @staticmethod - def pixel_addr(x, y): - """Translate an x,y coordinate to a pixel index.""" - if x <= 8: - x = 8 - x - y = 6 - y - else: - x = x - 8 - y = y - 8 - return x * 16 + y - - -class LedShim(Matrix): - """Supports the LED SHIM by Pimoroni""" - - width = 28 - height = 3 - - def __init__(self, i2c, address=0x75): - super().__init__(i2c, address) - - # pylint: disable-msg=too-many-arguments - def pixelrgb(self, x, r, g, b, blink=None, frame=None): - """ - Blink or brightness for x-pixel - - :param x: horizontal pixel position - :param r: red brightness value 0->255 - :param g: green brightness value 0->255 - :param b: blue brightness value 0->255 - :param blink: True to blink - :param frame: the frame to set the pixel - """ - super().pixel(x, 0, r, blink, frame) - super().pixel(x, 1, g, blink, frame) - super().pixel(x, 2, b, blink, frame) - - # pylint: disable=inconsistent-return-statements - # pylint: disable=too-many-return-statements - # pylint: disable=too-many-branches - - @staticmethod - def pixel_addr(x, y): - """Translate an x,y coordinate to a pixel index.""" - if y == 0: - if x < 7: - return 118 - x - if x < 15: - return 141 - x - if x < 21: - return 106 + x - if x == 21: - return 15 - return x - 14 - - if y == 1: - if x < 2: - return 69 - x - if x < 7: - return 86 - x - if x < 12: - return 28 - x - if x < 14: - return 45 - x - if x == 14: - return 47 - if x == 15: - return 41 - if x < 21: - return x + 9 - if x == 21: - return 95 - if x < 26: - return x + 67 - return x + 50 - - if x == 0: - return 85 - if x < 7: - return 102 - x - if x < 11: - return 44 - x - if x < 14: - return 61 - x - if x == 14: - return 63 - if x < 17: - return 42 + x - if x < 21: - return x + 25 - if x == 21: - return 111 - if x < 27: - return x + 83 - return 93 diff --git a/adafruit_is31fl3731/charlie_wing.py b/adafruit_is31fl3731/charlie_wing.py index ba180c7..15a09ec 100644 --- a/adafruit_is31fl3731/charlie_wing.py +++ b/adafruit_is31fl3731/charlie_wing.py @@ -49,16 +49,14 @@ class CharlieWing(IS31FL3731): - """Supports the Charlieplexed feather wing - """ + """Supports the Charlieplexed feather wing""" width = 15 height = 7 @staticmethod def pixel_addr(x, y): - """Calulate the offset into the device array for x,y pixel - """ + """Calulate the offset into the device array for x,y pixel""" if x > 7: x = 15 - x y += 8 diff --git a/adafruit_is31fl3731/matrix.py b/adafruit_is31fl3731/matrix.py index 22bbeee..fbf9ef1 100644 --- a/adafruit_is31fl3731/matrix.py +++ b/adafruit_is31fl3731/matrix.py @@ -49,14 +49,12 @@ class Matrix(IS31FL3731): - """Supports the Charlieplexed feather wing - """ + """Supports the Charlieplexed feather wing""" width = 16 height = 9 @staticmethod def pixel_addr(x, y): - """Calulate the offset into the device array for x,y pixel - """ + """Calulate the offset into the device array for x,y pixel""" return x + y * 16 diff --git a/adafruit_is31fl3731/matrix_11x7.py b/adafruit_is31fl3731/matrix_11x7.py index ef749a7..3aedd34 100644 --- a/adafruit_is31fl3731/matrix_11x7.py +++ b/adafruit_is31fl3731/matrix_11x7.py @@ -47,6 +47,7 @@ # imports from . import IS31FL3731 + class Matrix11x7(IS31FL3731): """Supports the 11x7 LED Matrix Breakout by Pimoroni""" From 3fa3ffe4e96f0c91bb3ee47c1e84bbf3328a6af0 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Mon, 8 Mar 2021 09:17:34 -0800 Subject: [PATCH 14/14] Updated license info for each split file --- adafruit_is31fl3731/charlie_bonnet.py | 22 ++-------------------- adafruit_is31fl3731/charlie_wing.py | 22 ++-------------------- adafruit_is31fl3731/keybow2040.py | 22 ++-------------------- adafruit_is31fl3731/led_shim.py | 22 ++-------------------- adafruit_is31fl3731/matrix.py | 22 ++-------------------- adafruit_is31fl3731/matrix_11x7.py | 22 ++-------------------- adafruit_is31fl3731/scroll_phat_hd.py | 22 ++-------------------- 7 files changed, 14 insertions(+), 140 deletions(-) diff --git a/adafruit_is31fl3731/charlie_bonnet.py b/adafruit_is31fl3731/charlie_bonnet.py index 2cac00f..5dad110 100644 --- a/adafruit_is31fl3731/charlie_bonnet.py +++ b/adafruit_is31fl3731/charlie_bonnet.py @@ -1,24 +1,6 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries # -# Copyright (c) 2017 Tony DiCola -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# SPDX-License-Identifier: MIT """ `adafruit_is31fl3731.charlie_bonnet` diff --git a/adafruit_is31fl3731/charlie_wing.py b/adafruit_is31fl3731/charlie_wing.py index 15a09ec..79d9224 100644 --- a/adafruit_is31fl3731/charlie_wing.py +++ b/adafruit_is31fl3731/charlie_wing.py @@ -1,24 +1,6 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries # -# Copyright (c) 2017 Tony DiCola -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# SPDX-License-Identifier: MIT """ `adafruit_is31fl3731.charlie_wing` diff --git a/adafruit_is31fl3731/keybow2040.py b/adafruit_is31fl3731/keybow2040.py index 7b84263..d8946a9 100644 --- a/adafruit_is31fl3731/keybow2040.py +++ b/adafruit_is31fl3731/keybow2040.py @@ -1,24 +1,6 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries # -# Copyright (c) 2017 Tony DiCola -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# SPDX-License-Identifier: MIT """ `adafruit_is31fl3731.charlie_bonnet` diff --git a/adafruit_is31fl3731/led_shim.py b/adafruit_is31fl3731/led_shim.py index 0c23128..fbba938 100644 --- a/adafruit_is31fl3731/led_shim.py +++ b/adafruit_is31fl3731/led_shim.py @@ -1,24 +1,6 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries # -# Copyright (c) 2017 Tony DiCola -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# SPDX-License-Identifier: MIT """ `adafruit_is31fl3731.led_shim` diff --git a/adafruit_is31fl3731/matrix.py b/adafruit_is31fl3731/matrix.py index fbf9ef1..94a2c9e 100644 --- a/adafruit_is31fl3731/matrix.py +++ b/adafruit_is31fl3731/matrix.py @@ -1,24 +1,6 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries # -# Copyright (c) 2017 Tony DiCola -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# SPDX-License-Identifier: MIT """ `adafruit_is31fl3731.matrix` diff --git a/adafruit_is31fl3731/matrix_11x7.py b/adafruit_is31fl3731/matrix_11x7.py index 3aedd34..dc61d61 100644 --- a/adafruit_is31fl3731/matrix_11x7.py +++ b/adafruit_is31fl3731/matrix_11x7.py @@ -1,24 +1,6 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries # -# Copyright (c) 2017 Tony DiCola -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# SPDX-License-Identifier: MIT """ `adafruit_is31fl3731.charlie_bonnet` diff --git a/adafruit_is31fl3731/scroll_phat_hd.py b/adafruit_is31fl3731/scroll_phat_hd.py index 618a502..9504a36 100644 --- a/adafruit_is31fl3731/scroll_phat_hd.py +++ b/adafruit_is31fl3731/scroll_phat_hd.py @@ -1,24 +1,6 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries # -# Copyright (c) 2017 Tony DiCola -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# SPDX-License-Identifier: MIT """ `adafruit_is31fl3731.scroll_phat_hd`