Chat freely about anything...

User avatar
By folny82
#9967
sfranzyshen wrote:
folny82 wrote:Neither this update code not working I think that the code will need to define the exact number of blocks to make it work.


1) Does the code work at lower channels (assuming yes)
2) If you set it to high channels and it fails, can you set it back to lower channels and it work again? or does the esp8266 lockup and need reset?

I have a post out to the "Questions about TPM2 protocol" fourm ... waiting on feed back before continuing ... wish you could just increase your mtu's 8-)


1) Yes the code is working properly when a small number of channels
2) Yes if you set it to high channels and it fails, can you set it back to lower channels and it work again.
User avatar
By sfranzyshen
#9981 I think I may have "assumed" something that isn't true ... the documents say that Paketnummer is between 1-255. but pixelcontroller is clearly sending Paketnummer == 0x00.

if you feel like making one more change ... just to see ...

from this:
if (packagenum == 0x00 || numpackages == 0x01) { // no frame split found

to this:
if (packagenum == 0x00 && numpackages == 0x01) { // no frame split found

from this:
if (packagenum == numpackages) { // all packets found

to this:
if ((packagenum + 1) == numpackages) { // all packets found

please test this with both lower channels and higher channels ...
if fails with higher ... does going lower need a reset?
User avatar
By folny82
#9985
sfranzyshen wrote:I think I may have "assumed" something that isn't true ... the documents say that Paketnummer is between 1-255. but pixelcontroller is clearly sending Paketnummer == 0x00.

if you feel like making one more change ... just to see ...

from this:
if (packagenum == 0x00 || numpackages == 0x01) { // no frame split found

to this:
if (packagenum == 0x00 && numpackages == 0x01) { // no frame split found

from this:
if (packagenum == numpackages) { // all packets found

to this:
if ((packagenum + 1) == numpackages) { // all packets found

please test this with both lower channels and higher channels ...
if fails with higher ... does going lower need a reset?


Well done already it works as it should :D 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 ;)
User avatar
By sfranzyshen
#10017
folny82 wrote:Well done already it works as it should :D 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 ;)


:D 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;
                    }
                }
            }
        }
    }
}