From: Mark Slee Date: Sun, 11 Aug 2013 00:33:54 +0000 (-0700) Subject: Fix mapping output to use correct number of channels/cubes no matter what is in mappi... X-Git-Url: https://git.piment-noir.org/?p=SugarCubes.git;a=commitdiff_plain;h=b0071f510add65f1d6318492a00adc692a97bc41 Fix mapping output to use correct number of channels/cubes no matter what is in mapping file --- diff --git a/_Internals.pde b/_Internals.pde index fa7ecc1..d51463c 100644 --- a/_Internals.pde +++ b/_Internals.pde @@ -213,8 +213,8 @@ void draw() { // TODO(mcslee): move into GLucose engine if (pandaBoardsEnabled) { - pandaFront.send(colors); - // pandaRear.send(colors); + // pandaFront.send(colors); + pandaRear.send(colors); } } diff --git a/_Mappings.pde b/_Mappings.pde index 20c6db5..47e4d2e 100644 --- a/_Mappings.pde +++ b/_Mappings.pde @@ -131,27 +131,27 @@ class SCMapping implements GLucose.Mapping { public int[][] buildFrontChannelList() { return new int[][] { - { 1, 2, 3, 4, 0 }, // ch1 - { 5, 6, 7, 8, 0 }, // ch2 - { 9, 10, 11, 12, 0 }, // ch3 - { 13, 14, 15, 16, 0 }, // ch4 - { 17, 18, 19, 20, 0 }, // ch5 - { 21, 22, 23, 24, 0 }, // ch6 - { 25, 26, 27, 28, 0 }, // ch7 - { 29, 30, 31, 32, 0 }, // ch8 + { 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 int[][] buildRearChannelList() { return new int[][] { - { 33, 34, 35, 36, 0 }, // ch9 - { 37, 38, 39, 40, 0 }, // ch10 - { 41, 42, 43, 44, 0 }, // ch11 - { 45, 46, 47, 48, 0 }, // ch12 - { 49, 50, 51, 52, 0 }, // ch13 - { 53, 54, 55, 56, 0 }, // ch14 - { 57, 58, 59, 60, 0 }, // ch15 - { 61, 62, 63, 64, 0 }, // ch16 + { 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 }; } } diff --git a/_PandaDriver.pde b/_PandaDriver.pde index 01b7169..5e37ccb 100644 --- a/_PandaDriver.pde +++ b/_PandaDriver.pde @@ -24,9 +24,15 @@ public class PandaDriver { // 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; @@ -41,8 +47,10 @@ public class PandaDriver { private ArrayList buildMappedList(Model model, int[][] channelList) { ArrayList points = new ArrayList(); - 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);