Skip to content

Commit

Permalink
split set color param to r, g, b
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepmistry committed Dec 24, 2014
1 parent 7489f38 commit 40a2610
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ When that returns you're finally ready to use the ble-bean api:
```
bean.requestTemp(callback);
bean.requestAccell(callback);
bean.setColor(color, callback); //where color is a buffer of r,g,b hex values
bean.setColor(r, g, b, callback); // r, g, b are 0-255/0x00 - 0xff
bean.write(data, callback); //where data is a buffer
```
Huge gotcha here though, the callback to all api commands DO NOT GIVE YOU BACK YOUR DATA, they simply confirms that the request has left your computer.
Expand Down
4 changes: 2 additions & 2 deletions examples/bean_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Bean.discover(function(bean){
var readData = function() {

//set random led colors between 0-255. I find red overpowering so red between 0-64
bean.setColor(new Buffer([getRandomInt(0,64),getRandomInt(0,255),getRandomInt(0,255)]),
bean.setColor(getRandomInt(0,64),getRandomInt(0,255),getRandomInt(0,255),
function(){
console.log("led color sent");
});
Expand Down Expand Up @@ -73,7 +73,7 @@ var exitHandler = function exitHandler() {
triedToExit = true;
console.log('Turning off led...');
clearInterval(intervalId);
connectedBean.setColor(new Buffer([0x0,0x0,0x0]), function(){});
connectedBean.setColor(0x0,0x0,0x0, function(){});
//no way to know if succesful but often behind other commands going out, so just wait 2 seconds
console.log('Disconnecting from Device...');
setTimeout(connectedBean.disconnect.bind(connectedBean, function(){}), 2000);
Expand Down
2 changes: 1 addition & 1 deletion examples/ble.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var exitHandler = function exitHandler() {
triedToExit = true;
console.log('Turning off led...');
clearInterval(intervalId);
connectedBean.setColor(new Buffer([0x0,0x0,0x0]), function(){});
connectedBean.setColor(0x0,0x0,0x0, function(){});
//no way to know if succesful but often behind other commands going out, so just wait 2 seconds
console.log('Disconnecting from Device...');
setTimeout(connectedBean.disconnect.bind(connectedBean, function(){}), 2000);
Expand Down
2 changes: 1 addition & 1 deletion examples/firmata.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var exitHandler = function exitHandler() {
triedToExit = true;
console.log('Turning off led...');
clearInterval(intervalId);
connectedBean.setColor(new Buffer([0x0,0x0,0x0]), function(){});
connectedBean.setColor(0x0,0x0,0x0, function(){});
//no way to know if succesful but often behind other commands going out, so just wait 2 seconds
console.log('Disconnecting from Device...');
setTimeout(connectedBean.disconnect.bind(connectedBean, function(){}), 2000);
Expand Down
2 changes: 1 addition & 1 deletion examples/scratch.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ var exitHandler = function exitHandler() {
triedToExit = true;
console.log('Turning off led...');
clearInterval(intervalId);
connectedBean.setColor(new Buffer([0x0,0x0,0x0]), function(){});
connectedBean.setColor(0x0,0x0,0x0, function(){});
//no way to know if succesful but often behind other commands going out, so just wait 2 seconds
console.log('Disconnecting from Device...');
setTimeout(connectedBean.disconnect.bind(connectedBean, function(){}), 2000);
Expand Down
2 changes: 1 addition & 1 deletion examples/serial.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var exitHandler = function exitHandler() {
triedToExit = true;
console.log('Turning off led...');
clearInterval(intervalId);
connectedBean.setColor(new Buffer([0x0,0x0,0x0]), function(){});
connectedBean.setColor(0x0,0x0,0x0, function(){});
//no way to know if succesful but often behind other commands going out, so just wait 2 seconds
console.log('Disconnecting from Device...');
setTimeout(connectedBean.disconnect.bind(connectedBean, function(){}), 2000);
Expand Down
4 changes: 2 additions & 2 deletions lib/Bean.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ Bean.prototype.write = function(data, done){
this.send(commands.MSG_ID_SERIAL_DATA, data, done);
}

Bean.prototype.setColor = function(color,done){
this.send(commands.MSG_ID_CC_LED_WRITE_ALL, color, done);
Bean.prototype.setColor = function(r,g,b,done){
this.send(commands.MSG_ID_CC_LED_WRITE_ALL, new Buffer([r, g, b]), done);
};

Bean.prototype.requestAccell = function(done){
Expand Down

0 comments on commit 40a2610

Please sign in to comment.