Skip to content

Instantly share code, notes, and snippets.

@scottgwald
Last active August 29, 2015 13:59
Show Gist options
  • Select an option

  • Save scottgwald/11000721 to your computer and use it in GitHub Desktop.

Select an option

Save scottgwald/11000721 to your computer and use it in GitHub Desktop.
[wearscript] Picaboo
<html style="width:100%; height:100%; overflow:hidden">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.0/zepto.min.js"></script>
</head>
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<img id="theImage" src="" width=640 height=360>
<script>
var lightThreshold = 25;
var theImage = $('#theImage');
var isCovered;
var currentPath = coveredPath;
var coveredPath = "http://imgur.com/TVDbSR1.jpg";
var uncoveredPath = "http://imgur.com/Mk0XZNL.jpg";
function setImage() {
if (isCovered) {
if (currentPath != coveredPath) {
WS.say("where are you");
theImage.attr('src', coveredPath);
currentPath = coveredPath;
}
} else {
if (currentPath != uncoveredPath) {
WS.say("picaboo");
theImage.attr('src', uncoveredPath);
currentPath = uncoveredPath;
}
}
}
function main() {
if (WS.scriptVersion(1)) return;
WS.sound('SUCCESS');
WS.sensorOn('light', .01, function (data) {
isCovered = data['values'][0] <= lightThreshold;
setImage();
});
WS.dataLog(false, true, .15);
}
window.onload = main;
</script>
</body>
</html>
{"name":"Picaboo"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment