Skip to content

Cleanup and lint. #2

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 1 commit into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions adafruit_is31fl3741/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@

"""

# imports
import math
import time
import adafruit_bus_device.i2c_device as i2c_device
from adafruit_register.i2c_struct import ROUnaryStruct, UnaryStruct
from adafruit_register.i2c_bit import RWBit
from micropython import const

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3741.git"
Expand Down
120 changes: 62 additions & 58 deletions adafruit_is31fl3741/adafruit_ledglasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,98 +22,102 @@
https://github.com/adafruit/circuitpython/releases

"""

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


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

def __init__(self, is31_controller):
self._is31 = is31_controller

def __setitem__(self, led, color):
if not 0 <= led <= 23:
raise ValueError("led must be 0~23")

ledmap = ((287, 31, 30), # 0
(278, 1, 0), # 1
(273, 274, 275), # 2
(282, 283, 284), # 3
(270, 271, 272), # 4
(27, 28, 29), # 5
(23, 24, 25), # 6
(276, 277, 22), # 7
(20, 21, 26), # 8
(50, 51, 56), # 9
(80, 81, 86), # 10
(110, 111, 116), #11
(140, 141, 146), #12
(170, 171, 176), #13
(200, 201, 206), #14
(230, 231, 236), #15
(260, 261, 266), #16
(348, 349, 262), #17
(233, 234, 235), #18
(237, 238, 239), #19
(339, 340, 232), #20
(327, 328, 329), #21
(305, 91, 90), #22
(296, 61, 60), # 23
)
ledmap = (
(287, 31, 30), # 0
(278, 1, 0), # 1
(273, 274, 275), # 2
(282, 283, 284), # 3
(270, 271, 272), # 4
(27, 28, 29), # 5
(23, 24, 25), # 6
(276, 277, 22), # 7
(20, 21, 26), # 8
(50, 51, 56), # 9
(80, 81, 86), # 10
(110, 111, 116), # 11
(140, 141, 146), # 12
(170, 171, 176), # 13
(200, 201, 206), # 14
(230, 231, 236), # 15
(260, 261, 266), # 16
(348, 349, 262), # 17
(233, 234, 235), # 18
(237, 238, 239), # 19
(339, 340, 232), # 20
(327, 328, 329), # 21
(305, 91, 90), # 22
(296, 61, 60), # 23
)
rgb = ledmap[led]
self._is31[rgb[0]] = (color >> 16) & 0xFF
self._is31[rgb[1]] = (color >> 8) & 0xFF
self._is31[rgb[2]] = color & 0xFF



class Left_Ring:
"""The left eye ring of the LED glasses"""

def __init__(self, is31_controller):
self._is31 = is31_controller

def __setitem__(self, led, color):
if not 0 <= led <= 23:
raise ValueError("led must be 0~23")

ledmap = (
(341, 211, 210), #0
(332, 181, 180), #1
(323, 151, 150), #2
(127, 126, 125), #3
(154, 153, 152), #4
(163, 162, 161), #5
(166, 165, 164), #6
(244, 243, 242), #7
(259, 258, 257), #8
(169, 168, 167), #9
(139, 138, 137), #10
(109, 108, 107), #11
(79, 78, 77), #12
(49, 48, 47), #13
(199, 198, 197), #14
(229, 228, 227), #15
(19, 18, 17), #16
(4, 3, 2), #17
(16, 15, 14), #18
(13, 12, 11), #19
(10, 9, 8), #20
(217, 216, 215), #21
(7, 6, 5), #22
(350, 241, 240), #23
)
(341, 211, 210), # 0
(332, 181, 180), # 1
(323, 151, 150), # 2
(127, 126, 125), # 3
(154, 153, 152), # 4
(163, 162, 161), # 5
(166, 165, 164), # 6
(244, 243, 242), # 7
(259, 258, 257), # 8
(169, 168, 167), # 9
(139, 138, 137), # 10
(109, 108, 107), # 11
(79, 78, 77), # 12
(49, 48, 47), # 13
(199, 198, 197), # 14
(229, 228, 227), # 15
(19, 18, 17), # 16
(4, 3, 2), # 17
(16, 15, 14), # 18
(13, 12, 11), # 19
(10, 9, 8), # 20
(217, 216, 215), # 21
(7, 6, 5), # 22
(350, 241, 240), # 23
)
rgb = ledmap[led]
self._is31[rgb[0]] = (color >> 16) & 0xFF
self._is31[rgb[1]] = (color >> 8) & 0xFF
self._is31[rgb[2]] = color & 0xFF




class LED_Glasses(IS31FL3741):
"""Class representing LED Glasses"""

def __init__(self, i2c):
super().__init__(i2c)
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)
14 changes: 6 additions & 8 deletions examples/is31fl3741_glassesrings.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import time
import board
import microcontroller
import busio
from adafruit_is31fl3741.adafruit_ledglasses import LED_Glasses
from rainbowio import colorwheel
from adafruit_is31fl3741.adafruit_ledglasses import LED_Glasses

i2c = busio.I2C(microcontroller.pin.P0_08, microcontroller.pin.P0_06)
glasses = LED_Glasses(i2c)
glasses = LED_Glasses(board.I2C())

wheeloffset = 0
while True:
for i in range(24):
glasses.right_ring[i] = colorwheel(i/24*255 + wheeloffset)
glasses.left_ring[23-i] = colorwheel(i/24*255 + wheeloffset)
glasses.right_ring[i] = colorwheel(i / 24 * 255 + wheeloffset)
glasses.left_ring[23 - i] = colorwheel(i / 24 * 255 + wheeloffset)
wheeloffset += 10
5 changes: 2 additions & 3 deletions examples/is31fl3741_rgbswirl.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
is31 = Adafruit_RGBMatrixQT(board.I2C())
is31.set_led_scaling(0xFF)
is31.global_current = 0xFF
# print("global current is", is31.global_current)
# print("Global current is: ", is31.global_current)
is31.enable = True
# print("Enabled?", is31.enable)
# print("Enabled? ", is31.enable)

wheeloffset = 0
while True:

for y in range(9):
for x in range(13):
is31.pixel(x, y, colorwheel((y * 13 + x) * 2 + wheeloffset))
Expand Down
12 changes: 5 additions & 7 deletions examples/is31fl3741_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@
import board
import adafruit_is31fl3741

i2c = board.I2C()

is31 = adafruit_is31fl3741.IS31FL3741(i2c)
is31 = adafruit_is31fl3741.IS31FL3741(board.I2C())

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

# light up every LED, one at a time
while True:
for i in range(351):
is31[i] = 255
for pixel in range(351):
is31[pixel] = 255
time.sleep(0.01)
is31[i] = 0
is31[pixel] = 0
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

Adafruit-Blinka
adafruit-circuitpython-framebuf
adafruit-circuitpython-register