Skip to content

Commit

Permalink
implement firmata digital-read
Browse files Browse the repository at this point in the history
  • Loading branch information
nakkaya committed Dec 29, 2010
1 parent 77d0891 commit 88b3272
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/clodiuno/firmata.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand All @@ -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]
Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit 88b3272

Please sign in to comment.