Skip to content

Commit d85fd57

Browse files
committed
Split library into package and adapt examples+doc
1 parent 17fd7df commit d85fd57

15 files changed

+460
-198
lines changed

README.rst

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

6767
.. code:: python
6868
69-
import adafruit_is31fl3731
69+
from adafruit_is31fl3731 import Matrix
7070
import board
7171
import busio
7272
with busio.I2C(board.SCL, board.SDA) as i2c:
73-
display = adafruit_is31fl3731.Matrix(i2c)
73+
display = Matrix(i2c)
7474
display.fill(127)
7575
7676
7777
Charlie Wing:
7878

7979
.. code:: python
8080
81-
import adafruit_is31fl3731
81+
from adafruit_is31fl3731.CharlieWing import CharlieWing
8282
import board
8383
import busio
8484
with busio.I2C(board.SCL, board.SDA) as i2c:
85-
display = adafruit_is31fl3731.CharlieWing(i2c)
85+
display = CharlieWing(i2c)
8686
display.fill(127)
8787
8888
# Turn off pixel 4,4, change its brightness and turn it back on

adafruit_is31fl3731/CharlieBonnet.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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`
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 16x9 Charlieplexed PWM LED Matrix Driver - IS31FL3731
38+
<https://www.adafruit.com/product/2946>`_
39+
40+
* `Adafruit 15x7 CharliePlex LED Matrix Display FeatherWings
41+
<https://www.adafruit.com/product/2965>`_
42+
43+
**Software and Dependencies:**
44+
45+
* Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards:
46+
https://github.com/adafruit/circuitpython/releases
47+
"""
48+
49+
# imports
50+
from . import Matrix
51+
52+
53+
class CharlieBonnet(Matrix):
54+
"""Supports the Charlieplexed bonnet"""
55+
56+
width = 16
57+
height = 8
58+
59+
@staticmethod
60+
def pixel_addr(x, y):
61+
"""Calulate the offset into the device array for x,y pixel"""
62+
if x >= 8:
63+
return (x - 6) * 16 - (y + 1)
64+
return (x + 1) * 16 + (7 - y)

adafruit_is31fl3731/CharlieWing.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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`
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 16x9 Charlieplexed PWM LED Matrix Driver - IS31FL3731
38+
<https://www.adafruit.com/product/2946>`_
39+
40+
* `Adafruit 15x7 CharliePlex LED Matrix Display FeatherWings
41+
<https://www.adafruit.com/product/2965>`_
42+
43+
**Software and Dependencies:**
44+
45+
* Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards:
46+
https://github.com/adafruit/circuitpython/releases
47+
"""
48+
49+
# imports
50+
from . import Matrix
51+
52+
53+
class CharlieWing(Matrix):
54+
"""Supports the Charlieplexed feather wing
55+
"""
56+
57+
width = 15
58+
height = 7
59+
60+
@staticmethod
61+
def pixel_addr(x, y):
62+
"""Calulate the offset into the device array for x,y pixel
63+
"""
64+
if x > 7:
65+
x = 15 - x
66+
y += 8
67+
else:
68+
y = 7 - y
69+
return x * 16 + y

adafruit_is31fl3731/LedShim.py

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
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.LedShim`
25+
====================================================
26+
27+
CircuitPython driver for the IS31FL3731 charlieplex IC.
28+
29+
30+
* Author: David Glaude
31+
32+
Implementation Notes
33+
--------------------
34+
35+
**Hardware:**
36+
37+
* `Pimoroni 28 RGB Led Shim
38+
<https://www.adafruit.com/product/3831>`_
39+
40+
**Software and Dependencies:**
41+
42+
* Adafruit CircuitPython firmware:
43+
https://github.com/adafruit/circuitpython/releases
44+
"""
45+
46+
# imports
47+
from . import Matrix
48+
49+
50+
class LedShim(Matrix):
51+
"""Supports the LED SHIM by Pimoroni"""
52+
53+
width = 28
54+
height = 3
55+
56+
def __init__(self, i2c, address=0x75):
57+
super().__init__(i2c, address)
58+
59+
# pylint: disable-msg=too-many-arguments
60+
def pixelrgb(self, x, r, g, b, blink=None, frame=None):
61+
"""
62+
Blink or brightness for x-pixel
63+
64+
:param x: horizontal pixel position
65+
:param r: red brightness value 0->255
66+
:param g: green brightness value 0->255
67+
:param b: blue brightness value 0->255
68+
:param blink: True to blink
69+
:param frame: the frame to set the pixel
70+
"""
71+
super().pixel(x, 0, r, blink, frame)
72+
super().pixel(x, 1, g, blink, frame)
73+
super().pixel(x, 2, b, blink, frame)
74+
75+
# pylint: disable=inconsistent-return-statements
76+
# pylint: disable=too-many-return-statements
77+
# pylint: disable=too-many-branches
78+
79+
@staticmethod
80+
def pixel_addr(x, y):
81+
"""Translate an x,y coordinate to a pixel index."""
82+
if y == 0:
83+
if x < 7:
84+
return 118 - x
85+
if x < 15:
86+
return 141 - x
87+
if x < 21:
88+
return 106 + x
89+
if x == 21:
90+
return 15
91+
return x - 14
92+
93+
if y == 1:
94+
if x < 2:
95+
return 69 - x
96+
if x < 7:
97+
return 86 - x
98+
if x < 12:
99+
return 28 - x
100+
if x < 14:
101+
return 45 - x
102+
if x == 14:
103+
return 47
104+
if x == 15:
105+
return 41
106+
if x < 21:
107+
return x + 9
108+
if x == 21:
109+
return 95
110+
if x < 26:
111+
return x + 67
112+
return x + 50
113+
114+
if x == 0:
115+
return 85
116+
if x < 7:
117+
return 102 - x
118+
if x < 11:
119+
return 44 - x
120+
if x < 14:
121+
return 61 - x
122+
if x == 14:
123+
return 63
124+
if x < 17:
125+
return 42 + x
126+
if x < 21:
127+
return x + 25
128+
if x == 21:
129+
return 111
130+
if x < 27:
131+
return x + 83
132+
return 93

adafruit_is31fl3731/ScrollPhatHD.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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.ScrollPhatHD`
25+
====================================================
26+
27+
CircuitPython driver for the Pimoroni 17x7 Scroll pHAT HD.
28+
29+
30+
* Author: David Glaude
31+
32+
Implementation Notes
33+
--------------------
34+
35+
**Hardware:**
36+
37+
* `Pimoroni 17x7 Scroll pHAT HD
38+
<https://www.adafruit.com/product/3473>`_
39+
40+
**Software and Dependencies:**
41+
42+
* Adafruit CircuitPython firmware:
43+
https://github.com/adafruit/circuitpython/releases
44+
"""
45+
46+
# imports
47+
from . import Matrix
48+
49+
50+
class ScrollPhatHD(Matrix):
51+
"""Supports the Scroll pHAT HD by Pimoroni"""
52+
53+
width = 17
54+
height = 7
55+
56+
@staticmethod
57+
def pixel_addr(x, y):
58+
"""Translate an x,y coordinate to a pixel index."""
59+
if x <= 8:
60+
x = 8 - x
61+
y = 6 - y
62+
else:
63+
x = x - 8
64+
y = y - 8
65+
return x * 16 + y

0 commit comments

Comments
 (0)