Added a draft for an ambient mode
[kaka/cakelight.git] / src / kaka / cakelight / LedController.java
index 9a23331..97f14c9 100644 (file)
@@ -7,24 +7,30 @@ 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 {
-            SpiDevice 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
-            );
+            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();
+        }
     }
 }