NerfStatTrak/NerfStatTrek.ino
Mark van Renswoude 2e8007d510 Support for gun armed detection
First attempt at implementing animation
2016-12-05 23:42:20 +01:00

54 lines
972 B
C++

#include "NerfStatTrekConfig.h"
#include "Globals.h"
#include "StateHandler.h"
#include "StateDefault.h"
void setup()
{
// Configure display
display = new SegmentDisplay();
#ifdef SDUseSPI
display->setClockSpeed(NerfClockSpeed);
#else
display->setClockPin(NerfClockPin);
display->setDataPin(NerfDataPin);
#endif
display->setLatchPin(NerfLatchPin);
display->setDigits(NerfDigits);
display->begin();
// Configure buttons
buttonA = new Button();
buttonA->init(NerfButtonA);
buttonB = new Button();
buttonB->init(NerfButtonB);
buttonArmed = new Button();
buttonArmed->init(NerfButtonArmed, LOW);
setCurrentState(new DefaultState());
}
void loop()
{
currentTime = millis();
buttonA->update(currentTime);
buttonB->update(currentTime);
buttonArmed->update(currentTime);
// Count the shot no matter which state we're in
if (buttonArmed->changed() && !buttonArmed->pressed())
shots++;
currentState->loop();
}