sfranzyshen wrote:folny82 wrote:Well done already it works as it should I did some tests and it seems that everything is okay I just had to overwrite this line "if ((packagenum + 0) == numpackages) { // all packets found" 1 to 0 because not sit channels. Still, I think it would be great to add the code simple function test when the ESP module connects source could be suddenly turned all colors and then turn it off would be a good idea to verify the functionality of the matrix
This is great news ... we are almost there. Yes it worked ... but there are still a couple of bugs ... it is working becuase every frame was being seen as a split frame. this just showed us that copying the data to the framebuffer and send it to the ws2812 code is working as expected ...
Here is the final routine ... if you would check this again as before and give feedback ... but I think we got it ... then we can talk about ws2812 init code & possible configuration.Code: Select alluint16_t framebuffer_len = 0;
unsigned char framebuffer[1536]; //max 512 rgb pixels
static void ICACHE_FLASH_ATTR tpm2net_recv(void *arg, char *pusrdata, unsigned short length) {
unsigned char *data =(unsigned char *)pusrdata; //pointer to espconn's returned data
if (data && length >= 6 && data[0]==0x9C) { // header identifier (packet start)
uint8_t blocktype = data[1]; // block type
uint16_t framelength = ((uint16_t)data[2] << 8) | (uint16_t)data[3]; // frame length
uint8_t packagenum = data[4]; // packet number 0-255 0x00 = no frame split
uint8_t numpackages = data[5]; // total packets 1-255
if (blocktype == 0xDA) { // data command ...
if (length >= framelength + 7 && data[6+framelength]==0x36) { // header end (packet stop)
if (numpackages == 0x01) { // no frame split found
unsigned char *frame = &data[6]; // pointer 'frame' to espconn's data (start of data)
ws2812_out(frame, framelength); // send data to strip
} else { //frame split is found
os_memcpy (&framebuffer[framebuffer_len], &data[6], framelength);
framebuffer_len += framelength;
if (packagenum == numpackages) { // all packets found
unsigned char *frame = &framebuffer[0]; // pointer 'frame' framebuffer
ws2812_out(frame, framebuffer_len); // send data to strip
framebuffer_len = 0;
}
}
}
}
}
}
Hi
Today I tested the code not found error seems that everything is working properly.