Turn off lights when exiting
authorTomas Wenström <tomas.wenstrom@gmail.com>
Mon, 4 Sep 2017 14:16:32 +0000 (16:16 +0200)
committerTomas Wenström <tomas.wenstrom@gmail.com>
Mon, 4 Sep 2017 14:16:32 +0000 (16:16 +0200)
src/kaka/cakelight/CakeLight.java
src/kaka/cakelight/Console.java
src/kaka/cakelight/LedFrame.java

index 6a00a37..69f6677 100644 (file)
@@ -39,4 +39,9 @@ public class CakeLight {
 //     byte[] data = frame.getData();
 //     saveFile(data, "/home/kaka/test.img");
     }
+
+    public void turnOff() {
+        cleanup();
+        ledController.onFrame(LedFrame.from(config));
+    }
 }
index a856203..fef4301 100644 (file)
@@ -33,7 +33,7 @@ public class Console extends Thread {
                    config.leds.brightness = Integer.parseInt(split[1]);
                    System.out.println("setting brightness to " + split[1]);
                } else if (input.matches("q|quit")) {
-                   cakelight.cleanup();
+                   cakelight.turnOff();
                    System.out.println("stopping cakelight");
                    break;
                }
index 546e78b..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;