1D-Pong game based on a LED strip with 150 LPD6803-controlled pixels. Game keeps score for 'best-of-21' game. Written for KL25Z
Diff: GameButton.cpp
- Revision:
- 21:a554229e884b
- Child:
- 26:448ee3b0b481
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GameButton.cpp Tue Aug 27 18:54:15 2013 +0000 @@ -0,0 +1,30 @@ +#include "GameButton.h" + +GameButton::GameButton(PinName pin, float time=0.5) +{ + pushflag = false; + intpin = new InterruptIn(pin); + (*intpin).mode(PullUp); + (*intpin).fall(this, &GameButton::PushHandler); + m_time = time; + m_timeoutactive = false; + //timeout = new Timeout(m_time); +} + +void GameButton::PushHandler(void) +{ + pushflag = true; + m_timeoutactive = true; + timeout.attach(this, &GameButton::TimeOutHandler, m_time); + pushhandlercallback(); +} + +void GameButton::TimeOutHandler(void) +{ + m_timeoutactive = false; +} + +bool GameButton::getTimeoutActive(void) +{ + return m_timeoutactive; +} \ No newline at end of file