kleen up
This commit is contained in:
parent
fd5f4e2cc5
commit
b7692eac46
1 changed files with 16 additions and 22 deletions
|
|
@ -1,51 +1,45 @@
|
||||||
# Gemma IO demo - Dotstar
|
# Gemma IO demo - Dotstar
|
||||||
|
|
||||||
from digitalio import *
|
import board
|
||||||
from board import *
|
import adafruit_dotstar
|
||||||
import dotstar
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
numpix = 64
|
numpix = 64
|
||||||
strip = dotstar.DotStar(D2, D0, numpix, brightness=0.2)
|
strip = adafruit_dotstar.DotStar(board.D2, board.D0, numpix, brightness=0.2)
|
||||||
|
|
||||||
led = DigitalInOut(D13)
|
|
||||||
led.direction = Direction.OUTPUT
|
|
||||||
|
|
||||||
def wheel(pos):
|
def wheel(pos):
|
||||||
# Input a value 0 to 255 to get a color value.
|
# Input a value 0 to 255 to get a color value.
|
||||||
# The colours are a transition r - g - b - back to r.
|
# The colours are a transition r - g - b - back to r.
|
||||||
if (pos < 0):
|
if (pos < 0) or (pos > 255):
|
||||||
return [0, 0, 0]
|
return (0, 0, 0)
|
||||||
if (pos > 255):
|
|
||||||
return [0, 0, 0]
|
|
||||||
if (pos < 85):
|
if (pos < 85):
|
||||||
return [int(pos * 3), int(255 - (pos*3)), 0]
|
return (int(pos * 3), int(255 - (pos*3)), 0)
|
||||||
elif (pos < 170):
|
elif (pos < 170):
|
||||||
pos -= 85
|
pos -= 85
|
||||||
return [int(255 - pos*3), 0, int(pos*3)]
|
return (int(255 - pos*3), 0, int(pos*3))
|
||||||
else:
|
else:
|
||||||
pos -= 170
|
pos -= 170
|
||||||
return [0, int(pos*3), int(255 - pos*3)]
|
return (0, int(pos*3), int(255 - pos*3))
|
||||||
|
|
||||||
def rainbow_cycle(wait):
|
def rainbow_cycle(wait):
|
||||||
for j in range(255):
|
for j in range(255):
|
||||||
for i in range(len(strip)):
|
for i in range(len(strip)):
|
||||||
idx = int ((i * 256 / len(strip)) + j)
|
idx = int ((i * 256 / len(strip)) + j)
|
||||||
strip[i] = wheel(idx & 255)
|
strip[i] = wheel(idx & 255)
|
||||||
strip.write()
|
strip.show()
|
||||||
time.sleep(wait)
|
time.sleep(wait)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
strip.fill([255, 0, 0])
|
strip.fill((255, 0, 0))
|
||||||
strip.write()
|
strip.show()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
strip.fill([0, 255, 0])
|
strip.fill((0, 255, 0))
|
||||||
strip.write()
|
strip.show()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
strip.fill([0, 0, 255])
|
strip.fill((0, 0, 255))
|
||||||
strip.write()
|
strip.show()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
rainbow_cycle(0)
|
rainbow_cycle(0.001) # high speed rainbow cycle w/1ms delay per sweep
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue