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.cpp
- Revision:
- 3:8b5fcf3857ac
- Parent:
- 2:e5ea47fb1ede
diff -r e5ea47fb1ede -r 8b5fcf3857ac TouchScreen.cpp --- a/TouchScreen.cpp Sun May 08 14:43:16 2016 +0000 +++ b/TouchScreen.cpp Tue May 17 16:28:08 2016 +0000 @@ -28,17 +28,17 @@ void TouchScreen::setTouchStartHandler(TouchCallbackHandler handler) { - _touchStartHandler = handler; + _touchStartHandler.attach(handler); } void TouchScreen::setTouchMoveHandler(TouchCallbackHandler handler) { - _touchMoveHandler = handler; + _touchMoveHandler.attach(handler); } void TouchScreen::setTouchEndHandler(TouchCallbackHandler handler) { - _touchEndHandler = handler; + _touchEndHandler.attach(handler); } void TouchScreen::setMovementTheshold(int thresholdInPixels) { @@ -116,7 +116,7 @@ _currentPosition = _getPosition(); // Raise an event if we got a valid position if(_currentPosition.valid && _touchStartHandler) { - _touchStartHandler(_currentPosition); + _touchStartHandler.call(_currentPosition); } } @@ -124,7 +124,7 @@ { // Raise an event if we got a valid position if(_currentPosition.valid && _touchEndHandler) { - _touchEndHandler(_currentPosition); + _touchEndHandler.call(_currentPosition); } } @@ -139,7 +139,7 @@ if(_touchMoveHandler && _moved(newPosition, _lastPosition)) { _lastPosition = _currentPosition; _currentPosition = newPosition; - _touchMoveHandler(_currentPosition); + _touchMoveHandler.call(_currentPosition); } }