Skip to content

Commit

Permalink
Button: limit dataHandler call to changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Jun 18, 2015
1 parent c3d83e7 commit 3da536c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ var Controllers = {
this.io.digitalWrite(this.pin, this.io.HIGH);
}

this.io.digitalRead(this.pin, dataHandler);
var last = null;

this.io.digitalRead(this.pin, function(data) {
if (data !== last) {
dataHandler(data);
}
last = data;
});
}
},
toBoolean: {
Expand Down

0 comments on commit 3da536c

Please sign in to comment.