diff --git a/README.rst b/README.rst index 61fa057..c4a352c 100644 --- a/README.rst +++ b/README.rst @@ -66,11 +66,11 @@ Matrix: .. code:: python - import adafruit_is31fl3731 + from adafruit_is31fl3731.matrix 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.charlie_wing 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.py b/adafruit_is31fl3731/__init__.py similarity index 79% rename from adafruit_is31fl3731.py rename to adafruit_is31fl3731/__init__.py index b7c3e95..0929626 100644 --- a/adafruit_is31fl3731.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: @@ -78,9 +89,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 +310,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 @@ -364,139 +377,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/adafruit_is31fl3731/charlie_bonnet.py b/adafruit_is31fl3731/charlie_bonnet.py new file mode 100644 index 0000000..473d9ed --- /dev/null +++ b/adafruit_is31fl3731/charlie_bonnet.py @@ -0,0 +1,62 @@ +# 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.charlie_bonnet` +==================================================== + +CircuitPython driver for the IS31FL3731 charlieplex IC. + + +* Author(s): Tony DiCola, Melissa LeBlanc-Williams + +Implementation Notes +-------------------- + +**Hardware:** + +* `Adafruit 16x8 CharliePlex LED Matrix Bonnets + `_ + + +**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 CharlieBonnet(IS31FL3731): + """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/charlie_wing.py b/adafruit_is31fl3731/charlie_wing.py new file mode 100644 index 0000000..1aa9055 --- /dev/null +++ b/adafruit_is31fl3731/charlie_wing.py @@ -0,0 +1,66 @@ +# 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.charlie_wing` +==================================================== + +CircuitPython driver for the IS31FL3731 charlieplex IC. + + +* Author(s): Tony DiCola, Melissa LeBlanc-Williams + +Implementation Notes +-------------------- + +**Hardware:** + +* `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 IS31FL3731 + + +class CharlieWing(IS31FL3731): + """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/led_shim.py b/adafruit_is31fl3731/led_shim.py new file mode 100644 index 0000000..d1c6a85 --- /dev/null +++ b/adafruit_is31fl3731/led_shim.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.led_shim` +==================================================== + +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 IS31FL3731 + + +class LedShim(IS31FL3731): + """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/matrix.py b/adafruit_is31fl3731/matrix.py new file mode 100644 index 0000000..92b7866 --- /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.matrix` +==================================================== + +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/scroll_phat_hd.py b/adafruit_is31fl3731/scroll_phat_hd.py new file mode 100644 index 0000000..e01fd78 --- /dev/null +++ b/adafruit_is31fl3731/scroll_phat_hd.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.scroll_phat_hd` +==================================================== + +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 IS31FL3731 + + +class ScrollPhatHD(IS31FL3731): + """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/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: 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: diff --git a/examples/is31fl3731_blink_example.py b/examples/is31fl3731_blink_example.py index 5319879..b68c1e7 100644 --- a/examples/is31fl3731_blink_example.py +++ b/examples/is31fl3731_blink_example.py @@ -1,20 +1,22 @@ -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.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 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.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)) -# initial display using Feather CharlieWing LED 15 x 7 -display = adafruit_is31fl3731.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 = 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 b678daa..c5a83fa 100644 --- a/examples/is31fl3731_frame_example.py +++ b/examples/is31fl3731_frame_example.py @@ -1,21 +1,23 @@ 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.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 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.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)) -# 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) +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 3d658b0..6d5bec5 100644 --- a/examples/is31fl3731_ledshim_rainbow.py +++ b/examples/is31fl3731_ledshim_rainbow.py @@ -1,44 +1,25 @@ import time import board import busio -import adafruit_is31fl3731 +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 = adafruit_is31fl3731.LedShim(i2c) +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): diff --git a/examples/is31fl3731_pillow_animated_gif.py b/examples/is31fl3731_pillow_animated_gif.py index dffbfc9..d7f983d 100644 --- a/examples/is31fl3731_pillow_animated_gif.py +++ b/examples/is31fl3731_pillow_animated_gif.py @@ -15,14 +15,19 @@ 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.matrix import Matrix as Display +# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet +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.scroll_phat_hd import ScrollPhatHD as Display 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 = 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 5b24b00..120f9fb 100644 --- a/examples/is31fl3731_pillow_marquee.py +++ b/examples/is31fl3731_pillow_marquee.py @@ -10,17 +10,21 @@ 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.matrix import Matrix as Display +# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet +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.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 = adafruit_is31fl3731.Matrix(i2c) -# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -display = adafruit_is31fl3731.CharlieBonnet(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 2f298c9..2383466 100644 --- a/examples/is31fl3731_pillow_numbers.py +++ b/examples/is31fl3731_pillow_numbers.py @@ -11,16 +11,20 @@ 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.matrix import Matrix as Display +# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet +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.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 = adafruit_is31fl3731.Matrix(i2c) -# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -display = adafruit_is31fl3731.CharlieBonnet(i2c) +display = Display(i2c) display.fill(0) diff --git a/examples/is31fl3731_simpletest.py b/examples/is31fl3731_simpletest.py index 221c8b3..c7d0e80 100644 --- a/examples/is31fl3731_simpletest.py +++ b/examples/is31fl3731_simpletest.py @@ -1,20 +1,19 @@ 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.charlie_wing import CharlieWing as Display # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = adafruit_is31fl3731.Matrix(i2c) - +# from adafruit_is31fl3731.matrix import Matrix as Display # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -# display = adafruit_is31fl3731.CharlieBonnet(i2c) +# 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.scroll_phat_hd import ScrollPhatHD as Display + +i2c = busio.I2C(board.SCL, board.SDA) -# initial display using Pimoroni Scroll Phat HD LED 17 x 7 -# display = adafruit_is31fl3731.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 e570176..9c945a0 100644 --- a/examples/is31fl3731_text_example.py +++ b/examples/is31fl3731_text_example.py @@ -1,19 +1,20 @@ 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.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 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.scroll_phat_hd import ScrollPhatHD as Display 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) +display = Display(i2c) text_to_show = "Adafruit!!" diff --git a/examples/is31fl3731_wave_example.py b/examples/is31fl3731_wave_example.py index 332f0a5..3b25a77 100644 --- a/examples/is31fl3731_wave_example.py +++ b/examples/is31fl3731_wave_example.py @@ -1,46 +1,26 @@ import board import busio -import adafruit_is31fl3731 + +# uncomment next line if you are using Feather CharlieWing LED 15 x 7 +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 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.scroll_phat_hd import ScrollPhatHD as Display 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 -# initialize display using Feather CharlieWing LED 15 x 7 -display = adafruit_is31fl3731.CharlieWing(i2c) -# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -# display = adafruit_is31fl3731.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 = Display(i2c) while True: for incr in range(24): 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"], )