forked from itead/ITEADLIB_Arduino_Nextion
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNexTouch.h
130 lines (110 loc) · 3.36 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
* @file NexTouch.h
*
* The definition of class NexTouch.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @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 "application.h"
#include "NexConfig.h"
#include "NexObject.h"
/**
* @addtogroup TouchEvent
* @{
*/
/**
* 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, void *value);
public: /* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name, void *value);
*/
NexTouch(uint8_t pid, uint8_t cid, const char *name, void *value);
/**
* 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);
/**
* Attach an callback function of value touch event.
*
* @param value - callback called with ptr when a value touch event occurs.
* @param ptr - parameter passed into value[default:NULL].
* @return none.
*
* @note If calling this method multiply, the last call is valid.
*/
void attachValue(NexTouchEventCb value, void *ptr = NULL);
/**
* Detach an callback function.
*
* @return none.
*/
void detachValue(void);
private: /* methods */
void push(void);
void pop(void);
void value(uint8_t type, void *value);
private: /* data */
NexTouchEventCb __cb_push;
void *__cbpush_ptr;
NexTouchEventCb __cb_pop;
void *__cbpop_ptr;
NexTouchEventCb __cb_value;
void *__cbvalue_ptr;
};
/**
* @}
*/
#endif /* #ifndef __NEXTOUCH_H__ */