linted the CircuitPython new scripts, the old have some syntax that will fail during github check
This commit is contained in:
parent
9bcd6adb43
commit
78d0dace5e
3 changed files with 17 additions and 20 deletions
|
|
@ -1,11 +1,11 @@
|
|||
# This script requires a Raspberry Pi 2, 3 or Zero. Circuit Python must
|
||||
# be installed and it is strongly recommended that you use the latest
|
||||
# This script requires a Raspberry Pi 2, 3 or Zero. Circuit Python must
|
||||
# be installed and it is strongly recommended that you use the latest
|
||||
# release of Raspbian.
|
||||
|
||||
import time
|
||||
import os
|
||||
import board
|
||||
import digitalio
|
||||
import os
|
||||
|
||||
print("press a button!")
|
||||
|
||||
|
|
@ -23,23 +23,16 @@ button3.pull = digitalio.Pull.UP
|
|||
|
||||
while True:
|
||||
|
||||
# omxplayer is a media player install by default with a full Raspbian installation.
|
||||
# It uses the Pi's GPU for playback and accepts output flags to control where to
|
||||
# direct the audio. local is the headphone port, hdmi would be your monitor
|
||||
# or both. It defaults to whichever device is selected for audio
|
||||
# in raspi-config or you can override with the follow syntax.
|
||||
#
|
||||
# omxplayer -o local <file>
|
||||
# omxplayer -o local <file>
|
||||
# omxplayer -o hdmi <file>
|
||||
# omxplayer -o both <file>
|
||||
#
|
||||
if not button1.value:
|
||||
if not button1.value:
|
||||
os.system('omxplayer temple-bell.mp3 &')
|
||||
|
||||
if not button2.value:
|
||||
if not button2.value:
|
||||
os.system('omxplayer temple-bell-bigger.mp3 &')
|
||||
|
||||
if not button3.value:
|
||||
if not button3.value:
|
||||
os.system('omxplayer temple-bell-huge.mp3 &')
|
||||
|
||||
time.sleep(.25)
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
# release of Raspbian.
|
||||
|
||||
import time
|
||||
import board
|
||||
import digitalio
|
||||
from os import listdir
|
||||
import subprocess
|
||||
import board
|
||||
import digitalio
|
||||
|
||||
button1 = digitalio.DigitalInOut(board.D23)
|
||||
button1.direction = digitalio.Direction.INPUT
|
||||
|
|
@ -22,7 +22,7 @@ button3.pull = digitalio.Pull.UP
|
|||
|
||||
mp3_files = [ f for f in listdir('.') if f[-4:] == '.mp3' ]
|
||||
|
||||
if not (len(mp3_files) > 0):
|
||||
if not len(mp3_files) > 0:
|
||||
print("No mp3 files found!")
|
||||
|
||||
print('--- Available mp3 files ---')
|
||||
|
|
@ -31,19 +31,19 @@ print('--- Press button #1 to select mp3, button #2 to play current. ---')
|
|||
|
||||
index = 0
|
||||
while True:
|
||||
if (button1.value == False):
|
||||
if not button1.value:
|
||||
index += 1
|
||||
if index >= len(mp3_files):
|
||||
index = 0
|
||||
print("--- " + mp3_files[index] + " ---")
|
||||
|
||||
if (button2.value == False):
|
||||
if not button2.value:
|
||||
subprocess.Popen(['omxplayer', mp3_files[index]])
|
||||
print('--- Playing ' + mp3_files[index] + ' ---')
|
||||
print('--- Press button #3 to clear playing mp3s. ---')
|
||||
time.sleep(0.25)
|
||||
|
||||
if (button3.value == False):
|
||||
if not button3.value:
|
||||
subprocess.call(['killall', 'omxplayer'])
|
||||
print('--- Cleared all existing mp3s. ---')
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
# Playing_Sounds_and_Using_Buttons_with_Raspberry_Pi
|
||||
|
||||
Code to accompany this tutorial:
|
||||
https://learn.adafruit.com/playing-sounds-and-using-buttons-with-raspberry-pi
|
||||
Loading…
Reference in a new issue