Skip to content

Commit d934a5a

Browse files
committed
Fix merge conflicts and manually merge newer PRs
2 parents 52dad15 + 9001117 commit d934a5a

22 files changed

+734
-189
lines changed

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,23 @@ Matrix:
6767

6868
.. code:: python
6969
70-
import adafruit_is31fl3731
70+
from adafruit_is31fl3731.matrix import Matrix
7171
import board
7272
import busio
7373
with busio.I2C(board.SCL, board.SDA) as i2c:
74-
display = adafruit_is31fl3731.Matrix(i2c)
74+
display = Matrix(i2c)
7575
display.fill(127)
7676
7777
7878
Charlie Wing:
7979

8080
.. code:: python
8181
82-
import adafruit_is31fl3731
82+
from adafruit_is31fl3731.charlie_wing import CharlieWing
8383
import board
8484
import busio
8585
with busio.I2C(board.SCL, board.SDA) as i2c:
86-
display = adafruit_is31fl3731.CharlieWing(i2c)
86+
display = CharlieWing(i2c)
8787
display.fill(127)
8888
8989
# Turn off pixel 4,4, change its brightness and turn it back on

adafruit_is31fl3731.py renamed to adafruit_is31fl3731/__init__.py

Lines changed: 25 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
99
CircuitPython driver for the IS31FL3731 charlieplex IC.
1010
11+
Base library.
1112
12-
* Author(s): Tony DiCola, Melissa LeBlanc-Williams
13+
* Author(s): Tony DiCola, Melissa LeBlanc-Williams, David Glaude
1314
1415
Implementation Notes
1516
--------------------
@@ -22,16 +23,29 @@
2223
* `Adafruit 15x7 CharliePlex LED Matrix Display FeatherWings
2324
<https://www.adafruit.com/product/2965>`_
2425
25-
* Pimoroni LED SHIM
26-
<https://shop.pimoroni.com/products/led-shim>_
26+
* `Adafruit 16x8 CharliePlex LED Matrix Bonnets
27+
<https://www.adafruit.com/product/4127>`_
2728
28-
* Pimoroni Keybow 2040
29-
<https://shop.pimoroni.com/products/keybow-2040>_
29+
* `Pimoroni 17x7 Scroll pHAT HD
30+
<https://www.adafruit.com/product/3473>`_
31+
32+
* `Pimoroni 28x3 (r,g,b) Led Shim
33+
<https://www.adafruit.com/product/3831>`_
34+
35+
* `Pimoroni LED SHIM
36+
<https://shop.pimoroni.com/products/led-shim>`_
37+
38+
* `Pimoroni Keybow 2040
39+
<https://shop.pimoroni.com/products/keybow-2040>`_
40+
41+
* `Pimoroni 11x7 LED Matrix Breakout
42+
<https://shop.pimoroni.com/products/11x7-led-matrix-breakout>`_
3043
3144
**Software and Dependencies:**
3245
33-
* Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards:
46+
* Adafruit CircuitPython firmware for the supported boards:
3447
https://github.com/adafruit/circuitpython/releases
48+
3549
"""
3650

3751
# imports
@@ -66,9 +80,10 @@
6680
_COLOR_OFFSET = const(0x24)
6781

6882

69-
class Matrix:
83+
class IS31FL3731:
7084
"""
71-
The Matrix class support the main function for driving the 16x9 matrix Display
85+
The IS31FL3731 is an abstract class contain the main function related to this chip.
86+
Each board needs to define width, height and pixel_addr.
7287
7388
:param ~adafruit_bus_device.i2c_device i2c_device: the connected i2c bus i2c_device
7489
:param address: the device address; defaults to 0x74
@@ -283,6 +298,7 @@ def fill(self, color=None, blink=None, frame=None):
283298
for col in range(18):
284299
self._register(frame, _BLINK_OFFSET + col, data)
285300

