Clean up some stuff now that we know each pandaboard has fixed # of channels
authorMark Slee <mcslee@Mark-Slees-MacBook-Pro.local>
Sun, 11 Aug 2013 02:07:39 +0000 (19:07 -0700)
committerMark Slee <mcslee@Mark-Slees-MacBook-Pro.local>
Sun, 11 Aug 2013 02:07:39 +0000 (19:07 -0700)
TestPatterns.pde
_Overlay.pde

index 52e8ea45f72a2929cf371b55ef38be3834b0df4e..733494541ec28d1c5e6fce48ea7612007c2b1530 100644 (file)
@@ -187,23 +187,13 @@ class MappingTool extends SCPattern {
   MappingTool(GLucose glucose, PandaMapping[] pandaMappings) {
     super(glucose);
     this.pandaMappings = pandaMappings;
-    int totalChannels = 0;
-    for (PandaMapping pm : pandaMappings) {
-       totalChannels += pm.channelList.length;
-    }
-    numChannels = totalChannels;
+    numChannels = pandaMappings.length * PandaMapping.CHANNELS_PER_BOARD;
     setChannel();
   }
   
   private void setChannel() {
-    mappingChannelIndex = channelIndex;
-    for (PandaMapping pm : pandaMappings) {
-      if (mappingChannelIndex < pm.channelList.length) {
-        activeMapping = pm;
-        break;
-      }
-      mappingChannelIndex -= pm.channelList.length;
-    }
+    mappingChannelIndex = channelIndex % PandaMapping.CHANNELS_PER_BOARD;
+    activeMapping = pandaMappings[channelIndex / PandaMapping.CHANNELS_PER_BOARD];
   }
   
   private int cubeInChannel(Cube c) {
index a07db2c0d5a7ce6db55577d6d12d02eee37a9b6d..5bafe290aee9ac51b03bf4c0ac6e4b04e5e63382 100644 (file)
@@ -713,10 +713,7 @@ class DebugUI {
   final int DEBUG_STATE_OFF = 2;
   
   DebugUI(PandaMapping[] pandaMappings) {
-    int totalChannels = 0;
-    for (PandaMapping pm : pandaMappings) {
-      totalChannels += pm.channelList.length;
-    }
+    int totalChannels = pandaMappings.length * PandaMapping.CHANNELS_PER_BOARD;
     channelList = new int[totalChannels][];
     int channelIndex = 0;
     for (PandaMapping pm : pandaMappings) {
@@ -731,7 +728,7 @@ class DebugUI {
     }
   }
   
-  void draw() {
+  void draw() {    
     noStroke();
     int xBase = debugX;
     int yPos = debugY;