Skip to content

Instantly share code, notes, and snippets.

@BrianAdams
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrianAdams/c4a8f36f96c973a41bc9 to your computer and use it in GitHub Desktop.
Save BrianAdams/c4a8f36f96c973a41bc9 to your computer and use it in GitHub Desktop.
Example code for pebblecloud simply.js integration with socket.io and OpenROV
simply.text({
title: 'Rov Demo!',
body: 'loading'
});
//Replace code with the IP address of the ROV as seen by your phone
var io = simply.loadScript('http://192.168.156.202:8080/socket.io/socket.io.js', false);
var socket = io.connect('http://192.168.156.202:8080');
socket.on('status', simply.wrapHandler(function (data) {
if (data) {
simply.body('Head:' + data.hdgd + '\r\nDept:' + data.deap);
} else {
simply.body('no data');
}
}));
socket.on('connect', simply.wrapHandler(function() {
simply.body('connected');
}));
socket.on('error', simply.wrapHandler(function(err) {
simply.body(err || 'no value');
}));
simply.on('singleClick', function(e) {
if (e.button==='up'){
socket.emit('brightness_update',1);
console.log(util2.format('Lights On', e));
simply.subtitle('Lights On');
}
if (e.button==='down'){
socket.emit('brightness_update',0);
console.log(util2.format('Lights Off!', e));
simply.subtitle('Lights Off');
}
});
simply.on('longClick', function(e) {
console.log(util2.format('long clicked $button!', e));
simply.vibe();
simply.scrollable(e.button !== 'select');
});
simply.on('accelTap', function(e) {
console.log(util2.format('tapped accel axis $axis $direction!', e));
simply.subtitle('Tapped ' + (e.direction > 0 ? '+' : '-') + e.axis + '!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment