Chat freely about anything...

User avatar
By sfranzyshen
#9891 UPDATED: 2/17/2015 - 8:32am
frame splitting support:
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;
                    }
                }
            }
        }
    }
}

If you try this please give us feedback here!
Last edited by sfranzyshen on Tue Feb 17, 2015 11:33 am, edited 11 times in total.
User avatar
By folny82
#9897 I have a problem with compiling the code where you be the problem ? :(

05:53:36 **** Build of configuration Default for project esp8266_tpm2net_ws2812 ****
mingw32-make.exe -f C:/Espressif/examples/esp8266_tpm2net_ws2812/Makefile all
CC user/tpm2net.c
user/tpm2net.c: In function 'tpm2net_recv':
user/tpm2net.c:43:42: error: initialization makes pointer from integer without a cast [-Werror]
unsigned char *frame = framebuffer[0]; // pointer 'frame' framebuffer
^
cc1.exe: all warnings being treated as errors
C:/Espressif/examples/esp8266_tpm2net_ws2812/Makefile:315: recipe for target 'build/user/tpm2net.o' failed
mingw32-make.exe: *** [build/user/tpm2net.o] Error 1

05:53:37 Build Finished (took 680ms)
User avatar
By sfranzyshen
#9924
folny82 wrote:I have a problem with compiling the code where you be the problem ? :(


Yup! I be the problem ... change framebuffer[0] to &framebuffer[0] ...

unsigned char *frame = &framebuffer[0]; // pointer 'frame' framebuffer