From 8d21a72ca7b82f972caf3d6ef71760f3b0184ff3 Mon Sep 17 00:00:00 2001 From: dave griffiths Date: Thu, 12 Feb 2015 15:07:38 +0000 Subject: [PATCH] gpio/osc/jellyfish comms --- pattern-matrix/pattern-matrix.py | 14 +++++++++----- pattern-matrix/wwloomsim.scm | 10 +++++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/pattern-matrix/pattern-matrix.py b/pattern-matrix/pattern-matrix.py index 1ba1bed..27bb8a7 100644 --- a/pattern-matrix/pattern-matrix.py +++ b/pattern-matrix/pattern-matrix.py @@ -6,7 +6,7 @@ driver.init() print(driver.read_all()) -def send_weave_structure(blocks): +def send_weave_structure(blocks,last): weave = [blocks[0],blocks[1],blocks[2],blocks[3], blocks[8],blocks[9],blocks[10],blocks[11], blocks[16],blocks[17],blocks[18],blocks[19], @@ -14,10 +14,14 @@ def send_weave_structure(blocks): conv = reduce(lambda r,e: r+"0 " if e==0 else r+"1 ", weave,"") - osc.Message("/eval",["(with-primitive warp \n (write-into-executable! \n warp-draft-start \n (list "+conv+")))\n"+ - "(with-primitive weft \n (write-into-executable! \n weft-draft-start \n (list "+conv+")))"]).sendlocal(8000) + if last!=conv: + last=conv + osc.Message("/eval",["(with-primitive warp \n (set-draft! \n warp-draft-start \n (list "+conv+")))\n"+ + "(with-primitive weft \n (set-draft! \n weft-draft-start \n (list "+conv+")))"]).sendlocal(8000) + return last +last = "" while 1: - send_weave_structure(driver.read_all()) - time.sleep(1) + last=send_weave_structure(driver.read_all(),last) + time.sleep(0.5) diff --git a/pattern-matrix/wwloomsim.scm b/pattern-matrix/wwloomsim.scm index bf1fe68..48a66c4 100644 --- a/pattern-matrix/wwloomsim.scm +++ b/pattern-matrix/wwloomsim.scm @@ -242,12 +242,12 @@ (define weft-draft-start 15) (define warp-draft-start 14) -(define (write-into-executable! start data) +(define (set-draft! start data) (when (not (null? data)) (pdata-set! "x" start (if (zero? (car data)) (vector 0 0 0) (vector 1 0 0))) - (write-into-executable! (+ start 1) (cdr data)))) + (set-draft! (+ start 1) (cdr data)))) (msg "hello") @@ -257,7 +257,11 @@ (pdata-set! "x" 11 (with-primitive weft - (pdata-ref "x" 12)))) + (pdata-ref "x" 12))) + (pdata-set! + "x" 12 (with-primitive + weft + (pdata-ref "x" 13)))) (with-primitive weft -- GitLab