-
Notifications
You must be signed in to change notification settings - Fork 1
/
macros.lua
70 lines (55 loc) · 1.45 KB
/
macros.lua
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
-- greeting after connection
function onConnect()
signal.enabled[1] = true;
signal.enabled[2] = true;
signal.auto = false;
startSignal()
turn(servo.center)
tmr.alarm(macro.tmr, signal.interval*3.5, 0, function()
stopSignal();
signal.enabled[1] = false;
signal.enabled[2] = false;
signal.auto = true;
end);
end
-- goodby after disconnect
function onDisconnect()
signal.enabled[1] = true;
signal.enabled[2] = true;
signal.auto = false;
startSignal()
turn(servo.center)
tmr.alarm(macro.tmr, signal.interval*1.5, 0, function()
stopSignal();
signal.enabled[1] = false;
signal.enabled[2] = false;
signal.auto = true;
stop()
end);
end
--wifi connection has been set up
function onWifiConnected()
signal.enabled[1] = true;
signal.enabled[2] = true;
signal.auto = false;
startSignal()
tmr.alarm(macro.tmr, signal.interval, 0, function()
stopSignal();
signal.enabled[1] = false;
signal.enabled[2] = false;
signal.auto = true;
toggleLights()
tmr.alarm(macro.tmr, signal.interval, 0, function()
toggleLights()
end);
end);
end
-- stops everything
function stop()
-- Turn off servo
pwm.stop(servo.pin)
gpio.write(servo.enable, gpio.HIGH)
-- Turn off motor
pwm.setduty(motor.pinA, 0)
pwm.setduty(motor.pinB, 0)
end