migration to platformio

This commit is contained in:
Marcel 2024-05-23 16:16:00 +02:00
commit cad91967b1
22 changed files with 2985 additions and 0 deletions

37
src/statemachine.cpp Normal file
View file

@ -0,0 +1,37 @@
#include "statemachine.h"
#include "station.h"
#include "context.h"
StateMachine::StateMachine(State* initialState)
: currentState(initialState) {}
StateMachine::~StateMachine() {
delete currentState;
}
void StateMachine::updateState(State* newState) {
if (newState != currentState) {
delete currentState;
currentState = newState;
}
}
void StateMachine::pickedUp(const Context& context) {
State* newState = currentState->pickedUp(context);
updateState(newState);
}
void StateMachine::putDown(const Context& context, Station* newStation) {
State* newState = currentState->putDown(context, newStation);
updateState(newState);
}
void StateMachine::update(const Context& context) {
State* newState = currentState->update(context);
updateState(newState);
}
String StateMachine::updateDisplay() const
{
return currentState->updateDisplay();
}