Examples should use console.log instead of Logger
This commit is contained in:
parent
9065a319f6
commit
30cf20049c
|
@ -15,9 +15,9 @@ Cylon.robot
|
|||
|
||||
work: (my) ->
|
||||
my.sensor.on 'upperLimit', (val) ->
|
||||
Logger.info "Upper limit reached ===> #{val}"
|
||||
console.log "Upper limit reached ===> #{val}"
|
||||
|
||||
my.sensor.on 'lowerLimit', (val) ->
|
||||
Logger.info "Lower limit reached ===> #{val}"
|
||||
console.log "Lower limit reached ===> #{val}"
|
||||
|
||||
.start()
|
||||
|
|
|
@ -17,11 +17,11 @@ Cylon.robot({
|
|||
|
||||
work: function(my) {
|
||||
my.sensor.on('upperLimit', function(val) {
|
||||
Logger.info("Upper limit reached ===> " + val);
|
||||
console.log("Upper limit reached ===> " + val);
|
||||
});
|
||||
|
||||
my.sensor.on('lowerLimit', function(val) {
|
||||
Logger.info("Lower limit reached ===> " + val);
|
||||
console.log("Lower limit reached ===> " + val);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -36,10 +36,10 @@ tell it what work we want to do:
|
|||
|
||||
work: (my) ->
|
||||
my.sensor.on 'upperLimit', (val) ->
|
||||
Logger.info "Upper limit reached: #{val}"
|
||||
console.log "Upper limit reached: #{val}"
|
||||
|
||||
my.sensor.on 'lowerLimit', (val) ->
|
||||
Logger.info "Lower limit reached: #{val}"
|
||||
console.log "Lower limit reached: #{val}"
|
||||
|
||||
Now that our robot knows what work to do, and the work it will be doing that
|
||||
hardware with, we can start it:
|
||||
|
|
|
@ -14,7 +14,7 @@ SpheroRobot =
|
|||
|
||||
work: (my) ->
|
||||
every 1.seconds(), ->
|
||||
Logger.info my.name
|
||||
console.log my.name
|
||||
my.sphero.setRGB Math.floor(Math.random() * 100000)
|
||||
my.sphero.roll 60, Math.floor(Math.random() * 360)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ var SpheroRobot = {
|
|||
|
||||
work: function(my) {
|
||||
every((1).seconds(), function() {
|
||||
Logger.info(my.name);
|
||||
console.log(my.name);
|
||||
my.sphero.setRandomColor();
|
||||
my.sphero.roll(60, Math.floor(Math.random() * 360));
|
||||
});
|
||||
|
|
|
@ -46,7 +46,7 @@ roll in a random direction.
|
|||
|
||||
work: (my) ->
|
||||
every 1.seconds(), ->
|
||||
Logger.info my.name
|
||||
console.log my.name
|
||||
my.sphero.setRandomColor()
|
||||
my.sphero.roll 60, Math.floor(Math.random() * 360)
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ Cylon.robot
|
|||
angle += increment
|
||||
my.servo.angle angle
|
||||
|
||||
Logger.info "Current Angle: #{my.servo.currentAngle()}"
|
||||
console.log "Current Angle: #{my.servo.currentAngle()}"
|
||||
|
||||
increment = -increment if (angle is 30) or (angle is 150)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ Cylon.robot
|
|||
work: (my) ->
|
||||
my.blinkm.on 'start', ->
|
||||
my.blinkm.version (version) ->
|
||||
Logger.info "Started BlinkM version #{version}"
|
||||
console.log "Started BlinkM version #{version}"
|
||||
|
||||
my.blinkm.off()
|
||||
lit = false
|
||||
|
@ -16,11 +16,11 @@ Cylon.robot
|
|||
every 1.second(), ->
|
||||
if lit
|
||||
lit = false
|
||||
Logger.info 'on'
|
||||
console.log 'on'
|
||||
my.blinkm.rgb 0xaa, 0, 0
|
||||
else
|
||||
lit = true
|
||||
Logger.info 'off'
|
||||
console.log 'off'
|
||||
my.blinkm.rgb 0, 0, 0
|
||||
|
||||
.start()
|
||||
|
|
|
@ -8,7 +8,7 @@ Cylon.robot({
|
|||
work: function(my) {
|
||||
my.blinkm.on('start', function() {
|
||||
my.blinkm.version(function(version) {
|
||||
Logger.info("Started BlinkM version " + version);
|
||||
console.log("Started BlinkM version " + version);
|
||||
});
|
||||
|
||||
my.blinkm.off();
|
||||
|
@ -18,11 +18,11 @@ Cylon.robot({
|
|||
every((1).second(), function() {
|
||||
if (lit) {
|
||||
lit = false;
|
||||
Logger.info('on');
|
||||
console.log('on');
|
||||
my.blinkm.rgb(0xaa, 0, 0);
|
||||
} else {
|
||||
lit = true;
|
||||
Logger.info('off');
|
||||
console.log('off');
|
||||
my.blinkm.rgb(0, 0, 0);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -32,7 +32,7 @@ When the BlinkM sends the 'start' event, we'll set up our events
|
|||
We'll request the BlinkM's version, and print that to the console:
|
||||
|
||||
my.blinkm.version (version) ->
|
||||
Logger.info "Started BlinkM version #{version}"
|
||||
console.log "Started BlinkM version #{version}"
|
||||
|
||||
By default, we'll turn the LED off and assign a boolean that we'll use to
|
||||
determine if it's on or not:
|
||||
|
@ -46,11 +46,11 @@ which state we need to transition the BlinkM to:
|
|||
every 1.second(), ->
|
||||
if lit
|
||||
lit = false
|
||||
Logger.info 'on'
|
||||
console.log 'on'
|
||||
my.blinkm.rgb 0xaa, 0, 0
|
||||
else
|
||||
lit = true
|
||||
Logger.info 'off'
|
||||
console.log 'off'
|
||||
my.blinkm.rgb 0, 0, 0
|
||||
|
||||
Now that our robot knows what to do, let's get started:
|
||||
|
|
|
@ -38,7 +38,7 @@ class ConwayRobot
|
|||
birthday: ->
|
||||
@age += 1
|
||||
|
||||
Logger.info "Happy birthday, #{@name}. You are #{@age} and had #{@contacts} contacts."
|
||||
console.log "Happy birthday, #{@name}. You are #{@age} and had #{@contacts} contacts."
|
||||
|
||||
if @enoughContacts()
|
||||
@rebirth() if not @alive?
|
||||
|
|
|
@ -51,7 +51,7 @@ var ConwayRobot = (function() {
|
|||
ConwayRobot.prototype.birthday = function() {
|
||||
this.age += 1;
|
||||
|
||||
Logger.info("Happy birthday, " + this.name + ". You are " + this.age + " and had " + this.contacts + " contacts.");
|
||||
console.log("Happy birthday, " + this.name + ". You are " + this.age + " and had " + this.contacts + " contacts.");
|
||||
|
||||
if (this.enoughContacts()) {
|
||||
if (this.alive == null) { this.rebirth(); }
|
||||
|
|
|
@ -101,7 +101,7 @@ the number of contacts it had in the last tick.
|
|||
birthday: ->
|
||||
@age += 1
|
||||
|
||||
Logger.info "Happy birthday, #{@name}. You are #{@age} and had #{@contacts} contacts."
|
||||
console.log "Happy birthday, #{@name}. You are #{@age} and had #{@contacts} contacts."
|
||||
|
||||
if @enoughContacts()
|
||||
@rebirth() if not @alive?
|
||||
|
|
|
@ -11,6 +11,6 @@ Cylon.robot
|
|||
|
||||
work: (my) ->
|
||||
my.drone.config 'general:navdata_demo', 'TRUE'
|
||||
my.nav.on 'update', (data) -> Logger.info data
|
||||
my.nav.on 'update', (data) -> console.log data
|
||||
|
||||
.start()
|
||||
|
|
|
@ -9,6 +9,6 @@ Cylon.robot({
|
|||
|
||||
work: function(my) {
|
||||
my.drone.config('general:navdata_demo', 'TRUE');
|
||||
my.nav.on('update', function(data) { Logger.info(data); });
|
||||
my.nav.on('update', function(data) { console.log(data); });
|
||||
}
|
||||
}).start();
|
||||
|
|
|
@ -32,7 +32,7 @@ drone's config, and log data to the console whenever the nav board emits the
|
|||
|
||||
work: (my) ->
|
||||
my.drone.config 'general:navdata_demo', 'TRUE'
|
||||
my.nav.on 'update', (data) -> Logger.info data
|
||||
my.nav.on 'update', (data) -> console.log data
|
||||
|
||||
Simple enough. Now all that's left is to start the robot:
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@ Cylon = require '../..'
|
|||
Cylon.robot
|
||||
work: ->
|
||||
every 1.second(), ->
|
||||
Logger.info("Hello, human!")
|
||||
console.log("Hello, human!")
|
||||
|
||||
after 10.seconds(), ->
|
||||
Logger.info "Impressive."
|
||||
console.log "Impressive."
|
||||
|
||||
.start()
|
||||
|
|
|
@ -2,7 +2,7 @@ var Cylon = require('../..');
|
|||
|
||||
Cylon.robot({
|
||||
work: function() {
|
||||
every(1..second(), function() { Logger.info("Hello, human!"); });
|
||||
after(10..seconds(), function() { Logger.info("Impressive."); });
|
||||
every(1..second(), function() { console.log("Hello, human!"); });
|
||||
after(10..seconds(), function() { console.log("Impressive."); });
|
||||
}
|
||||
}).start();
|
||||
|
|
|
@ -17,10 +17,10 @@ message after ten seconds have elapsed.
|
|||
|
||||
work: ->
|
||||
every 1.second(), ->
|
||||
Logger.info("Hello, human!")
|
||||
console.log("Hello, human!")
|
||||
|
||||
after 10.seconds(), ->
|
||||
Logger.info "Impressive."
|
||||
console.log "Impressive."
|
||||
|
||||
Simple as can be. Now that we're done, let's start the robot:
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ class SpheroRobot
|
|||
connection: { name: 'Sphero', adaptor: 'sphero' }
|
||||
|
||||
work: (my) ->
|
||||
Logger.info "Robot #{my.name} is now working!"
|
||||
console.log "Robot #{my.name} is now working!"
|
||||
|
||||
for bot in bots
|
||||
robot = new SpheroRobot
|
||||
|
|
|
@ -12,7 +12,7 @@ var SpheroRobot = (function() {
|
|||
SpheroRobot.prototype.connection = { name: 'Sphero', adaptor: 'sphero' };
|
||||
|
||||
SpheroRobot.prototype.work = function(my) {
|
||||
Logger.info("Robot " + my.name + " is now working!");
|
||||
console.log("Robot " + my.name + " is now working!");
|
||||
};
|
||||
|
||||
return SpheroRobot;
|
||||
|
|
|
@ -38,7 +38,7 @@ We'll just give our robots some basic work so we can tell they're actually
|
|||
working:
|
||||
|
||||
work: (my) ->
|
||||
Logger.info "Robot #{my.name} is now working!"
|
||||
console.log "Robot #{my.name} is now working!"
|
||||
|
||||
And that's all we need for that.
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ Cylon.robot
|
|||
every 0.05.seconds(), ->
|
||||
speed += increment
|
||||
my.motor.speed(speed)
|
||||
Logger.info "Current Speed: #{my.motor.currentSpeed() }"
|
||||
console.log "Current Speed: #{my.motor.currentSpeed() }"
|
||||
increment = -increment if (speed is 0) or (speed is 255)
|
||||
|
||||
.start()
|
||||
|
|
|
@ -12,7 +12,7 @@ Cylon.robot({
|
|||
speed += increment;
|
||||
my.motor.speed(speed);
|
||||
|
||||
Logger.info("Current Speed: " + (my.motor.currentSpeed()));
|
||||
console.log("Current Speed: " + (my.motor.currentSpeed()));
|
||||
|
||||
if ((speed === 0) || (speed === 255)) { increment = -increment; }
|
||||
});
|
||||
|
|
|
@ -38,7 +38,7 @@ values supported:
|
|||
every 0.05.seconds(), ->
|
||||
speed += increment
|
||||
my.motor.speed(speed)
|
||||
Logger.info "Current Speed: #{my.motor.currentSpeed() }"
|
||||
console.log "Current Speed: #{my.motor.currentSpeed() }"
|
||||
increment = -increment if (speed is 0) or (speed is 255)
|
||||
|
||||
And with all that done, we can now start our robot:
|
||||
|
|
|
@ -13,7 +13,7 @@ Cylon.robot
|
|||
angle += increment
|
||||
my.servo.angle angle
|
||||
|
||||
Logger.info "Current Angle: #{my.servo.currentAngle()}"
|
||||
console.log "Current Angle: #{my.servo.currentAngle()}"
|
||||
|
||||
increment = -increment if (angle is 30) or (angle is 150)
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ Cylon.robot({
|
|||
every(1..seconds(), function() {
|
||||
angle += increment;
|
||||
my.servo.angle(angle);
|
||||
Logger.info("Current Angle: " + (my.servo.currentAngle()));
|
||||
console.log("Current Angle: " + (my.servo.currentAngle()));
|
||||
if ((angle === 30) || (angle === 150)) { increment = -increment; }
|
||||
});
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ supported:
|
|||
angle += increment
|
||||
my.servo.angle(angle)
|
||||
|
||||
Logger.info "Current angle: #{my.servo.currentAngle() }"
|
||||
console.log "Current angle: #{my.servo.currentAngle() }"
|
||||
|
||||
increment = -increment if (angle is 30) or (angle is 150)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ class MyRobot
|
|||
|
||||
work: (me) ->
|
||||
every 1.seconds(), ->
|
||||
Logger.info me.name
|
||||
console.log me.name
|
||||
|
||||
robot = new MyRobot
|
||||
robot.name = "frankie"
|
||||
|
|
|
@ -13,7 +13,7 @@ var MyRobot = (function() {
|
|||
|
||||
MyRobot.prototype.work = function(me) {
|
||||
every((1).seconds(), function() {
|
||||
Logger.info(me.name);
|
||||
console.log(me.name);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ busy, we'll just tell it to print it's name every second.
|
|||
|
||||
work: (me) ->
|
||||
every 1.seconds(), ->
|
||||
Logger.info me.name
|
||||
console.log me.name
|
||||
|
||||
And with that all done, we can now instantiate our robot:
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ Cylon.robot
|
|||
msg += "Bucks: #{data.sobject.Bucks__c},"
|
||||
msg += "SM_Id: #{data.sobject.Id}"
|
||||
|
||||
Logger.info msg
|
||||
console.log msg
|
||||
|
||||
i = 0
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ Cylon.robot({
|
|||
msg += "Bucks: " + data.sobject.Bucks__c + ",";
|
||||
msg += "SM_Id: " + data.sobject.Id;
|
||||
|
||||
Logger.info(msg);
|
||||
console.log(msg);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ Cylon.robot
|
|||
angle += increment
|
||||
my.servo.angle angle
|
||||
|
||||
Logger.info "Current Angle: #{my.servo.currentAngle()}"
|
||||
console.log "Current Angle: #{my.servo.currentAngle()}"
|
||||
|
||||
increment = -increment if (angle is 30) or (angle is 150)
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ Cylon.robot({
|
|||
angle += increment;
|
||||
my.servo.angle(angle);
|
||||
|
||||
Logger.info("Current Angle: " + (my.servo.currentAngle()));
|
||||
console.log("Current Angle: " + (my.servo.currentAngle()));
|
||||
|
||||
if ((angle === 30) || (angle === 150)) { increment = -increment; }
|
||||
});
|
||||
|
|
|
@ -38,7 +38,7 @@ supported:
|
|||
every 1.seconds(), ->
|
||||
angle += increment
|
||||
my.servo.angle(angle)
|
||||
Logger.info "Current angle: #{my.servo.currentAngle() }"
|
||||
console.log "Current angle: #{my.servo.currentAngle() }"
|
||||
increment = -increment if (angle is 30) or (angle is 150)
|
||||
|
||||
And with all that done, we can now start our robot:
|
||||
|
|
|
@ -20,7 +20,7 @@ class SalesforceRobot
|
|||
msg += "Bucks: #{data.sobject.Bucks__c},"
|
||||
msg += "SM_Id: #{data.sobject.Id}"
|
||||
|
||||
Logger.info msg
|
||||
console.log msg
|
||||
|
||||
me.master.findRobot data.sobject.Sphero_Name__c, (err, spheroBot) ->
|
||||
spheroBot.react spheroBot.devices.sphero
|
||||
|
@ -38,7 +38,7 @@ class SpheroRobot
|
|||
|
||||
work: (me) ->
|
||||
me.sphero.on 'connect', ->
|
||||
Logger.info 'Setting up Collision Detection...'
|
||||
console.log 'Setting up Collision Detection...'
|
||||
me.sphero.detectCollisions()
|
||||
me.sphero.stop()
|
||||
me.sphero.setRGB 0x00FF00
|
||||
|
|
|
@ -28,7 +28,7 @@ var SalesforceRobot = (function() {
|
|||
msg = "Sphero: " + data.sobject.Sphero_Name__c + ",";
|
||||
msg += "Bucks: " + data.sobject.Bucks__c + ",";
|
||||
msg += "SM_Id: " + data.sobject.Id;
|
||||
Logger.info(msg);
|
||||
console.log(msg);
|
||||
me.master.findRobot(data.sobject.Sphero_Name__c, function(err, spheroBot) {
|
||||
spheroBot.react(spheroBot.devices.sphero);
|
||||
});
|
||||
|
@ -57,7 +57,7 @@ var SpheroRobot = (function() {
|
|||
|
||||
SpheroRobot.prototype.work = function(me) {
|
||||
me.sphero.on('connect', function() {
|
||||
Logger.info('Setting up Collision Detection...');
|
||||
console.log('Setting up Collision Detection...');
|
||||
me.sphero.detectCollisions();
|
||||
me.sphero.stop();
|
||||
me.sphero.setRGB(0x00FF00);
|
||||
|
|
|
@ -10,7 +10,7 @@ class PebbleRobot
|
|||
robot.message_queue().push(msg)
|
||||
|
||||
work: (me) ->
|
||||
me.pebble.on 'connect', -> Logger.info "Connected!"
|
||||
me.pebble.on 'connect', -> console.log "Connected!"
|
||||
|
||||
class SalesforceRobot
|
||||
connection:
|
||||
|
@ -37,7 +37,7 @@ class SalesforceRobot
|
|||
msg += "data Bucks: #{bucks},"
|
||||
msg += "SM_Id: #{data.sobject.Id}"
|
||||
|
||||
Logger.info msg
|
||||
console.log msg
|
||||
|
||||
me.master.findRobot name, (err, spheroBot) ->
|
||||
spheroBot.react spheroBot.devices.sphero
|
||||
|
@ -78,7 +78,7 @@ class SpheroRobot
|
|||
work: (me) ->
|
||||
|
||||
me.sphero.on 'connect', ->
|
||||
Logger.info 'Setting up Collision Detection...'
|
||||
console.log 'Setting up Collision Detection...'
|
||||
me.sphero.detectCollisions()
|
||||
me.sphero.stop()
|
||||
me.sphero.setRGB 0x00FF00
|
||||
|
|
|
@ -17,7 +17,7 @@ var PebbleRobot = (function() {
|
|||
};
|
||||
|
||||
PebbleRobot.prototype.work = function(me) {
|
||||
me.pebble.on('connect', function() { Logger.info("Connected!"); });
|
||||
me.pebble.on('connect', function() { console.log("Connected!"); });
|
||||
};
|
||||
|
||||
return PebbleRobot;
|
||||
|
@ -55,7 +55,7 @@ var SalesforceRobot = (function() {
|
|||
msg += "data Bucks: " + bucks + ",";
|
||||
msg += "SM_Id: " + data.sobject.Id;
|
||||
|
||||
Logger.info(msg);
|
||||
console.log(msg);
|
||||
|
||||
me.master.findRobot(name, function(err, spheroBot) {
|
||||
spheroBot.react(spheroBot.devices.sphero);
|
||||
|
@ -122,7 +122,7 @@ var SpheroRobot = (function() {
|
|||
|
||||
SpheroRobot.prototype.work = function(me) {
|
||||
me.sphero.on('connect', function() {
|
||||
Logger.info('Setting up Collision Detection...');
|
||||
console.log('Setting up Collision Detection...');
|
||||
me.sphero.detectCollisions();
|
||||
me.sphero.stop();
|
||||
me.sphero.setRGB(0x00FF00);
|
||||
|
|
|
@ -9,15 +9,15 @@ Cylon.robot
|
|||
bitFilter = 0xFFFF00
|
||||
|
||||
me.sphero.on 'connect', ->
|
||||
Logger.info "Setting up Collision Detection..."
|
||||
console.log "Setting up Collision Detection..."
|
||||
me.sphero.detectCollisions()
|
||||
me.sphero.setRGB color
|
||||
me.sphero.stop()
|
||||
|
||||
me.sphero.on 'collision', (data) ->
|
||||
Logger.info "Collision:"
|
||||
console.log "Collision:"
|
||||
color = color ^ bitFilter
|
||||
Logger.info "Color: #{color.toString(16)} "
|
||||
console.log "Color: #{color.toString(16)} "
|
||||
me.sphero.setRGB color
|
||||
me.sphero.roll 90, Math.floor(Math.random() * 360)
|
||||
|
||||
|
|
|
@ -9,16 +9,16 @@ Cylon.robot({
|
|||
var bitFilter = 0xFFFF00;
|
||||
|
||||
me.sphero.on('connect', function() {
|
||||
Logger.info("Setting up Collision Detection...");
|
||||
console.log("Setting up Collision Detection...");
|
||||
me.sphero.detectCollisions();
|
||||
me.sphero.setRGB(color);
|
||||
me.sphero.stop();
|
||||
});
|
||||
|
||||
me.sphero.on('collision', function(data) {
|
||||
Logger.info("Collision:");
|
||||
console.log("Collision:");
|
||||
color = color ^ bitFilter;
|
||||
Logger.info("Color: " + (color.toString(16)) + " ");
|
||||
console.log("Color: " + (color.toString(16)) + " ");
|
||||
me.sphero.setRGB(color);
|
||||
me.sphero.roll(90, Math.floor(Math.random() * 360));
|
||||
});
|
||||
|
|
|
@ -34,7 +34,7 @@ When our Sphero emits the 'connect' event, we're going to hook up collision
|
|||
detection, make sure it's not moving, and set a color.
|
||||
|
||||
me.sphero.on 'connect', ->
|
||||
Logger.info "Setting up Collision Detection..."
|
||||
console.log "Setting up Collision Detection..."
|
||||
me.sphero.detectCollisions()
|
||||
me.sphero.setRGB color
|
||||
me.sphero.stop()
|
||||
|
@ -43,7 +43,7 @@ And when our Sphero detects a collision, we want to notify the user of this via
|
|||
the console.
|
||||
|
||||
me.sphero.on 'collision', (data) ->
|
||||
Logger.info "Collision:"
|
||||
console.log "Collision:"
|
||||
|
||||
We get the new color for a Sphero by doing a bitwise XOR operation on it, using
|
||||
the bitfilter above.
|
||||
|
@ -54,7 +54,7 @@ With our new color in hand, we can let the user know what color we're using now,
|
|||
and change the Sphero to that color. We'll also tell the Sphero to roll in
|
||||
a random direction, at speed 90.
|
||||
|
||||
Logger.info "Color: #{color.toString(16)} "
|
||||
console.log "Color: #{color.toString(16)} "
|
||||
me.sphero.setRGB color
|
||||
|
||||
me.sphero.roll 90, Math.floor(Math.random() * 360)
|
||||
|
|
|
@ -6,28 +6,28 @@ Cylon.robot
|
|||
|
||||
work: (me) ->
|
||||
me.sphero.on 'connect', ->
|
||||
Logger.info "Setting up Collision Detection..."
|
||||
console.log "Setting up Collision Detection..."
|
||||
me.sphero.detectCollisions()
|
||||
me.sphero.setRGB 0x00FF00
|
||||
|
||||
me.sphero.on 'update', (data) ->
|
||||
Logger.info "Update event eventName: #{data} "
|
||||
Logger.info "Update event args: "
|
||||
Logger.info data
|
||||
console.log "Update event eventName: #{data} "
|
||||
console.log "Update event args: "
|
||||
console.log data
|
||||
|
||||
me.sphero.on 'message', (data) ->
|
||||
me.sphero.setRGB 0x0000FF
|
||||
Logger.info "Message:"
|
||||
Logger.info data
|
||||
console.log "Message:"
|
||||
console.log data
|
||||
|
||||
me.sphero.on 'collision', (data) ->
|
||||
me.sphero.setRGB 0xFF0000
|
||||
Logger.info "Collision:"
|
||||
Logger.info data
|
||||
console.log "Collision:"
|
||||
console.log data
|
||||
|
||||
me.sphero.on 'notification', (data) ->
|
||||
me.sphero.setRGB 0xFF0000
|
||||
Logger.info "Notification:"
|
||||
Logger.info data
|
||||
console.log "Notification:"
|
||||
console.log data
|
||||
|
||||
.start()
|
||||
|
|
|
@ -6,33 +6,33 @@ Cylon.robot({
|
|||
|
||||
work: function(me) {
|
||||
me.sphero.on('connect', function() {
|
||||
Logger.info("Setting up Collision Detection...");
|
||||
console.log("Setting up Collision Detection...");
|
||||
me.sphero.detectCollisions();
|
||||
me.sphero.setRGB(0x00FF00);
|
||||
});
|
||||
|
||||
me.sphero.on('update', function(data) {
|
||||
Logger.info("Update event eventName: " + data + " ");
|
||||
Logger.info("Update event args: ");
|
||||
Logger.info(data);
|
||||
console.log("Update event eventName: " + data + " ");
|
||||
console.log("Update event args: ");
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
me.sphero.on('message', function(data) {
|
||||
me.sphero.setRGB(0x0000FF);
|
||||
Logger.info("Message:");
|
||||
Logger.info(data);
|
||||
console.log("Message:");
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
me.sphero.on('collision', function(data) {
|
||||
me.sphero.setRGB(0xFF0000);
|
||||
Logger.info("Collision:");
|
||||
Logger.info(data);
|
||||
console.log("Collision:");
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
me.sphero.on('notification', function(data) {
|
||||
me.sphero.setRGB(0xFF0000);
|
||||
Logger.info("Notification:");
|
||||
Logger.info(data);
|
||||
console.log("Notification:");
|
||||
console.log(data);
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
|
|
|
@ -26,7 +26,7 @@ When the Sphero's connected, we want to set up collision detection and change
|
|||
it's color.
|
||||
|
||||
me.sphero.on 'connect', ->
|
||||
Logger.info "Setting up Collision Detection..."
|
||||
console.log "Setting up Collision Detection..."
|
||||
me.sphero.detectCollisions()
|
||||
me.sphero.setRGB 0x00FF00
|
||||
|
||||
|
@ -34,33 +34,33 @@ When the Sphero emits an 'update' event, we want to log the data it's provided
|
|||
to us:
|
||||
|
||||
me.sphero.on 'update', (data) ->
|
||||
Logger.info "Update event eventName: #{data} "
|
||||
Logger.info "Update event args: "
|
||||
Logger.info data
|
||||
console.log "Update event eventName: #{data} "
|
||||
console.log "Update event args: "
|
||||
console.log data
|
||||
|
||||
Similarly, when we get a message from the Sphero, we want to log the data, but
|
||||
we'll also change it's color while we're at it.
|
||||
|
||||
me.sphero.on 'message', (data) ->
|
||||
me.sphero.setRGB 0x0000FF
|
||||
Logger.info "Message:"
|
||||
Logger.info data
|
||||
console.log "Message:"
|
||||
console.log data
|
||||
|
||||
In the event of a collision, we want to change the color of the Sphero again, as
|
||||
well as logging the data provided by the collision event.
|
||||
|
||||
me.sphero.on 'collision', (data) ->
|
||||
me.sphero.setRGB 0xFF0000
|
||||
Logger.info "Collision:"
|
||||
Logger.info data
|
||||
console.log "Collision:"
|
||||
console.log data
|
||||
|
||||
And, last but not least, when we get a notification event we want to record it's
|
||||
data and change the color.
|
||||
|
||||
me.sphero.on 'notification', (data) ->
|
||||
me.sphero.setRGB 0xFF0000
|
||||
Logger.info "Notification:"
|
||||
Logger.info data
|
||||
console.log "Notification:"
|
||||
console.log data
|
||||
|
||||
And with all that done, we can finally start the robot.
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ class SpheroRobot
|
|||
|
||||
work: (my) ->
|
||||
every 1.seconds(), ->
|
||||
Logger.info my.name
|
||||
console.log my.name
|
||||
my.sphero.setRandomColor()
|
||||
my.sphero.roll 60, Math.floor(Math.random() * 360)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ var SpheroRobot = (function() {
|
|||
|
||||
SpheroRobot.prototype.work = function(my) {
|
||||
every((1).second(), function() {
|
||||
Logger.info(my.name);
|
||||
console.log(my.name);
|
||||
my.sphero.setRandomColor();
|
||||
my.sphero.roll(60, Math.floor(Math.random() * 360));
|
||||
});
|
||||
|
|
|
@ -31,7 +31,7 @@ name, change to a random color, and roll in a random direction.
|
|||
|
||||
work: (my) ->
|
||||
every 1.seconds(), ->
|
||||
Logger.info my.name
|
||||
console.log my.name
|
||||
my.sphero.setRandomColor()
|
||||
my.sphero.roll 60, Math.floor(Math.random() * 360)
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ Cylon.robot
|
|||
name = "cylon"
|
||||
|
||||
me.checkTravis = ->
|
||||
Logger.info "Checking repo #{user}/#{name}"
|
||||
console.log "Checking repo #{user}/#{name}"
|
||||
me.sphero.setRGB BLUE, true
|
||||
|
||||
travis.repos {
|
||||
|
|
|
@ -16,7 +16,7 @@ Cylon.robot({
|
|||
var name = "cylon"
|
||||
|
||||
me.checkTravis = function() {
|
||||
Logger.info("Checking repo "+user+"/"+name);
|
||||
console.log("Checking repo "+user+"/"+name);
|
||||
me.sphero.setRGB(BLUE, true);
|
||||
|
||||
travis.repos(
|
||||
|
|
|
@ -65,7 +65,7 @@ on the state of the last build.
|
|||
|
||||
First, it will log that it's checking Travis to the logger:
|
||||
|
||||
Logger.info "Checking last build status for #{user}/#{name}"
|
||||
console.log "Checking last build status for #{user}/#{name}"
|
||||
|
||||
Let's set the default color of the Sphero to blue until we know what the build
|
||||
status is:
|
||||
|
|
Loading…
Reference in New Issue