Skip to content

Commit 87d0714

Browse files
authored
Merge pull request #2002 from kattni/dotstar-template
Add/update DotStar single LED template code
2 parents f5dab4a + 13f5649 commit 87d0714

File tree

3 files changed

+25
-7
lines changed
  • CircuitPython_Templates
    • status_led_one_dotstar_rainbow
    • status_led_one_dotstar_rgb
    • status_led_one_neopixel_rainbow

3 files changed

+25
-7
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
2+
# SPDX-License-Identifier: Unlicense
3+
"""
4+
CircuitPython DotStar red, green, blue, brightness control example.
5+
"""
6+
import time
7+
import board
8+
from rainbowio import colorwheel
9+
import adafruit_dotstar
10+
11+
dot = adafruit_dotstar.DotStar(board.DOTSTAR_CLOCK, board.DOTSTAR_DATA, 1)
12+
dot.brightness = 0.3
13+
14+
15+
def rainbow(delay):
16+
for color_value in range(255):
17+
dot[0] = colorwheel(color_value)
18+
time.sleep(delay)
19+
20+
21+
while True:
22+
rainbow(0.02)

CircuitPython_Templates/status_led_one_dotstar_rgb/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: 2021 Anne Barela for Adafruit Industries
22
# SPDX-License-Identifier: Unlicense
33
"""
4-
CircuitPython DotStar red, green, blue, brightness control example - single DotStar.
4+
CircuitPython DotStar red, green, blue, brightness control example.
55
"""
66
import time
77
import board

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)