Created
May 5, 2014 03:31
-
-
Save scottgwald/11528253 to your computer and use it in GitHub Desktop.
[wearscript] empa
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" bgcolor="#000"> | |
<canvas id="canvas" width="640" height="360" style="display:block"></canvas> | |
<script> | |
function server() { | |
WS.log('Welcome to WearScript'); | |
WS.say('Welcome to WearScript'); | |
WS.empaPair(onEmpaPaired); | |
} | |
function onEmpaPaired() { | |
console.log("Paired empa"); | |
WS.sensorOn("empaGSR", .2, onGSR); | |
// WS.sensorOn("empaGSR", .2, function(data) {console.log(JSON.stringify(data))}); | |
WS.sensorOn("empaBattery", .2, function(data) {console.log(JSON.stringify(data))}); | |
// WS.dataLog(false, true, .15); | |
} | |
function onGSR(data) { | |
clearCanvas(); | |
drawTextLine(data.values[0], 2); | |
} | |
function clearCanvas() { | |
context.fillStyle = "rgb(0, 0, 0)"; | |
context.fillRect(0, 0, 640, 360); | |
} | |
function drawTextLine(text, _number) { | |
var number = _number; | |
if ( number === undefined ) { | |
console.log("No number given, setting to 0"); | |
number = 0; | |
} | |
baseline = 40 + 50 * number; | |
context.fillStyle = "rgb(200,200,200)"; | |
context.font = '28pt Calibri'; | |
context.textAlign = 'left'; | |
context.fillText(text, 10, baseline); | |
} | |
function drawGSR(val) { | |
ctx.drawText() | |
} | |
function main() { | |
if (WS.scriptVersion(1)) return; | |
context = document.getElementById('canvas').getContext("2d"); | |
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