Skip to content

Commit

Permalink
Merge pull request neophob#20 from okyeron/master
Browse files Browse the repository at this point in the history
Updated stealth output for 24 bit color
  • Loading branch information
neophob committed Jul 3, 2012
2 parents 943ac8f + ddc2414 commit 2a95ab5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 17 deletions.
24 changes: 15 additions & 9 deletions data/ArduinoFw/stealthSpi/stealthSpi.ino
Expand Up @@ -61,8 +61,7 @@ int led_latch = 24; // latch pin is 24/B4 = PB4 on Teensy
#define END_OF_DATA 0x20

//frame size for specific color resolution
//32pixels * 2 byte per color (15bit - one bit wasted)
#define COLOR_5BIT_FRAME_SIZE 64
#define COLOR_5BIT_FRAME_SIZE 96
#define SERIAL_HEADER_SIZE 5
//--- protocol data end

Expand All @@ -71,16 +70,13 @@ int led_latch = 24; // latch pin is 24/B4 = PB4 on Teensy
#define SERIAL_WAIT_DELAY 3

//define nr of Panels*2 here, 4 means 2 panels
#define NR_OF_PANELS 8
#define NR_OF_PANELS 4
#define PIXELS_PER_PANEL 32

//this should match RX_BUFFER_SIZE from HardwareSerial.cpp
//array that will hold the serial input string
byte serInStr[COLOR_5BIT_FRAME_SIZE+SERIAL_HEADER_SIZE];

//initialize pixels
//Neophob_LPD6803 strip = Neophob_LPD6803(PIXELS_PER_PANEL*NR_OF_PANELS);

#define SERIALBUFFERSIZE 4
byte serialResonse[SERIALBUFFERSIZE];

