@Test public void writesToSpiDeviceWhenWriting() throws Exception { int[] anyColors = {Color.RED, Color.DKGRAY, Color.GREEN, Color.WHITE, Color.YELLOW}; driver.write(anyColors); verify(device).write(any(byte[].class), anyInt()); }
public void write(int[] colors) throws IOException { byte[] ledData = new byte[WS2801_PACKET_LENGTH * colors.length]; for (int i = 0; i < colors.length; i++) { int outputPosition = i * WS2801_PACKET_LENGTH; int di = direction == Direction.NORMAL ? i : colors.length - i - 1; System.arraycopy(colorUnpacker.unpack(colors[di]), 0, ledData, outputPosition, WS2801_PACKET_LENGTH); } device.write(ledData, ledData.length); }
Ws2801 implements AutoCloseable { public void write(int[] colors) throws IOException { byte[] ledData = new byte[WS2801_PACKET_LENGTH * colors.length]; for (int i = 0; i < colors.length; i++) { int outputPosition = i * WS2801_PACKET_LENGTH; int di = direction == Direction.NORMAL ? i : colors.length - i - 1; System.arraycopy(colorUnpacker.unpack(colors[di]), 0, ledData, outputPosition, WS2801_PACKET_LENGTH); } device.write(ledData, ledData.length); } }
Ws2801 implements AutoCloseable { public void write(int[] colors) throws IOException { byte[] ledData = new byte[WS2801_PACKET_LENGTH * colors.length]; for (int i = 0; i < colors.length; i++) { int outputPosition = i * WS2801_PACKET_LENGTH; int di = direction == Direction.NORMAL ? i : colors.length - i - 1; System.arraycopy(colorUnpacker.unpack(colors[di]), 0, ledData, outputPosition, WS2801_PACKET_LENGTH); } device.write(ledData, ledData.length); } Ws2801(SpiDevice device, ColorUnpacker colorUnpacker, Direction direction); }
Ws2801 implements AutoCloseable { public void write(int[] colors) throws IOException { byte[] ledData = new byte[WS2801_PACKET_LENGTH * colors.length]; for (int i = 0; i < colors.length; i++) { int outputPosition = i * WS2801_PACKET_LENGTH; int di = direction == Direction.NORMAL ? i : colors.length - i - 1; System.arraycopy(colorUnpacker.unpack(colors[di]), 0, ledData, outputPosition, WS2801_PACKET_LENGTH); } device.write(ledData, ledData.length); } Ws2801(SpiDevice device, ColorUnpacker colorUnpacker, Direction direction); static Ws2801 create(String spiBusPort); static Ws2801 create(String spiBusPort, Mode ledMode); static Ws2801 create(String spiBusPort, Mode ledMode, Direction direction); void write(int[] colors); @Override void close(); }
Ws2801 implements AutoCloseable { public void write(int[] colors) throws IOException { byte[] ledData = new byte[WS2801_PACKET_LENGTH * colors.length]; for (int i = 0; i < colors.length; i++) { int outputPosition = i * WS2801_PACKET_LENGTH; int di = direction == Direction.NORMAL ? i : colors.length - i - 1; System.arraycopy(colorUnpacker.unpack(colors[di]), 0, ledData, outputPosition, WS2801_PACKET_LENGTH); } device.write(ledData, ledData.length); } Ws2801(SpiDevice device, ColorUnpacker colorUnpacker, Direction direction); static Ws2801 create(String spiBusPort); static Ws2801 create(String spiBusPort, Mode ledMode); static Ws2801 create(String spiBusPort, Mode ledMode, Direction direction); void write(int[] colors); @Override void close();  }