private int cubeIndex = 0;
private int stripIndex = 0;
+ private int channelIndex = 0;
- public boolean mappingModeSingleCube = true;
+ public final int MAPPING_MODE_ALL = 0;
+ public final int MAPPING_MODE_CHANNEL = 1;
+ public final int MAPPING_MODE_SINGLE_CUBE = 2;
+ public int mappingMode = MAPPING_MODE_ALL;
public final int CUBE_MODE_ALL = 0;
public final int CUBE_MODE_SINGLE_STRIP = 1;
public boolean channelModeGreen = false;
public boolean channelModeBlue = false;
- MappingTool(GLucose glucose) {
+ private final static int NUM_CHANNELS = 16;
+
+ private final int[][] frontChannels;
+ private final int[][] rearChannels;
+ private int[] activeChannels;
+
+ MappingTool(GLucose glucose, int[][]frontChannels, int[][]rearChannels) {
super(glucose);
+ this.frontChannels = frontChannels;
+ this.rearChannels = rearChannels;
+ setChannel();
+ }
+
+ private void setChannel() {
+ if (channelIndex < frontChannels.length) {
+ activeChannels = frontChannels[channelIndex];
+ } else {
+ activeChannels = rearChannels[channelIndex - frontChannels.length];
+ }
+ }
+
+ private int cubeInChannel(Cube c) {
+ int i = 1;
+ for (int index : activeChannels) {
+ if (c == model.getCubeByRawIndex(index)) {
+ return i;
+ }
+ ++i;
+ }
+ return 0;
}
private void printInfo() {
int ci = 0;
for (Cube cube : model.cubes) {
- if (!mappingModeSingleCube || (cubeIndex == ci)) {
- if (cubeMode == CUBE_MODE_STRIP_PATTERN) {
+ boolean cubeOn = false;
+ int channelIndex = cubeInChannel(cube);
+ switch (mappingMode) {
+ case MAPPING_MODE_ALL: cubeOn = true; break;
+ case MAPPING_MODE_SINGLE_CUBE: cubeOn = (cubeIndex == ci); break;
+ case MAPPING_MODE_CHANNEL: cubeOn = (channelIndex > 0); break;
+ }
+ if (cubeOn) {
+ if (mappingMode == MAPPING_MODE_CHANNEL) {
+ color cc = off;
+ switch (channelIndex) {
+ case 1: cc = r; break;
+ case 2: cc = r|g; break;
+ case 3: cc = g; break;
+ case 4: cc = b; break;
+ case 5: cc = r|b; break;
+ }
+ setColor(cube, cc);
+ } else if (cubeMode == CUBE_MODE_STRIP_PATTERN) {
int si = 0;
color sc = off;
for (Strip strip : cube.strips) {
cubeIndex += model.cubes.size();
}
}
+
+ public void incChannel() {
+ channelIndex = (channelIndex + 1) % NUM_CHANNELS;
+ setChannel();
+ }
+
+ public void decChannel() {
+ --channelIndex;
+ if (channelIndex < 0) {
+ channelIndex += NUM_CHANNELS;
+ }
+ setChannel();
+ }
public void incStrip() {
int stripsPerCube = Cube.CLIPS_PER_CUBE * Clip.STRIPS_PER_CLIP;
public void keyPressed() {
switch (keyCode) {
- case UP: incCube(); break;
- case DOWN: decCube(); break;
+ case UP: if (mappingMode == MAPPING_MODE_CHANNEL) incChannel(); else incCube(); break;
+ case DOWN: if (mappingMode == MAPPING_MODE_CHANNEL) decChannel(); else decCube(); break;
case LEFT: decStrip(); break;
case RIGHT: incStrip(); break;
}
// Set the patterns
glucose.lx.setPatterns(patterns = patterns(glucose));
- mappingTool = new MappingTool(glucose);
logTime("Built patterns");
glucose.lx.addEffects(effects = effects(glucose));
logTime("Built effects");
int[][] frontChannels = glucose.mapping.buildFrontChannelList();
int[][] rearChannels = glucose.mapping.buildRearChannelList();
int[][] flippedRGB = glucose.mapping.buildFlippedRGBList();
+ mappingTool = new MappingTool(glucose, frontChannels, rearChannels);
pandaFront = new PandaDriver(new NetAddress("192.168.1.28", 9001), glucose.model, frontChannels, flippedRGB);
pandaRear = new PandaDriver(new NetAddress("192.168.1.29", 9001), glucose.model, rearChannels, flippedRGB);
logTime("Build PandaDriver");
cubes[56] = new Cube(1, 53, 0, 40, 70, 70);
cubes[57] = new Cube(-15, 24, 0, 15, 0, 0);
//cubes[58] what the heck happened here? never noticed before 4/8/2013
- //cubes[59] what the heck happened here? never noticed before 4/8/2013
+ cubes[59] = new Cube(40, 46, 100, 0, 0, 355, false, 2, 3); // copies from 75
cubes[60] = new Cube(40, 164, 120, 0, 0, 12.5, false, 4, 3);
cubes[61] = new Cube(32, 148, 100, 0, 0, 3, false, 4, 2);
cubes[62] = new Cube(30, 132, 90, 10, 350, 5);
}
,
{
- 30, 31, 32, 17, 3 // Pandaboard B, structural channel 2
+ 31, 32, 17, 3, 0 // Pandaboard B, structural channel 2, normally 30, 31, 32, 17, 3 (disconnected 30)
}
,
{
}
,
{
- 69, 75, 74, 76, 73 // Pandaboard D, structural channel 4
+ 69, 75, 74, 76, 73 // Pandaboard D, structural channel 4, normally 64 first
}
,
{
}
,
{
- 64, 75, 72, 49, 50 // Pandaboard F, structural channel 14, right top backside
+ 64, 59, 72, 49, 50 // Pandaboard F, structural channel 14, right top backside (second cube is missing from sim)
}
,
{
// syntax is {cube #, strip #, strip #, . . . }
return new int[][] {
{
- 22, 4, 8
+ 22, 4, 7
}
,
{
}
,
{
- 15, 6, 8
+ 15, 6, 8, 9
}
,
{
{
74, 6, 7
}
+ ,
+ {
+ 21, 10
+ }
+ ,
+ {
+ 37, 11
+ }
+ ,
+ {
+ 61, 5
+ }
+ ,
+ {
+ 33, 12
+ }
};
}
}
private MappingTool mappingTool;
private final String MAPPING_MODE_ALL = "All On";
+ private final String MAPPING_MODE_CHANNEL = "Channel";
private final String MAPPING_MODE_SINGLE_CUBE = "Single Cube";
+
private final String[] mappingModes = {
MAPPING_MODE_ALL,
- MAPPING_MODE_SINGLE_CUBE,
+ MAPPING_MODE_CHANNEL,
+ MAPPING_MODE_SINGLE_CUBE
};
private final Method mappingModeStateMethod;
private int firstMappingY;
private int firstCubeY;
private int firstChannelY;
+ private int channelFieldY;
private int cubeFieldY;
private int stripFieldY;
private boolean dragCube;
private boolean dragStrip;
+ private boolean dragChannel;
MappingUI(MappingTool mappingTool) {
this.mappingTool = mappingTool;
}
public int getMappingState(Object mappingMode) {
- boolean active = (mappingMode == MAPPING_MODE_SINGLE_CUBE) == mappingTool.mappingModeSingleCube;
+ boolean active = false;
+ if (mappingMode == MAPPING_MODE_ALL) {
+ active = mappingTool.mappingMode == mappingTool.MAPPING_MODE_ALL;
+ } else if (mappingMode == MAPPING_MODE_CHANNEL) {
+ active = mappingTool.mappingMode == mappingTool.MAPPING_MODE_CHANNEL;
+ } else if (mappingMode == MAPPING_MODE_SINGLE_CUBE) {
+ active = mappingTool.mappingMode == mappingTool.MAPPING_MODE_SINGLE_CUBE;
+ }
return active ? STATE_ACTIVE : STATE_DEFAULT;
}
firstChannelY = yPos + lineHeight + 6;
yPos = drawObjectList(yPos, "CHANNELS", channelModes, channelModes, channelModeStateMethod);
yPos += sectionSpacing;
+
+ channelFieldY = yPos + lineHeight + 6;
+ yPos = drawValueField(yPos, "CHANNEL ID", mappingTool.channelIndex + 1);
+ yPos += sectionSpacing;
cubeFieldY = yPos + lineHeight + 6;
yPos = drawValueField(yPos, "CUBE ID", glucose.model.getRawIndexForCube(mappingTool.cubeIndex));
private int lastY;
public void mousePressed() {
- dragCube = dragStrip = false;
+ dragCube = dragStrip = dragChannel = false;
lastY = mouseY;
if (mouseY >= stripFieldY) {
if (mouseY < stripFieldY + lineHeight) {
if (mouseY < cubeFieldY + lineHeight) {
dragCube = true;
}
+ } else if (mouseY >= channelFieldY) {
+ if (mouseY < channelFieldY + lineHeight) {
+ dragChannel = true;
+ }
} else if (mouseY >= firstChannelY) {
int index = objectClickIndex(firstChannelY);
switch (index) {
}
} else if (mouseY >= firstMappingY) {
int index = objectClickIndex(firstMappingY);
- if (index < 2) {
- mappingTool.mappingModeSingleCube = (index > 0);
+ switch (index) {
+ case 0: mappingTool.mappingMode = mappingTool.MAPPING_MODE_ALL; break;
+ case 1: mappingTool.mappingMode = mappingTool.MAPPING_MODE_CHANNEL; break;
+ case 2: mappingTool.mappingMode = mappingTool.MAPPING_MODE_SINGLE_CUBE; break;
}
}
}
} else {
mappingTool.incStrip();
}
+ } else if (dragChannel) {
+ if (dy < 0) {
+ mappingTool.decChannel();
+ } else {
+ mappingTool.incChannel();
+ }
}
}