NexTouch.cpp
Go to the documentation of this file.
#include "NexTouch.h"
NexTouch::NexTouch(uint8_t pid, uint8_t cid, const char *name)
:NexObject(pid, cid, name)
{
this->__cb_push = NULL;
this->__cb_pop = NULL;
this->__cbpop_ptr = NULL;
this->__cbpush_ptr = NULL;
}
void NexTouch::attachPush(NexTouchEventCb push, void *ptr)
{
this->__cb_push = push;
this->__cbpush_ptr = ptr;
}
void NexTouch::detachPush(void)
{
this->__cb_push = NULL;
this->__cbpush_ptr = NULL;
}
void NexTouch::attachPop(NexTouchEventCb pop, void *ptr)
{
this->__cb_pop = pop;
this->__cbpop_ptr = ptr;
}
void NexTouch::detachPop(void)
{
this->__cb_pop = NULL;
this->__cbpop_ptr = NULL;
}
void NexTouch::push(void)
{
if (__cb_push)
{
__cb_push(__cbpush_ptr);
}
}
void NexTouch::pop(void)
{
if (__cb_pop)
{
__cb_pop(__cbpop_ptr);
}
}
void NexTouch::iterate(NexTouch **list, uint8_t pid, uint8_t cid, int32_t event)
{
NexTouch *e = NULL;
uint16_t i = 0;
if (NULL == list)
{
return;
}
for(i = 0; (e = list[i]) != NULL; i++)
{
if (e->getObjPid() == pid && e->getObjCid() == cid)
{
e->printObjInfo();
if (NEX_EVENT_PUSH == event)
{
e->push();
}
else if (NEX_EVENT_POP == event)
{
e->pop();
}
break;
}
}
}
NexTouch::detachPop
void detachPop(void)
Detach an callback function.
Definition: NexTouch.cpp:45
NexTouch::attachPop
void attachPop(NexTouchEventCb pop, void *ptr=NULL)
Attach an callback function of pop touch event.
Definition: NexTouch.cpp:39
NexTouchEventCb
void(* NexTouchEventCb)(void *ptr)
Type of callback funciton when an touch event occurs.
Definition: NexTouch.h:45
NexTouch::detachPush
void detachPush(void)
Detach an callback function.
Definition: NexTouch.cpp:33
NEX_EVENT_PUSH
#define NEX_EVENT_PUSH
Push touch event occuring when your finger or pen coming to Nextion touch pannel. ...
Definition: NexTouch.h:32
NexTouch::NexTouch
NexTouch(uint8_t pid, uint8_t cid, const char *name)
Constructor.
Definition: NexTouch.cpp:18
NexTouch.h
The definition of class NexTouch.
NEX_EVENT_POP
#define NEX_EVENT_POP
Pop touch event occuring when your finger or pen leaving from Nextion touch pannel.
Definition: NexTouch.h:37
NexObject
Root class of all Nextion components.
Definition: NexObject.h:32
NexTouch
Father class of the components with touch events.
Definition: NexTouch.h:53
NexObject::printObjInfo
void printObjInfo(void)
Print current object'address, page id, component id and name.
Definition: NexObject.cpp:39
NexTouch::attachPush
void attachPush(NexTouchEventCb push, void *ptr=NULL)
Attach an callback function of push touch event.
Definition: NexTouch.cpp:27