Permalink
Browse files

fixed digital read and bumped version

  • Loading branch information...
1 parent 1e27eb8 commit 75f3e769720b0c6dd159a54d1f090b29ee303910 @jgautier jgautier committed Jun 8, 2011
Showing with 4 additions and 5 deletions.
  1. +3 −4 lib/firmata.js
  2. +1 −1 package.json
View
@@ -63,14 +63,13 @@ var Board=function(port,callback){
board.emit('analog-read',{pin:port,value:value});
}else if(cmd == DIGITAL_MESSAGE){
var port = (board.currentBuffer[0]&0x0F);
- var lsb = board.currentBuffer[1];
- var msb = board.currentBuffer[2];
- var mask = (msb << 7) + lsb;
+ var portValue = board.currentBuffer[1]|(board.currentBuffer[2] << 7);
for(var i = 0; i < 8; i++){
var pinNumber = 8*port+i;
var pin = board.pins[pinNumber];
if(pin.mode == board.MODES.INPUT){
- pin.value = ((mask & 1) << pinNumber)>0?1:0;
+ console.log(portValue);
+ pin.value = (portValue >> (i & 0x07)) & 0x01;
board.emit('digital-read-'+pinNumber,pin.value);
board.emit('digital-read',{pin: pinNumber,value:pin.value});
}
View
@@ -1,6 +1,6 @@
{ "name" : "firmata"
, "description" : "A library to control an arduino running firmata"
-, "version" : "0.1.1"
+, "version" : "0.1.2"
, "author" : "Julian Gautier"
, "homepage" : "http://www.github.com/jgautier/firmata"
, "repository" :

0 comments on commit 75f3e76

Please sign in to comment.