-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic.py
68 lines (52 loc) · 1.58 KB
/
basic.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
63
64
65
66
67
68
import time
import random
r2.DomeLightsRelay.Enable()
r2.DomeMotorRelay.Enable()
if not "-mute" in args:
r2.SoundRelay.Enable()
r2.BodyServosRelay.Enable()
time.sleep(1)
r2.Head.Enable()
r2.Head.SetPosition(0)
r2.LeftUtilityArm.SetTarget(0)
r2.RightUtilityArm.SetTarget(0)
nextHeadMove = time.time() + 10
nextSound = time.time()
nextHologram = time.time()
hologramOff = time.time() + 1e6
class HeadMove:
def __init__(self, head):
self.Head = head
self.NextMoveTime = 0
def Update(self):
t = time.time()
if t > self.NextMoveTime:
self.Head.SetPosition(random.randint(-90, 90))
self.NextMoveTime = t + random.randint(1, 10)
scripts = []
scripts.append(HeadMove(r2.Head))
from HoloProjector import *
scripts.append(TwitchHoloProjector(r2.FrontHoloProjector))
scripts.append(TwitchHoloProjector(r2.TopHoloProjector))
scripts.append(TwitchHoloProjector(r2.RearHoloProjector))
while running():
t = time.time()
for script in scripts:
script.Update()
if t > nextHologram:
nextHologram = t + random.randint(60, 180)
hologramOff = t + 30
r2.FrontHoloProjector.SetMessage()
#r2.Sound.Play("")
elif t > hologramOff:
r2.FrontHoloProjector.SetDefault()
hologramOff = t + 1e6
if t > nextSound:
nextSound = t + random.randint(10, 20)
r2.Sound.Play("Generic")
if r2.Network.Changed("BB8"):
if r2.Network.IsConnected("BB8"):
r2.Sound.Play("Happy")
else:
r2.Sound.Play("Sad")
r2.DomeMotorRelay.Disable()