Skip to content

Instantly share code, notes, and snippets.

@drGrove
Created March 24, 2014 22:10
Show Gist options
  • Save drGrove/9750376 to your computer and use it in GitHub Desktop.
Save drGrove/9750376 to your computer and use it in GitHub Desktop.
[wearscript] Myo Hue
<html style="width:100%; height:100%; overflow:hidden">
<body style="width:100%; height:100%; overflow:hidden; margin:0; background: #000;">
<script data-require="jquery" data-semver="2.0.3" src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script>
function server() {
WS.say('Welcome to Wearscript Hue Glass Demo')
WS.log('Welcome to Wearscript Hue Glass Demo')
var numHue = 3;
function updateHue( hueState ){
for(var x = 1; x <= numHue; x++){
$.ajax({
url: 'http://192.168.1.66/api/wearscript/lights/' + x + '/state',
type: 'PUT',
dataType: 'application/json',
data: hueState,
success: function(res) {
WS.log('success', res);
},
error: function(res){
WS.log('error', res.responseText)
}
})
}
}
WS.gestureCallback('onGesture', function (name) {
if(name == 'TAP'){
updateHue( '{"on":true}')
}
if(name == 'TWO_TAP'){
updateHue( '{"on": false}' );
}
});
WS.gestureCallback('onGestureSWIPE_LEFT', function () {
updateHue( '{"on":false}')
});
WS.gestureCallback('onGestureSWIPE_RIGHT', function () {
updateHue( '{"on": true}' );
});
function doSpeech(){
WS.speechRecognize('What do you want to do?', function(data){
if(data == 'turn off'){
updateHue( '{"on": false}' );
}
if(data == 'turn on'){
updateHue( '{"on": true}' );
}
})
}
/*
WS.gestureCallback('onMyo', function (x) {
WS.say(x);
WS.log(x);
if (x == 'FINGERS_SPREAD') {
updateHue( '{"on": true}' );
}
if (x == 'FIST') {
updateHue('{"on":false}' );
}
if(x == 'WAVE_IN'){
updateHue('{"on:true,"hue":25500}')
}
if(x == 'WAVE_OUT'){
updateHue('{"on":true,"hue":65535}')
}
});
*/
}
function main() {
if (WS.scriptVersion(1)) return;
WS.serverConnect('{{WSUrl}}', server);
}
window.onload = main;
</script>
</body>
</html>
{"name": "Myo/Glass Hue"}
<html>
<body>
<script>
WS.say('I am phone')
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment