forked from DanNixon/NeoNextion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNextionCallbackFunctionHandler.h
45 lines (38 loc) · 1.01 KB
/
NextionCallbackFunctionHandler.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
/*! \file */
#ifndef __NEONEXTION_NEXTIONCALLBACKFUNCTIONHANDLER
#define __NEONEXTION_NEXTIONCALLBACKFUNCTIONHANDLER
#include "INextionCallback.h"
/*!
* \class NextionCallbackFunctionHandler
* \brief Event handler for function pointers.
*/
class NextionCallbackFunctionHandler : public INextionCallback
{
public:
/*!
* \typedef NextionFunction
* \brief Event handler function for display events.
*/
typedef void (*NextionFunction)(NextionEventType, INextionTouchable *);
/*!
* \brief Creates a new function pointer callback handler.
* \param f Pointer to callback function
*/
NextionCallbackFunctionHandler(NextionFunction f)
: m_function(f)
{
}
/*!
* \copydoc INextionCallback::handleNextionEvent
*
* Displatches the event to the function.
*/
void handleNextionEvent(NextionEventType type, INextionTouchable *widget)
{
if (m_function != NULL)
m_function(type, widget);
}
private:
NextionFunction m_function; //!< Pointer to the callback function
};
#endif