From 45f43cc2debb7f90b01e7a5c7d355218ab9cdeed Mon Sep 17 00:00:00 2001 From: Mark Slee Date: Sat, 10 Aug 2013 18:55:57 -0700 Subject: [PATCH] Change mapping and debug tools to be generic, panda mappings totally generic --- TestPatterns.pde | 37 ++++++++++++++++++------------ _Internals.pde | 22 ++++++++++-------- _Mappings.pde | 58 ++++++++++++++++++++++++++++++----------------- _Overlay.pde | 17 ++++++++------ _PandaDriver.pde | 2 +- code/GLucose.jar | Bin 18794 -> 18753 bytes 6 files changed, 82 insertions(+), 54 deletions(-) diff --git a/TestPatterns.pde b/TestPatterns.pde index acc50c7..52e8ea4 100644 --- a/TestPatterns.pde +++ b/TestPatterns.pde @@ -178,30 +178,37 @@ class MappingTool extends SCPattern { public boolean channelModeGreen = false; public boolean channelModeBlue = false; - private final static int NUM_CHANNELS = 16; + private final int numChannels; - private final int[][] frontChannels; - private final int[][] rearChannels; - private int[] activeChannels; + private final PandaMapping[] pandaMappings; + private PandaMapping activeMapping; + private int mappingChannelIndex; - MappingTool(GLucose glucose, int[][]frontChannels, int[][]rearChannels) { + MappingTool(GLucose glucose, PandaMapping[] pandaMappings) { super(glucose); - this.frontChannels = frontChannels; - this.rearChannels = rearChannels; + this.pandaMappings = pandaMappings; + int totalChannels = 0; + for (PandaMapping pm : pandaMappings) { + totalChannels += pm.channelList.length; + } + numChannels = totalChannels; setChannel(); } private void setChannel() { - if (channelIndex < frontChannels.length) { - activeChannels = frontChannels[channelIndex]; - } else { - activeChannels = rearChannels[channelIndex - frontChannels.length]; + mappingChannelIndex = channelIndex; + for (PandaMapping pm : pandaMappings) { + if (mappingChannelIndex < pm.channelList.length) { + activeMapping = pm; + break; + } + mappingChannelIndex -= pm.channelList.length; } } private int cubeInChannel(Cube c) { int i = 1; - for (int index : activeChannels) { + for (int index : activeMapping.channelList[mappingChannelIndex]) { if (c == model.getCubeByRawIndex(index)) { return i; } @@ -221,7 +228,7 @@ class MappingTool extends SCPattern { } public void strip(int delta) { - int len = Cube.FACES_PER_CUBE * Face.STRIPS_PER_FACE; + int len = Cube.STRIPS_PER_CUBE; stripIndex = (len + stripIndex + delta) % len; printInfo(); } @@ -299,14 +306,14 @@ class MappingTool extends SCPattern { } public void incChannel() { - channelIndex = (channelIndex + 1) % NUM_CHANNELS; + channelIndex = (channelIndex + 1) % numChannels; setChannel(); } public void decChannel() { --channelIndex; if (channelIndex < 0) { - channelIndex += NUM_CHANNELS; + channelIndex += numChannels; } setChannel(); } diff --git a/_Internals.pde b/_Internals.pde index e2c343a..82feb2d 100644 --- a/_Internals.pde +++ b/_Internals.pde @@ -47,6 +47,7 @@ final float BASS_Z = (TRAILER_DEPTH - BASS_DEPTH) / 2.; int targetFramerate = 60; int startMillis, lastMillis; +SCMapping mapping; GLucose glucose; HeronLX lx; MappingTool mappingTool; @@ -75,7 +76,8 @@ void setup() { logTime("Created viewport"); // Create the GLucose engine to run the cubes - glucose = new GLucose(this, new SCMapping()); + mapping = new SCMapping(); + glucose = new GLucose(this, mapping); lx = glucose.lx; lx.enableKeyboardTempo(); logTime("Built GLucose engine"); @@ -89,19 +91,19 @@ void setup() { logTime("Built transitions"); // Build output driver - int[][] frontChannels = glucose.mapping.buildFrontChannelList(); - int[][] rearChannels = glucose.mapping.buildRearChannelList(); - mappingTool = new MappingTool(glucose, frontChannels, rearChannels); - pandaBoards = new PandaDriver[] { - new PandaDriver("10.200.1.28", glucose.model, frontChannels), - new PandaDriver("10.200.1.29", glucose.model, rearChannels), - }; - logTime("Build PandaDriver"); + PandaMapping[] pandaMappings = mapping.buildPandaList(); + pandaBoards = new PandaDriver[pandaMappings.length]; + int pbi = 0; + for (PandaMapping pm : pandaMappings) { + pandaBoards[pbi++] = new PandaDriver(pm.ip, glucose.model, pm.channelList); + } + mappingTool = new MappingTool(glucose, pandaMappings); + logTime("Built PandaDriver"); // Build overlay UI ui = controlUI = new ControlUI(); mappingUI = new MappingUI(mappingTool); - debugUI = new DebugUI(frontChannels, rearChannels); + debugUI = new DebugUI(pandaMappings); logTime("Built overlay UI"); // MIDI devices diff --git a/_Mappings.pde b/_Mappings.pde index 47e4d2e..3959846 100644 --- a/_Mappings.pde +++ b/_Mappings.pde @@ -13,6 +13,7 @@ * when physical changes or tuning is being done to the structure. */ class SCMapping implements GLucose.Mapping { + public Cube[] buildCubeArray() { // TODO(mcslee): find a cleaner way of representing this data, probably // serialized in some more neutral form. also figure out what's going on @@ -129,30 +130,45 @@ class SCMapping implements GLucose.Mapping { return cubes; } - public int[][] buildFrontChannelList() { - return new int[][] { - { 1, 2, 3, 4 }, // ch1 - { 5, 6, 7, 8 }, // ch2 - { 9, 10, 11, 12 }, // ch3 - { 13, 14, 15, 16 }, // ch4 - { 17, 18, 19, 20 }, // ch5 - { 21, 22, 23, 24 }, // ch6 - { 25, 26, 27, 28 }, // ch7 - { 29, 30, 31, 32 }, // ch8 + public PandaMapping[] buildPandaList() { + return new PandaMapping[] { + new PandaMapping( + "10.200.1.28", new int[][] { + { 1, 2, 3, 4 }, // ch1 + { 5, 6, 7, 8 }, // ch2 + { 9, 10, 11, 12 }, // ch3 + { 13, 14, 15, 16 }, // ch4 + { 17, 18, 19, 20 }, // ch5 + { 21, 22, 23, 24 }, // ch6 + { 25, 26, 27, 28 }, // ch7 + { 29, 30, 31, 32 }, // ch8 + }), + + new PandaMapping( + "10.200.1.29", new int[][] { + { 33, 34, 35, 36 }, // ch9 + { 37, 38, 39, 40 }, // ch10 + { 41, 42, 43, 44 }, // ch11 + { 45, 46, 47, 48 }, // ch12 + { 49, 50, 51, 52 }, // ch13 + { 53, 54, 55, 56 }, // ch14 + { 57, 58, 59, 60 }, // ch15 + { 61, 62, 63, 64 }, // ch16 + }), + }; } +} - public int[][] buildRearChannelList() { - return new int[][] { - { 33, 34, 35, 36 }, // ch9 - { 37, 38, 39, 40 }, // ch10 - { 41, 42, 43, 44 }, // ch11 - { 45, 46, 47, 48 }, // ch12 - { 49, 50, 51, 52 }, // ch13 - { 53, 54, 55, 56 }, // ch14 - { 57, 58, 59, 60 }, // ch15 - { 61, 62, 63, 64 }, // ch16 - }; +class PandaMapping { + + final String ip; + final int[][] channelList; + + PandaMapping(String ip, int[][] channelList) { + this.ip = ip; + this.channelList = channelList; } } + diff --git a/_Overlay.pde b/_Overlay.pde index 971ffde..a07db2c 100644 --- a/_Overlay.pde +++ b/_Overlay.pde @@ -712,14 +712,17 @@ class DebugUI { final int DEBUG_STATE_WHITE = 1; final int DEBUG_STATE_OFF = 2; - DebugUI(int[][] frontChannels, int[][] rearChannels) { - channelList = new int[frontChannels.length + rearChannels.length][]; - int channelIndex = 0; - for (int[] channel : frontChannels) { - channelList[channelIndex++] = channel; + DebugUI(PandaMapping[] pandaMappings) { + int totalChannels = 0; + for (PandaMapping pm : pandaMappings) { + totalChannels += pm.channelList.length; } - for (int[] channel : rearChannels) { - channelList[channelIndex++] = channel; + channelList = new int[totalChannels][]; + int channelIndex = 0; + for (PandaMapping pm : pandaMappings) { + for (int[] channel : pm.channelList) { + channelList[channelIndex++] = channel; + } } for (int i = 0; i < debugState.length; ++i) { for (int j = 0; j < debugState[i].length; ++j) { diff --git a/_PandaDriver.pde b/_PandaDriver.pde index 5e47764..d90613e 100644 --- a/_PandaDriver.pde +++ b/_PandaDriver.pde @@ -54,7 +54,7 @@ public class PandaDriver { public void toggle() { enabled = !enabled; - println("PandaBoard/" + ip + " Output: " + (enabled ? "ON" : "OFF")); + println("PandaBoard Output/" + ip + ": " + (enabled ? "ON" : "OFF")); } private ArrayList buildMappedList(Model model, int[][] channelList) { diff --git a/code/GLucose.jar b/code/GLucose.jar index 346b56f1913f358c9d95f6a933d6f02a15ced394..c8f7976cead46ef1389223192addd90c5d5669a8 100644 GIT binary patch delta 1061 zcmZXSZAep57{|}O)2qyFwmJ3Q?W&t*zRjsq*L>ZZ&bJgLOSHlY3ZYji{7@<`=!*rq zJqAURV#^O9Xc-g~NhRe6Em%QDQYlH65x(UIQRtjI{4l$4&hMQ6`Jd-G=Q;P6n|k4< zB-It705L+r2sMC9l0?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