Skip to content

Instantly share code, notes, and snippets.

@colegleason
Forked from connerbrooks/glass.html
Last active August 29, 2015 13:57
Show Gist options
  • Save colegleason/9735180 to your computer and use it in GitHub Desktop.
Save colegleason/9735180 to your computer and use it in GitHub Desktop.
[wearscript] Pebble
<html style="width:100%; height:100%; overflow:hidden">
<head>
</head>
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<canvas id="canvas" width="640" height="360" style="display:block"></canvas>
<script>
function cb(data) {
WSRAW.log('x: ' + data['values'][0] + ' y: ' + data['values'][1] + ' z: ' + data['values'][2]);
WSRAW.pebbleSetBody('x: ' + data['values'][0] + ' y: '+ data['values'][1] + ' z: ' + data['values'][2], false);
}
function server() {
WS.log('Welcome to WearScript-Pebble');
WS.say('Welcome to WearScript-Pebble');
WS.pebbleSetBody('connected!', false);
WS.sensorOn(WS.sensor("pebbleAccelerometer"), .25, 'cb');
WS.pebbleSetSubtitle('Accel Data', false);
WS.gestureCallback('onPebbleSingleClick', function (name) {
WS.log('onPebbleSingleClick: ' + name);
WS.pebbleSetTitle(name + ' clicked', false);
WS.say(name);
});
WS.gestureCallback('onPebbleLongClick', function (name) {
WS.log('onPebbleLongClick: ' + name);
WS.pebbleVibe(2);
});
WS.gestureCallback('onPebbleAccelTap', function (axis, direction) {
WS.log('onPebbleAccelTap: ' + axis + ' ' + direction);
});
}
function main() {
if (WS.scriptVersion(1)) return;
WS.serverConnect('{{WSUrl}}', 'server');
}
window.onload = main;
</script>
</body>
</html>
{
"name": "Pebble"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment