Skip to content
Browse files

Source code, display case design, and sprint 2 report

  • Loading branch information...
1 parent b4128ad commit 0f15e27b3440dfb53d8315f91eb87402506ce4e4 @awentz awentz committed Nov 1, 2012
View
1,579 documents/DisplayCase.ai
1,579 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
BIN documents/Sprint 2 Report.docx
Binary file not shown.
View
49 src/renard_clojure/core.clj
@@ -0,0 +1,49 @@
+(ns renard-clojure.core
+ (:use [cheshire.core]))
+
+(use 'serial-port)
+
+
+;to avoid having to use two-byte protocol version,
+;instead, replace reserved channel values with nearby values
+(defn package-values [channel-values]
+ ;(concat [0x7e 0x80]
+ (replace {0x7d 0x7c 0x7e 0x7c 0x7f 0x80} channel-values))
+
+
+(defn create-packets [pkg channel-count]
+ (loop [x (quot (count pkg) channel-count) rpkg pkg result []]
+ (if (>= x 0)
+ (recur (- x 1) (drop channel-count rpkg) (concat result [0x7e 0x80] (take channel-count rpkg)))
+ result)))
+
+
+;pad every n values so that micro controller doesn't get behind
+(defn insert-padding [pkg n]
+ (if (> n (count pkg))
+ pkg
+ (loop [x (quot (count pkg) n) rpkg pkg result []]
+ (if (> x 0)
+ (recur (- x 1) (drop n rpkg) (concat result (take n rpkg) '(0x7f)))
+ result))))
+
+;package the channel-values into packets of size channel-count and place a pad byte every n bytes
+(defn pack-n-pad [channel-values n channel-count]
+ (insert-padding (create-packets (package-values channel-values) channel-count) n))
+
+(defn renard-open-port [port]
+ (open port))
+
+(defn renard-close-port [port]
+ (close port))
+
+;write data to port
+(defn renard-write [data port]
+ (let [d (pack-n-pad data 100 32)]
+ (write-int-seq port d)))
+
+
+(defn test-lights []
+ (dotimes [n 1000]
+ ()))
+
View
39 src/renard_clojure/osc-server.clj
@@ -0,0 +1,39 @@
+(ns renard-clojure.osc-server
+ (:use [overtone.core]
+ [renard-clojure.core]))
+
+(def renard-out :temp)
+(def port (renard-open-port "COM28"))
+
+(def channel-map (loop [n 1 result {}]
+ (if (> n 32)
+ result
+ (recur (+ n 1) (merge result {(str "/Renard/fader" n) 0})))))
+
+(zero-conf-on)
+
+(defn make-osc-server [name port]
+ (osc-server port name))
+
+(defn add-osc-handles [server]
+ (dotimes [n 33] (osc-handle server (str "/Renard/fader" n)
+ (fn [msg]
+ (do
+ (def channel-map
+ (assoc channel-map (str "/Renard/fader" n) (int (first (:args msg)))))
+ (renard-write channel-map port)
+ )))))
+
+(defn remove-osc-handles [server]
+ (osc-rm-all-handlers server "/Renard"))
+
+(defn close-osc-server [server] (osc-close server))
+
+
+
+(def server (make-osc-server "renard" 44100))
+
+(add-osc-handles server)
+
+
+

0 comments on commit 0f15e27

Please sign in to comment.
Something went wrong with that request. Please try again.