X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fkaka%2Fcakelight%2FCommands.java;h=38fb77e8ac522f7818cae90fb4adccaf5648f3a3;hb=40a06a9bffb56d41e931038fcfdb8f10fe8ca441;hp=048e6c6da9ca6511ced3054dcd6f18a8f1e24840;hpb=c6384b556c76a6a8e13ee4562664230fe1a3c3a1;p=kaka%2Fcakelight.git diff --git a/src/kaka/cakelight/Commands.java b/src/kaka/cakelight/Commands.java index 048e6c6..38fb77e 100644 --- a/src/kaka/cakelight/Commands.java +++ b/src/kaka/cakelight/Commands.java @@ -1,9 +1,6 @@ package kaka.cakelight; -import kaka.cakelight.mode.AmbientMode; -import kaka.cakelight.mode.SingleColorMode; -import kaka.cakelight.mode.TwoColorNoiseMode; -import kaka.cakelight.mode.VideoMode; +import kaka.cakelight.mode.*; import java.util.function.BiFunction; @@ -64,7 +61,7 @@ class Commands { static Console.Command brightness() { return command(new String[] {"b", "brightness"}, (console, args) -> { if (args.length == 1) { - int b = Integer.parseInt(args[0].replaceAll("\\+-", "")); + int b = Integer.parseInt(args[0].replaceAll("[+-]+", "")); if (args[0].startsWith("+")) { b = Math.min(console.getConfig().leds.brightness + b, 31); } else if (args[0].startsWith("-")) { @@ -132,4 +129,17 @@ class Commands { } }); } + + static Console.Command sunriseMode() { + return command(new String[] {"sunrise"}, (console, args) -> { + if (args.length == 1) { + int durationSeconds = Integer.parseInt(args[0]); + console.getCakelight().setMode(new SunriseMode(durationSeconds)); + console.out("setting sunrise mode with duration " + durationSeconds); + return true; + } else { + return false; + } + }); + } }