CompCrop.ino
#include "Nextion.h"
/*
* Declare a crop object [page id:0,component id:1, component name: "q0"].
*/
NexCrop q0 = NexCrop(0, 1, "q0");
NexTouch *nex_listen_list[] =
{
&q0,
NULL
};
/*
* Crop component pop callback function.
* In this example,the image of current crop component will be changed every time when it is released.
*/
void q0PopCallback(void *ptr)
{
uint32_t number = 0;
dbSerialPrintln("q0PopCallback");
q0.getPic(&number);
number += 1;
number %= 2;
q0.setPic(number);
}
void setup(void)
{
nexInit();
q0.attachPop(q0PopCallback);
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
NexCrop::getPic
bool getPic(uint32_t *number)
Get the number of picture.
Definition: NexCrop.cpp:46
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
Nextion.h
The header file including all other header files provided by this library.
NexCrop::setPic
bool setPic(uint32_t number)
Set the number of picture.
Definition: NexCrop.cpp:55
NexCrop
NexCrop component.
Definition: NexCrop.h:30
NexTouch
Father class of the components with touch events.
Definition: NexTouch.h:53