301+
# This function must be replaced for each board
286302
@staticmethod
287303
def pixel_addr(x, y):
288304
"""Calulate the offset into the device array for x,y pixel"""
@@ -348,6 +364,7 @@ def image(self, img, blink=None, frame=None):
348364
for x in range(self.width): # yes this double loop is slow,
349365
for y in range(self.height): # but these displays are small!
350366
self.pixel(x, y, pixels[(x, y)], blink=blink, frame=frame)
367+
<<<<<<< HEAD:adafruit_is31fl3731.py
351368

352369

353370
class CharlieWing(Matrix):
@@ -482,58 +499,3 @@ def pixel_addr(x, y):
482499
if x < 27:
483500
return x + 83
484501
return 93
485-
486-
487-
class Keybow2040(Matrix):
488-
"""Supports the Pimoroni Keybow 2040 with 4x4 matrix of RGB LEDs """
489-
490-
width = 16
491-
height = 3
492-
493-
# pylint: disable=too-many-arguments
494-
495-
def pixelrgb(self, x, y, r, g, b, blink=None, frame=None):
496-
"""
497-
Blink or brightness for x, y-pixel
498-
499-
:param x: horizontal pixel position
500-
:param y: vertical pixel position
501-
:param r: red brightness value 0->255
502-
:param g: green brightness value 0->255
503-
:param b: blue brightness value 0->255
504-
:param blink: True to blink
505-
:param frame: the frame to set the pixel
506-
"""
507-
x = x + (4 * y)
508-
509-
super().pixel(x, 0, r, blink, frame)
510-
super().pixel(x, 1, g, blink, frame)
511-
super().pixel(x, 2, b, blink, frame)
512-
513-
# pylint: disable=inconsistent-return-statements
514-
# pylint: disable=too-many-return-statements
515-
# pylint: disable=too-many-branches
516-
517-
@staticmethod
518-
def pixel_addr(x, y):
519-
520-
lookup = [
521-
(120, 88, 104), # 0, 0
522-
(136, 40, 72), # 1, 0
523-
(112, 80, 96), # 2, 0
524-
(128, 32, 64), # 3, 0
525-
(121, 89, 105), # 0, 1
526-
(137, 41, 73), # 1, 1
527-
(113, 81, 97), # 2, 1
528-
(129, 33, 65), # 3, 1
529-
(122, 90, 106), # 0, 2
530-
(138, 25, 74), # 1, 2
531-
(114, 82, 98), # 2, 2
532-
(130, 17, 66), # 3, 2
533-
(123, 91, 107), # 0, 3
534-
(139, 26, 75), # 1, 3
535-
(115, 83, 99), # 2, 3
536-
(131, 18, 67), # 3, 3
537-
]
538-
539-
return lookup[x][y]

adafruit_is31fl3731/charlie_bonnet.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2017 Tony DiCola
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
23+
"""
24+
`adafruit_is31fl3731.charlie_bonnet`
25+
====================================================
26+
27+
CircuitPython driver for the IS31FL3731 charlieplex IC.
28+
29+
30+
* Author(s): Tony DiCola, Melissa LeBlanc-Williams
31+
32+
Implementation Notes
33+
--------------------
34+
35+
**Hardware:**
36+
37+
* `Adafruit 16x8 CharliePlex LED Matrix Bonnets
38+
<https://www.adafruit.com/product/4127>`_
39+
40+
41+
**Software and Dependencies:**
42+
43+
* Adafruit CircuitPython firmware for the supported boards:
44+
https://github.com/adafruit/circuitpython/releases
45+
46+
"""
47+
48+
# imports
49+
from . import IS31FL3731
50+
51+
52+
class CharlieBonnet(IS31FL3731):
53+
"""Supports the Charlieplexed bonnet"""
54+
55+
width = 16
56+
height = 8
57+
58+
@staticmethod
59+
def pixel_addr(x, y):
60+
"""Calulate the offset into the device array for x,y pixel"""
61+
if x >= 8:
62+
return (x - 6) * 16 - (y + 1)
63+
return (x + 1) * 16 + (7 - y)

