Manager library for an existing state library. Enables easy usage with Arduino.
#include "Statemanager.h"
/**
* Initialization
*
* @param byte [buttonStateSwitchPin] pin number of button that switches the states.
* @param byte stateVector Vector containing all initial states.
*/
// Create vector with states
const State stateArr[] = {
State(STATE_IDLE_ENTER, STATE_IDLE_UPDATE, STATE_IDLE_EXIT),
State(STATE_MVSACALIBRATION_UPDATE),
State(STATE_GRIPPERCALIBRATION_ENTER, STATE_GRIPPERCALIBRATION_UPDATE, STATE_GRIPPERCALIBRATION_EXIT),
State(STATE_GRIPPERSIMULINK_MODE1_ENTER, STATE_GRIPPERSIMULINK_MODE1_UPDATE, STATE_GRIPPERSIMULINK_MODE1_EXIT)
};
// Initialize the stateManager with the states
std::vector<State> statesVector (stateArr, stateArr + sizeof(stateArr) / sizeof(stateArr[0]) );
StateManager stateMngr = StateManager(BUTTON_STATESWITCH_PIN, statesVector);
/**
* Usage
*/
// In the Arduino loop
void loop()
{
// Check states (check which one is active and run the update function)
stateMngr.checkStates();
}
// Transition to next state
stateMngr.transitionToNextState();
This library has been developed by Wilbert van de Ridder for a BSc assignment at the University of Twente.