Added a LED controller that consumes LED frames from the modes
[kaka/cakelight.git] / src / kaka / cakelight / CakeLight.java
CommitLineData
4a2d6056
TW
1package kaka.cakelight;
2
4a2d6056
TW
3public class CakeLight {
4 private Configuration config;
5 private Mode mode;
03b67a73 6 private LedController ledController;
4a2d6056 7
03b67a73 8 public CakeLight(Configuration config, LedController ledController) {
4a2d6056 9 this.config = config;
03b67a73 10 this.ledController = ledController;
4a2d6056
TW
11 }
12
13 public void setMode(Mode mode) {
14 cleanup();
15 this.mode = mode;
03b67a73 16 mode.setFrameListener(ledController);
4a2d6056
TW
17 mode.enter(config);
18 }
19
20 public void cleanup() {
21 if (this.mode != null) {
22 this.mode.exit();
23 }
24 }
25
26 public void startLoop() {
27 // TODO
28// FrameGrabber grabber = FrameGrabber.from(config);
29// grabber.prepare();
30// Frame frame = grabber.grabFrame();
31// double time = 0;
32// for (int i = 0; i < 100; i++) {
33// time += timeIt("frame", () -> grabber.grabFrame());
34// }
35// System.out.println("time = " + time);
36// grabber.close();
37// byte[] data = frame.getData();
38// saveFile(data, "/home/kaka/test.img");
39 }
40}