From aecc9347c969494fed4719219bf9a832509b19e7 Mon Sep 17 00:00:00 2001 From: Craig Richardson Date: Mon, 14 May 2018 19:11:51 +0100 Subject: [PATCH] Autformat the rest --- Morse_Code_Flasher/main.py | 55 ++++++++++++++++--- Motorized_Turntable/turntable.py | 9 +-- .../Mystical_LED_Halloween_Hood.py | 36 ++++++------ NeoPixel_Blinkendisc/NeoPixel_Blinkendisc.py | 36 ++++++------ .../HSV_FancyLED_NeoPixel_Dailer.py | 5 +- NeoPixel_Dialer/RGB_NeoPixel_Dialer.py | 7 ++- .../NeoPixel_GoPro_Lens_Light.py | 11 ++-- .../NeoPixel_Jewel_10_Minute_Necklace.py | 39 ++++++------- NeoPixel_Punk_Collar/NeoPixel_Punk_Collar.py | 14 ++--- NeoPixel_Ring_Bangle_Bracelet/Figure_Eight.py | 12 ++-- NeoPixel_Ring_Bangle_Bracelet/Random_Flash.py | 16 +++--- NeoPixel_Ring_Bangle_Bracelet/Sine_Wave.py | 10 ++-- NeoPixel_Tiara/NeoPixel_Tiara.py | 19 ++++--- .../PMS5003_CircuitPython/main.py | 8 +-- Remote_Tree_Ornament/main.py | 2 +- 15 files changed, 164 insertions(+), 115 deletions(-) diff --git a/Morse_Code_Flasher/main.py b/Morse_Code_Flasher/main.py index 9911569c..89684ba2 100644 --- a/Morse_Code_Flasher/main.py +++ b/Morse_Code_Flasher/main.py @@ -7,30 +7,67 @@ # License: MIT License (https://opensource.org/licenses/MIT) import time + import board import neopixel # Configuration: # Message to display (capital letters and numbers only) message = 'SOS' -dot_length = 0.15 # Duration of one Morse dot -dash_length = (dot_length * 3.0) # Duration of one Morse dash -symbol_gap = dot_length # Duration of gap between dot or dash +dot_length = 0.15 # Duration of one Morse dot +dash_length = (dot_length * 3.0) # Duration of one Morse dash +symbol_gap = dot_length # Duration of gap between dot or dash character_gap = (dot_length * 3.0) # Duration of gap between characters -flash_color = (255, 0, 0) # Color of the morse display. -brightness = 0.5 # Display brightness (0.0 - 1.0) -morse = [('A', '.-'), ('B', '-...'), ('C', '-.-.'), ('D', '-..'), ('E', '.'), ('F', '..-.'), ('G', '--.'), ('H', '....'), ('I', '..'), ('J', '.---'), ('K', '-.-'), ('L', '.-..'), ('M', '--'), ('N', '-.'), ('O', '---'), ('P', '.--.'), ('Q', '--.-'), ('R', '.-.'), ('S', - '...'), ('T', '-'), ('U', '..-'), ('V', '...-'), ('W', '.--'), ('X', '-..-'), ('Y', '-.--'), ('Z', '--..'), ('0', '-----'), ('1', '.----'), ('2', '..---'), ('3', '...--'), ('4', '....-'), ('5', '.....'), ('6', '-....'), ('7', '--...'), ('8', '---..'), ('9', '----.')] +flash_color = (255, 0, 0) # Color of the morse display. +brightness = 0.5 # Display brightness (0.0 - 1.0) +morse = [ + ('A', '.-'), + ('B', '-...'), + ('C', '-.-.'), + ('D', '-..'), + ('E', '.'), + ('F', '..-.'), + ('G', '--.'), + ('H', '....'), + ('I', '..'), + ('J', '.---'), + ('K', '-.-'), + ('L', '.-..'), + ('M', '--'), + ('N', '-.'), + ('O', '---'), + ('P', '.--.'), + ('Q', '--.-'), + ('R', '.-.'), + ('S', '...'), + ('T', '-'), + ('U', '..-'), + ('V', '...-'), + ('W', '.--'), + ('X', '-..-'), + ('Y', '-.--'), + ('Z', '--..'), + ('0', '-----'), + ('1', '.----'), + ('2', '..---'), + ('3', '...--'), + ('4', '....-'), + ('5', '.....'), + ('6', '-....'), + ('7', '--...'), + ('8', '---..'), + ('9', '----.'), +] + # Define a class that represents the morse flasher. class MorseFlasher: - def __init__(self, color=(255, 255, 255)): # set the color adjusted for brightness self._color = ( - int(color[0]*brightness), int(color[1]*brightness), int(color[2]*brightness)) + int(color[0] * brightness), int(color[1] * brightness), int(color[2] * brightness)) def light(self, on=True): if on: diff --git a/Motorized_Turntable/turntable.py b/Motorized_Turntable/turntable.py index 68a66023..0026ba53 100644 --- a/Motorized_Turntable/turntable.py +++ b/Motorized_Turntable/turntable.py @@ -1,9 +1,10 @@ -import board import time -import pulseio -from digitalio import DigitalInOut, Direction, Pull -from analogio import AnalogIn + import adafruit_motor.servo +import board +import pulseio +from analogio import AnalogIn +from digitalio import DigitalInOut, Direction, Pull pwm = pulseio.PWMOut(board.D5, frequency=50) servo = adafruit_motor.servo.Servo(pwm) diff --git a/Mystical_LED_Halloween_Hood/Mystical_LED_Halloween_Hood.py b/Mystical_LED_Halloween_Hood/Mystical_LED_Halloween_Hood.py index 42fc5a07..d5575390 100644 --- a/Mystical_LED_Halloween_Hood/Mystical_LED_Halloween_Hood.py +++ b/Mystical_LED_Halloween_Hood/Mystical_LED_Halloween_Hood.py @@ -1,36 +1,36 @@ import board import neopixel -import time + try: import urandom as random # for v1.0 API support except ImportError: import random -numpix = 17 # Number of NeoPixels -pixpin = board.D1 # Pin where NeoPixels are connected +numpix = 17 # Number of NeoPixels +pixpin = board.D1 # Pin where NeoPixels are connected strip = neopixel.NeoPixel(pixpin, numpix) -minAlpha = 0.1 # Minimum brightness -maxAlpha = 0.4 # Maximum brightness +minAlpha = 0.1 # Minimum brightness +maxAlpha = 0.4 # Maximum brightness alpha = (minAlpha + maxAlpha) / 2 # Start in middle alphaDelta = 0.008 # Amount to change brightness each time through loop -alphaUp = True # If True, brightness increasing, else decreasing +alphaUp = True # If True, brightness increasing, else decreasing strip.fill([255, 0, 0]) # Fill red, or change to R,G,B of your liking while True: # Loop forever... - if random.randint(1, 5) == 5: # 1-in-5 random chance - alphaUp = not alphaUp # of reversing direction - if alphaUp: # Increasing brightness? - alpha += alphaDelta # Add some amount - if alpha >= maxAlpha: # At or above max? + if random.randint(1, 5) == 5: # 1-in-5 random chance + alphaUp = not alphaUp # of reversing direction + if alphaUp: # Increasing brightness? + alpha += alphaDelta # Add some amount + if alpha >= maxAlpha: # At or above max? alpha = maxAlpha # Limit to max - alphaUp = False # and switch direction - else: # Else decreasing brightness - alpha -= alphaDelta # Subtract some amount - if alpha <= minAlpha: # At or below min? + alphaUp = False # and switch direction + else: # Else decreasing brightness + alpha -= alphaDelta # Subtract some amount + if alpha <= minAlpha: # At or below min? alpha = minAlpha # Limit to min - alphaUp = True # and switch direction + alphaUp = True # and switch direction - strip.brightness = alpha # Set brightness to 0.0 to 1.0 - strip.write() # and issue data to LED strip + strip.brightness = alpha # Set brightness to 0.0 to 1.0 + strip.write() # and issue data to LED strip diff --git a/NeoPixel_Blinkendisc/NeoPixel_Blinkendisc.py b/NeoPixel_Blinkendisc/NeoPixel_Blinkendisc.py index 67e1f282..d4b6dadc 100644 --- a/NeoPixel_Blinkendisc/NeoPixel_Blinkendisc.py +++ b/NeoPixel_Blinkendisc/NeoPixel_Blinkendisc.py @@ -1,32 +1,34 @@ +import time + +import analogio import board import digitalio -import analogio import neopixel -import time + try: import urandom as random # for v1.0 API support except: import random -num_leds = 24 # 24 LED NeoPixel ring -neopixel_pin = board.D0 # Pin where NeoPixels are connected -vibration_pin = board.D1 # Pin where vibration switch is connected -analog_pin = board.A0 # Not connected to anything +num_leds = 24 # 24 LED NeoPixel ring +neopixel_pin = board.D0 # Pin where NeoPixels are connected +vibration_pin = board.D1 # Pin where vibration switch is connected +analog_pin = board.A0 # Not connected to anything strip = neopixel.NeoPixel(neopixel_pin, num_leds) -default_frame_len = 0.06 # Time (in seconds) of typical animation frame -max_frame_len = 0.25 # Gradually slows toward this +default_frame_len = 0.06 # Time (in seconds) of typical animation frame +max_frame_len = 0.25 # Gradually slows toward this min_frame_len = 0.005 # But sometimes as little as this -cooldown_at = 2.0 # After this many seconds, start slowing down -dim_at = 2.5 # After this many seconds, dim LEDs -brightness_high = 0.5 # Active brightness +cooldown_at = 2.0 # After this many seconds, start slowing down +dim_at = 2.5 # After this many seconds, dim LEDs +brightness_high = 0.5 # Active brightness brightness_low = 0.125 # Idle brightness -color = [0, 120, 30] # Initial LED color -offset = 0 # Animation position +color = [0, 120, 30] # Initial LED color +offset = 0 # Animation position frame_len = default_frame_len # Frame-to-frame time, seconds -last_vibration = 0.0 # Time of last vibration -last_frame = 0.0 # Time of last animation frame +last_vibration = 0.0 # Time of last vibration +last_frame = 0.0 # Time of last animation frame # Random number generator is seeded from an unused 'floating' # analog input - this helps ensure the random color choices @@ -55,10 +57,10 @@ while True: # Loop forever... random.randint(32, 255), random.randint(32, 255)] frame_len = default_frame_len # Reset frame timing - last_vibration = t # Save last trigger time + last_vibration = t # Save last trigger time # Stretch out frames if nothing has happened in a couple of seconds: - if((t - last_vibration) > cooldown_at): + if ((t - last_vibration) > cooldown_at): frame_len += 0.001 # Add 1 ms if frame_len > max_frame_len: frame_len = min_frame_len diff --git a/NeoPixel_Dialer/HSV_FancyLED_NeoPixel_Dailer.py b/NeoPixel_Dialer/HSV_FancyLED_NeoPixel_Dailer.py index eb76a696..5578c2e5 100644 --- a/NeoPixel_Dialer/HSV_FancyLED_NeoPixel_Dailer.py +++ b/NeoPixel_Dialer/HSV_FancyLED_NeoPixel_Dailer.py @@ -1,10 +1,11 @@ import time -from analogio import AnalogIn + +import adafruit_character_lcd import adafruit_fancyled.adafruit_fancyled as fancy import board import digitalio -import adafruit_character_lcd import neopixel +from analogio import AnalogIn lcd_rs = digitalio.DigitalInOut(board.D5) lcd_en = digitalio.DigitalInOut(board.D6) diff --git a/NeoPixel_Dialer/RGB_NeoPixel_Dialer.py b/NeoPixel_Dialer/RGB_NeoPixel_Dialer.py index 0c9229c0..99b85f86 100644 --- a/NeoPixel_Dialer/RGB_NeoPixel_Dialer.py +++ b/NeoPixel_Dialer/RGB_NeoPixel_Dialer.py @@ -1,10 +1,11 @@ -import time import math -from analogio import AnalogIn +import time + +import adafruit_character_lcd import board import digitalio -import adafruit_character_lcd import neopixel +from analogio import AnalogIn lcd_rs = digitalio.DigitalInOut(board.D5) lcd_en = digitalio.DigitalInOut(board.D6) diff --git a/NeoPixel_GoPro_Lens_Light/NeoPixel_GoPro_Lens_Light.py b/NeoPixel_GoPro_Lens_Light/NeoPixel_GoPro_Lens_Light.py index 8d9f0603..538a0f63 100644 --- a/NeoPixel_GoPro_Lens_Light/NeoPixel_GoPro_Lens_Light.py +++ b/NeoPixel_GoPro_Lens_Light/NeoPixel_GoPro_Lens_Light.py @@ -1,12 +1,13 @@ -from analogio import AnalogIn -import board import time + +import board import neopixel +from analogio import AnalogIn pot = AnalogIn(board.A1) # what pin the pot is on -pixpin = board.D0 # what pin the LEDs are on -numpix = 16 # number of LEDs in ring! -BPP = 4 # required for RGBW ring +pixpin = board.D0 # what pin the LEDs are on +numpix = 16 # number of LEDs in ring! +BPP = 4 # required for RGBW ring ring = neopixel.NeoPixel(pixpin, numpix, bpp=BPP, brightness=0.9) diff --git a/NeoPixel_Jewel_10_Minute_Necklace/NeoPixel_Jewel_10_Minute_Necklace.py b/NeoPixel_Jewel_10_Minute_Necklace/NeoPixel_Jewel_10_Minute_Necklace.py index 5fc67503..8fab2753 100644 --- a/NeoPixel_Jewel_10_Minute_Necklace/NeoPixel_Jewel_10_Minute_Necklace.py +++ b/NeoPixel_Jewel_10_Minute_Necklace/NeoPixel_Jewel_10_Minute_Necklace.py @@ -1,6 +1,7 @@ +import time + import board import neopixel -import time pixpin = board.D1 numpix = 7 @@ -11,9 +12,9 @@ rgb_colors = ([179, 0, 0], [0, 179, 0], [0, 0, 0]) -rgb_idx = 0 # index counter - primary color we are on -color = (0, 164, 179) # Starting color -mode = 0 # Current animation effect +rgb_idx = 0 # index counter - primary color we are on +color = (0, 164, 179) # Starting color +mode = 0 # Current animation effect offset = 0 prevtime = 0 @@ -24,17 +25,17 @@ def wheel(pos): if (pos < 0) or (pos > 255): return (0, 0, 0) if (pos < 85): - return (int(pos * 3), int(255 - (pos*3)), 0) + return (int(pos * 3), int(255 - (pos * 3)), 0) elif (pos < 170): pos -= 85 - return (int(255 - pos*3), 0, int(pos*3)) + return (int(255 - pos * 3), 0, int(pos * 3)) else: pos -= 170 - return (0, int(pos*3), int(255 - pos*3)) + return (0, int(pos * 3), int(255 - pos * 3)) def rainbow_cycle(wait): - for j in range(255*6): # 6 cycles of all colors on wheel + for j in range(255 * 6): # 6 cycles of all colors on wheel for r in range(len(pixels)): idx = int((r * 255 / len(pixels)) + j) pixels[r] = wheel(idx & 255) @@ -45,14 +46,14 @@ def rainbow_cycle(wait): def rainbow(wait): for j in range(255): for i in range(len(pixels)): - idx = int(i+j) + idx = int(i + j) pixels[i] = wheel(idx & 255) pixels.write() time.sleep(wait) def rainbow_cycle_slow(wait): - for j in range(255*3): # 3 cycles of all colors on wheel + for j in range(255 * 3): # 3 cycles of all colors on wheel for r in range(len(pixels)): idx = int((r * 255 / len(pixels)) + j) pixels[r] = wheel(idx & 255) @@ -61,7 +62,7 @@ def rainbow_cycle_slow(wait): def rainbow_hold(wait): - for j in range(255*1): # 3 cycles of all colors on wheel + for j in range(255 * 1): # 3 cycles of all colors on wheel for r in range(len(pixels)): idx = int((r * 255 / len(pixels)) + j) pixels[r] = wheel(idx & 255) @@ -71,26 +72,26 @@ def rainbow_hold(wait): while True: - if (mode == 0): # rainbow hold + if (mode == 0): # rainbow hold rainbow_hold(0.02) time.sleep(.5) - elif (mode == 1): # rainbow cycle slow + elif (mode == 1): # rainbow cycle slow rainbow_cycle_slow(0.02) time.sleep(0.05) - elif (mode == 2): # rainbow cycle fast + elif (mode == 2): # rainbow cycle fast rainbow_cycle(0.005) time.sleep(0.050) t = time.monotonic() - if ((t - prevtime) > 8): # Every 8 seconds... - mode += 1 # Next mode - if(mode > 2): # End of modes? - mode = 0 # Start modes over + if ((t - prevtime) > 8): # Every 8 seconds... + mode += 1 # Next mode + if (mode > 2): # 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 diff --git a/NeoPixel_Punk_Collar/NeoPixel_Punk_Collar.py b/NeoPixel_Punk_Collar/NeoPixel_Punk_Collar.py index bb0f6ba4..937b0b40 100644 --- a/NeoPixel_Punk_Collar/NeoPixel_Punk_Collar.py +++ b/NeoPixel_Punk_Collar/NeoPixel_Punk_Collar.py @@ -1,7 +1,8 @@ -from digitalio import DigitalInOut, Direction +import time + import board import neopixel -import time +from digitalio import DigitalInOut, Direction pixpin = board.D1 numpix = 5 @@ -24,13 +25,13 @@ def wheel(pos): if (pos < 0) or (pos > 255): return (0, 0, 0) if (pos < 85): - return (int(pos * 3), int(255 - (pos*3)), 0) + return (int(pos * 3), int(255 - (pos * 3)), 0) elif (pos < 170): pos -= 85 - return (int(255 - pos*3), 0, int(pos*3)) + return (int(255 - pos * 3), 0, int(pos * 3)) else: pos -= 170 - return (0, int(pos*3), int(255 - pos*3)) + return (0, int(pos * 3), int(255 - pos * 3)) def rainbow_cycle(wait): @@ -44,12 +45,11 @@ def rainbow_cycle(wait): def rainbow(wait): for j in range(255): for i in range(len(strip)): - idx = int(i+j) + idx = int(i + j) strip[i] = wheel(idx & 255) while True: - colorWipe((255, 0, 0), .1) # red and delay colorWipe((0, 255, 0), .1) # green and delay colorWipe((0, 0, 255), .1) # blue and delay diff --git a/NeoPixel_Ring_Bangle_Bracelet/Figure_Eight.py b/NeoPixel_Ring_Bangle_Bracelet/Figure_Eight.py index 270c0bb9..556a22a4 100644 --- a/NeoPixel_Ring_Bangle_Bracelet/Figure_Eight.py +++ b/NeoPixel_Ring_Bangle_Bracelet/Figure_Eight.py @@ -1,21 +1,23 @@ +import time + import board import neopixel -import time + try: import urandom as random except ImportError: import random -numpix = 64 # Number of NeoPixels +numpix = 64 # Number of NeoPixels pixpin = board.D1 # Pin where NeoPixels are connected strip = neopixel.NeoPixel(pixpin, numpix, brightness=0.15) color = [5, 250, 200] # RGB color - cyan sine = [ # These are the pixels in order of animation - 70 pixels in total: - 4, 3, 2, 1, 0, 15, 14, 13, 12, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 4, 3, 2, 1, 0, 15, 14, 13, 12, 20, 21, 22, 23, 24, 25, 26, 27, 28, 36, 35, 34, 33, 32, 47, 46, 45, 44, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 48, 49, 50, 51, 52, 44, 43, 42, 41, 40, 39, 38, 37, 36, 28, - 29, 30, 31, 16, 17, 18, 19, 20, 12, 11, 10, 9, 8, 7, 6, 5] + 29, 30, 31, 16, 17, 18, 19, 20, 12, 11, 10, 9, 8, 7, 6, 5] while True: # Loop forever... for i in range(len(sine)): @@ -23,5 +25,5 @@ while True: # Loop forever... strip[sine[i]] = [0, 0, 0] # Draw 'head,' 10 pixels ahead: strip[sine[(i + 10) % len(sine)]] = color - strip.write() # Refresh LED states + strip.write() # Refresh LED states time.sleep(0.04) # 40 millisecond delay diff --git a/NeoPixel_Ring_Bangle_Bracelet/Random_Flash.py b/NeoPixel_Ring_Bangle_Bracelet/Random_Flash.py index f8a97119..ef1d7cc6 100644 --- a/NeoPixel_Ring_Bangle_Bracelet/Random_Flash.py +++ b/NeoPixel_Ring_Bangle_Bracelet/Random_Flash.py @@ -1,28 +1,28 @@ import board import neopixel -import time + try: import urandom as random except ImportError: import random -numpix = 64 # Number of NeoPixels +numpix = 64 # Number of NeoPixels pixpin = board.D1 # Pin where NeoPixels are connected strip = neopixel.NeoPixel(pixpin, numpix, brightness=0.0) colors = [ [232, 100, 255], # Purple - [200, 200, 20], # Yellow + [200, 200, 20], # Yellow [30, 200, 200], # Blue ] while True: # Loop forever... c = random.randint(0, len(colors) - 1) # Choose random color index - j = random.randint(0, numpix - 1) # Choose random pixel - strip[j] = colors[c] # Set pixel to color + j = random.randint(0, numpix - 1) # Choose random pixel + strip[j] = colors[c] # Set pixel to color for i in range(1, 5): - strip.brightness = i / 5.0 # Ramp up brightness + strip.brightness = i / 5.0 # Ramp up brightness strip.write() for i in range(5, 0, -1): - strip.brightness = i / 5.0 # Ramp down brightness + strip.brightness = i / 5.0 # Ramp down brightness strip.write() - strip[j] = [0, 0, 0] # Set pixel to 'off' + strip[j] = [0, 0, 0] # Set pixel to 'off' diff --git a/NeoPixel_Ring_Bangle_Bracelet/Sine_Wave.py b/NeoPixel_Ring_Bangle_Bracelet/Sine_Wave.py index 43c536c6..fdc293d5 100644 --- a/NeoPixel_Ring_Bangle_Bracelet/Sine_Wave.py +++ b/NeoPixel_Ring_Bangle_Bracelet/Sine_Wave.py @@ -1,18 +1,20 @@ +import time + import board import neopixel -import time + try: import urandom as random # for v1.0 API support except ImportError: import random -numpix = 64 # Number of NeoPixels +numpix = 64 # Number of NeoPixels pixpin = board.D1 # Pin where NeoPixels are connected strip = neopixel.NeoPixel(pixpin, numpix, brightness=0.15) color = [75, 250, 100] # RGB color - teal sine = [ # These are the pixels in order of animation - 36 pixels in total: - 4, 3, 2, 1, 0, 15, 14, 13, 12, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 4, 3, 2, 1, 0, 15, 14, 13, 12, 20, 21, 22, 23, 24, 25, 26, 27, 28, 36, 35, 34, 33, 32, 47, 46, 45, 44, 52, 53, 54, 55, 56, 57, 58, 59, 60] while True: # Loop forever... @@ -21,5 +23,5 @@ while True: # Loop forever... strip[sine[i]] = color # Erase 'tail,' 8 pixels back: strip[sine[(i + len(sine) - 8) % len(sine)]] = [0, 0, 0] - strip.write() # Refresh LED states + strip.write() # Refresh LED states time.sleep(0.016) # 16 millisecond delay diff --git a/NeoPixel_Tiara/NeoPixel_Tiara.py b/NeoPixel_Tiara/NeoPixel_Tiara.py index af64a5f4..93108c9a 100644 --- a/NeoPixel_Tiara/NeoPixel_Tiara.py +++ b/NeoPixel_Tiara/NeoPixel_Tiara.py @@ -1,36 +1,37 @@ +import time + import board import neopixel -import time + try: import urandom as random except ImportError: import random -numpix = 7 # Number of NeoPixels +numpix = 7 # Number of NeoPixels pixpin = board.D1 # Pin where NeoPixels are connected strip = neopixel.NeoPixel(pixpin, numpix, brightness=1, auto_write=True) colors = [ [232, 100, 255], # Purple - [200, 200, 20], # Yellow + [200, 200, 20], # Yellow [30, 200, 200], # Blue ] def flash_random(wait, howmany): - for k in range(howmany): c = random.randint(0, len(colors) - 1) # Choose random color index - j = random.randint(0, numpix - 1) # Choose random pixel - strip[j] = colors[c] # Set pixel to color + j = random.randint(0, numpix - 1) # Choose random pixel + strip[j] = colors[c] # Set pixel to color for i in range(1, 5): - strip.brightness = i / 5.0 # Ramp up brightness + strip.brightness = i / 5.0 # Ramp up brightness time.sleep(wait) for i in range(5, 0, -1): - strip.brightness = i / 5.0 # Ramp down brightness - strip[j] = [0, 0, 0] # Set pixel to 'off' + strip.brightness = i / 5.0 # Ramp down brightness + strip[j] = [0, 0, 0] # Set pixel to 'off' time.sleep(wait) diff --git a/PMS5003_Air_Quality_Sensor/PMS5003_CircuitPython/main.py b/PMS5003_Air_Quality_Sensor/PMS5003_CircuitPython/main.py index dfcf87eb..2eac70bc 100644 --- a/PMS5003_Air_Quality_Sensor/PMS5003_CircuitPython/main.py +++ b/PMS5003_Air_Quality_Sensor/PMS5003_CircuitPython/main.py @@ -1,7 +1,7 @@ -from digitalio import DigitalInOut, Direction import board import busio -import time +from digitalio import DigitalInOut, Direction + try: import struct except ImportError: @@ -26,7 +26,7 @@ while True: buffer.pop(0) if len(buffer) > 200: - buffer = [] # avoid an overrun if all bad data + buffer = [] # avoid an overrun if all bad data if len(buffer) < 32: continue @@ -66,4 +66,4 @@ while True: print("---------------------------------------") buffer = buffer[32:] - #print("Buffer ", buffer) + # print("Buffer ", buffer) diff --git a/Remote_Tree_Ornament/main.py b/Remote_Tree_Ornament/main.py index d1f37138..54afbada 100644 --- a/Remote_Tree_Ornament/main.py +++ b/Remote_Tree_Ornament/main.py @@ -77,7 +77,7 @@ while True: except adafruit_irremote.IRNECRepeatException: # unusual short code! print("NEC repeat!") command = last_command - except adafruit_irremote.IRDecodeException as e: # failed to decode + except adafruit_irremote.IRDecodeException as e: # failed to decode print("Failed to decode:", e) except MemoryError as e: print("Memory error: ", e)