X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fkaka%2Fcakelight%2FCommands.java;h=a5b612cf99a071c598d6bdb0bc7dfb938edb653b;hb=171e69a4005421544957603fe2d16aaa8bc41880;hp=75b1b100adab4f47edef0c70d7bd5c8962c22649;hpb=2b49e4e255f8591fb730f88e71b6b006008ccd3d;p=kaka%2Fcakelight.git diff --git a/src/kaka/cakelight/Commands.java b/src/kaka/cakelight/Commands.java index 75b1b10..a5b612c 100644 --- a/src/kaka/cakelight/Commands.java +++ b/src/kaka/cakelight/Commands.java @@ -2,6 +2,7 @@ package kaka.cakelight; import kaka.cakelight.mode.AmbientMode; import kaka.cakelight.mode.SingleColorMode; +import kaka.cakelight.mode.SunriseMode; import kaka.cakelight.mode.TwoColorNoiseMode; import kaka.cakelight.mode.VideoMode; @@ -24,10 +25,19 @@ class Commands { }; } + static Console.Command help() { + return command(new String[] {"?", "h", "help"}, (console, args) -> { + for (Console.Command c : console.getCommands()) { + System.out.println(String.join("|", c.getNames())); + } + return true; + }); + } + static Console.Command quit() { return command(new String[] {"q", "quit"}, (console, args) -> { - console.getCakelight().turnOff(); - console.out("stopping cakelight"); + console.quit(); + console.out("terminating"); return true; }); } @@ -64,7 +74,12 @@ class Commands { static Console.Command brightness() { return command(new String[] {"b", "brightness"}, (console, args) -> { if (args.length == 1) { - int b = Integer.parseInt(args[0]); + 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("-")) { + b = Math.max(console.getConfig().leds.brightness - b, 0); + } console.getConfig().leds.brightness = b; console.out("setting brightness to " + b); return true; @@ -127,4 +142,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; + } + }); + } }