1 package kaka.cakelight;
3 public class LedFrame {
5 private int roff = 0, goff = 2, boff = 1; // Color values are stored as RBG, which is what the LED list takes.
7 public static LedFrame from(Configuration config) {
8 LedFrame frame = new LedFrame();
9 frame.bytes = new byte[config.leds.getCount() * 3];
13 public void fillColor(int r, int g, int b) {
14 for (int i = 0; i < bytes.length; i += 3) {
15 bytes[i + roff] = (byte)r;
16 bytes[i + goff] = (byte)g;
17 bytes[i + boff] = (byte)b;
21 public void fillColor(Color color) {
22 fillColor(color.r(), color.g(), color.b());
25 public void setLedColor(int led, Color color) {
27 bytes[offset + roff] = (byte)color.r();
28 bytes[offset + goff] = (byte)color.g();
29 bytes[offset + boff] = (byte)color.b();
32 public Color getLedColor(int led) {
35 bytes[offset + roff] & 0xff,
36 bytes[offset + goff] & 0xff,
37 bytes[offset + boff] & 0xff
41 public byte[] getBytes() {