Skip to content

Instantly share code, notes, and snippets.

@mdobson
Created March 4, 2014 20:13
Show Gist options
  • Save mdobson/9354689 to your computer and use it in GitHub Desktop.
Save mdobson/9354689 to your computer and use it in GitHub Desktop.
Streaming API first round.
var PhotosensorDriver = module.exports = function() {
this.type = 'photosensor';
this.name = "joes-office-photosensor";
this.data = {};
this.state = 'on';
this.value = 0;
};
PhotosensorDriver.prototype.init = function(config) {
config
.stream('value', this.onValue);
};
PhotosensorDriver.prototype.onValue = function(emitter) {
setInterval(function() {
emitter.emit('data', Math.floor(Math.random() * 100));
}, 2000);
/*this.board.on('digitalChange', function(e) {
emitter.emit('data', e.value);
});*/
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment