diff --git a/src/main/java/com/neophob/sematrix/output/PixelInvadersDevice.java b/src/main/java/com/neophob/sematrix/output/PixelInvadersDevice.java index d97010ee..2fbdfd95 100644 --- a/src/main/java/com/neophob/sematrix/output/PixelInvadersDevice.java +++ b/src/main/java/com/neophob/sematrix/output/PixelInvadersDevice.java @@ -25,7 +25,6 @@ import java.util.logging.Logger; import com.neophob.sematrix.glue.Collector; -import com.neophob.sematrix.output.pixelinvaders.Lpd6803; import com.neophob.sematrix.output.pixelinvaders.Lpd6803Common; import com.neophob.sematrix.properties.ApplicationConfigurationHelper; import com.neophob.sematrix.properties.ColorFormat; @@ -107,9 +106,9 @@ public void sendPayload() { int[] bfr = RotateBuffer.transformImage(super.getBufferForScreen(ofs), displayOptions.get(panelNr), - Lpd6803.NR_OF_LED_HORIZONTAL, Lpd6803.NR_OF_LED_VERTICAL); + lpd6803.getNrOfLedHorizontal(), lpd6803.getNrOfLedVertical()); - bfr = OutputHelper.flipSecondScanline(bfr, Lpd6803.NR_OF_LED_HORIZONTAL, Lpd6803.NR_OF_LED_VERTICAL); + bfr = OutputHelper.flipSecondScanline(bfr, lpd6803.getNrOfLedHorizontal(), lpd6803.getNrOfLedVertical()); if (lpd6803.didFrameChange((byte)ofs, bfr)) { this.transformedBuffer.put(panelNr, bfr); diff --git a/src/main/java/com/neophob/sematrix/output/PixelInvadersNetDevice.java b/src/main/java/com/neophob/sematrix/output/PixelInvadersNetDevice.java index d590a133..7ad2a502 100644 --- a/src/main/java/com/neophob/sematrix/output/PixelInvadersNetDevice.java +++ b/src/main/java/com/neophob/sematrix/output/PixelInvadersNetDevice.java @@ -52,7 +52,7 @@ public PixelInvadersNetDevice(ApplicationConfigurationHelper ph, PixelController String ip = ph.getPixelinvadersNetIp(); int port = ph.getPixelinvadersNetPort(); try { - lpd6803 = new Lpd6803Net( Collector.getInstance().getPapplet(), ip, port, ph.getPixelInvadersCorrectionMap() ); + lpd6803 = new Lpd6803Net(Collector.getInstance().getPapplet(), ip, port, ph.getPixelInvadersCorrectionMap(), ph.getDeviceXResolution() ); this.initialized = lpd6803.connected(); super.setLpd6803(lpd6803); LOG.log(Level.INFO, "\nPING result: "+ this.initialized+"\n\n"); diff --git a/src/main/java/com/neophob/sematrix/output/PixelInvadersSerialDevice.java b/src/main/java/com/neophob/sematrix/output/PixelInvadersSerialDevice.java index 47b4411a..cb0eb09c 100644 --- a/src/main/java/com/neophob/sematrix/output/PixelInvadersSerialDevice.java +++ b/src/main/java/com/neophob/sematrix/output/PixelInvadersSerialDevice.java @@ -51,7 +51,7 @@ public PixelInvadersSerialDevice(ApplicationConfigurationHelper ph, PixelControl super(OutputDeviceEnum.PIXELINVADERS, ph, controller, 5); try { - lpd6803 = new Lpd6803( Collector.getInstance().getPapplet(), ph.getPixelInvadersBlacklist(), ph.getPixelInvadersCorrectionMap(), panelOrder.size() ); + lpd6803 = new Lpd6803(Collector.getInstance().getPapplet(), ph.getPixelInvadersBlacklist(), ph.getPixelInvadersCorrectionMap(), ph.getDeviceXResolution()); this.initialized = lpd6803.ping(); super.setLpd6803(lpd6803); LOG.log(Level.INFO, "\nPING result: "+ this.initialized+"\n\n"); diff --git a/src/main/java/com/neophob/sematrix/output/pixelinvaders/Lpd6803.java b/src/main/java/com/neophob/sematrix/output/pixelinvaders/Lpd6803.java index 03211297..7b8d62f9 100644 --- a/src/main/java/com/neophob/sematrix/output/pixelinvaders/Lpd6803.java +++ b/src/main/java/com/neophob/sematrix/output/pixelinvaders/Lpd6803.java @@ -107,8 +107,8 @@ public class Lpd6803 extends Lpd6803Common { * @param app the app * @throws NoSerialPortFoundException the no serial port found exception */ - public Lpd6803(PApplet app, List portBlacklist, Map correctionMap, int totalPanels) throws NoSerialPortFoundException { - this(app, null, 0, portBlacklist, correctionMap); + public Lpd6803(PApplet app, List portBlacklist, Map correctionMap, int panelSize) throws NoSerialPortFoundException { + this(app, null, 0, portBlacklist, correctionMap, panelSize); } @@ -120,8 +120,8 @@ public Lpd6803(PApplet app, List portBlacklist, Map * @param baud the baud * @throws NoSerialPortFoundException the no serial port found exception */ - public Lpd6803(PApplet app, String portName, int baud, List portBlacklist, Map correctionMap) throws NoSerialPortFoundException { - + public Lpd6803(PApplet app, String portName, int baud, List portBlacklist, Map correctionMap, int panelSize) throws NoSerialPortFoundException { + super(panelSize, panelSize); LOG.log(Level.INFO, "Initialize LPD6803 lib v{0}", VERSION); this.app = app; diff --git a/src/main/java/com/neophob/sematrix/output/pixelinvaders/Lpd6803Common.java b/src/main/java/com/neophob/sematrix/output/pixelinvaders/Lpd6803Common.java index bfcba909..b008d820 100644 --- a/src/main/java/com/neophob/sematrix/output/pixelinvaders/Lpd6803Common.java +++ b/src/main/java/com/neophob/sematrix/output/pixelinvaders/Lpd6803Common.java @@ -19,14 +19,12 @@ public abstract class Lpd6803Common { /** The log. */ private static final Logger LOG = Logger.getLogger(Lpd6803Common.class.getName()); - /** number of leds horizontal
TODO: should be dynamic, someday. */ - public static final int NR_OF_LED_HORIZONTAL = 8; + protected int nrOfLedHorizontal; - /** number of leds vertical
TODO: should be dynamic, someday. */ - public static final int NR_OF_LED_VERTICAL = NR_OF_LED_HORIZONTAL; + protected int nrOfLedVertical; /** The Constant BUFFERSIZE. */ - protected static final int BUFFERSIZE = NR_OF_LED_HORIZONTAL*NR_OF_LED_VERTICAL; + protected int bufferSize; protected static Adler32 adler = new Adler32(); @@ -45,6 +43,11 @@ public abstract class Lpd6803Common { /** The ack errors. */ protected long ackErrors = 0; + public Lpd6803Common(int xRes, int yRes) { + this.nrOfLedHorizontal = xRes; + this.nrOfLedVertical = yRes; + this.bufferSize = xRes*yRes; + } /** * return connection state of lib. @@ -67,8 +70,8 @@ public boolean connected() { * @return nr of sended bytes */ public int sendRgbFrame(byte ofs, int[] data, ColorFormat colorFormat, int totalPanels) { - if (data.length!=BUFFERSIZE) { - throw new IllegalArgumentException("data lenght must be 64 bytes!"); + if (data.length!=bufferSize) { + throw new IllegalArgumentException("data lenght must be "+bufferSize+" bytes, was "+data.length); } int ofsAsInt = ofs; @@ -245,5 +248,21 @@ public boolean isInitialized() { return initialized; } + /** + * + * @return + */ + public int getNrOfLedHorizontal() { + return nrOfLedHorizontal; + } + + /** + * + * @return + */ + public int getNrOfLedVertical() { + return nrOfLedVertical; + } + } diff --git a/src/main/java/com/neophob/sematrix/output/pixelinvaders/Lpd6803Net.java b/src/main/java/com/neophob/sematrix/output/pixelinvaders/Lpd6803Net.java index 3b6dd15c..221a21b0 100644 --- a/src/main/java/com/neophob/sematrix/output/pixelinvaders/Lpd6803Net.java +++ b/src/main/java/com/neophob/sematrix/output/pixelinvaders/Lpd6803Net.java @@ -78,7 +78,8 @@ public class Lpd6803Net extends Lpd6803Common{ * @param baud the baud * @throws NoSerialPortFoundException the no serial port found exception */ - public Lpd6803Net(PApplet pa, String destIp, int destPort, Map correctionMap) throws Exception { + public Lpd6803Net(PApplet pa, String destIp, int destPort, Map correctionMap, int panelSize) throws Exception { + super(panelSize, panelSize); LOG.log(Level.INFO, "Initialize LPD6803 net lib v{0}", VERSION); this.destIp = destIp; diff --git a/src/main/java/com/neophob/sematrix/properties/ApplicationConfigurationHelper.java b/src/main/java/com/neophob/sematrix/properties/ApplicationConfigurationHelper.java index 00643bd8..3f1dccbd 100644 --- a/src/main/java/com/neophob/sematrix/properties/ApplicationConfigurationHelper.java +++ b/src/main/java/com/neophob/sematrix/properties/ApplicationConfigurationHelper.java @@ -447,8 +447,14 @@ private int parsePixelInvaderConfig() { String value = config.getProperty(ConfigConstant.PIXELINVADERS_ROW1); if (StringUtils.isNotBlank(value)) { - this.deviceXResolution = 8; - this.deviceYResolution = 8; + + if (parseBoolean(ConfigConstant.PIXELINVADERS_IS_AN_EXPEDITINVADER)) { + this.deviceXResolution = 4; + this.deviceYResolution = 4; + } else { + this.deviceXResolution = 8; + this.deviceYResolution = 8; + } devicesInRow1 = 0; devicesInRow2 = 0; diff --git a/src/main/java/com/neophob/sematrix/properties/ConfigConstant.java b/src/main/java/com/neophob/sematrix/properties/ConfigConstant.java index 407d5117..3256b219 100644 --- a/src/main/java/com/neophob/sematrix/properties/ConfigConstant.java +++ b/src/main/java/com/neophob/sematrix/properties/ConfigConstant.java @@ -107,7 +107,9 @@ private ConfigConstant() { public static final String PIXELINVADERS_NET_IP = "pixelinvaders.panel.ip"; - public static final String PIXELINVADERS_NET_PORT = "pixelinvaders.panel.port"; + public static final String PIXELINVADERS_NET_PORT = "pixelinvaders.panel.port"; + + public static final String PIXELINVADERS_IS_AN_EXPEDITINVADER = "pixelinvaders.is.a.expeditinvader"; /** The Constant STEALTH_ROW1. */ public static final String STEALTH_ROW1 = "stealth.layout.row1"; diff --git a/src/test/java/com/neophob/sematrix/output/CacheMechanismTest.java b/src/test/java/com/neophob/sematrix/output/CacheMechanismTest.java index ad5acfdf..894353c1 100644 --- a/src/test/java/com/neophob/sematrix/output/CacheMechanismTest.java +++ b/src/test/java/com/neophob/sematrix/output/CacheMechanismTest.java @@ -36,6 +36,10 @@ public class CacheMechanismTest { class DummyOutput extends Lpd6803Common { + public DummyOutput() { + super(8,8); + } + boolean ackReturnValue=false; @Override diff --git a/src/test/java/com/neophob/sematrix/output/PixelControllerDeviceTest.java b/src/test/java/com/neophob/sematrix/output/PixelControllerDeviceTest.java index 8656d684..883758df 100644 --- a/src/test/java/com/neophob/sematrix/output/PixelControllerDeviceTest.java +++ b/src/test/java/com/neophob/sematrix/output/PixelControllerDeviceTest.java @@ -33,7 +33,11 @@ */ public class PixelControllerDeviceTest extends Lpd6803Common { - @Test + public PixelControllerDeviceTest() { + super(8,8); + } + + @Test public void testChaching() { int[] b = new int[64]; assertTrue(didFrameChange((byte)0, b));