linting
This commit is contained in:
parent
4c43ce978e
commit
74d22d2d64
5 changed files with 43 additions and 44 deletions
|
|
@ -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.seesaw import Seesaw
|
||||||
from adafruit_seesaw.pwmout import PWMOut
|
from adafruit_seesaw.pwmout import PWMOut
|
||||||
from adafruit_motor import servo
|
from adafruit_motor import servo
|
||||||
from busio import I2C
|
from busio import I2C
|
||||||
import board
|
import board
|
||||||
import time
|
|
||||||
|
|
||||||
|
|
||||||
# Create seesaw object
|
# Create seesaw object
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
# CircuitPython 3.0 CRICKIT demo
|
# CircuitPython 3.0 CRICKIT demo
|
||||||
|
import time
|
||||||
from adafruit_seesaw.seesaw import Seesaw
|
from adafruit_seesaw.seesaw import Seesaw
|
||||||
from adafruit_seesaw.pwmout import PWMOut
|
from adafruit_seesaw.pwmout import PWMOut
|
||||||
from adafruit_motor import servo
|
from adafruit_motor import servo
|
||||||
|
|
@ -6,7 +7,6 @@ from busio import I2C
|
||||||
import audioio
|
import audioio
|
||||||
import microcontroller
|
import microcontroller
|
||||||
import board
|
import board
|
||||||
import time
|
|
||||||
|
|
||||||
i2c = I2C(board.SCL, board.SDA)
|
i2c = I2C(board.SCL, board.SDA)
|
||||||
ss = Seesaw(i2c)
|
ss = Seesaw(i2c)
|
||||||
|
|
@ -47,7 +47,7 @@ try:
|
||||||
except:
|
except:
|
||||||
print("File system not writable, halting")
|
print("File system not writable, halting")
|
||||||
while True:
|
while True:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#################### Audio files
|
#################### Audio files
|
||||||
wavfile = "yanny.wav"
|
wavfile = "yanny.wav"
|
||||||
|
|
@ -81,18 +81,18 @@ selection = None
|
||||||
# wait until
|
# wait until
|
||||||
while not selection:
|
while not selection:
|
||||||
if not ss.digital_read(BUTTON_1):
|
if not ss.digital_read(BUTTON_1):
|
||||||
selection = "Yanny"
|
selection = "Yanny"
|
||||||
ss.digital_write(LED_1, True)
|
ss.digital_write(LED_1, True)
|
||||||
myservo.angle = LOOKLEFT
|
myservo.angle = LOOKLEFT
|
||||||
break
|
break
|
||||||
if not ss.digital_read(BUTTON_2):
|
if not ss.digital_read(BUTTON_2):
|
||||||
selection = "Laurel"
|
selection = "Laurel"
|
||||||
ss.digital_write(LED_2, True)
|
ss.digital_write(LED_2, True)
|
||||||
myservo.angle = LOOKRIGHT
|
myservo.angle = LOOKRIGHT
|
||||||
break
|
break
|
||||||
# if we havent selected, wait until they do!
|
# if we havent selected, wait until they do!
|
||||||
if a.playing and time.monotonic() - t > 15.5:
|
if a.playing and time.monotonic() - t > 15.5:
|
||||||
a.pause()
|
a.pause()
|
||||||
|
|
||||||
# now we have a selection!
|
# now we have a selection!
|
||||||
with open(logfile, "a") as fp:
|
with open(logfile, "a") as fp:
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import time
|
||||||
import gc
|
import gc
|
||||||
import pulseio
|
import pulseio
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
@ -15,7 +16,6 @@ import audioio
|
||||||
gc.collect()
|
gc.collect()
|
||||||
from busio import I2C
|
from busio import I2C
|
||||||
import board
|
import board
|
||||||
import time
|
|
||||||
|
|
||||||
|
|
||||||
print("Blimp!")
|
print("Blimp!")
|
||||||
|
|
@ -44,7 +44,7 @@ def play_audio(wavfile):
|
||||||
wav = audioio.WaveFile(f)
|
wav = audioio.WaveFile(f)
|
||||||
a.play(wav)
|
a.play(wav)
|
||||||
while a.playing:
|
while a.playing:
|
||||||
pass
|
pass
|
||||||
f.close()
|
f.close()
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
|
|
@ -54,34 +54,34 @@ t = time.monotonic()
|
||||||
while True:
|
while True:
|
||||||
command = None # assume no remote commands came in
|
command = None # assume no remote commands came in
|
||||||
if len(pulsein) > 25: # check in any IR data came in
|
if len(pulsein) > 25: # check in any IR data came in
|
||||||
pulses = decoder.read_pulses(pulsein)
|
pulses = decoder.read_pulses(pulsein)
|
||||||
try:
|
try:
|
||||||
code = decoder.decode_bits(pulses, debug=False)
|
code = decoder.decode_bits(pulses, debug=False)
|
||||||
if code in (REMOTE_FORWARD, REMOTE_BACKWARD, REMOTE_PAUSE):
|
if code in (REMOTE_FORWARD, REMOTE_BACKWARD, REMOTE_PAUSE):
|
||||||
# we only listen to a few different codes
|
# we only listen to a few different codes
|
||||||
command = code
|
command = code
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
# on any failure, lets just restart
|
# on any failure, lets just restart
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if command:
|
if command:
|
||||||
if code == REMOTE_FORWARD:
|
if code == REMOTE_FORWARD:
|
||||||
play_audio("fan_forward.wav")
|
play_audio("fan_forward.wav")
|
||||||
motor_a.throttle = 1 # full speed forward
|
motor_a.throttle = 1 # full speed forward
|
||||||
pixels.fill((255,0,0))
|
pixels.fill((255,0,0))
|
||||||
elif code == REMOTE_BACKWARD:
|
elif code == REMOTE_BACKWARD:
|
||||||
play_audio("fan_backward.wav")
|
play_audio("fan_backward.wav")
|
||||||
motor_a.throttle = -1 # full speed backward
|
motor_a.throttle = -1 # full speed backward
|
||||||
pixels.fill((0,0,255))
|
pixels.fill((0,0,255))
|
||||||
elif code == REMOTE_PAUSE:
|
elif code == REMOTE_PAUSE:
|
||||||
motor_a.throttle = 0 # stop motor
|
motor_a.throttle = 0 # stop motor
|
||||||
play_audio("fan_stopped.wav")
|
play_audio("fan_stopped.wav")
|
||||||
pixels.fill((0,0,0))
|
pixels.fill((0,0,0))
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
# play yayayay every 3 seconds
|
# play yayayay every 3 seconds
|
||||||
if (time.monotonic() - t > 3) and motor_a.throttle != 0:
|
if (time.monotonic() - t > 3) and motor_a.throttle != 0:
|
||||||
t = time.monotonic()
|
t = time.monotonic()
|
||||||
play_audio("yayyayyay.wav")
|
play_audio("yayyayyay.wav")
|
||||||
|
|
|
||||||
|
|
@ -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
|
# transforming a value in one range to a value in another (like Arduino's map
|
||||||
# function).
|
# function).
|
||||||
|
|
||||||
|
# pylint: disable=redefined-outer-name
|
||||||
def lerp(x, x0, x1, y0, y1):
|
def lerp(x, x0, x1, y0, y1):
|
||||||
return y0 + (x - x0) * ((y1 - y0) / (x1 - x0))
|
return y0 + (x - x0) * ((y1 - y0) / (x1 - x0))
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=redefined-outer-name
|
|
||||||
# Main loop below will run forever:
|
# Main loop below will run forever:
|
||||||
while True:
|
while True:
|
||||||
# Get the current time at the start of the animation update.
|
# Get the current time at the start of the animation update.
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ def display_emulating_screen():
|
||||||
oled.show()
|
oled.show()
|
||||||
|
|
||||||
|
|
||||||
#pylint disable=global-statement
|
# pylint disable=global-statement
|
||||||
def emulate():
|
def emulate():
|
||||||
global current_mode
|
global current_mode
|
||||||
data = load_file(current_dir.selected_filepath)
|
data = load_file(current_dir.selected_filepath)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue