Skip to content

Commit c622016

Browse files
authored
Merge pull request adafruit#1887 from PaintYourDragon/main
Update one EyeLights example to use library’s fill() function…
2 parents f8e1e95 + 503f080 commit c622016

File tree

1 file changed

+8
-9
lines changed
  • EyeLights_Accelerometer_Tap/EyeLights_Accelerometer_Tap_CircuitPython

1 file changed

+8
-9
lines changed

EyeLights_Accelerometer_Tap/EyeLights_Accelerometer_Tap_CircuitPython/code.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@
5454
interpolated_color = (0, 0, 0) # LEDs off at startup, they'll ramp up
5555

5656

57-
def fill_color(color):
58-
"""Given an (R,G,B) tuple, fill both LED rings with this color."""
59-
# Convert tuple to a 'packed' 24-bit value
60-
packed = (int(color[0]) << 16) | (int(color[1]) << 8) | int(color[2])
61-
for i in range(24):
62-
glasses.left_ring[i] = glasses.right_ring[i] = packed
63-
64-
6557
while True: # Loop forever...
6658

6759
# The try/except here is because VERY INFREQUENTLY the I2C bus will
@@ -79,7 +71,14 @@ def fill_color(color):
7971
interpolated_color[2] * 0.85 + target_color[2] * 0.15,
8072
)
8173
# Fill both rings with interpolated_color, then refresh the LEDs.
82-
fill_color(interpolated_color)
74+
# fill_color(interpolated_color)
75+
packed = (
76+
(int(interpolated_color[0]) << 16)
77+
| (int(interpolated_color[1]) << 8)
78+
| int(interpolated_color[2])
79+
)
80+
glasses.left_ring.fill(packed)
81+
glasses.right_ring.fill(packed)
8382
glasses.show()
8483

8584
# The look-down detection only needs the accelerometer's Y axis.

0 commit comments

Comments
 (0)