Skip to content

Commit 13f5649

Browse files
committed
Simplify rainbow code
1 parent e5fc534 commit 13f5649

File tree

2 files changed

+4
-11
lines changed
  • CircuitPython_Templates
    • status_led_one_dotstar_rainbow
    • status_led_one_neopixel_rainbow

2 files changed

+4
-11
lines changed

CircuitPython_Templates/status_led_one_dotstar_rainbow/code.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
22
# SPDX-License-Identifier: Unlicense
33
"""
4-
CircuitPython DotStar rainbow, brightness control example.
4+
CircuitPython DotStar red, green, blue, brightness control example.
55
"""
66
import time
77
import board
@@ -14,10 +14,7 @@
1414

1515
def rainbow(delay):
1616
for color_value in range(255):
17-
for led in range(1):
18-
dot_index = (led * 256 // 1) + color_value
19-
dot[led] = colorwheel(dot_index & 255)
20-
dot.show()
17+
dot[0] = colorwheel(color_value)
2118
time.sleep(delay)
2219

2320

CircuitPython_Templates/status_led_one_neopixel_rainbow/code.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@
66
from rainbowio import colorwheel
77
import neopixel
88

9-
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, auto_write=False)
10-
9+
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1)
1110
pixel.brightness = 0.3
1211

1312

1413
def rainbow(delay):
1514
for color_value in range(255):
16-
for led in range(1):
17-
pixel_index = (led * 256 // 1) + color_value
18-
pixel[led] = colorwheel(pixel_index & 255)
19-
pixel.show()
15+
pixel[0] = colorwheel(color_value)
2016
time.sleep(delay)
2117

2218

0 commit comments

Comments
 (0)