Start a new topic

indicate to arduino code that nextion woke up

I would like to know whether I can indicate to arduino code that the nextion woke up.

Thank you for your help!


 when the Nextion "wake up" just let him send out something, and at Arduino observe for this "something" ...


How you do this is up to your own code and logic ...

You might like to refer to the Instruction set:

https://www.itead.cc/wiki/Nextion_Instruction_Set#Format_of_Device_Return_Data

There are two return codes that will be sent when the device wakes up alternatively - 0x68 and 0x87

 

And for even more clarity


After reading and understanding the Nextion Instruction Set Michael linked to,


1) Nextion woke up on its own

    - Nextion sends a return code as Michael refers to

2) Nextion woke up on receiving sleep=0 command

    - send out something as Gerry refers to

3) Nextion sleeps on its own

    - Nextion sends a return code as Michael refers to

4) Nextion sleeps on receiving sleep=1 command

    - send out something just before as Gerry refers to

    * in case #4 - wasn't it MCU that sends sleep=1?



 


Thank you for help!


I got a code and I rewrote it, but the 5. row doesn't work, is this code good or not

0x88  This data is sent after a successful power-on initialization on the device

0x87, 0x68 is not good, I want that after waking up the monitor refreshes not just items but

datas from arduino. This is b1_0PopCallback.


uint8_t c;

while (nexSerial.available() > 0)

  {delay(10);

  c = nexSerial.read();

  if ((0x88) == c) {b1_0PopCallback;}

  if ((0x65) == 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]);} } } }


best regards

Hajni

Ahhh, are we support to say the code is bad? or terrible?


0x88 will be triggered on any byte value received with 0x88.

Why use wrong codes and expect to receive results

Why deviate from 0x65 templated format and expect it to be complete.


Sorry, there is no means this code could accomplish such goal

Read the instruction set linked above

Read the C code for 0x65 segment


First you must understand these before merely tossing code at random

and expecting results.  Code is exacting instructions for the MCU to follow.

It will do exactly as you instruct it, first take time to learn.  Read and read.

  if ((0x65) == 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]);

        }

     }

  }


What do you think this segment of code says?


Look closely at HOW the above code manages to determine the touch event.

It certainly wasn't

  if ((0x65) == c) { NexTouch() }


The code says

  if ((0x65) == c)  {                    if the char is 0x65

     if (nexSerial.available() >= 6)  {  and there are 6 or more other chars waiting (7 total with c)

        __buffer[0] = c;                  then set c in first spot of buffer

        for (i = 1; i < 7; i++)  {                  and for 1 to 6

           __buffer[i] = nexSerial.read();    set buffer slot i  by reading char from buffer

        }

        __buffer[i] = 0x00;              null terminating what was just read by setting buffer[7] to 0x00

        if (0xFF == __buffer[4] && 0xFF == __buffer[5] && 0xFF == __buffer[6]) { 

           NexTouch::iterate(nex_listen_list, __buffer[1], __buffer[2], (int32_t)__buffer[3]);

        }    the lines above here say only if the last three are 0xFF ... then call iterate with slots 1,2 and 3

     }

  }

}


Now look at Your line 5 and tell me it isn't missing much.

if ((0x88) == c) {b1_0PopCallback;}

 - yours says on each occurrence of 0x88 call your popcallback routine.


Coding Questions will only be answered in the Free Chat

 - support tickets are reserved Level 2 for hardware failures.


Login or Signup to post a comment