Turn off lights when exiting
[kaka/cakelight.git] / src / kaka / cakelight / LedFrame.java
index a0e1404..18b8f22 100644 (file)
@@ -8,6 +8,9 @@ public class LedFrame {
     private int stride;
     private int roff, goff, boff; // RGB offsets
 
+    /**
+     * @return a frame initiated to black
+     */
     public static LedFrame from(Configuration config) {
         LedFrame frame = new LedFrame();
         frame.config = config;
@@ -37,7 +40,8 @@ public class LedFrame {
                 frame.goff = 2 + 4;
                 frame.boff = 1 + 4;
                 frame.bytes = new byte[4 + config.leds.getCount() * frame.stride + 4];
-                Arrays.fill(frame.bytes, 4, frame.bytes.length - 1, (byte)0xff); // Initiate the first byte of each LED + the end frame with ones
+                Arrays.fill(frame.bytes, 4, frame.bytes.length - 5, (byte)(0b11100000 | config.leds.brightness)); // Initiate the first byte of each LED
+                Arrays.fill(frame.bytes, frame.bytes.length - 5, frame.bytes.length - 1, (byte)0xff); // Initiate the end frame with ones
                 break;
         }
         return frame;