From b58e5a1d7f3eb9abcd1dc9c14f8bfe668cb7ba82 Mon Sep 17 00:00:00 2001 From: Mark Slee Date: Thu, 12 Sep 2013 19:01:56 -0700 Subject: [PATCH] Remove threading stuff from PandaDriver --- _Internals.pde | 2 +- _PandaDriver.pde | 48 +++++------------------------------------------- 2 files changed, 6 insertions(+), 44 deletions(-) diff --git a/_Internals.pde b/_Internals.pde index e2291fb..6be54a4 100644 --- a/_Internals.pde +++ b/_Internals.pde @@ -249,7 +249,7 @@ void draw() { // TODO(mcslee): move into GLucose engine for (PandaDriver p : pandaBoards) { - p.sendNow(colors); + p.send(colors); } } diff --git a/_PandaDriver.pde b/_PandaDriver.pde index 2c8b96c..a65a0fe 100644 --- a/_PandaDriver.pde +++ b/_PandaDriver.pde @@ -1,11 +1,6 @@ import netP5.*; import oscP5.*; -//import hypermedia.net.*; - - - - /** * DOUBLE BLACK DIAMOND DOUBLE BLACK DIAMOND * @@ -19,24 +14,7 @@ import oscP5.*; * This class implements the output function to the Panda Boards. It * will be moved into GLucose once stabilized. */ -public static class PandaDriver extends Thread{ - int lastSeen; - void start(){super.start();} - void run(){ - while(true){ - if(queue.size()>0) { - for(int i=0; i queue; public PandaDriver(String ip, Model model, PandaMapping pm) { this(ip); - queue = new ArrayList(); - // Ok, we are initialized, time to build the array if points in order to // send out. We start at the head of our point buffer, and work our way // down. This is the order in which points will be sent down the wire. @@ -323,18 +291,13 @@ public static class PandaDriver extends Thread{ } public final void send(int[] colors) { - queue.add(colors); - } - public final void sendNow(int[] colors) { - if (!enabled || colors==null) { + if (!enabled) { return; } int len = 0; int packetNum = 0; - if(points==null) { return; } - for (int index: points) { - int c = 0; - if(index>0) { c= colors[index]; } + for (int index : points) { + int c = (index < 0) ? 0 : colors[index]; byte r = (byte) ((c >> 16) & 0xFF); byte g = (byte) ((c >> 8) & 0xFF); byte b = (byte) ((c) & 0xFF); @@ -363,7 +326,6 @@ public static class PandaDriver extends Thread{ message.add(packet.length); message.add(packet); try { - //udp.send(packet, "10.200.1.29", 9001); OscP5.flush(message, address); } catch (Exception x) { x.printStackTrace(); -- 2.34.1