-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyFirstScript.myo
77 lines (63 loc) · 1.71 KB
/
MyFirstScript.myo
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
--scriptId = 'com.thalmic.examples.myfirstscript'
scriptId = 'edu.stanford.myo.myfirstscript'
scriptTitle = "My First Script"
scriptDetailsUrl = ""
locked = true
appTitle = ""
function onForegroundWindowChange(app, title)
myo.debug("onForegroundWindowChange: " .. app .. ", " .. title)
appTitle = title
return true
end
function activeAppName()
return appTitle
end
function onPoseEdge(pose, edge)
myo.debug("onPoseEdge: " .. pose .. ": " .. edge)
pose = conditionallySwapWave(pose)
if (pose ~= "rest" and pose ~= "unknown") then
-- hold if edge is on, timed if edge is off
myo.unlock(edge == "off" and "timed" or "hold")
end
local keyEdge = edge == "off" and "up" or "down"
if (pose == "waveOut") then
onWaveOut(keyEdge)
elseif (pose == "waveIn") then
onWaveIn(keyEdge)
elseif (pose == "fist") then
onFist(keyEdge)
elseif (pose == "fingersSpread") then
onFingersSpread(keyEdge)
end
end
function onWaveOut(keyEdge)
myo.debug("Next")
--myo.vibrate("short")
myo.keyboard("tab", keyEdge)
end
function onWaveIn(keyEdge)
myo.debug("Previous")
--myo.vibrate("short")
--myo.vibrate("short")
myo.keyboard("tab",keyEdge,"shift")
end
function onFist(keyEdge)
myo.debug("Enter")
--myo.vibrate("medium")
myo.keyboard("return",keyEdge)
end
function onFingersSpread(keyEdge)
myo.debug("Escape")
--myo.vibrate("long")
myo.keyboard("escape", keyEdge)
end
function conditionallySwapWave(pose)
if myo.getArm() == "left" then
if pose == "waveIn" then
pose = "waveOut"
elseif pose == "waveOut" then
pose = "waveIn"
end
end
return pose
end