forked from danclarke/WorkingStargateMk2Raspi
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDialProgram.py
More file actions
executable file
·82 lines (69 loc) · 2.73 KB
/
Copy pathDialProgram.py
File metadata and controls
executable file
·82 lines (69 loc) · 2.73 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from StargateControl import StargateControl
from time import sleep
import config
class DialProgram:
is_dialing = False
def __init__(self, gateControl, lightControl, audio):
self.gateControl = gateControl
self.lightControl = lightControl
self.audio = audio
def dial(self, address):
length = len(address);
if (length < 7) or (length > 9):
raise ValueError('Address length must be 7, 8, or 9')
DialProgram.is_dialing = True
self.lightControl.all_off()
self.gateControl.move_home()
self.lightControl.all_off()
direction = StargateControl.FORWARD
for i, symbol in enumerate(address):
self.audio.play_roll()
sleep(config.audio_delay_time)
self.gateControl.move_to_symbol(symbol, direction)
self.audio.stop_roll()
self.audio.play_chevron_lock()
sleep(config.audio_delay_time)
self.gateControl.lock_chevron()
if config.enable_gary_jones and length == 7: # Not currently available for 8 or 9-symbol addresses
# Wait for play_chevron_lock() to finish
while self.audio.is_playing():
sleep(0.1)
continue
self.audio.play_chevron(i+1)
sleep(config.audio_delay_time)
if i == 6: # Wait for "chevron 7 locked" before engaging wormhole
while self.audio.is_playing():
sleep(0.1)
continue
else:
sleep(config.chevron_engage_time)
self.audio.play_chevron_unlock()
sleep(config.audio_delay_time)
if i == length-1:
self.gateControl.unlock_chevron(False)
else:
self.gateControl.unlock_chevron()
while self.audio.is_playing():
sleep(0.01)
continue
#if i == length-1:
# break
self.lightControl.light_chevron(config.chevron_light_order[i])
if direction == StargateControl.FORWARD:
direction = StargateControl.BACKWARD
else:
direction = StargateControl.FORWARD
self.audio.play_open()
self.lightControl.all_on()
sleep(1)
while self.audio.is_playing():
sleep(0.1)
continue
if config.play_theme:
self.audio.play_theme()
while self.audio.is_playing():
sleep(0.1)
continue
self.audio.play_close()
self.lightControl.all_off()
DialProgram.is_dialing = False