+ frame.config = config;
+ switch (config.leds.type) {
+ /*
+ * The WS2801 strip takes its input as a plain list of 24-bit colors in RBG order (at least mine did).
+ */
+ case WS2801:
+ frame.start = 0;
+ frame.stride = 3;
+ frame.roff = 0;
+ frame.goff = 2;
+ frame.boff = 1;
+ frame.bytes = new byte[config.leds.getCount() * frame.stride];
+ break;
+
+ /*
+ * The APA102 strip takes its input as:
+ * <ol>
+ * <li>a start frame of 4 bytes (all zeroes)</li>
+ * <li>a frame of 4 bytes for each LED (111 (3 bits) + global illumination (5 bits) + BGR)</li>
+ * <li>an (optional) end frame of 4 bytes (all ones)</li>
+ * </ol>
+ */
+ case APA102:
+ frame.start = 4;
+ frame.stride = 4;
+ frame.roff = 3;
+ frame.goff = 2;
+ frame.boff = 1;
+ frame.bytes = new byte[4 + config.leds.getCount() * frame.stride + 4 * 2]; // 1 end frame doesn't seem to work, so we add another
+ Arrays.fill(frame.bytes, 4, frame.bytes.length - 9, (byte)(0b11100000 | config.leds.brightness)); // Initiate the first byte of each LED
+ Arrays.fill(frame.bytes, frame.bytes.length - 9, frame.bytes.length, (byte)0xff); // Initiate the end frame(s) with ones
+ break;
+ }