Expand Down Expand Up @@ -153,7 +149,6 @@ void setup() {

panel.fillScreen(make_color(64, 0, 0)); // flash red to show update is good
panel.sendFrame();
// delay(100);

serialDataRecv = 0; //no serial data received yet
}
Expand Down Expand Up @@ -225,18 +220,29 @@ void updatePixels(byte ofs, byte* buffer) {
uint16_t currentLed = ofs*PIXELS_PER_PANEL; // this is offset * amount of bytes of data in each packet
byte x=0;

// draw 32 pixels per ofs packet chunk
for (byte i=0; i < PIXELS_PER_PANEL; i++) {
//convert buffer to bytes
byte rz = buffer[x];
byte gz = buffer[x+1];
byte bz = buffer[x+2];
panel.drawPixelNum(currentLed, make_color(rz, gz, bz));
x+=3;
currentLed++;
}
/*
for (byte i=0; i < PIXELS_PER_PANEL; i++) {
//get 15 bit color
tmpBits = buffer[x] << 8 | buffer[x+1];
//convert it to 24 bit per color
byte bz = tmpBits & 0x1F;
byte gz = (tmpBits >> 5) & 0x1F;
byte rz= (tmpBits >> 10) & 0x1F;
byte rz = (tmpBits >> 10) & 0x1F;
panel.drawPixelNum(currentLed, make_color(rz<<2, gz<<2, bz<<2));
x+=2;
currentLed++;
}

*/
/* //this is working on 8x8 grid
if (ofs == 0){
for (i = 0; i < panel.width()/4; i++) {
Expand Down
6 changes: 4 additions & 2 deletions data/config.properties
Expand Up @@ -113,11 +113,13 @@ panel.color.order=RGB,RBG
#pixelinvaders.layout.row1=ROTATE_180,NO_ROTATE
#pixelinvaders.layout.row2=NO_ROTATE,NO_ROTATE

stealth.layout.row1=NO_ROTATE

#=========================
#settings for null output
#=========================
nulloutput.devices.row1=2
nulloutput.devices.row2=0
#nulloutput.devices.row1=2
#nulloutput.devices.row2=0

#=========================
#settings for artnet, minidmx and adavision
Expand Down
31 changes: 25 additions & 6 deletions src/main/java/com/neophob/sematrix/output/stealth/Stealth.java
Expand Up @@ -76,7 +76,10 @@ public class Stealth {

/** The Constant BUFFERSIZE. */
private static final int PANELBUFFERSIZE = NR_OF_LED_HORIZONTAL*NR_OF_LED_VERTICAL;
private static final int DATABUFFERSIZE = 64;
// payload buffer is 64 bytes for 15bit color
// private static final int DATABUFFERSIZE = 64;
// payload buffer is 96 bytes for 24 bit color
private static final int DATABUFFERSIZE = 96;

/** internal lib version. */
public static final String VERSION = "1.0";
Expand Down Expand Up @@ -325,8 +328,8 @@ public boolean sendRgbFrame(byte ofs, int[] data, ColorFormat colorFormat) {
if (data.length!=PANELBUFFERSIZE) {
throw new IllegalArgumentException("data length must be 256 bytes!");
}
return sendFrame(ofs, OutputHelper.convertBufferTo15bit(data, colorFormat));
// return sendFrame(ofs, OutputHelper.convertBufferTo24bit(data, colorFormat));
// return sendFrame(ofs, OutputHelper.convertBufferTo15bit(data, colorFormat));
return sendFrame(ofs, OutputHelper.convertBufferTo24bit(data, colorFormat));
}


Expand Down Expand Up @@ -367,8 +370,8 @@ private boolean didFrameChange(byte ofs, byte data[]) {
*/
public boolean sendFrame(byte ofs, byte data[]) throws IllegalArgumentException {
//LOG.log(Level.INFO, "data length: "+data.length);
if (data.length!=512) {
throw new IllegalArgumentException("data length must be 128 bytes! ");
if (data.length!=(8*DATABUFFERSIZE)) {
throw new IllegalArgumentException("data length must be 768 bytes! ");
}

/* //TODO stop if connection counter > n
Expand All @@ -384,6 +387,7 @@ public boolean sendFrame(byte ofs, byte data[]) throws IllegalArgumentException
byte ofsSix = (byte)(ofsFive+1);
byte ofsSeven = (byte)(ofsSix+1);
byte ofsEight = (byte)(ofsSeven+1);
// byte ofsNine = (byte)(ofsEight+1);
byte frameOne[] = new byte[DATABUFFERSIZE];
byte frameTwo[] = new byte[DATABUFFERSIZE];
byte frameThree[] = new byte[DATABUFFERSIZE];
Expand All @@ -392,6 +396,7 @@ public boolean sendFrame(byte ofs, byte data[]) throws IllegalArgumentException
byte frameSix[] = new byte[DATABUFFERSIZE];
byte frameSeven[] = new byte[DATABUFFERSIZE];
byte frameEight[] = new byte[DATABUFFERSIZE];
// byte frameNine[] = new byte[DATABUFFERSIZE];
boolean returnValue = false;

System.arraycopy(data, 0, frameOne, 0, DATABUFFERSIZE);
Expand All @@ -402,6 +407,7 @@ public boolean sendFrame(byte ofs, byte data[]) throws IllegalArgumentException
System.arraycopy(data, DATABUFFERSIZE*5, frameSix, 0, DATABUFFERSIZE);
System.arraycopy(data, DATABUFFERSIZE*6, frameSeven, 0, DATABUFFERSIZE);
System.arraycopy(data, DATABUFFERSIZE*7, frameEight, 0, DATABUFFERSIZE);
// System.arraycopy(data, DATABUFFERSIZE*8, frameNine, 0, DATABUFFERSIZE);

byte sendlen = DATABUFFERSIZE;
byte cmdfull[] = new byte[sendlen+7];
Expand Down Expand Up @@ -502,12 +508,23 @@ public boolean sendFrame(byte ofs, byte data[]) throws IllegalArgumentException
}
}

/* //send frame Nine
if (didFrameChange(ofsNine, frameNine)) {
cmdfull[1] = ofsNine;
flipSecondScanline(cmdfull, frameNine);
if (sendSerialData(cmdfull)) {
returnValue=true;
} else {
lastDataMap.put(ofsNine, "");
}
}
*/
/**/
return returnValue;
}

/**
* this function feed the framebufferdata (32 pixels a 2bytes (aka 16bit)
* this function feed the framebufferdata (32 pixels a 3bytes (aka 24bit)
* to the send array. each second scanline gets inverteds
*
* @param cmdfull the cmdfull
Expand All @@ -519,6 +536,8 @@ private static void flipSecondScanline(byte cmdfull[], byte frameData[]) {
cmdfull[16+5+i] = frameData[i+16];
cmdfull[32+5+i] = frameData[i+32];
cmdfull[48+5+i] = frameData[i+48];
cmdfull[64+5+i] = frameData[i+64];
cmdfull[80+5+i] = frameData[i+80];

}

Expand Down

0 comments on commit 2a95ab5

Please sign in to comment.