X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fkaka%2Fcakelight%2FConfiguration.java;h=4d727cc6de67bd4f0e25897b562a42036b6d891d;hb=f2eedb6d98ae638d65c9bfd1a9a339a060235592;hp=0d7bf5bac87b8e793a03c6a60e4537acb15b8fe5;hpb=03670958a5eab132a4f1a6ae5ae58b88f55bfe2f;p=kaka%2Fcakelight.git diff --git a/src/kaka/cakelight/Configuration.java b/src/kaka/cakelight/Configuration.java index 0d7bf5b..4d727cc 100644 --- a/src/kaka/cakelight/Configuration.java +++ b/src/kaka/cakelight/Configuration.java @@ -1,5 +1,7 @@ package kaka.cakelight; +import org.opencv.imgproc.Imgproc; + import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; @@ -10,10 +12,12 @@ public class Configuration { private List> settings = new ArrayList<>(); public VideoConfiguration video; public LedConfiguration leds; + public double gamma; private Configuration(Properties prop) { video = new VideoConfiguration(prop); leds = new LedConfiguration(prop); + gamma = Double.parseDouble(get(prop,"gamma", "1")); } public static Configuration from(String propertiesFile) { @@ -59,12 +63,23 @@ public class Configuration { public int width; public int height; public int bpp; + public int format; public CropConfiguration crop; private VideoConfiguration(Properties prop) { width = Integer.parseInt(get(prop, "video.width", "720")); height = Integer.parseInt(get(prop, "video.height", "576")); bpp = Integer.parseInt(get(prop, "video.bpp", "2")); + switch (get(prop, "video.format", "").toUpperCase()) { + case "YUYV": + format = Imgproc.COLOR_YUV2BGR_YUYV; + break; + case "YVYU": + format = Imgproc.COLOR_YUV2BGR_YVYU; + break; + default: + format = Imgproc.COLOR_YUV2BGR_UYVY; + } crop = new CropConfiguration(prop); } @@ -83,10 +98,29 @@ 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; + break; + case "APA102": + default: + type = LedType.APA102; + } } + + public int getCount() { + return cols * 2 + rows * 2; + } + } + + public enum LedType { + WS2801, APA102 } }