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!
|
||||
# type the keycode or string
|
||||
k = buttonkeys[i] # get the corresp. keycode/str
|
||||
if type(k) is str:
|
||||
if isinstance(k, str):
|
||||
layout.write(k)
|
||||
else:
|
||||
kbd.press(controlkey, k) # press...
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ def wheel(pos):
|
|||
# The colours are a transition r - g - b - back to r.
|
||||
if (pos < 0) or (pos > 255):
|
||||
return (0, 0, 0)
|
||||
if (pos < 85):
|
||||
if pos < 85:
|
||||
return (int(pos * 3), int(255 - (pos * 3)), 0)
|
||||
elif (pos < 170):
|
||||
elif pos < 170:
|
||||
pos -= 85
|
||||
return (int(255 - pos * 3), 0, int(pos * 3))
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# Gemma IO demo - USB/Serial echo
|
||||
|
||||
import busio
|
||||
from board import *
|
||||
from digitalio import *
|
||||
from board import D0, D2, D13
|
||||
from digitalio import DigitalInOut, Direction
|
||||
|
||||
led = DigitalInOut(D13)
|
||||
led.direction = Direction.OUTPUT
|
||||
|
|
|
|||
|
|
@ -27,19 +27,14 @@ prevtime = 0
|
|||
|
||||
pixels = neopixel.NeoPixel(pixpin, numpix, brightness=.3, auto_write=False)
|
||||
|
||||
|
||||
def setup():
|
||||
prevtime = time.monotonic()
|
||||
|
||||
|
||||
setup()
|
||||
prevtime = time.monotonic()
|
||||
|
||||
while True:
|
||||
i = 0
|
||||
t = 0
|
||||
|
||||
# Random sparks - just one LED on at a time!
|
||||
if (mode == 0):
|
||||
if mode == 0:
|
||||
i = random.randint(0, (numpix - 1))
|
||||
pixels[i] = color
|
||||
pixels.write()
|
||||
|
|
@ -47,12 +42,12 @@ while True:
|
|||
pixels[i] = (0, 0, 0)
|
||||
|
||||
# Spinny wheels (8 LEDs on at a time)
|
||||
elif (mode == 1):
|
||||
elif mode == 1:
|
||||
for i in range(0, numpix):
|
||||
c = 0
|
||||
|
||||
# 4 pixels on...
|
||||
if (((offset + i) & 7) < 2):
|
||||
if ((offset + i) & 7) < 2:
|
||||
c = color
|
||||
|
||||
pixels[i] = c # First eye
|
||||
|
|
@ -64,12 +59,12 @@ while True:
|
|||
|
||||
t = time.monotonic()
|
||||
|
||||
if ((t - prevtime) > 8): # Every 8 seconds...
|
||||
if (t - prevtime) > 8: # Every 8 seconds...
|
||||
mode += 1 # Next mode
|
||||
if (mode > 1): # End of modes?
|
||||
if mode > 1: # End of modes?
|
||||
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
|
||||
|
||||
color = rgb_colors[rgb_idx] # next color assignment
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ while True:
|
|||
strip[pos] = ([255, 48, 0]) # brightest
|
||||
strip[pos + 1] = ([128, 0, 0]) # Medium red
|
||||
|
||||
if ((pos + 2) < numpix):
|
||||
if (pos + 2) < numpix:
|
||||
# Dark red, do not exceed number of pixels
|
||||
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.
|
||||
for j in range(-2, 2):
|
||||
strip[pos + j] = (0, 0, 0)
|
||||
if ((pos + 2) < numpix):
|
||||
if (pos + 2) < numpix:
|
||||
strip[pos + 2] = (0, 0, 0)
|
||||
|
||||
# Bounce off ends of strip
|
||||
pos += direction
|
||||
if (pos < 0):
|
||||
if pos < 0:
|
||||
pos = 1
|
||||
direction = -direction
|
||||
elif (pos >= (numpix - 1)):
|
||||
elif pos >= (numpix - 1):
|
||||
pos = numpix - 2
|
||||
direction = -direction
|
||||
|
|
|
|||
Loading…
Reference in a new issue