Skip to content
This repository has been archived by the owner on Sep 19, 2021. It is now read-only.

Commit

Permalink
minidmx, display connection state in the gui
Browse files Browse the repository at this point in the history
  • Loading branch information
neophob committed Oct 21, 2013
1 parent 0991591 commit e38ec02
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
14 changes: 14 additions & 0 deletions src/main/java/com/neophob/sematrix/output/MiniDmxDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,18 @@ public boolean isConnected() {
return this.initialized;
}

@Override
public boolean isSupportConnectionState() {
return true;
}


@Override
public String getConnectionStatus(){
if (initialized) {
return "Connected on port "+miniDmx.getSerialPortName();
}
return "Not connected!";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ public static MiniDmxPayloadEnum getDmxPayload(int payloadSize) throws IllegalAr
/** map to store checksum of image. */
private long lastDataMap;

private String serialPortName="";

/**
* Create a new instance to communicate with the rainbowduino.
*
Expand Down Expand Up @@ -245,7 +247,6 @@ public MiniDmxSerial(PApplet app, String portName, int targetBuffersize, int bau

lastDataMap = 0L;

String serialPortName="";
this.miniDmxPayload = MiniDmxPayloadEnum.getDmxPayload(targetBuffersize);
LOG.log(Level.INFO, "MiniDMX payload size: {0}, padding bytes: {1}, baudrate: {2}", new Object[] {
this.miniDmxPayload.payloadSize,
Expand Down Expand Up @@ -363,7 +364,7 @@ public boolean ping() {
r.nextBytes(data);

//just send a frame
return sendFrame(data);
return sendFrame(data)>0;
}


Expand All @@ -376,7 +377,7 @@ public boolean ping() {
* @param colorFormat the color format
* @return true if send was successful
*/
public boolean sendRgbFrame(int[] data, ColorFormat colorFormat) {
public int sendRgbFrame(int[] data, ColorFormat colorFormat) {
return sendFrame(OutputHelper.convertBufferTo24bit(data, colorFormat));
}

Expand Down Expand Up @@ -419,7 +420,7 @@ private boolean didFrameChange(byte data[]) {
* @return true if send was successful
* @throws IllegalArgumentException the illegal argument exception
*/
public boolean sendFrame(byte data[]) throws IllegalArgumentException {
public int sendFrame(byte data[]) throws IllegalArgumentException {
//respect the padding!
int sourceDataLength = miniDmxPayload.getPayloadSize()-miniDmxPayload.paddingBytes;

Expand All @@ -438,14 +439,14 @@ public boolean sendFrame(byte data[]) throws IllegalArgumentException {
//send frame only if needed
if (didFrameChange(data)) {
if (sendSerialData(cmdfull)) {
return true;
return cmdfull.length;
} else {
//in case of an error, make sure we send it the next time!
lastDataMap=0L;
}
}

return false;
return -1;
}


Expand Down Expand Up @@ -583,5 +584,13 @@ public long getAckErrors() {
return ackErrors;
}

/**
*
* @return
*/
public String getSerialPortName() {
return serialPortName;
}


}

0 comments on commit e38ec02

Please sign in to comment.