Removed commented lines + todos
[kaka/cakelight.git] / src / kaka / cakelight / LedController.java
index 9749483..559719a 100644 (file)
@@ -1,10 +1,31 @@
 package kaka.cakelight;
 
-import java.util.function.Consumer;
+import com.pi4j.io.spi.SpiChannel;
+import com.pi4j.io.spi.SpiDevice;
+import com.pi4j.io.spi.SpiFactory;
 
-public class LedController implements Consumer<LedFrame> {
-    @Override
-    public void accept(LedFrame ledFrame) {
-       // TODO
+import java.io.IOException;
+
+public class LedController {
+    private SpiDevice spi;
+
+    public static void main(String args[]) {
+        new LedController(null);
+    }
+
+    public LedController(Configuration config) {
+        try {
+            spi = SpiFactory.getInstance(SpiChannel.CS0);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void onFrame(LedFrame ledFrame) {
+        try {
+            spi.write(ledFrame.getBytes());
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
     }
 }