LXPattern[] patterns(GLucose glucose) {
return new LXPattern[] {
-
+
// Slee
new Swarm(glucose),
new SpaceTime(glucose),
new TestTowerPattern(glucose),
new TestProjectionPattern(glucose),
new TestStripPattern(glucose),
+ new TestBassMapping(glucose),
+ new TestFloorMapping(glucose),
+ new TestSpeakerMapping(glucose),
// new TestHuePattern(glucose),
// new TestXPattern(glucose),
// new TestYPattern(glucose),
}
}
+class TestSpeakerMapping extends TestPattern {
+ TestSpeakerMapping(GLucose glucose) {
+ super(glucose);
+ }
+
+ public void run(int deltaMs) {
+ int h = 0;
+ for (Speaker speaker : model.speakers) {
+ for (Strip strip : speaker.strips) {
+ float b = 100;
+ for (Point p : strip.points) {
+ colors[p.index] = color(h % 360, 100, b);
+ b = max(0, b - 10);
+ }
+ h += 70;
+ }
+ }
+ }
+
+}
+
+class TestBassMapping extends TestPattern {
+ TestBassMapping(GLucose glucose) {
+ super(glucose);
+ }
+
+ public void run(int deltaMs) {
+ int[] strips = { 2, 1, 0, 3, 13, 12, 15, 14, 9, 8, 11, 10, 5, 4, 7, 6 };
+ int h = 0;
+ for (int si : strips) {
+ float b = 100;
+ for (Point p : model.bassBox.strips.get(si).points) {
+ colors[p.index] = color(h % 360, 100, b);
+ b = max(0, b - 10);
+ }
+ h += 70;
+ }
+ }
+}
+
+class TestFloorMapping extends TestPattern {
+ TestFloorMapping(GLucose glucose) {
+ super(glucose);
+ }
+
+ public void run(int deltaMs) {
+ int[] strutIndices = {6, 5, 4, 3, 2, 1, 0, 7};
+ int h = 0;
+ for (int si : strutIndices) {
+ float b = 100;
+ for (Point p : model.bassBox.struts.get(si).points) {
+ colors[p.index] = color(h % 360, 100, b);
+ b = max(0, b - 10);
+ }
+ h += 50;
+ }
+ int[] floorIndices = {0, 1, 2, 3};
+ h = 0;
+ for (int fi : floorIndices) {
+ float b = 100;
+ for (Point p : model.boothFloor.strips.get(fi).points) {
+ colors[p.index] = color(h, 100, b);
+ b = max(0, b - 3);
+ }
+ h += 90;
+ }
+ }
+}
+
class TestStripPattern extends TestPattern {
SinLFO d = new SinLFO(4, 40, 4000);
}
public PandaMapping[] buildPandaList() {
+ final int LEFT_SPEAKER = 0;
+ final int RIGHT_SPEAKER = 1;
+
return new PandaMapping[] {
new PandaMapping(
"10.200.1.29", new ChannelMapping[] {
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }),
- new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }),
+ new ChannelMapping(),
+ new ChannelMapping(),
+ new ChannelMapping(),
+ new ChannelMapping(),
+ new ChannelMapping(),
+ new ChannelMapping(),
+ new ChannelMapping(),
+ new ChannelMapping(ChannelMapping.MODE_BASS),
+ new ChannelMapping(ChannelMapping.MODE_STRUTS_AND_FLOOR),
+ new ChannelMapping(ChannelMapping.MODE_SPEAKER, LEFT_SPEAKER),
+ new ChannelMapping(ChannelMapping.MODE_SPEAKER, RIGHT_SPEAKER),
}),
new PandaMapping(
"10.200.1.28", new ChannelMapping[] {
- new ChannelMapping(ChannelMapping.MODE_BASS),
- new ChannelMapping(ChannelMapping.MODE_FLOOR),
- new ChannelMapping(ChannelMapping.MODE_SPEAKER, 0),
- new ChannelMapping(ChannelMapping.MODE_SPEAKER, 1),
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
+ new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }),
}),
};
}
public static final int MODE_CUBES = 1;
public static final int MODE_BASS = 2;
public static final int MODE_SPEAKER = 3;
- public static final int MODE_FLOOR = 4;
+ public static final int MODE_STRUTS_AND_FLOOR = 4;
public static final int MODE_INVALID = 5;
public static final int NO_OBJECT = -1;
if (speakerIndex < 0 || speakerIndex >= glucose.model.speakers.size()) {
throw new RuntimeException("Invalid speaker channel mapping: " + speakerIndex);
}
- } else if ((mode == MODE_FLOOR) || (mode == MODE_BASS) || (mode == MODE_NULL)) {
+ } else if ((mode == MODE_STRUTS_AND_FLOOR) || (mode == MODE_BASS) || (mode == MODE_NULL)) {
if (rawObjectIndices.length > 0) {
throw new RuntimeException("Bass/floor/null mappings cannot specify object indices");
}
case ChannelMapping.MODE_SPEAKER:
drawNumBox(xPos, yPos, "S" + channel.objectIndices[0], debugState[channelNum][1]);
break;
- case ChannelMapping.MODE_FLOOR:
+ case ChannelMapping.MODE_STRUTS_AND_FLOOR:
drawNumBox(xPos, yPos, "F", debugState[channelNum][1]);
break;
case ChannelMapping.MODE_NULL:
state = debugState[channelIndex][1];
if (state != DEBUG_STATE_ANIM) {
color debugColor = (state == DEBUG_STATE_WHITE) ? white : off;
- for (Point p : glucose.model.bassBox.points) {
- colors[p.index] = debugColor;
+ for (Strip s : glucose.model.bassBox.boxStrips) {
+ for (Point p : s.points) {
+ colors[p.index] = debugColor;
+ }
}
}
break;
- case ChannelMapping.MODE_FLOOR:
+ case ChannelMapping.MODE_STRUTS_AND_FLOOR:
state = debugState[channelIndex][1];
if (state != DEBUG_STATE_ANIM) {
color debugColor = (state == DEBUG_STATE_WHITE) ? white : off;
for (Point p : glucose.model.boothFloor.points) {
colors[p.index] = debugColor;
}
+ for (Strip s : glucose.model.bassBox.struts) {
+ for (Point p : s.points) {
+ colors[p.index] = debugColor;
+ }
+ }
}
break;
};
private final static int[][] BASS_STRIP_ORDERING = {
- {0, FORWARD },
- {1, FORWARD },
- {2, FORWARD },
- {3, FORWARD },
- {4, FORWARD },
- {5, FORWARD },
- {6, FORWARD },
- {7, FORWARD },
- {8, FORWARD },
- {9, FORWARD },
- {10, FORWARD },
- {11, FORWARD },
- {12, FORWARD },
- {13, FORWARD },
- {14, FORWARD },
- {15, FORWARD },
- {16, FORWARD },
- {17, FORWARD },
- {18, FORWARD },
- {19, FORWARD },
- {20, FORWARD },
- {21, FORWARD },
- {22, FORWARD },
+ // front face, counterclockwise from bottom front left
+ {2, BACKWARD },
+ {1, BACKWARD },
+ {0, BACKWARD },
+ {3, BACKWARD },
+
+ // left face, counterclockwise from bottom front left
+ {13, BACKWARD },
+ {12, BACKWARD },
+ {15, BACKWARD },
+ {14, BACKWARD },
+
+ // back face, counterclockwise from bottom rear left
+ {9, BACKWARD },
+ {8, BACKWARD },
+ {11, BACKWARD },
+ {10, BACKWARD },
+
+ // right face, counterclockwise from bottom rear right
+ {5, BACKWARD },
+ {4, BACKWARD },
+ {7, BACKWARD },
+ {6, BACKWARD },
+ };
+
+ private final static int[][] STRUT_STRIP_ORDERING = {
+ {6, BACKWARD},
+ {5, FORWARD},
+ {4, BACKWARD},
+ {3, FORWARD},
+ {2, BACKWARD},
+ {1, FORWARD},
+ {0, BACKWARD, /* dummy pixels at the end of string, remove when strip is fixed */ 4},
+ {7, FORWARD},
};
private final static int[][] FLOOR_STRIP_ORDERING = {
{0, FORWARD},
{1, FORWARD},
{2, FORWARD},
- {3, FORWARD},
+ {3, BACKWARD},
};
- private final static int[][] SPEAKER_STRIP_ORDERING = {
- {0, FORWARD },
- {1, FORWARD },
- {2, FORWARD },
- {3, FORWARD },
- {4, FORWARD },
- {5, FORWARD },
- {6, FORWARD },
- {7, FORWARD },
- {8, FORWARD },
- {9, FORWARD },
- {10, FORWARD },
- {11, FORWARD },
- {12, FORWARD },
- {13, FORWARD },
- {14, FORWARD },
- {15, FORWARD },
+ // The speakers are currently configured to be wired the same
+ // as cubes with Wiring.FRONT_LEFT. If this needs to be changed,
+ // remove this null assignment and change the below to have mappings
+ // for the LEFT and RIGHT speaker
+ private final static int[][][] SPEAKER_STRIP_ORDERING = null; /* {
+ // Left speaker
+ {
+ // Front face, counter-clockwise from bottom left
+ {2, BACKWARD },
+ {1, BACKWARD },
+ {0, BACKWARD },
+ {3, BACKWARD },
+ },
+ // Right speaker
+ {
+ // Front face, counter-clockwise from bottom left
+ {2, BACKWARD },
+ {1, BACKWARD },
+ {0, BACKWARD },
+ {3, BACKWARD },
+ }
+ };*/
+
+ private final static int[][] LEFT_SPEAKER_STRIP_ORDERING = {
};
public PandaDriver(String ip, Model model, PandaMapping pm) {
case ChannelMapping.MODE_BASS:
for (int[] config : BASS_STRIP_ORDERING) {
pi = mapStrip(model.bassBox.strips.get(config[0]), config[1], points, pi);
+ if (config.length >= 3) pi += config[2];
}
break;
- case ChannelMapping.MODE_FLOOR:
+ case ChannelMapping.MODE_STRUTS_AND_FLOOR:
+ for (int[] config : STRUT_STRIP_ORDERING) {
+ pi = mapStrip(model.bassBox.struts.get(config[0]), config[1], points, pi);
+ if (config.length >= 3) pi += config[2];
+ }
for (int[] config : FLOOR_STRIP_ORDERING) {
pi = mapStrip(model.boothFloor.strips.get(config[0]), config[1], points, pi);
+ if (config.length >= 3) pi += config[2];
}
break;
case ChannelMapping.MODE_SPEAKER:
- for (int[] config : SPEAKER_STRIP_ORDERING) {
+ int [][] speakerStripOrdering;
+ if (SPEAKER_STRIP_ORDERING == null) {
+ // Copy the cube strip ordering
+ int[] frontLeftCubeWiring = CUBE_STRIP_ORDERINGS[0];
+ speakerStripOrdering = new int[frontLeftCubeWiring.length][];
+ for (int i = 0; i < frontLeftCubeWiring.length; ++i) {
+ speakerStripOrdering[i] = new int[] { frontLeftCubeWiring[0], BACKWARD };
+ }
+ } else {
+ speakerStripOrdering = SPEAKER_STRIP_ORDERING[channel.objectIndices[0]];
+ }
+ for (int[] config : speakerStripOrdering) {
Speaker speaker = model.speakers.get(channel.objectIndices[0]);
pi = mapStrip(speaker.strips.get(config[0]), config[1], points, pi);
+ if (config.length >= 3) pi += config[2];
}
break;
return pi;
}
+ public void disable() {
+ if (enabled) {
+ enabled = false;
+ println("PandaBoard/" + ip + ": OFF");
+ }
+ }
+
+ public void enable() {
+ if (!enabled) {
+ enabled = true;
+ println("PandaBoard/" + ip + ": ON");
+ }
+ }
+
public void toggle() {
enabled = !enabled;
println("PandaBoard/" + ip + ": " + (enabled ? "ON" : "OFF"));