Fix Flake8 issues
This commit is contained in:
parent
5a23e531c8
commit
852e9affb0
5 changed files with 20 additions and 23 deletions
|
|
@ -31,11 +31,11 @@ def cog(pos):
|
|||
if (pos < 8) or (pos > 250):
|
||||
# return (120, 0, 0, 0) #first color, red: for RGBW NeoPixels
|
||||
return (120, 0, 0) # first color, red: for RGB NeoPixels
|
||||
if (pos < 85):
|
||||
if pos < 85:
|
||||
return (int(pos * 3), int(255 - (pos * 3)), 0)
|
||||
# return (125, 35, 0, 0) #second color, brass: for RGBW NeoPixels
|
||||
return (125, 35, 0) # second color, brass: for RGB NeoPixels
|
||||
elif (pos < 170):
|
||||
# return (125, 35, 0) # second color, brass: for RGB NeoPixels
|
||||
elif pos < 170:
|
||||
pos -= 85
|
||||
# return (int(255 - pos*3), 0, int(pos*3), 0)#: for RGBW NeoPixels
|
||||
return (int(255 - pos * 3), 0, int(pos * 3)) # : for RGB NeoPixels
|
||||
|
|
|
|||
|
|
@ -85,19 +85,16 @@ gammas = [
|
|||
215, 218, 220, 223, 225, 228, 231, 233, 236, 239, 241, 244, 247, 249, 252, 255]
|
||||
|
||||
|
||||
def h2rgb(hue):
|
||||
# return value
|
||||
ret = 0
|
||||
def h2rgb(colour_hue):
|
||||
colour_hue %= 90
|
||||
h = hue_table[colour_hue >> 1]
|
||||
|
||||
hue %= 90
|
||||
h = hue_table[hue >> 1]
|
||||
|
||||
if hue & 1:
|
||||
if colour_hue & 1:
|
||||
ret = h & 15
|
||||
else:
|
||||
ret = (h >> 4)
|
||||
|
||||
return (ret * 17)
|
||||
return ret * 17
|
||||
|
||||
|
||||
def wave_setup():
|
||||
|
|
@ -108,11 +105,11 @@ def wave_setup():
|
|||
[0, 7, 30, 0, 0, 0, 0, 0]]
|
||||
|
||||
# assign random starting colors to waves
|
||||
for w in range(n_waves):
|
||||
wave[w][hue] = wave[w][hue_target] = 90 + random.randint(0, 90)
|
||||
wave[w][red] = h2rgb(wave[w][hue] - 30)
|
||||
wave[w][green] = h2rgb(wave[w][hue])
|
||||
wave[w][blue] = h2rgb(wave[w][hue] + 30)
|
||||
for wave_index in range(n_waves):
|
||||
wave[wave_index][hue] = wave[wave_index][hue_target] = 90 + random.randint(0, 90)
|
||||
wave[wave_index][red] = h2rgb(wave[wave_index][hue] - 30)
|
||||
wave[wave_index][green] = h2rgb(wave[wave_index][hue])
|
||||
wave[wave_index][blue] = h2rgb(wave[wave_index][hue] + 30)
|
||||
|
||||
|
||||
def vibration_detector():
|
||||
|
|
@ -124,7 +121,7 @@ def vibration_detector():
|
|||
while True:
|
||||
|
||||
# wait for vibration sensor to trigger
|
||||
if ramping_up == False:
|
||||
if not ramping_up:
|
||||
ramping_up = vibration_detector()
|
||||
wave_setup()
|
||||
|
||||
|
|
@ -150,7 +147,7 @@ while True:
|
|||
if wave[w][hue] == wave[w][hue_target]:
|
||||
|
||||
# There's a tiny random chance of picking a new hue...
|
||||
if (not random.randint(frames_per_second * 4, 255)):
|
||||
if not random.randint(frames_per_second * 4, 255):
|
||||
# Within 1/3 color wheel
|
||||
wave[w][hue_target] = random.randint(
|
||||
wave[w][hue] - 30, wave[w][hue] + 30)
|
||||
|
|
|
|||
|
|
@ -21,9 +21,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]
|
||||
elif (pos < 85):
|
||||
elif 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:
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ def cycle_sequence(seq):
|
|||
|
||||
def rainbow_cycle(seq):
|
||||
"""Rainbow cycle generator"""
|
||||
rainbow = cycle_sequence(seq)
|
||||
rainbow_sequence = cycle_sequence(seq)
|
||||
while True:
|
||||
# pylint: disable=stop-iteration-return
|
||||
led[0] = (wheel(next(rainbow)))
|
||||
led[0] = (wheel(next(rainbow_sequence)))
|
||||
yield
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,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...
|
||||
|
|
|
|||
Loading…
Reference in a new issue