From: Tomas Wenström Date: Thu, 24 Aug 2017 19:27:32 +0000 (+0200) Subject: Added a light level config (0-31) for APA102 only X-Git-Url: http://dolda2000.com/gitweb/?p=kaka%2Fcakelight.git;a=commitdiff_plain;h=f2eedb6d98ae638d65c9bfd1a9a339a060235592 Added a light level config (0-31) for APA102 only --- diff --git a/config.properties.template b/config.properties.template index 7732340..a7e6633 100644 --- a/config.properties.template +++ b/config.properties.template @@ -14,6 +14,7 @@ video.crop.bottom=18 # Supported types: apa102, ws2801 leds.type=apa102 +leds.level=31 leds.cols=32 leds.rows=17 diff --git a/src/kaka/cakelight/Configuration.java b/src/kaka/cakelight/Configuration.java index 21c2072..4d727cc 100644 --- a/src/kaka/cakelight/Configuration.java +++ b/src/kaka/cakelight/Configuration.java @@ -98,11 +98,13 @@ public class Configuration { public class LedConfiguration { public int cols; public int rows; + public int level; public LedType type; private LedConfiguration(Properties prop) { cols = Integer.parseInt(get(prop, "leds.cols")); rows = Integer.parseInt(get(prop, "leds.rows")); + level = Math.min(0, Math.max(31, Integer.parseInt(get(prop, "leds.level", "31")))); switch (get(prop, "leds.type", "").toUpperCase()) { case "WS2801": type = LedType.WS2801; diff --git a/src/kaka/cakelight/LedFrame.java b/src/kaka/cakelight/LedFrame.java index a0e1404..cb92dab 100644 --- a/src/kaka/cakelight/LedFrame.java +++ b/src/kaka/cakelight/LedFrame.java @@ -37,7 +37,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.level)); // 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;