Fix Flake8 issues

This commit is contained in:
Craig Richardson 2018-05-14 20:56:51 +01:00
parent 5a23e531c8
commit 852e9affb0
5 changed files with 20 additions and 23 deletions

View file

@ -31,11 +31,11 @@ def cog(pos):
if (pos < 8) or (pos > 250): if (pos < 8) or (pos > 250):
# return (120, 0, 0, 0) #first color, red: for RGBW NeoPixels # return (120, 0, 0, 0) #first color, red: for RGBW NeoPixels
return (120, 0, 0) # first color, red: for RGB 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 (int(pos * 3), int(255 - (pos * 3)), 0)
# return (125, 35, 0, 0) #second color, brass: for RGBW NeoPixels # return (125, 35, 0, 0) #second color, brass: for RGBW NeoPixels
return (125, 35, 0) # second color, brass: for RGB NeoPixels # return (125, 35, 0) # second color, brass: for RGB NeoPixels
elif (pos < 170): elif pos < 170:
pos -= 85 pos -= 85
# return (int(255 - pos*3), 0, int(pos*3), 0)#: for RGBW NeoPixels # 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 return (int(255 - pos * 3), 0, int(pos * 3)) # : for RGB NeoPixels

View file

@ -85,19 +85,16 @@ gammas = [
215, 218, 220, 223, 225, 228, 231, 233, 236, 239, 241, 244, 247, 249, 252, 255] 215, 218, 220, 223, 225, 228, 231, 233, 236, 239, 241, 244, 247, 249, 252, 255]
def h2rgb(hue): def h2rgb(colour_hue):
# return value colour_hue %= 90
ret = 0 h = hue_table[colour_hue >> 1]
hue %= 90 if colour_hue & 1:
h = hue_table[hue >> 1]
if hue & 1:
ret = h & 15 ret = h & 15
else: else:
ret = (h >> 4) ret = (h >> 4)
return (ret * 17) return ret * 17
def wave_setup(): def wave_setup():
@ -108,11 +105,11 @@ def wave_setup():
[0, 7, 30, 0, 0, 0, 0, 0]] [0, 7, 30, 0, 0, 0, 0, 0]]
# assign random starting colors to waves # assign random starting colors to waves
for w in range(n_waves): for wave_index in range(n_waves):
wave[w][hue] = wave[w][hue_target] = 90 + random.randint(0, 90) wave[wave_index][hue] = wave[wave_index][hue_target] = 90 + random.randint(0, 90)
wave[w][red] = h2rgb(wave[w][hue] - 30) wave[wave_index][red] = h2rgb(wave[wave_index][hue] - 30)
wave[w][green] = h2rgb(wave[w][hue]) wave[wave_index][green] = h2rgb(wave[wave_index][hue])
wave[w][blue] = h2rgb(wave[w][hue] + 30) wave[wave_index][blue] = h2rgb(wave[wave_index][hue] + 30)
def vibration_detector(): def vibration_detector():
@ -124,7 +121,7 @@ def vibration_detector():
while True: while True:
# wait for vibration sensor to trigger # wait for vibration sensor to trigger
if ramping_up == False: if not ramping_up:
ramping_up = vibration_detector() ramping_up = vibration_detector()
wave_setup() wave_setup()
@ -150,7 +147,7 @@ while True:
if wave[w][hue] == wave[w][hue_target]: if wave[w][hue] == wave[w][hue_target]:
# There's a tiny random chance of picking a new hue... # 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 # Within 1/3 color wheel
wave[w][hue_target] = random.randint( wave[w][hue_target] = random.randint(
wave[w][hue] - 30, wave[w][hue] + 30) wave[w][hue] - 30, wave[w][hue] + 30)

View file

@ -21,9 +21,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]
elif (pos < 85): elif 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:

View file

@ -34,10 +34,10 @@ def cycle_sequence(seq):
def rainbow_cycle(seq): def rainbow_cycle(seq):
"""Rainbow cycle generator""" """Rainbow cycle generator"""
rainbow = cycle_sequence(seq) rainbow_sequence = cycle_sequence(seq)
while True: while True:
# pylint: disable=stop-iteration-return # pylint: disable=stop-iteration-return
led[0] = (wheel(next(rainbow))) led[0] = (wheel(next(rainbow_sequence)))
yield yield

View file

@ -54,7 +54,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...