Skip to content

Commit ae0d9e6

Browse files
authored
Merge pull request #2 from kattni/cleanup
Cleanup and lint.
2 parents bc2d788 + 0887636 commit ae0d9e6

File tree

6 files changed

+76
-80
lines changed

6 files changed

+76
-80
lines changed

adafruit_is31fl3741/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,9 @@
2424
2525
"""
2626

27-
# imports
28-
import math
29-
import time
3027
import adafruit_bus_device.i2c_device as i2c_device
3128
from adafruit_register.i2c_struct import ROUnaryStruct, UnaryStruct
3229
from adafruit_register.i2c_bit import RWBit
33-
from micropython import const
3430

3531
__version__ = "0.0.0-auto.0"
3632
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3741.git"

adafruit_is31fl3741/adafruit_ledglasses.py

Lines changed: 62 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -22,98 +22,102 @@
2222
https://github.com/adafruit/circuitpython/releases
2323
2424
"""
25-
26-
# imports
25+
# pylint: disable=abstract-method, super-init-not-called
2726
from . import IS31FL3741
2827

28+
2929
class Right_Ring(IS31FL3741):
3030
"""The right eye ring of the LED glasses"""
31+
3132
def __init__(self, is31_controller):
3233
self._is31 = is31_controller
33-
34+
3435
def __setitem__(self, led, color):
3536
if not 0 <= led <= 23:
3637
raise ValueError("led must be 0~23")
3738

38-
ledmap = ((287, 31, 30), # 0
39-
(278, 1, 0), # 1
40-
(273, 274, 275), # 2
41-
(282, 283, 284), # 3
42-
(270, 271, 272), # 4
43-
(27, 28, 29), # 5
44-
(23, 24, 25), # 6
45-
(276, 277, 22), # 7
46-
(20, 21, 26), # 8
47-
(50, 51, 56), # 9
48-
(80, 81, 86), # 10
49-
(110, 111, 116), #11
50-
(140, 141, 146), #12
51-
(170, 171, 176), #13
52-
(200, 201, 206), #14
53-
(230, 231, 236), #15
54-
(260, 261, 266), #16
55-
(348, 349, 262), #17
56-
(233, 234, 235), #18
57-
(237, 238, 239), #19
58-
(339, 340, 232), #20
59-
(327, 328, 329), #21
60-
(305, 91, 90), #22
61-
(296, 61, 60), # 23
62-
)
39+
ledmap = (
40+
(287, 31, 30), # 0
41+
(278, 1, 0), # 1
42+
(273, 274, 275), # 2
43+
(282, 283, 284), # 3
44+
(270, 271, 272), # 4
45+
(27, 28, 29), # 5
46+
(23, 24, 25), # 6
47+
(276, 277, 22), # 7
48+
(20, 21, 26), # 8
49+
(50, 51, 56), # 9
50+
(80, 81, 86), # 10
51+
(110, 111, 116), # 11
52+
(140, 141, 146), # 12
53+
(170, 171, 176), # 13
54+
(200, 201, 206), # 14
55+
(230, 231, 236), # 15
56+
(260, 261, 266), # 16
57+
(348, 349, 262), # 17
58+
(233, 234, 235), # 18
59+
(237, 238, 239), # 19
60+
(339, 340, 232), # 20
61+
(327, 328, 329), # 21
62+
(305, 91, 90), # 22
63+
(296, 61, 60), # 23
64+
)
6365
rgb = ledmap[led]
6466
self._is31[rgb[0]] = (color >> 16) & 0xFF
6567
self._is31[rgb[1]] = (color >> 8) & 0xFF
6668
self._is31[rgb[2]] = color & 0xFF
67-
69+
70+
6871
class Left_Ring:
6972
"""The left eye ring of the LED glasses"""
73+
7074
def __init__(self, is31_controller):
7175
self._is31 = is31_controller
72-
76+
7377
def __setitem__(self, led, color):
7478
if not 0 <= led <= 23:
7579
raise ValueError("led must be 0~23")
7680

