From a276d5abce63f4d7b54ae59a026730fdf7591b85 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tomas=20Wenstr=C3=B6m?= Date: Mon, 4 Sep 2017 16:16:32 +0200 Subject: [PATCH] Turn off lights when exiting --- src/kaka/cakelight/CakeLight.java | 5 +++++ src/kaka/cakelight/Console.java | 2 +- src/kaka/cakelight/LedFrame.java | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/kaka/cakelight/CakeLight.java b/src/kaka/cakelight/CakeLight.java index 6a00a37..69f6677 100644 --- a/src/kaka/cakelight/CakeLight.java +++ b/src/kaka/cakelight/CakeLight.java @@ -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)); + } } diff --git a/src/kaka/cakelight/Console.java b/src/kaka/cakelight/Console.java index a856203..fef4301 100644 --- a/src/kaka/cakelight/Console.java +++ b/src/kaka/cakelight/Console.java @@ -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; } diff --git a/src/kaka/cakelight/LedFrame.java b/src/kaka/cakelight/LedFrame.java index 546e78b..18b8f22 100644 --- a/src/kaka/cakelight/LedFrame.java +++ b/src/kaka/cakelight/LedFrame.java @@ -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; -- 2.11.0