Added gamma correction
[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         Color.calculateGammaCorrection(config.gamma);
12     }
13
14     public void setMode(Mode mode) {
15         cleanup();
16         this.mode = mode;
17         mode.setFrameListener(ledController::onFrame);
18         mode.enter(config);
19     }
20
21     public void cleanup() {
22         if (this.mode != null) {
23             this.mode.exit();
24         }
25     }
26
27     public void startLoop() {
28         // TODO
29 //        FrameGrabber grabber = FrameGrabber.from(config);
30 //        grabber.prepare();
31 //        Frame frame = grabber.grabFrame();
32 //        double time = 0;
33 //        for (int i = 0; i < 100; i++) {
34 //            time += timeIt("frame", () -> grabber.grabFrame());
35 //        }
36 //        System.out.println("time = " + time);
37 //        grabber.close();
38 //      byte[] data = frame.getData();
39 //      saveFile(data, "/home/kaka/test.img");
40     }
41 }