diff --git a/GemmaM0_Clockwork_Goggles/gemma_m0_clockwork_goggles.py b/GemmaM0_Clockwork_Goggles/gemma_m0_clockwork_goggles.py index 3e9357ea..c0a7c3b5 100644 --- a/GemmaM0_Clockwork_Goggles/gemma_m0_clockwork_goggles.py +++ b/GemmaM0_Clockwork_Goggles/gemma_m0_clockwork_goggles.py @@ -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 diff --git a/Gemma_Firewalker_Lite_Sneakers/Gemma_Firewalker_Lite_Sneakers.py b/Gemma_Firewalker_Lite_Sneakers/Gemma_Firewalker_Lite_Sneakers.py index 14fbe57c..0fa0c2b1 100644 --- a/Gemma_Firewalker_Lite_Sneakers/Gemma_Firewalker_Lite_Sneakers.py +++ b/Gemma_Firewalker_Lite_Sneakers/Gemma_Firewalker_Lite_Sneakers.py @@ -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) diff --git a/Gemma_Hoop_Earrings/Gemma_Hoop_Earrings.py b/Gemma_Hoop_Earrings/Gemma_Hoop_Earrings.py index b7c3d0f4..ef048b94 100644 --- a/Gemma_Hoop_Earrings/Gemma_Hoop_Earrings.py +++ b/Gemma_Hoop_Earrings/Gemma_Hoop_Earrings.py @@ -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: diff --git a/Gemma_LightTouch/gemma_lighttouch.py b/Gemma_LightTouch/gemma_lighttouch.py index d92d753b..edb899a7 100644 --- a/Gemma_LightTouch/gemma_lighttouch.py +++ b/Gemma_LightTouch/gemma_lighttouch.py @@ -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 diff --git a/Introducing_CircuitPlaygroundExpress/CircuitPlaygroundExpress_HIDKeyboard.py b/Introducing_CircuitPlaygroundExpress/CircuitPlaygroundExpress_HIDKeyboard.py index 1f8afd47..5d4273d8 100644 --- a/Introducing_CircuitPlaygroundExpress/CircuitPlaygroundExpress_HIDKeyboard.py +++ b/Introducing_CircuitPlaygroundExpress/CircuitPlaygroundExpress_HIDKeyboard.py @@ -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...