-
Notifications
You must be signed in to change notification settings - Fork 322
/
NexTouch.h
116 lines (99 loc) · 2.95 KB
/
NexTouch.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
* @file NexTouch.h
*
* The definition of class NexTouch.
*
* @author Wu Pengfei (email:<[email protected]>)
* @date 2015/8/13
*
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#ifndef __NEXTOUCH_H__
#define __NEXTOUCH_H__
#include <Arduino.h>
#include "NexConfig.h"
#include "NexObject.h"
/**
* @addtogroup TouchEvent
* @{
*/
/**
* Push touch event occuring when your finger or pen coming to Nextion touch pannel.
*/
#define NEX_EVENT_PUSH (0x01)
/**
* Pop touch event occuring when your finger or pen leaving from Nextion touch pannel.
*/
#define NEX_EVENT_POP (0x00)
/**
* Type of callback funciton when an touch event occurs.
*
* @param ptr - user pointer for any purpose. Commonly, it is a pointer to a object.
* @return none.
*/
typedef void (*NexTouchEventCb)(void *ptr);
/**
* Father class of the components with touch events.
*
* Derives from NexObject and provides methods allowing user to attach
* (or detach) a callback function called when push(or pop) touch event occurs.
*/
class NexTouch: public NexObject
{
public: /* static methods */
static void iterate(NexTouch **list, uint8_t pid, uint8_t cid, int32_t event);
public: /* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexTouch(uint8_t pid, uint8_t cid, const char *name);
/**
* Attach an callback function of push touch event.
*
* @param push - callback called with ptr when a push touch event occurs.
* @param ptr - parameter passed into push[default:NULL].
* @return none.
*
* @note If calling this method multiply, the last call is valid.
*/
void attachPush(NexTouchEventCb push, void *ptr = NULL);
/**
* Detach an callback function.
*
* @return none.
*/
void detachPush(void);
/**
* Attach an callback function of pop touch event.
*
* @param pop - callback called with ptr when a pop touch event occurs.
* @param ptr - parameter passed into pop[default:NULL].
* @return none.
*
* @note If calling this method multiply, the last call is valid.
*/
void attachPop(NexTouchEventCb pop, void *ptr = NULL);
/**
* Detach an callback function.
*
* @return none.
*/
void detachPop(void);
private: /* methods */
void push(void);
void pop(void);
private: /* data */
NexTouchEventCb __cb_push;
void *__cbpush_ptr;
NexTouchEventCb __cb_pop;
void *__cbpop_ptr;
};
/**
* @}
*/
#endif /* #ifndef __NEXTOUCH_H__ */