// List of point indices on the board
private final int[] points;
+
+ // How many channels are on the panda board
+ private final static int CHANNELS_PER_BOARD = 8;
+
+ // How many cubes per channel xc_PB is configured for
+ private final static int CUBES_PER_CHANNEL = 4;
// Packet data
- private final byte[] packet = new byte[4*352]; // TODO: de-magic-number
+ private final byte[] packet = new byte[4*352]; // TODO: de-magic-number, UDP related?
public PandaDriver(NetAddress address, Model model, int[][] channelList) {
this.address = address;
private ArrayList<Integer> buildMappedList(Model model, int[][] channelList) {
ArrayList<Integer> points = new ArrayList<Integer>();
- for (int[] channel : channelList) {
- for (int cubeNumber : channel) {
+ for (int chi = 0; chi < CHANNELS_PER_BOARD; ++chi) {
+ int[] channel = (chi < channelList.length) ? channelList[chi] : new int[]{};
+ for (int ci = 0; ci < CUBES_PER_CHANNEL; ++ci) {
+ int cubeNumber = (ci < channel.length) ? channel[ci] : 0;
if (cubeNumber == 0) {
for (int i = 0; i < (Cube.FACES_PER_CUBE*Face.STRIPS_PER_FACE*Strip.POINTS_PER_STRIP); ++i) {
points.add(0);
// Flush once packet is full buffer size
if (len >= packet.length) {
- sendPacket(packetNum++, len);
+ sendPacket(packetNum++);
len = 0;
}
}
// Flush any remaining data
if (len > 0) {
- sendPacket(packetNum++, len);
+ sendPacket(packetNum++);
}
}
- private void sendPacket(int packetNum, int len) {
+ private void sendPacket(int packetNum) {
message.clearArguments();
message.add(packetNum);
- message.add(len);
+ message.add(packet.length);
message.add(packet);
try {
OscP5.flush(message, address);