-
Notifications
You must be signed in to change notification settings - Fork 9
/
spells.py
62 lines (57 loc) · 2.04 KB
/
spells.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import os
from gpiozero import LED
import ble
import music
# You might be running on a device that doesn't have GPIOs
print("\n\n\nAttempting to use GPIOs - if you don't have any, ignore these exceptions.")
try:
digitalLogger = LED(17)
otherpin = LED(27)
except BaseException:
pass
bubblesSwitch = False
class Spells:
def __init__(self, args):
self.args = args
if args.use_ble:
ble.runScanAndSet(False)
def cast(self, spell):
global bubblesSwitch
# Invoke IoT (or any other) actions here
if (spell == "center"):
music.play_mp3(f'{self.args.home}/pi_to_potter/music/reys.mp3')
elif (spell == "circle"):
music.play_mp3(f'{self.args.home}/pi_to_potter/music/audio.mp3')
elif (spell == "eight"):
print("Togging digital logger.")
music.play_mp3(f'{self.args.home}/pi_to_potter/music/tinkle.mp3')
digitalLogger.toggle()
None
elif (spell == "left"):
print("Toggling magic crystal.")
if self.args.use_ble:
ble.toggleBLE()
elif (spell == "square"):
None
elif (spell == "swish"):
None
elif (spell == "tee"):
print("Togging bubbles.")
bubblesSwitch = not bubblesSwitch
music.play_mp3(
f'{self.args.home}/pi_to_potter/music/spellshot.mp3')
if (bubblesSwitch):
os.system(f'{self.args.home}/pi_to_potter/bubbleson.sh')
else:
os.system(f'{self.args.home}/pi_to_potter/bubblesoff.sh')
None
elif (spell == "triangle"):
print("Toggling outlet.")
print("Playing audio file...")
music.play_mp3(f'{self.args.home}/pi_to_potter/music/wonder.mp3')
elif (spell == "zee"):
print("Toggling 'other' pin.")
print("Playing audio file...")
music.play_mp3(f'{self.args.home}/pi_to_potter/music/zoo.mp3')
None
print("CAST: %s" % spell)