Some pure JS examples for the purists
This commit is contained in:
parent
b29f911628
commit
a95bd2e0ee
|
@ -0,0 +1,11 @@
|
|||
var Cylon = require('..');
|
||||
|
||||
// Initialize the robot
|
||||
Cylon.robot({
|
||||
connection: { name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' },
|
||||
device: {name: 'led', driver: 'led', pin: 13},
|
||||
|
||||
work: function(my) {
|
||||
every((1).seconds(), function() {my.led.toggle()});
|
||||
}
|
||||
}).start();
|
|
@ -0,0 +1,12 @@
|
|||
var Cylon = require('..');
|
||||
|
||||
// Initialize the robot
|
||||
Cylon.robot({
|
||||
connection: { name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' },
|
||||
devices: [{name: 'led', driver: 'led', pin: 13},
|
||||
{name: 'button', driver: 'button', pin: 2}],
|
||||
|
||||
work: function(my) {
|
||||
my.button.on('push', function() {my.led.toggle()});
|
||||
}
|
||||
}).start();
|
|
@ -0,0 +1,45 @@
|
|||
var Cylon = require('..')
|
||||
var Travis = require('travis-ci')
|
||||
|
||||
var travis = new Travis({version: '2.0.0'});
|
||||
|
||||
var BLUE = 0x0000ff
|
||||
var GREEN = 0x00ff00
|
||||
var RED = 0xff0000
|
||||
|
||||
Cylon.robot({
|
||||
connection: {name: 'sphero', adaptor: 'sphero', port: '/dev/rfcomm0'},
|
||||
device: {name: 'sphero', driver: 'sphero'},
|
||||
|
||||
work: function(me) {
|
||||
var user = "hybridgroup"
|
||||
var name = "cylon"
|
||||
|
||||
me.checkTravis = function() {
|
||||
Logger.info("Checking repo "+user+"/"+name);
|
||||
me.sphero.setRGB(BLUE, true);
|
||||
|
||||
travis.repos(
|
||||
{ owner_name: user, name: name },
|
||||
function(err, res) {
|
||||
if (res.repo != undefined) {
|
||||
if (res.repo.last_build_state == 'passed') {
|
||||
me.sphero.setRGB(GREEN, true);
|
||||
} else if (res.repo.last_build_state == 'failed') {
|
||||
me.sphero.setRGB(RED, true);
|
||||
} else {
|
||||
me.sphero.setRGB(BLUE, true);
|
||||
}
|
||||
} else {
|
||||
me.sphero.setRGB BLUE, true
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
me.checkTravis();
|
||||
|
||||
every((10).seconds(), function() {
|
||||
me.checkTravis();
|
||||
});
|
||||
}
|
||||
}).start();
|
Loading…
Reference in New Issue