7781
ledmap = (
78-
(341, 211, 210), #0
79-
(332, 181, 180), #1
80-
(323, 151, 150), #2
81-
(127, 126, 125), #3
82-
(154, 153, 152), #4
83-
(163, 162, 161), #5
84-
(166, 165, 164), #6
85-
(244, 243, 242), #7
86-
(259, 258, 257), #8
87-
(169, 168, 167), #9
88-
(139, 138, 137), #10
89-
(109, 108, 107), #11
90-
(79, 78, 77), #12
91-
(49, 48, 47), #13
92-
(199, 198, 197), #14
93-
(229, 228, 227), #15
94-
(19, 18, 17), #16
95-
(4, 3, 2), #17
96-
(16, 15, 14), #18
97-
(13, 12, 11), #19
98-
(10, 9, 8), #20
99-
(217, 216, 215), #21
100-
(7, 6, 5), #22
101-
(350, 241, 240), #23
102-
)
82+
(341, 211, 210), # 0
83+
(332, 181, 180), # 1
84+
(323, 151, 150), # 2
85+
(127, 126, 125), # 3
86+
(154, 153, 152), # 4
87+
(163, 162, 161), # 5
88+
(166, 165, 164), # 6
89+
(244, 243, 242), # 7
90+
(259, 258, 257), # 8
91+
(169, 168, 167), # 9
92+
(139, 138, 137), # 10
93+
(109, 108, 107), # 11
94+
(79, 78, 77), # 12
95+
(49, 48, 47), # 13
96+
(199, 198, 197), # 14
97+
(229, 228, 227), # 15
98+
(19, 18, 17), # 16
99+
(4, 3, 2), # 17
100+
(16, 15, 14), # 18
101+
(13, 12, 11), # 19
102+
(10, 9, 8), # 20
103+
(217, 216, 215), # 21
104+
(7, 6, 5), # 22
105+
(350, 241, 240), # 23
106+
)
103107
rgb = ledmap[led]
104108
self._is31[rgb[0]] = (color >> 16) & 0xFF
105109
self._is31[rgb[1]] = (color >> 8) & 0xFF
106110
self._is31[rgb[2]] = color & 0xFF
107111

108112

109-
110-
111113
class LED_Glasses(IS31FL3741):
114+
"""Class representing LED Glasses"""
115+
112116
def __init__(self, i2c):
113117
super().__init__(i2c)
114118
self.set_led_scaling(0xFF) # turn on LEDs all the way
115119
self.global_current = 0xFE # set current to max
116120
self.enable = True # enable!
117-
121+
118122
self.right_ring = Right_Ring(self)
119123
self.left_ring = Left_Ring(self)

examples/is31fl3741_glassesrings.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1+
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
13

2-
import time
34
import board
4-
import microcontroller
5-
import busio
6-
from adafruit_is31fl3741.adafruit_ledglasses import LED_Glasses
75
from rainbowio import colorwheel
6+
from adafruit_is31fl3741.adafruit_ledglasses import LED_Glasses
87

9-
i2c = busio.I2C(microcontroller.pin.P0_08, microcontroller.pin.P0_06)
10-
glasses = LED_Glasses(i2c)
8+
glasses = LED_Glasses(board.I2C())
119

1210
wheeloffset = 0
1311
while True:
1412
for i in range(24):
15-
glasses.right_ring[i] = colorwheel(i/24*255 + wheeloffset)
16-
glasses.left_ring[23-i] = colorwheel(i/24*255 + wheeloffset)
13+
glasses.right_ring[i] = colorwheel(i / 24 * 255 + wheeloffset)
14+
glasses.left_ring[23 - i] = colorwheel(i / 24 * 255 + wheeloffset)
1715
wheeloffset += 10

examples/is31fl3741_rgbswirl.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
is31 = Adafruit_RGBMatrixQT(board.I2C())
1010
is31.set_led_scaling(0xFF)
1111
is31.global_current = 0xFF
12-
# print("global current is", is31.global_current)
12+
# print("Global current is: ", is31.global_current)
1313
is31.enable = True
14-
# print("Enabled?", is31.enable)
14+
# print("Enabled? ", is31.enable)
1515

1616
wheeloffset = 0
1717
while True:
18-
1918
for y in range(9):
2019
for x in range(13):
2120
is31.pixel(x, y, colorwheel((y * 13 + x) * 2 + wheeloffset))

examples/is31fl3741_simpletest.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@
55
import board
66
import adafruit_is31fl3741
77

8-
i2c = board.I2C()
9-
10-
is31 = adafruit_is31fl3741.IS31FL3741(i2c)
8+
is31 = adafruit_is31fl3741.IS31FL3741(board.I2C())
119

1210
is31.set_led_scaling(0xFF) # turn on LEDs all the way
13-
is31.global_current = 0xFE # set current to max
11+
is31.global_current = 0xFF # set current to max
1412
is31.enable = True # enable!
1513

1614
# light up every LED, one at a time
1715
while True:
18-
for i in range(351):
19-
is31[i] = 255
16+
for pixel in range(351):
17+
is31[pixel] = 255
2018
time.sleep(0.01)
21-
is31[i] = 0
19+
is31[pixel] = 0

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
Adafruit-Blinka
66
adafruit-circuitpython-framebuf
7+
adafruit-circuitpython-register

0 commit comments

Comments
 (0)