Nextion NX4832T035_011 & Teensy 4.0 NexLoop is not working

Status
Not open for further replies.
Hello,
I'm working with Teensy and Nextion TFT, and it works good when I'm getting variables values, I started to do this instead of using Nexloop method because when I started this code I was using Arduino Mega, and sometimes Nexloop wasn't getting the event trigger because Arduino was busy in any other action, but get variables values is a little slow process, so now, I'm using Teensy 4.0 and I was thinking to use multithreading to check for any event on my Serial at same time I'm doing the other actions, but the Nexloop is not getting anything, so I made another code to only run Nexloop, and it didn't work either.

In addition, I put some indicators to my debugging serial port, to know where my code was getting stuck doing the Nexloop, and it's not doing the while loop


void nexLoop(NexTouch *nex_listen_list[])
{

static uint8_t __buffer[10];

uint16_t i;
uint8_t c;

while (nexSerial.available() > 0)
{

delay(10);
c = nexSerial.read();

if (NEX_RET_EVENT_TOUCH_HEAD == c)
{

if (nexSerial.available() >= 6)
{

__buffer[0] = c;
for (i = 1; i < 7; i++)
{
__buffer = nexSerial.read();
}
__buffer = 0x00;

if (0xFF == __buffer[4] && 0xFF == __buffer[5] && 0xFF == __buffer[6])
{
NexTouch::iterate(nex_listen_list, __buffer[1], __buffer[2], (int32_t)__buffer[3]);
}

}
}
}
}


I'm working with ITEADLIB, Arduino 1.8.13 & Teensyduino 1.53.


Thanks in advance
 
Last edited:
You probably need to show your full code. There is no explanation of "nexSerial".
Also put your code between Code tags. Use the # button above.
Your code will then look like this (You must add indenting yourself. It makes it easier for others who are NOT familiar with your code to understand it and possibly offer help. It also makes your code much easier to maintain in the future. Believe me you will forget what you were doing in the code when you come back to it in the future.):-
Code:
void nexLoop(NexTouch *nex_listen_list[])
{

    static uint8_t __buffer[10];

    uint16_t i;
    uint8_t c;

    while (nexSerial.available() > 0)
    {

        delay(10);
        c = nexSerial.read();

        if (NEX_RET_EVENT_TOUCH_HEAD == c)
        {

            if (nexSerial.available() >= 6)
            {

                __buffer[0] = c;
                for (i = 1; i < 7; i++)
                {
                    __buffer[i] = nexSerial.read();
                }
                __buffer[i] = 0x00;

                if (0xFF == __buffer[4] && 0xFF == __buffer[5] && 0xFF == __buffer[6])
                {
                    NexTouch::iterate(nex_listen_list, __buffer[1], __buffer[2], (int32_t)__buffer[3]);
                }

            }
        }
    }
}
 
Status
Not open for further replies.
Back
Top