@Test public void reversesColorsWhenUsingReversedDirection() throws Exception { driver = new Ws2801(device, unpacker, Direction.REVERSED); driver.write(new int[]{0x0, 0x1}); verify(unpacker).unpack(0x1); verify(unpacker).unpack(0X0); }
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();  }