From: Tomas Wenström Date: Tue, 9 Apr 2019 17:50:17 +0000 (+0200) Subject: Added config for turning off lists X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=6a03452e2520ad9d3b2a9d7e1932bb93e696380d;p=kaka%2Fcakelight.git Added config for turning off lists --- diff --git a/config.properties.template b/config.properties.template index d7333fb..532e6a0 100644 --- a/config.properties.template +++ b/config.properties.template @@ -12,6 +12,11 @@ video.crop.right=29 video.crop.top=18 video.crop.bottom=18 +video.list.top=on +video.list.bottom=on +video.list.left=on +video.list.right=on + # Supported types: apa102, ws2801 leds.type=apa102 # LED brightness: 1-31 diff --git a/src/kaka/cakelight/Configuration.java b/src/kaka/cakelight/Configuration.java index 4f1525c..a68bb39 100644 --- a/src/kaka/cakelight/Configuration.java +++ b/src/kaka/cakelight/Configuration.java @@ -54,6 +54,7 @@ public class Configuration { public int bpp; public int format; public CropConfiguration crop; + public ListConfiguration list; private VideoConfiguration(Properties prop) { width = Integer.parseInt(get(prop, "video.width", "720")); @@ -70,6 +71,7 @@ public class Configuration { format = Imgproc.COLOR_YUV2BGR_UYVY; } crop = new CropConfiguration(prop); + list = new ListConfiguration(prop); } public class CropConfiguration { @@ -82,6 +84,17 @@ public class Configuration { bottom = Integer.parseInt(get(prop, "video.crop.bottom", "0")); } } + + public class ListConfiguration { + public boolean top, bottom, left, right; + + private ListConfiguration(Properties prop) { + top = get(prop, "video.list.top", "on").equals("on"); + bottom = get(prop, "video.list.bottom", "on").equals("on"); + left = get(prop, "video.list.left", "on").equals("on"); + right = get(prop, "video.list.right", "on").equals("on"); + } + } } public class LedConfiguration { diff --git a/src/kaka/cakelight/VideoFrame.java b/src/kaka/cakelight/VideoFrame.java index 30d8593..e77dcd9 100644 --- a/src/kaka/cakelight/VideoFrame.java +++ b/src/kaka/cakelight/VideoFrame.java @@ -172,10 +172,10 @@ public class VideoFrame { public LedFrame getLedFrame() { LedFrame frame = LedFrame.from(config); int led = 0; - for (int i = 0; i < config.leds.cols; i++) frame.setLedColor(led++, wrappedGetLedColor(ListPosition.BOTTOM, i)); - for (int i = config.leds.rows - 1; i >= 0; i--) frame.setLedColor(led++, wrappedGetLedColor(ListPosition.RIGHT, i)); - for (int i = config.leds.cols - 1; i >= 0; i--) frame.setLedColor(led++, wrappedGetLedColor(ListPosition.TOP, i)); - 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)); + 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)); return frame; } }