Few tiny cleanups
[SugarCubes.git] / _Grizzly.pde
index cc7dec87c235f1400444b948df5acdba13955907..25d390f07fba7d653039521539f7dabd395a2ca4 100644 (file)
@@ -8,25 +8,33 @@
  *
  *        EXPERTS ONLY!!              EXPERTS ONLY!!
  *
- * If you are an artist, you may ignore this file! It just sets
- * up the framework to run the patterns. Should not need modification
- * for general animation work.
+ * If you are an artist, you may ignore this file! It contains
+ * the code to drive grizzly board outputs.
  */
 
 GrizzlyOutput[] buildGrizzlies() throws SocketException, UnknownHostException {
   return new GrizzlyOutput[] {
-    new GrizzlyOutput(lx, "192.168.88.100", 1, 2, 3, 4, 5, 6, 7, 8),
-    new GrizzlyOutput(lx, "192.168.88.101", 9, 10, 11, 12, 13, 14, 15, 16),
+    new GrizzlyOutput(lx, "192.168.88.100", 6, 5, 6, 7, 7, 8, 1, 2, 4, 3, 11, 10, 9, 9, 12, 13),
+    new GrizzlyOutput(lx, "192.168.88.101", 25, 23, 24, 43, 45, 44, 1, 1, 1, 1, 1, 41, 42, 21, 20, 22),
+    new GrizzlyOutput(lx, "192.168.88.104", 26, 28, 27, 19, 18, 17, 1, 1, 18, 19, 15, 16, 14, 29, 30, 31),
+    new GrizzlyOutput(lx, "192.168.88.105", 1, 1, 1, 39, 38, 40, 34, 35, 33, 32, 37, 37, 1, 1, 1, 1),
   };
 }
 
+/**
+ * Grizzly Output, sends packets to one grizzly board with a fixed IP and a number
+ * of channels.
+ */
 class GrizzlyOutput extends LXDatagramOutput {
 
+  public final String ipAddress;
+  
   private int frameNumber = 0;
   
-  GrizzlyOutput(LX lx, String ipAddress, int ... cubeIndices) throws UnknownHostException, SocketException {
+  public GrizzlyOutput(LX lx, String ipAddress, int ... cubeIndices) throws UnknownHostException, SocketException {
     super(lx);
-    int channelNum = 1;
+    this.ipAddress = ipAddress;
+    int channelNum = 0;
     for (int rawCubeIndex : cubeIndices) {
       if (rawCubeIndex > 0) {
         Cube cube = model.getCubeByRawIndex(rawCubeIndex);
@@ -34,6 +42,7 @@ class GrizzlyOutput extends LXDatagramOutput {
       }
       ++channelNum;
     }
+    this.enabled.setValue(false);
   }
   
   protected void beforeSend(int[] colors) {
@@ -45,6 +54,9 @@ class GrizzlyOutput extends LXDatagramOutput {
   }
 }
 
+/**
+ * Datagram to a Grizzlyboard. A simple fixed OSC packet.
+ */
 static class GrizzlyDatagram extends LXDatagram {
   
   private static byte[] oscString(String s) {