5401c0f078c049f4c7ca80cc6dba830042759cfc
[kaka/cakelight.git] / src / kaka / cakelight / CakeLight.java
1 package kaka.cakelight;
2
3 public class CakeLight {
4     private Configuration config;
5     private Mode mode;
6     private LedController ledController;
7
8     public CakeLight(Configuration config, LedController ledController) {
9         this.config = config;
10         this.ledController = ledController;
11     }
12
13     public void setMode(Mode mode) {
14         cleanup();
15         this.mode = mode;
16         mode.setFrameListener(ledController::onFrame);
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 }