Added a draft for an ambient mode
[kaka/cakelight.git] / src / kaka / cakelight / LedController.java
index 201644d..97f14c9 100644 (file)
@@ -1,7 +1,36 @@
 package kaka.cakelight;
 
+import com.pi4j.io.spi.SpiChannel;
+import com.pi4j.io.spi.SpiDevice;
+import com.pi4j.io.spi.SpiFactory;
+
+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);
+//            spi.write(
+//                    (byte)0xff, (byte)0x0, (byte)0x0,
+//                    (byte)0x00, (byte)0xff, (byte)0x0,
+//                    (byte)0x0, (byte)0x00, (byte)0xff
+//            );
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
     public void onFrame(LedFrame ledFrame) {
-       // TODO
+        try {
+            spi.write(ledFrame.getBytes());
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
     }
 }