Permalink
Browse files

add command chaining.

  • Loading branch information...
1 parent 7947c17 commit 51bfe0894f583d6dc04a0b9096af219a028632c9 @mick committed Sep 25, 2012
Showing with 8 additions and 2 deletions.
  1. +1 −1 Readme.md
  2. +2 −0 example/cli.js
  3. +5 −1 lib/sphero.js
View
@@ -33,7 +33,7 @@ You can install NodeJS for by downloading it from [nodejs.org](http://nodejs.org
You will need node.js 8.x (32-bit only), (node-gyp(included with node) / Python 2.x / and the build tools provided by Visual Studio 2010)
-You must use the 32bit version of nodejs, because serialprt doesnt support builds on the x64 platform, yet.
+You must use the 32bit version of nodejs, because there are issues with the serialport builds on the x64 platform.
You can install NodeJS by downloading it from [nodejs.org](http://nodejs.org/download/) Current 32bit version is available here: [http://nodejs.org/dist/v0.8.9/node-v0.8.9-x86.msi](http://nodejs.org/dist/v0.8.9/node-v0.8.9-x86.msi)
Python. Remember you want the latest 2.x releease: [python windows binaries](http://www.python.org/download/releases/)
View
@@ -37,6 +37,8 @@ sphero.on("connected", function(ball){
if(key && key.name == 'left') sphero.setHeading(315);
if(key && key.name == 'up') sphero.roll(0, 0.5);
if(key && key.name == 'down') sphero.roll(0, 0);
+ if(key && key.name == 'x') sphero.setHeading(45).setHeading(315).setBackLED(1);
+
});
process.stdin.setRawMode(true);
process.stdin.resume();
View
@@ -57,27 +57,32 @@ SpheroCollection.prototype.close = function(){
this.balls.forEach(function(ball){
ball.close();
});
+ return this;
};
SpheroCollection.prototype.setRGBLED = function(r, g, b, persist, callback){
this.balls.forEach(function(ball){
ball.setRGBLED(r,g,b,persist, callback);
});
+ return this;
};
SpheroCollection.prototype.setBackLED = function(l, callback){
this.balls.forEach(function(ball){
ball.setBackLED(l, callback);
});
+ return this;
}
SpheroCollection.prototype.setHeading = function(heading, callback) {
this.balls.forEach(function(ball){
ball.setHeading(heading, callback);
});
+ return this;
}
SpheroCollection.prototype.roll = function(heading, speed, callback) {
this.balls.forEach(function(ball){
ball.roll(heading, speed, callback);
});
+ return this;
}
var Sphero = function(dev){
@@ -111,7 +116,6 @@ var Sphero = function(dev){
});
this.incomingBuffer = null;
this.dev.on('data', function (data) {
- console.log("got data: ", data);
if (Buffer.isBuffer(self.incomingBuffer)) {
var oldBuffer = self.incomingBuffer;
self.incomingBuffer = new Buffer(oldBuffer.length + data.length);

0 comments on commit 51bfe08

Please sign in to comment.