X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fkaka%2Fcakelight%2FLedFrame.java;h=a0e14049d392528ae131cc62cfae187a726ecad2;hb=14e552a7c3525d7d07aad4335465735537d12f52;hp=ab4ef5c9fa12bb825fc2a266538232c9b5d0de44;hpb=38c759f87fc7de47d9dee60088f2dbc60e0a55fb;p=kaka%2Fcakelight.git diff --git a/src/kaka/cakelight/LedFrame.java b/src/kaka/cakelight/LedFrame.java index ab4ef5c..a0e1404 100644 --- a/src/kaka/cakelight/LedFrame.java +++ b/src/kaka/cakelight/LedFrame.java @@ -1,14 +1,45 @@ package kaka.cakelight; +import java.util.Arrays; + public class LedFrame { private Configuration config; private byte[] bytes; - private int roff = 0, goff = 2, boff = 1; // Color values are stored as RBG, which is what the LED list takes. + private int stride; + private int roff, goff, boff; // RGB offsets public static LedFrame from(Configuration config) { LedFrame frame = new LedFrame(); frame.config = config; - frame.bytes = new byte[config.leds.getCount() * 3]; + 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.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: + *