Created
June 26, 2014 02:36
-
-
Save hatpick/9a92a7c2d0c3e3110ba0 to your computer and use it in GitHub Desktop.
[wearscript] sphero
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> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | |
<script type='text/javascript' src='https://cdn.firebase.com/js/client/1.0.15/firebase.js'></script> | |
</head> | |
<body style="width:100%; height:100%;text-align:center; overflow:hidden; margin:0" bgcolor="#000"> | |
<img style="height:360px;display:block;" src="http://orbotix.wpengine.netdna-cdn.com/wp-content/uploads/sphero-logo-vertical-blue-reg.jpg"> | |
<script> | |
var fb = new Firebase("https://sphero.firebaseio.com/"); | |
function server() { | |
WS.log('Welcome to WearScript'); | |
WS.sound('SUCCESS') | |
// Changes canvas color with head rotation | |
var sensors = ['gps', 'accelerometer', 'magneticField', 'orientation', 'gyroscope', | |
'light', 'gravity', 'linearAcceleration', 'rotationVector', 'pupil']; | |
for (var i = 0; i < sensors.length; i++) | |
WS.sensorOn(WS.sensor(sensors[i]), .15, function(data){ | |
if(data['type'] == WS.sensor('accelerometer')) { | |
var dirObj = new Object(); | |
dirObj.x = data['values'][0]; | |
dirObj.y = data['values'][1]; | |
dirObj.z = data['values'][2]; | |
fb.child("movement").set(dirObj); | |
} | |
}); | |
} | |
function main() { | |
if (WS.scriptVersion(1)) return; | |
WS.serverConnect('{{WSUrl}}', server); | |
} | |
window.onload = main; | |
</script> | |
</body> | |
</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
{"name":"Example"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment