From c8657a8d763ac80c8a6841f2a8e22be567a68ed2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tomas=20Wenstr=C3=B6m?= Date: Sun, 5 Nov 2017 20:27:04 +0100 Subject: [PATCH] Added a rainbow noise mode --- src/kaka/cakelight/AmbientMode.java | 7 +++++++ src/kaka/cakelight/Console.java | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/kaka/cakelight/AmbientMode.java b/src/kaka/cakelight/AmbientMode.java index 7836b90..35ec322 100644 --- a/src/kaka/cakelight/AmbientMode.java +++ b/src/kaka/cakelight/AmbientMode.java @@ -91,6 +91,13 @@ public class AmbientMode extends Mode { // TODO split into DynamicAmbient and St double g = Math.pow(Math.min(1, Math.max(0, noise.getr(0.0, 1.0, 1, x, y, time / 7000.0))), 1.5); frame.setLedColor(i, Color.rgb(1, g, 0)); } + } else if (type == 5) { + for (int i = 0; i < config.leds.getCount(); i++) { + double x = frame.xOf(i); + double y = frame.yOf(i); + double hue = (Math.min(1, Math.max(0, noise.getr(0.0, 1.0, 4, x, y, time / 7000.0))) + (time / 100000.0)) % 1.0; + frame.setLedColor(i, Color.hsv(hue, 1, 1)); + } } } diff --git a/src/kaka/cakelight/Console.java b/src/kaka/cakelight/Console.java index 6339138..b82806f 100644 --- a/src/kaka/cakelight/Console.java +++ b/src/kaka/cakelight/Console.java @@ -25,7 +25,7 @@ public class Console extends Thread { System.out.print("> "); try { String input = reader.readLine(); - if (input.equals("0") || input.equals("1") || input.equals("2") || input.equals("3") || input.equals("4")) { + if (input.matches("[0-5]")) { cakelight.setMode(new AmbientMode(new String[] {input})); System.out.println("setting ambient mode to " + input); } else if (input.matches("(b|brightness)\\s+[0-9]+")) { -- 2.11.0