Simplify rainbow code
This commit is contained in:
parent
e5fc534b8d
commit
13f5649bd0
2 changed files with 4 additions and 11 deletions
|
|
@ -1,7 +1,7 @@
|
|||
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
"""
|
||||
CircuitPython DotStar rainbow, brightness control example.
|
||||
CircuitPython DotStar red, green, blue, brightness control example.
|
||||
"""
|
||||
import time
|
||||
import board
|
||||
|
|
@ -14,10 +14,7 @@ dot.brightness = 0.3
|
|||
|
||||
def rainbow(delay):
|
||||
for color_value in range(255):
|
||||
for led in range(1):
|
||||
dot_index = (led * 256 // 1) + color_value
|
||||
dot[led] = colorwheel(dot_index & 255)
|
||||
dot.show()
|
||||
dot[0] = colorwheel(color_value)
|
||||
time.sleep(delay)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,17 +6,13 @@ import board
|
|||
from rainbowio import colorwheel
|
||||
import neopixel
|
||||
|
||||
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, auto_write=False)
|
||||
|
||||
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1)
|
||||
pixel.brightness = 0.3
|
||||
|
||||
|
||||
def rainbow(delay):
|
||||
for color_value in range(255):
|
||||
for led in range(1):
|
||||
pixel_index = (led * 256 // 1) + color_value
|
||||
pixel[led] = colorwheel(pixel_index & 255)
|
||||
pixel.show()
|
||||
pixel[0] = colorwheel(color_value)
|
||||
time.sleep(delay)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue