Skip to content

Commit 12c7300

Browse files
Merge pull request #3 from rhooper/grid
Add grid support to LED Glasses
2 parents be8931b + fa2e0f3 commit 12c7300

File tree

1 file changed

+109
-4
lines changed

1 file changed

+109
-4
lines changed

adafruit_is31fl3741/adafruit_ledglasses.py

Lines changed: 109 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries
1+
# SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries, Rose Hooper
22
#
33
# SPDX-License-Identifier: MIT
44

@@ -9,7 +9,7 @@
99
CircuitPython driver for the Adafruit IS31FL3741 RGB Matrix QT board
1010
1111
12-
* Author(s): ladyada
12+
* Author(s): ladyada, Rose Hooper
1313
1414
Implementation Notes
1515
--------------------
@@ -22,12 +22,11 @@
2222
https://github.com/adafruit/circuitpython/releases
2323
2424
"""
25-
# pylint: disable=abstract-method, super-init-not-called
2625
import adafruit_is31fl3741
2726
from . import IS31FL3741
2827

2928

30-
class Right_Ring(IS31FL3741):
29+
class Right_Ring:
3130
"""The right eye ring of the LED glasses"""
3231

3332
ledmap = (
@@ -132,11 +131,117 @@ def __getitem__(self, led):
132131
class LED_Glasses(IS31FL3741):
133132
"""Class representing LED Glasses"""
134133

134+
ledmap = [
135+
(None, None, None),
136+
(216, 215, 217),
137+
(186, 185, 187),
138+
(36, 35, 37),
139+
(66, 65, 67),
140+
(96, 95, 97),
141+
(126, 125, 127),
142+
(156, 155, 157),
143+
(246, 245, 247),
144+
(346, 347, 345),
145+
(337, 338, 336),
146+
(328, 329, 327),
147+
(319, 320, 318),
148+
(310, 311, 309),
149+
(301, 302, 300),
150+
(292, 293, 291),
151+
(283, 284, 282),
152+
(None, None, None),
153+
(9, 8, 10),
154+
(219, 218, 220),
155+
(189, 188, 190),
156+
(39, 38, 40),
157+
(69, 68, 70),
158+
(99, 98, 100),
159+
(129, 128, 130),
160+
(159, 158, 160),
161+
(249, 248, 250),
162+
(343, 344, 342),
163+
(334, 335, 333),
164+
(325, 326, 324),
165+
(316, 317, 315),
166+
(307, 308, 306),
167+
(298, 299, 297),
168+
(289, 290, 288),
169+
(280, 281, 279),
170+
(271, 272, 270),
171+
(12, 11, 13),
172+
(222, 221, 223),
173+
(192, 191, 193),
174+
(42, 41, 43),
175+
(72, 71, 73),
176+
(102, 101, 103),
177+
(132, 131, 133),
178+
(162, 161, 163),
179+
(252, 251, 253),
180+
(268, 269, 267),
181+
(238, 239, 237),
182+
(208, 209, 207),
183+
(178, 179, 177),
184+
(148, 149, 147),
185+
(118, 119, 117),
186+
(88, 89, 87),
187+
(58, 59, 57),
188+
(28, 29, 27),
189+
(15, 14, 16),
190+
(225, 224, 226),
191+
(195, 194, 196),
192+
(45, 44, 46),
193+
(75, 74, 76),
194+
(105, 104, 106),
195+
(135, 134, 136),
196+
(165, 164, 166),
197+
(255, 254, 256),
198+
(264, 265, 263),
199+
(234, 235, 233),
200+
(204, 205, 203),
201+
(174, 175, 173),
202+
(144, 145, 143),
203+
(114, 115, 113),
204+
(84, 85, 83),
205+
(54, 55, 53),
206+
(24, 25, 23),
207+
(3, 2, 4),
208+
(213, 212, 214),
209+
(183, 182, 184),
210+
(33, 32, 34),
211+
(63, 62, 64),
212+
(93, 92, 94),
213+
(123, 122, 124),
214+
(243, 242, 244),
215+
(None, None, None),
216+
(None, None, None),
217+
(349, 262, 348),
218+
(331, 202, 330),
219+
(322, 172, 321),
220+
(313, 142, 312),
221+
(304, 112, 303),
222+
(295, 82, 294),
223+
(286, 52, 285),
224+
(277, 22, 276),
225+
]
226+
width = 18
227+
height = 5
228+
# These pixels aren't connected to anything and are safe to use for pixels that aren't visible
229+
unused_pixels = (120, 121, 314)
230+
135231
def __init__(self, i2c, allocate=adafruit_is31fl3741.NO_BUFFER):
136232
super().__init__(i2c, allocate=allocate)
233+
137234
self.set_led_scaling(0xFF) # turn on LEDs all the way
138235
self.global_current = 0xFE # set current to max
139236
self.enable = True # enable!
140237

141238
self.right_ring = Right_Ring(self)
142239
self.left_ring = Left_Ring(self)
240+
self.grid = self
241+
242+
@staticmethod
243+
def pixel_addrs(x, y):
244+
addrs = LED_Glasses.ledmap[x + (LED_Glasses.width * y)]
245+
if addrs[0] is None:
246+
return LED_Glasses.unused_pixels
247+
return addrs

0 commit comments

Comments
 (0)