adafruit_is31fl3731/charlie_wing.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2017 Tony DiCola
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
23+
"""
24+
`adafruit_is31fl3731.charlie_wing`
25+
====================================================
26+
27+
CircuitPython driver for the IS31FL3731 charlieplex IC.
28+
29+
30+
* Author(s): Tony DiCola, Melissa LeBlanc-Williams
31+
32+
Implementation Notes
33+
--------------------
34+
35+
**Hardware:**
36+
37+
* `Adafruit 15x7 CharliePlex LED Matrix Display FeatherWings
38+
<https://www.adafruit.com/product/2965>`_
39+
40+
**Software and Dependencies:**
41+
42+
* Adafruit CircuitPython firmware for the supported boards:
43+
https://github.com/adafruit/circuitpython/releases
44+
45+
"""
46+
47+
# imports
48+
from . import IS31FL3731
49+
50+
51+
class CharlieWing(IS31FL3731):
52+
"""Supports the Charlieplexed feather wing
53+
"""
54+
55+
width = 15
56+
height = 7
57+
58+
@staticmethod
59+
def pixel_addr(x, y):
60+
"""Calulate the offset into the device array for x,y pixel
61+
"""
62+
if x > 7:
63+
x = 15 - x
64+
y += 8
65+
else:
66+
y = 7 - y
67+
return x * 16 + y

adafruit_is31fl3731/keybow2040.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2017 Tony DiCola
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
23+
"""
24+
`adafruit_is31fl3731.charlie_bonnet`
25+
====================================================
26+
27+
CircuitPython driver for the IS31FL3731 charlieplex IC.
28+
29+
30+
* Author(s): Tony DiCola, Melissa LeBlanc-Williams
31+
32+
Implementation Notes
33+
--------------------
34+
35+
**Hardware:**
36+
37+
* `Pimoroni Keybow 2040
38+
<https://shop.pimoroni.com/products/keybow-2040>`_
39+
40+
41+
**Software and Dependencies:**
42+
43+
* Adafruit CircuitPython firmware for the supported boards:
44+
https://github.com/adafruit/circuitpython/releases
45+
46+
"""
47+
48+
# imports
49+
from . import IS31FL3731
50+
51+
52+
class Keybow2040(IS31FL3731):
53+
"""Supports the Pimoroni Keybow 2040 with 4x4 matrix of RGB LEDs """
54+
55+
width = 16
56+
height = 3
57+
58+
# pylint: disable=too-many-arguments
59+
60+
def pixelrgb(self, x, y, r, g, b, blink=None, frame=None):
61+
"""
62+
Blink or brightness for x, y-pixel
63+
64+
:param x: horizontal pixel position
65+
:param y: vertical pixel position
66+
:param r: red brightness value 0->255
67+
:param g: green brightness value 0->255
68+
:param b: blue brightness value 0->255
69+
:param blink: True to blink
70+
:param frame: the frame to set the pixel
71+
"""
72+
x = (4 * (3 - x)) + y
73+
74+
super().pixel(x, 0, g, blink, frame)
75+
super().pixel(x, 1, r, blink, frame)
76+
super().pixel(x, 2, b, blink, frame)
77+
78+
# pylint: disable=inconsistent-return-statements
79+
# pylint: disable=too-many-return-statements
80+
# pylint: disable=too-many-branches
81+
82+
@staticmethod
83+
def pixel_addr(x, y):
84+
85+
lookup = [
86+
(120, 88, 104), # 0, 0
87+
(136, 40, 72), # 1, 0
88+
(112, 80, 96), # 2, 0
89+
(128, 32, 64), # 3, 0
90+
(121, 89, 105), # 0, 1
91+
(137, 41, 73), # 1, 1
92+
(113, 81, 97), # 2, 1
93+
(129, 33, 65), # 3, 1
94+
(122, 90, 106), # 0, 2
95+
(138, 25, 74), # 1, 2
96+
(114, 82, 98), # 2, 2
97+
(130, 17, 66), # 3, 2
98+
(123, 91, 107), # 0, 3
99+
(139, 26, 75), # 1, 3
100+
(115, 83, 99), # 2, 3
101+
(131, 18, 67), # 3, 3
102+
]
103+
104+
return lookup[x][y]

0 commit comments

Comments
 (0)