From 74d22d2d64e4153917a0f4ebda66af96a61e6848 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Tue, 29 May 2018 15:26:32 -0400 Subject: [PATCH] linting --- Crickits/trash_panda/code.py | 6 ++-- Crickits/yanny_or_laurel/code.py | 22 ++++++------- Crickits/yayayay_flier/code.py | 54 ++++++++++++++++---------------- Cyber_Flower/main.py | 3 +- EPROM_Emulator/main.py | 2 +- 5 files changed, 43 insertions(+), 44 deletions(-) diff --git a/Crickits/trash_panda/code.py b/Crickits/trash_panda/code.py index f28dc84f..91168420 100644 --- a/Crickits/trash_panda/code.py +++ b/Crickits/trash_panda/code.py @@ -1,10 +1,10 @@ -from digitalio import DigitalInOut, Direction, Pull +import time +from digitalio import DigitalInOut, Direction from adafruit_seesaw.seesaw import Seesaw from adafruit_seesaw.pwmout import PWMOut from adafruit_motor import servo from busio import I2C import board -import time # Create seesaw object @@ -22,7 +22,7 @@ for ss_pin in (17, 16, 15, 14): _servo = servo.Servo(pwm, min_pulse=600, max_pulse=2500) _servo.angle = 90 # starting angle, middle servos.append(_servo) - + print("Its TRASH PANDA TIME!") while True: diff --git a/Crickits/yanny_or_laurel/code.py b/Crickits/yanny_or_laurel/code.py index bfdcd141..7110df58 100644 --- a/Crickits/yanny_or_laurel/code.py +++ b/Crickits/yanny_or_laurel/code.py @@ -1,4 +1,5 @@ # CircuitPython 3.0 CRICKIT demo +import time from adafruit_seesaw.seesaw import Seesaw from adafruit_seesaw.pwmout import PWMOut from adafruit_motor import servo @@ -6,7 +7,6 @@ from busio import I2C import audioio import microcontroller import board -import time i2c = I2C(board.SCL, board.SDA) ss = Seesaw(i2c) @@ -47,7 +47,7 @@ try: except: print("File system not writable, halting") while True: - pass + pass #################### Audio files wavfile = "yanny.wav" @@ -81,18 +81,18 @@ selection = None # wait until while not selection: if not ss.digital_read(BUTTON_1): - selection = "Yanny" - ss.digital_write(LED_1, True) - myservo.angle = LOOKLEFT - break + selection = "Yanny" + ss.digital_write(LED_1, True) + myservo.angle = LOOKLEFT + break if not ss.digital_read(BUTTON_2): - selection = "Laurel" - ss.digital_write(LED_2, True) - myservo.angle = LOOKRIGHT - break + selection = "Laurel" + ss.digital_write(LED_2, True) + myservo.angle = LOOKRIGHT + break # if we havent selected, wait until they do! if a.playing and time.monotonic() - t > 15.5: - a.pause() + a.pause() # now we have a selection! with open(logfile, "a") as fp: diff --git a/Crickits/yayayay_flier/code.py b/Crickits/yayayay_flier/code.py index 66946db1..0ff7f726 100644 --- a/Crickits/yayayay_flier/code.py +++ b/Crickits/yayayay_flier/code.py @@ -1,3 +1,4 @@ +import time import gc import pulseio gc.collect() @@ -15,7 +16,6 @@ import audioio gc.collect() from busio import I2C import board -import time print("Blimp!") @@ -44,7 +44,7 @@ def play_audio(wavfile): wav = audioio.WaveFile(f) a.play(wav) while a.playing: - pass + pass f.close() gc.collect() @@ -54,34 +54,34 @@ t = time.monotonic() while True: command = None # assume no remote commands came in if len(pulsein) > 25: # check in any IR data came in - pulses = decoder.read_pulses(pulsein) - try: - code = decoder.decode_bits(pulses, debug=False) - if code in (REMOTE_FORWARD, REMOTE_BACKWARD, REMOTE_PAUSE): - # we only listen to a few different codes + pulses = decoder.read_pulses(pulsein) + try: + code = decoder.decode_bits(pulses, debug=False) + if code in (REMOTE_FORWARD, REMOTE_BACKWARD, REMOTE_PAUSE): + # we only listen to a few different codes command = code - else: - continue - # on any failure, lets just restart - except: - continue + else: + continue + # on any failure, lets just restart + except: + continue if command: - if code == REMOTE_FORWARD: - play_audio("fan_forward.wav") - motor_a.throttle = 1 # full speed forward - pixels.fill((255,0,0)) - elif code == REMOTE_BACKWARD: - play_audio("fan_backward.wav") - motor_a.throttle = -1 # full speed backward - pixels.fill((0,0,255)) - elif code == REMOTE_PAUSE: - motor_a.throttle = 0 # stop motor - play_audio("fan_stopped.wav") - pixels.fill((0,0,0)) - time.sleep(0.5) + if code == REMOTE_FORWARD: + play_audio("fan_forward.wav") + motor_a.throttle = 1 # full speed forward + pixels.fill((255,0,0)) + elif code == REMOTE_BACKWARD: + play_audio("fan_backward.wav") + motor_a.throttle = -1 # full speed backward + pixels.fill((0,0,255)) + elif code == REMOTE_PAUSE: + motor_a.throttle = 0 # stop motor + play_audio("fan_stopped.wav") + pixels.fill((0,0,0)) + time.sleep(0.5) # play yayayay every 3 seconds if (time.monotonic() - t > 3) and motor_a.throttle != 0: - t = time.monotonic() - play_audio("yayyayyay.wav") + t = time.monotonic() + play_audio("yayyayyay.wav") diff --git a/Cyber_Flower/main.py b/Cyber_Flower/main.py index a0d3da9d..cebe0a41 100644 --- a/Cyber_Flower/main.py +++ b/Cyber_Flower/main.py @@ -122,12 +122,11 @@ beat_phase = beat_period / 5.0 # Phase controls how long in-between # transforming a value in one range to a value in another (like Arduino's map # function). - +# pylint: disable=redefined-outer-name def lerp(x, x0, x1, y0, y1): return y0 + (x - x0) * ((y1 - y0) / (x1 - x0)) -# pylint: disable=redefined-outer-name # Main loop below will run forever: while True: # Get the current time at the start of the animation update. diff --git a/EPROM_Emulator/main.py b/EPROM_Emulator/main.py index 03aba4a0..ec19f4e5 100644 --- a/EPROM_Emulator/main.py +++ b/EPROM_Emulator/main.py @@ -120,7 +120,7 @@ def display_emulating_screen(): oled.show() -#pylint disable=global-statement +# pylint disable=global-statement def emulate(): global current_mode data = load_file(current_dir.selected_filepath)