feat: began working on cleaning up explorative main file

This commit is contained in:
Leonetienne
2025-12-13 20:50:31 +01:00
commit 181139aae5
11 changed files with 583 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
#pragma once
#include <Arduino.h>
// Singleton-instance
class StateMachine
{
public:
StateMachine(const StateMachine&) = delete;
StateMachine(StateMachine&&) = delete;
static StateMachine& getInstance() noexcept;
enum class State {
INITIALIZING,
IDLING,
MOVING,
ERROR
};
State getState() const noexcept { return state; };
String getLastError() const noexcept { return lastError; };
// May fail if a state transition from state a to b is not valid
bool setState(const State newState) noexcept;
bool raiseError(const String& reason) noexcept;
bool canSwitchToState(const State newState) const noexcept;
private:
StateMachine() noexcept {};
State state = State::INITIALIZING;
String lastError = "";
};