Mark van Renswoude
ba58eb93c0
- Button library - State handling and transitions - Default state: dual counter display - User unknown state: static for now - Lost the game state: static for now
46 lines
740 B
C++
46 lines
740 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);
|
|
|
|
|
|
setCurrentState(new DefaultState());
|
|
}
|
|
|
|
|
|
void loop()
|
|
{
|
|
currentTime = millis();
|
|
|
|
buttonA->update(currentTime);
|
|
buttonB->update(currentTime);
|
|
|
|
currentState->loop();
|
|
}
|