Last active
August 29, 2015 14:03
-
-
Save scottgwald/c7e0369cfa65478eccea to your computer and use it in GitHub Desktop.
[wearscript] myo simple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name":"Myo Simple", | |
"scripts": {"android:phone": "phone.html"} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> | |
var context; | |
function drawTitlePage() { | |
var titleBase = 170; | |
var subtitleBase = 240; | |
context.fillStyle = '#000000'; | |
context.fillRect(0, 0, 640, 360); | |
context.font = '64pt Calibri'; | |
context.fillStyle = '#FFFFFF'; | |
context.fillText('Myo Controller', 35, titleBase); | |
context.font = '28pt Calibri'; | |
context.fillText('Controlling Glass with Myo', 175, subtitleBase); | |
} | |
function main() { | |
if (WS.scriptVersion(1)) return; | |
context = document.getElementById('canvas').getContext("2d"); | |
drawTitlePage(); | |
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.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'); | |
} | |
}); | |
} | |
window.onload = main; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment