Skip to content

Instantly share code, notes, and snippets.

@fluidglassml
Last active August 29, 2015 14:00
Show Gist options
  • Save fluidglassml/11260520 to your computer and use it in GitHub Desktop.
Save fluidglassml/11260520 to your computer and use it in GitHub Desktop.
[wearscript] myo director
<html style="width:100%; height:100%; overflow:hidden">
<head>
<!-- You can include external scripts here like so... -->
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.0/zepto.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>-->
</head>
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<canvas id="canvas" width="640" height="360" style="display:block"></canvas>
<script>
function server() {
WS.log('Welcome to WearScript');
WS.say('I am the WearScript director');
//setInterval(function() {WS.say("right"); WS.control('SWIPE_RIGHT');}, 3000);
setTimeout(WS.myoPair(WS.myoTrain), 250);
WS.gestureCallback('onMyo', function (x) {
// if (x != "NONE")
// WS.say(x);
WS.log(x);
if (x == 'WAVE_IN') {
WS.say("advance abbott");
WS.publish("director", {role: "Abbott", command: "advance"});
} else if (x == 'WAVE_OUT') {
WS.say("advance costello");
WS.publish("director", {role: "Costello", command: "advance"});
} else if (x == 'FIST') {
WS.say("reset");
WS.publish("director", {command: "reset"});
}
// if (x == 'WAVE_IN') {
// WS.control('SWIPE_RIGHT');
// } else if (x == 'WAVE_OUT') {
// WS.control('SWIPE_LEFT');
// } else if (x == 'FIST') {
// WS.control('TAP');
// } else if (x == 'FINGERS_SPREAD') {
// WS.control('SWIPE_DOWN');
// }
});
// Hookup touch and eye gesture callbacks
WS.gestureCallback('onTwoFingerScroll', function (v, v2, v3) {
WS.log('onTwoFingerScroll: ' + v + ', ' + v2 + ', ' + v3);
});
}
function main() {
if (WS.scriptVersion(1)) return;
ctx = document.getElementById('canvas').getContext("2d");
WS.serverConnect('{{WSUrl}}', server);
}
window.onload = main;
</script>
</body>
</html>
{"name":"Myo Director"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment