WIP
[kaka/cakelight.git] / src / kaka / cakelight / CakeLight.java
diff --git a/src/kaka/cakelight/CakeLight.java b/src/kaka/cakelight/CakeLight.java
new file mode 100644 (file)
index 0000000..afc7b26
--- /dev/null
@@ -0,0 +1,39 @@
+package kaka.cakelight;
+
+import static kaka.cakelight.Main.timeIt;
+
+public class CakeLight {
+    private Configuration config;
+    private Mode mode;
+
+    public CakeLight(Configuration config) {
+        this.config = config;
+    }
+
+    public void setMode(Mode mode) {
+        cleanup();
+        this.mode = mode;
+        mode.enter(config);
+    }
+
+    public void cleanup() {
+        if (this.mode != null) {
+            this.mode.exit();
+        }
+    }
+
+    public void startLoop() {
+        // TODO
+//        FrameGrabber grabber = FrameGrabber.from(config);
+//        grabber.prepare();
+//        Frame frame = grabber.grabFrame();
+//        double time = 0;
+//        for (int i = 0; i < 100; i++) {
+//            time += timeIt("frame", () -> grabber.grabFrame());
+//        }
+//        System.out.println("time = " + time);
+//        grabber.close();
+//     byte[] data = frame.getData();
+//     saveFile(data, "/home/kaka/test.img");
+    }
+}