Comparing version 0.6.0 to 0.7.0
@@ -12,8 +12,39 @@ /*jslint node: true */ | ||
var pinState = 0; | ||
//every 10 seconds change pin | ||
var togglePin = function(){ | ||
console.log('toggling'); | ||
if(pinState){ | ||
pinState = 0; | ||
connectedBean.write(new Buffer([0x91,0x00,0x00]),function(error){ | ||
if(error) | ||
console.log(error); | ||
console.log('toggled', pinState); | ||
}); | ||
}else{ | ||
pinState = 1; | ||
connectedBean.write(new Buffer([0x91,0x20,0x00]),function(error){ | ||
if(error) | ||
console.log(error); | ||
console.log('toggled', pinState); | ||
}); | ||
} | ||
// board.digitalWrite(5, pinState); | ||
setTimeout(togglePin, 10000); | ||
} | ||
var readyBean = function(){ | ||
connectedBean.on("accell", function(x,y,z, valid, seq){ | ||
console.log("x:\t" + x + "\ty:\t" + y + "\tz:\t" + z ); | ||
}); | ||
togglePin(); | ||
// connectedBean.on("accell", function(x,y,z, valid, seq){ | ||
// console.log("x:\t" + x + "\ty:\t" + y + "\tz:\t" + z ); | ||
// }); | ||
connectedBean.on("read", function(data, valid, seq, size){ | ||
@@ -25,16 +56,16 @@ var status = valid ? "valid" : "invalid"; | ||
intervalId = setInterval(function() { | ||
// intervalId = setInterval(function() { | ||
//set random led colors between 0-255. I find red overpowering so red between 0-64 | ||
connectedBean.setColor(new Buffer([getRandomInt(0,64),getRandomInt(0,255),getRandomInt(0,255)]), | ||
function(){ | ||
console.log("set led"); | ||
}); | ||
// //set random led colors between 0-255. I find red overpowering so red between 0-64 | ||
// connectedBean.setColor(new Buffer([getRandomInt(0,64),getRandomInt(0,255),getRandomInt(0,255)]), | ||
// function(){ | ||
// console.log("set led"); | ||
// }); | ||
connectedBean.requestAccell( | ||
function(){ | ||
console.log("requested accell"); | ||
}); | ||
// connectedBean.requestAccell( | ||
// function(){ | ||
// console.log("requested accell"); | ||
// }); | ||
},1000); | ||
// },1000); | ||
@@ -87,4 +118,4 @@ }; | ||
console.log("found"); | ||
connectedScratch = new scratchAPI.Scratch(service); | ||
connectedScratch.on('ready', readyScratch); | ||
// connectedScratch = new scratchAPI.Scratch(service); | ||
// connectedScratch.on('ready', readyScratch); | ||
} | ||
@@ -91,0 +122,0 @@ }); |
@@ -99,10 +99,12 @@ /*jslint node: true */ | ||
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); | ||
this.send(commands.MSG_ID_CC_LED_WRITE_ALL, color, done); | ||
}; | ||
Bean.prototype.requestAccell = function(done){ | ||
var cmd = commands.MSG_ID_CC_ACCEL_READ; | ||
var payload = new Buffer([]); | ||
this.send(cmd,payload,done); | ||
this.send(commands.MSG_ID_CC_ACCEL_READ, new Buffer([]), done); | ||
}; |
{ | ||
"name": "ble-bean", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "Lightblue Bean BLE Services", | ||
@@ -5,0 +5,0 @@ "main": "lib/bean.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14671
344