From 88b32726daab61ee55e0960ce314fe047b7eb010 Mon Sep 17 00:00:00 2001 From: Nurullah Akkaya Date: Wed, 29 Dec 2010 20:50:10 +0200 Subject: [PATCH] implement firmata digital-read --- src/clodiuno/firmata.clj | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/clodiuno/firmata.clj b/src/clodiuno/firmata.clj index 3c1bdf6..9599391 100644 --- a/src/clodiuno/firmata.clj +++ b/src/clodiuno/firmata.clj @@ -75,7 +75,7 @@ (.write out 1))) (if (= type :digital) (do - (.write out (bit-or REPORT-DIGITAL pin)) + (.write out (bit-or REPORT-DIGITAL (if (< pin 8) 0 1))) (.write out 1))) (.flush out))) @@ -87,8 +87,8 @@ (.write out 0))) (if (= type :digital) (do - (.write out (bit-or REPORT-DIGITAL pin)) - (.write out 0))) + (.write out (bit-or REPORT-DIGITAL (if (< pin 8) 0 1))) + (.write out 0))) (.flush out))) (defmethod pin-mode :firmata [conn pin mode] @@ -122,6 +122,9 @@ (.write (byte-array (to-byte cmd state))) (.flush)))) +(defmethod digital-read :firmata [conn pin] + ((:digital-in-state @conn) pin)) + (defmethod analog-read :firmata [conn pin] ((:analog-in-state @conn) pin))