Skip to content

Add grid support to LED Glasses #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 109 additions & 4 deletions adafruit_is31fl3741/adafruit_ledglasses.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries
# SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries, Rose Hooper
#
# SPDX-License-Identifier: MIT

Expand All @@ -9,7 +9,7 @@
CircuitPython driver for the Adafruit IS31FL3741 RGB Matrix QT board


* Author(s): ladyada
* Author(s): ladyada, Rose Hooper

Implementation Notes
--------------------
Expand All @@ -22,12 +22,11 @@
https://github.com/adafruit/circuitpython/releases

"""
# pylint: disable=abstract-method, super-init-not-called
import adafruit_is31fl3741
from . import IS31FL3741


class Right_Ring(IS31FL3741):
class Right_Ring:
"""The right eye ring of the LED glasses"""

ledmap = (
Expand Down Expand Up @@ -132,11 +131,117 @@ def __getitem__(self, led):
class LED_Glasses(IS31FL3741):
"""Class representing LED Glasses"""

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

def __init__(self, i2c, allocate=adafruit_is31fl3741.NO_BUFFER):
super().__init__(i2c, allocate=allocate)

self.set_led_scaling(0xFF) # turn on LEDs all the way
self.global_current = 0xFE # set current to max
self.enable = True # enable!

self.right_ring = Right_Ring(self)
self.left_ring = Left_Ring(self)
self.grid = self

@staticmethod
def pixel_addrs(x, y):
addrs = LED_Glasses.ledmap[x + (LED_Glasses.width * y)]
if addrs[0] is None:
return LED_Glasses.unused_pixels
return addrs