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;
}
}
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();
}
}
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();
}
int targetFramerate = 60;
int startMillis, lastMillis;
+SCMapping mapping;
GLucose glucose;
HeronLX lx;
MappingTool mappingTool;
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");
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
* 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
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;
}
}
+
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) {
public void toggle() {
enabled = !enabled;
- println("PandaBoard/" + ip + " Output: " + (enabled ? "ON" : "OFF"));
+ println("PandaBoard Output/" + ip + ": " + (enabled ? "ON" : "OFF"));
}
private ArrayList<Integer> buildMappedList(Model model, int[][] channelList) {