| 1 | package kaka.cakelight; |
| 2 | |
| 3 | import com.pi4j.io.spi.SpiChannel; |
| 4 | import com.pi4j.io.spi.SpiDevice; |
| 5 | import com.pi4j.io.spi.SpiFactory; |
| 6 | |
| 7 | import java.io.IOException; |
| 8 | |
| 9 | public class LedController { |
| 10 | private SpiDevice spi; |
| 11 | |
| 12 | public static void main(String args[]) { |
| 13 | new LedController(null); |
| 14 | } |
| 15 | |
| 16 | public LedController(Configuration config) { |
| 17 | try { |
| 18 | spi = SpiFactory.getInstance(SpiChannel.CS0); |
| 19 | // spi.write( |
| 20 | // (byte)0xff, (byte)0x0, (byte)0x0, |
| 21 | // (byte)0x00, (byte)0xff, (byte)0x0, |
| 22 | // (byte)0x0, (byte)0x00, (byte)0xff |
| 23 | // ); |
| 24 | } catch (IOException e) { |
| 25 | e.printStackTrace(); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | public void onFrame(LedFrame ledFrame) { |
| 30 | try { |
| 31 | spi.write(ledFrame.getBytes()); |
| 32 | } catch (IOException e) { |
| 33 | e.printStackTrace(); |
| 34 | } |
| 35 | } |
| 36 | } |