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.pwmout import PWMOut
|
||||
from adafruit_motor import servo
|
||||
from busio import I2C
|
||||
import board
|
||||
import time
|
||||
|
||||
|
||||
# Create seesaw object
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue