Start a new topic

How call a routine in arduino when nextion wake up

I have a very simple code , and I put in nextion 


thsp=60 //1 minute

thup=1 //sleep


that run very good

But I don't know how can I run a routine in my arduino when nextion wake up, 

I put this code to probe in hardware.cpp and run well calling a screen, but i need to know that in arduino, anybody can help me?


I want to call wakeup() from my arduino code 


Thank you very much for any help !


hardware.cpp   in nexloop i put

    if (NEX_RET_EVENT_AUTOWAKE == c)

        {

            if (nexSerial.available() >= 3)

            {

                __buffer[0] = c;

                for (i = 1; i < 4; i++)

                {

                    __buffer[i] = nexSerial.read();

                }

                __buffer[i] = 0x00;

                if (0xFF == __buffer[1] && 0xFF == __buffer[2] && 0xFF == __buffer[3])

                {

                    // Need to create a new function to call when now wakes up

                    // call this new onwake function

     sendCommand("page 1");

                } 

            }

        }


arduino code----------------

#include "Nextion.h"

 

void n0PopCallback(void *ptr);

void b0PopCallback(void *ptr);

void b1PopCallback(void *ptr);

 

NexNumber n0 = NexNumber(0, 3, "n0");

NexButton b0 = NexButton(0, 1, "b0");

NexButton b1 = NexButton(0, 2, "b1");

 

char buffer[100] = {0};

NexTouch *nex_listen_list[] =

{

    &n0,

    &b0,

    &b1,

    NULL

};

 

void n0PopCallback(void *ptr)

{

    n0.setValue(50);

}

 

void b0PopCallback(void *ptr)

{

    uint32_t number;

    n0.getValue(&number);

    number += 1;

    n0.setValue(number);

}

 

void b1PopCallback(void *ptr)

{

    uint32_t number;

    n0.getValue(&number);

    number += 1;

    n0.setValue(number);

}

 

void setup(void)

{

    nexInit();

    n0.attachPop(n0PopCallback);

    b0.attachPop(b0PopCallback);

    b1.attachPop(b1PopCallback);

    dbSerialPrintln("setup done");

}

 

void loop(void)

{

    nexLoop(nex_listen_list);

}

 

void wakeup()

{

      dbSerialPrintln("you wake up");

 

    ///here it will be the code

}



HMI
ino
(953 Bytes)
1 Comment

 

Forum has been closed since the Nov. 15, 2017  23:59:59.

Please use new forum nextion.itead.cc