@Override
public void enter(Configuration config) {
this.config = config;
-// LedFrame frame = LedFrame.from(config);
-// frame.fillColor(255, 0, 128);
-// frame.setLedColor(0, Color.rgb(255, 0, 0));
-// frame.setLedColor(1, Color.rgb(0, 255, 0));
-// frame.setLedColor(2, Color.rgb(0, 0, 255));
-// for (int i = 0; i < config.leds.getCount(); i++) {
-//// int v = 255 * i / config.leds.getCount();
-// int v = 60 * (i % 3);
-// frame.setLedColor(i, Color.rgb(v, v, v));
-// }
-// frameListener.accept(frame);
startThread();
}
* @param count Goes from 0 to number of LEDs - 1
*/
private void updateFrame(LedFrame frame, long time, int count) {
- frame.setLedColor(count, Color.rgb(255, 0, 0));
- frame.setLedColor((count + 1) % config.leds.getCount(), Color.rgb(0, 255, 0));
- frame.setLedColor((count + 2) % config.leds.getCount(), Color.rgb(0, 0, 255));
-// for (int i = 0; i < config.leds.getCount(); i++) {
-//
-// }
+ for (int i = 0; i < config.leds.getCount(); i++) {
+ double r = Math.sin(2 * i * Math.PI / config.leds.getCount() + time * 0.001) * 0.5 + 0.5;
+ double g = Math.cos(2 * i * Math.PI / config.leds.getCount() + time * 0.002) * 0.5 + 0.5;
+ frame.setLedColor(i, Color.rgb(r, g, 0));
+ }
}
}