A library for ADS7843 touch-screens which is interrupt driven, allowing you to register callback handlers for touchStart, touchMove and touchEnd events.
Dependents: TouchScreenCalibrate TouchScreenGUIDemo
Diff: TouchScreen.h
- Revision:
- 3:8b5fcf3857ac
- Parent:
- 1:9bd85d0331a8
--- a/TouchScreen.h Sun May 08 14:43:16 2016 +0000 +++ b/TouchScreen.h Tue May 17 16:28:08 2016 +0000 @@ -66,18 +66,33 @@ * Register a handler which will be called every time a touch is detected on the screen **/ void setTouchStartHandler(TouchCallbackHandler handler); - + + template<typename T> + void setTouchStartHandler(T* tptr, void (T::*mptr)(TouchPosition)) { + _touchStartHandler.attach(tptr, mptr); + } + /** * Register a handler which will be called every time a movement greater than a given threshold is detected. * You can set the threshold with the setMovementThreshold() method **/ void setTouchMoveHandler(TouchCallbackHandler handler); + template<typename T> + void setTouchMoveHandler(T* tptr, void (T::*mptr)(TouchPosition)) { + _touchMoveHandler.attach(tptr, mptr); + } + /** * Register a handler which will be called when a touch stops being detected **/ void setTouchEndHandler(TouchCallbackHandler handler); + template<typename T> + void setTouchEndHandler(T* tptr, void (T::*mptr)(TouchPosition)) { + _touchEndHandler.attach(tptr, mptr); + } + /** * Set the dimensions and orientation of the LCD screen **/ @@ -136,11 +151,9 @@ TouchPosition _getPosition(); - TouchCallbackHandler _touchStartHandler; - TouchCallbackHandler _touchMoveHandler; - TouchCallbackHandler _touchEndHandler; - - FunctionPointer _f; + FunctionPointerArg1<void,TouchPosition> _touchStartHandler; + FunctionPointerArg1<void,TouchPosition> _touchMoveHandler; + FunctionPointerArg1<void,TouchPosition> _touchEndHandler; Thread* _handlerThread;