Add auto_write=False, turn off DotStar, linting.
@@ -5,30 +5,33 @@ import time
import board
import neopixel
+import adafruit_dotstar
try:
import urandom as random # for v1.0 API support
except ImportError:
import random
+dot = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
+dot[0] = (0, 0, 0)
+
numpix = 16 # Number of NeoPixels (e.g. 16-pixel ring)
pixpin = board.D0 # Pin where NeoPixels are connected
-strip = neopixel.NeoPixel(pixpin, numpix, brightness=.3)
+strip = neopixel.NeoPixel(pixpin, numpix, brightness=.3, auto_write=False)
def wheel(pos):
# Input a value 0 to 255 to get a color value.
# The colours are a transition r - g - b - back to r.
- if (pos < 0) or (pos > 255):
- return [0, 0, 0]
- elif pos < 85:
- return [int(pos * 3), int(255 - (pos * 3)), 0]
- elif pos < 170:
+ if pos < 0 or pos > 255:
+ return (0, 0, 0)
+ if pos < 85:
+ return (int(255 - pos*3), int(pos*3), 0)
+ if pos < 170:
pos -= 85
- return [int(255 - pos * 3), 0, int(pos * 3)]
- else:
+ return (0, int(255 - pos*3), int(pos*3))
pos -= 170
- return [0, int(pos * 3), int(255 - pos * 3)]
+ return (int(pos * 3), 0, int(255 - (pos*3)))
mode = 0 # Current animation effect
