Skip to content

Instantly share code, notes, and snippets.

@connerbrooks
Forked from kurtisnelson/glass.html
Created March 26, 2014 21:41
Show Gist options
  • Save connerbrooks/9794273 to your computer and use it in GitHub Desktop.
Save connerbrooks/9794273 to your computer and use it in GitHub Desktop.
[wearscript] Control your Glass with Myo, Pebble, or Magnets
<html style="width:100%; height:100%; overflow:hidden">
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<script>
function server() {
WS.myoTrain();
WS.say("ready");
WS.pebbleSetBody('connected!', false);
// Currently one of {NONE, FIST, FINGERS_SPREAD, WAVE_IN, WAVE_OUT}
WS.gestureCallback('onMyo', function (x) {
if(x == "WAVE_IN"){
WS.control("SWIPE_LEFT");
}else if(x == "WAVE_OUT"){
WS.control("SWIPE_RIGHT");
}else if(x == "FIST"){
WS.control("TAP");
}else if(x == "FINGERS_SPREAD"){
WS.control("SWIPE_DOWN");
}
});
WS.gestureCallback('onPebbleSingleClick', function (name) {
WS.pebbleSetTitle(name + ' clicked', false);
if(name == "up"){
WS.control("SWIPE_RIGHT");
}else if(name == "down"){
WS.control("SWIPE_LEFT");
}else if(name == "select"){
WS.control("TAP");
}
});
WS.gestureCallback('onPebbleLongClick', function (name) {
WS.pebbleVibe(2);
WS.control("SWIPE_DOWN");
});
}
function main() {
if (WS.scriptVersion(1)) return;
WS.serverConnect('{{WSUrl}}', server);
}
window.onload = main;
</script></body></html>
{"name": "FancyControls"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment