From d2eb7afda88d1b49e20c12da00dacf56df8cbc92 Mon Sep 17 00:00:00 2001 From: Richard Z Date: Fri, 24 Feb 2012 22:02:09 -0800 Subject: [PATCH] Outdated button down detection I'm guessing du.ino was changed recently, because this button detection logic was wrong in two different ways: - m[1] is actually a 2 character string, so comparing it to '0' and '1' will always fail - it had the values for up and down reversed. It makes sense that 1 be down and 0 be up, but I'm not sure where you want the fix for the two character value. --- lib/button.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/button.js b/lib/button.js index b4f3660..eb886ae 100644 --- a/lib/button.js +++ b/lib/button.js @@ -19,13 +19,13 @@ var Button = function (options) { this.board.on('data', function (m) { m = m.slice(0, -1).split('::'); if (m.length > 1 && m[0] == self.pin) { - // 1 is up - // 0 is down - if (m[1] == '1' && self.down) { + // 0 is up + // 1 is down + if (m[1] == 0 && self.down) { self.down = false; self.emit('up'); } - if (m[1] == '0' && !self.down) { + if (m[1] == 1 && !self.down) { self.down = true; self.emit('down'); }