Fix Flake8 issues
This commit is contained in:
parent
08cb52fbea
commit
df581b6d7f
5 changed files with 16 additions and 21 deletions
|
|
@ -51,7 +51,7 @@ while True:
|
||||||
pass # wait for it to be released!
|
pass # wait for it to be released!
|
||||||
# type the keycode or string
|
# type the keycode or string
|
||||||
k = buttonkeys[i] # get the corresp. keycode/str
|
k = buttonkeys[i] # get the corresp. keycode/str
|
||||||
if type(k) is str:
|
if isinstance(k, str):
|
||||||
layout.write(k)
|
layout.write(k)
|
||||||
else:
|
else:
|
||||||
kbd.press(controlkey, k) # press...
|
kbd.press(controlkey, k) # press...
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ def wheel(pos):
|
||||||
# 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) or (pos > 255):
|
if (pos < 0) or (pos > 255):
|
||||||
return (0, 0, 0)
|
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:
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# Gemma IO demo - USB/Serial echo
|
# Gemma IO demo - USB/Serial echo
|
||||||
|
|
||||||
import busio
|
import busio
|
||||||
from board import *
|
from board import D0, D2, D13
|
||||||
from digitalio import *
|
from digitalio import DigitalInOut, Direction
|
||||||
|
|
||||||
led = DigitalInOut(D13)
|
led = DigitalInOut(D13)
|
||||||
led.direction = Direction.OUTPUT
|
led.direction = Direction.OUTPUT
|
||||||
|
|
|
||||||
|
|
@ -27,19 +27,14 @@ prevtime = 0
|
||||||
|
|
||||||
pixels = neopixel.NeoPixel(pixpin, numpix, brightness=.3, auto_write=False)
|
pixels = neopixel.NeoPixel(pixpin, numpix, brightness=.3, auto_write=False)
|
||||||
|
|
||||||
|
prevtime = time.monotonic()
|
||||||
def setup():
|
|
||||||
prevtime = time.monotonic()
|
|
||||||
|
|
||||||
|
|
||||||
setup()
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
i = 0
|
i = 0
|
||||||
t = 0
|
t = 0
|
||||||
|
|
||||||
# Random sparks - just one LED on at a time!
|
# Random sparks - just one LED on at a time!
|
||||||
if (mode == 0):
|
if mode == 0:
|
||||||
i = random.randint(0, (numpix - 1))
|
i = random.randint(0, (numpix - 1))
|
||||||
pixels[i] = color
|
pixels[i] = color
|
||||||
pixels.write()
|
pixels.write()
|
||||||
|
|
@ -47,12 +42,12 @@ while True:
|
||||||
pixels[i] = (0, 0, 0)
|
pixels[i] = (0, 0, 0)
|
||||||
|
|
||||||
# Spinny wheels (8 LEDs on at a time)
|
# Spinny wheels (8 LEDs on at a time)
|
||||||
elif (mode == 1):
|
elif mode == 1:
|
||||||
for i in range(0, numpix):
|
for i in range(0, numpix):
|
||||||
c = 0
|
c = 0
|
||||||
|
|
||||||
# 4 pixels on...
|
# 4 pixels on...
|
||||||
if (((offset + i) & 7) < 2):
|
if ((offset + i) & 7) < 2:
|
||||||
c = color
|
c = color
|
||||||
|
|
||||||
pixels[i] = c # First eye
|
pixels[i] = c # First eye
|
||||||
|
|
@ -64,12 +59,12 @@ while True:
|
||||||
|
|
||||||
t = time.monotonic()
|
t = time.monotonic()
|
||||||
|
|
||||||
if ((t - prevtime) > 8): # Every 8 seconds...
|
if (t - prevtime) > 8: # Every 8 seconds...
|
||||||
mode += 1 # Next mode
|
mode += 1 # Next mode
|
||||||
if (mode > 1): # End of modes?
|
if mode > 1: # End of modes?
|
||||||
mode = 0 # Start modes over
|
mode = 0 # Start modes over
|
||||||
|
|
||||||
if (rgb_idx > 2): # reset R-->G-->B rotation
|
if rgb_idx > 2: # reset R-->G-->B rotation
|
||||||
rgb_idx = 0
|
rgb_idx = 0
|
||||||
|
|
||||||
color = rgb_colors[rgb_idx] # next color assignment
|
color = rgb_colors[rgb_idx] # next color assignment
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ while True:
|
||||||
strip[pos] = ([255, 48, 0]) # brightest
|
strip[pos] = ([255, 48, 0]) # brightest
|
||||||
strip[pos + 1] = ([128, 0, 0]) # Medium red
|
strip[pos + 1] = ([128, 0, 0]) # Medium red
|
||||||
|
|
||||||
if ((pos + 2) < numpix):
|
if (pos + 2) < numpix:
|
||||||
# Dark red, do not exceed number of pixels
|
# Dark red, do not exceed number of pixels
|
||||||
strip[pos + 2] = ([16, 0, 0])
|
strip[pos + 2] = ([16, 0, 0])
|
||||||
|
|
||||||
|
|
@ -26,14 +26,14 @@ while True:
|
||||||
# it's easier to erase it all and draw a new one next time.
|
# it's easier to erase it all and draw a new one next time.
|
||||||
for j in range(-2, 2):
|
for j in range(-2, 2):
|
||||||
strip[pos + j] = (0, 0, 0)
|
strip[pos + j] = (0, 0, 0)
|
||||||
if ((pos + 2) < numpix):
|
if (pos + 2) < numpix:
|
||||||
strip[pos + 2] = (0, 0, 0)
|
strip[pos + 2] = (0, 0, 0)
|
||||||
|
|
||||||
# Bounce off ends of strip
|
# Bounce off ends of strip
|
||||||
pos += direction
|
pos += direction
|
||||||
if (pos < 0):
|
if pos < 0:
|
||||||
pos = 1
|
pos = 1
|
||||||
direction = -direction
|
direction = -direction
|
||||||
elif (pos >= (numpix - 1)):
|
elif pos >= (numpix - 1):
|
||||||
pos = numpix - 2
|
pos = numpix - 2
|
||||||
direction = -direction
|
direction = -direction
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue