CompPicture.ino
#include "Nextion.h"
/*
* Declare a picture object [page id:0,component id:1, component name: "p0"].
*/
NexPicture p0 = NexPicture(0, 1, "p0");
NexTouch *nex_listen_list[] =
{
&p0,
NULL
};
void p0PopCallback(void *ptr)
{
uint32_t number = 0;
dbSerialPrintln("p0PopCallback");
p0.getPic(&number);
if (number == 1)
{
number = 2;
}
else
{
number = 1;
}
p0.setPic(number);
}
void setup(void)
{
nexInit();
p0.attachPop(p0PopCallback);
dbSerialPrintln("setup done");
}
void loop(void)
{
nexLoop(nex_listen_list);
}
nexLoop
void nexLoop(NexTouch *nex_listen_list[])
Listen touch event and calling callbacks attached before.
Definition: NexHardware.cpp:235
NexPicture::setPic
bool setPic(uint32_t number)
Set picture's number.
Definition: NexPicture.cpp:55
NexTouch::attachPop
void attachPop(NexTouchEventCb pop, void *ptr=NULL)
Attach an callback function of pop touch event.
Definition: NexTouch.cpp:39
nexInit
bool nexInit(void)
Init Nextion.
Definition: NexHardware.cpp:220
NexPicture
NexPicture component.
Definition: NexPicture.h:30
Nextion.h
The header file including all other header files provided by this library.
NexPicture::getPic
bool getPic(uint32_t *number)
Get picture's number.
Definition: NexPicture.cpp:46
NexTouch
Father class of the components with touch events.
Definition: NexTouch.h:53