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