Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Nextion NX4832T035_011 & Teensy 4.0 NexLoop is not working

  1. #1
    Junior Member
    Join Date
    Apr 2021
    Location
    Tijuana, Mexico
    Posts
    8

    Nextion NX4832T035_011 & Teensy 4.0 NexLoop is not working

    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[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]);
    }

    }
    }
    }
    }


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


    Thanks in advance
    Last edited by MiguelRodmen; 04-20-2021 at 02:37 AM.

  2. #2
    Senior Member
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    198
    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]);
                    }
    
                }
            }
        }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •