From a4fb845a65eb734bc9ee681e4756cf1a405c4ac8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tomas=20Wenstr=C3=B6m?= Date: Tue, 9 Apr 2019 20:05:43 +0200 Subject: [PATCH] Bugfix - draw leds black when list is off instead of skipping --- src/kaka/cakelight/Color.java | 2 ++ src/kaka/cakelight/VideoFrame.java | 25 +++++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/kaka/cakelight/Color.java b/src/kaka/cakelight/Color.java index fe010c7..c3f782f 100644 --- a/src/kaka/cakelight/Color.java +++ b/src/kaka/cakelight/Color.java @@ -1,6 +1,8 @@ package kaka.cakelight; public class Color { + public static final Color BLACK = Color.rgb(0, 0, 0); + private static int[] gammaCorrection = new int[256]; public static void calculateGammaCorrection(double gamma) { diff --git a/src/kaka/cakelight/VideoFrame.java b/src/kaka/cakelight/VideoFrame.java index e77dcd9..6435242 100644 --- a/src/kaka/cakelight/VideoFrame.java +++ b/src/kaka/cakelight/VideoFrame.java @@ -172,10 +172,27 @@ public class VideoFrame { public LedFrame getLedFrame() { LedFrame frame = LedFrame.from(config); int led = 0; - if (config.video.list.bottom) for (int i = 0; i < config.leds.cols; i++) frame.setLedColor(led++, wrappedGetLedColor(ListPosition.BOTTOM, i)); - if (config.video.list.right) for (int i = config.leds.rows - 1; i >= 0; i--) frame.setLedColor(led++, wrappedGetLedColor(ListPosition.RIGHT, i)); - if (config.video.list.top) for (int i = config.leds.cols - 1; i >= 0; i--) frame.setLedColor(led++, wrappedGetLedColor(ListPosition.TOP, i)); - if (config.video.list.left) for (int i = 0; i < config.leds.rows; i++) frame.setLedColor(led++, wrappedGetLedColor(ListPosition.LEFT, i)); + + if (config.video.list.bottom) + for (int i = 0; i < config.leds.cols; i++) frame.setLedColor(led++, wrappedGetLedColor(ListPosition.BOTTOM, i)); + else + for (int i = 0; i < config.leds.cols; i++) frame.setLedColor(led++, Color.BLACK); + + if (config.video.list.right) + for (int i = config.leds.rows - 1; i >= 0; i--) frame.setLedColor(led++, wrappedGetLedColor(ListPosition.RIGHT, i)); + else + for (int i = config.leds.rows - 1; i >= 0; i--) frame.setLedColor(led++, Color.BLACK); + + if (config.video.list.top) + for (int i = config.leds.cols - 1; i >= 0; i--) frame.setLedColor(led++, wrappedGetLedColor(ListPosition.TOP, i)); + else + for (int i = config.leds.cols - 1; i >= 0; i--) frame.setLedColor(led++, Color.BLACK); + + if (config.video.list.left) + for (int i = 0; i < config.leds.rows; i++) frame.setLedColor(led++, wrappedGetLedColor(ListPosition.LEFT, i)); + else + for (int i = 0; i < config.leds.rows; i++) frame.setLedColor(led++, Color.BLACK); + return frame; } } -- 2.11.0