mirror of
https://github.com/thelsing/knx.git
synced 2025-10-12 11:15:54 +02:00
57 lines
823 B
C++
57 lines
823 B
C++
#include "state.h"
|
|
#include "Arduino.h"
|
|
|
|
#ifdef USE_STATES
|
|
|
|
State* volatile currentState = 0;
|
|
State* volatile nextState = 0;
|
|
|
|
void switchToSate(State& state)
|
|
{
|
|
nextState = &state;
|
|
}
|
|
|
|
void checkStates()
|
|
{
|
|
if (!nextState)
|
|
return;
|
|
|
|
if (nextState == currentState)
|
|
return;
|
|
|
|
if (currentState)
|
|
{
|
|
printf("Leave %s\n", currentState->name());
|
|
currentState->leaveState();
|
|
}
|
|
|
|
currentState = nextState;
|
|
|
|
if (currentState)
|
|
{
|
|
printf("Enter %s\n", currentState->name());
|
|
currentState->enterState();
|
|
}
|
|
}
|
|
|
|
bool State::ledOn()
|
|
{
|
|
return _ledOn;
|
|
}
|
|
|
|
bool State::ledBlink()
|
|
{
|
|
return _ledBlink;
|
|
}
|
|
|
|
unsigned int State::blinkPeriod()
|
|
{
|
|
return _blinkPeriod;
|
|
}
|
|
|
|
void State::loop()
|
|
{
|
|
checkStates();
|
|
}
|
|
|
|
#endif |