1D-Pong game based on a LED strip with 150 LPD6803-controlled pixels. Game keeps score for 'best-of-21' game. Written for KL25Z
GameButton.cpp
- Committer:
- vsluiter
- Date:
- 2013-09-07
- Revision:
- 26:448ee3b0b481
- Parent:
- 21:a554229e884b
File content as of revision 26:448ee3b0b481:
#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; inpin = pin; //timeout = new Timeout(m_time); } void GameButton::PushHandler(void) { DigitalIn input(inpin); wait_ms(5); if(!input) { 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; }