--- /dev/null
+package kaka.cakelight;
+
+import java.io.IOException;
+import java.util.Optional;
+
+import static kaka.cakelight.Main.log;
+import static kaka.cakelight.Main.timeIt;
+
+public class VideoMode implements Mode {
+ private Configuration config;
+ private Thread thread;
+
+ @Override
+ public void enter(Configuration config) {
+ this.config = config;
+ startGrabberThread();
+ }
+
+ @Override
+ public void exit() {
+ thread.interrupt();
+ }
+
+ private void startGrabberThread() {
+ thread = new Thread() {
+ public void run() {
+ try (FrameGrabber grabber = FrameGrabber.from(config)) {
+ while (!isInterrupted()) {
+// Optional<Frame> frame = grabber.grabFrame();
+ timeIt("frame", grabber::grabFrame);
+ // TODO: process frame
+ // TODO: save where the LedController can access it
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ };
+ thread.start();
+ }
+}