TACOS/App/Src/tasks/toggle.cpp

49 lines
742 B
C++

/*
* toggle.cpp
*
* Created on: Nov 10, 2023
* Author: Dario
*/
#include <tasks/toggle.hpp>
#include <sta/tacos/statemachine.hpp>
#include <sta/debug/debug.hpp>
namespace demo
{
Toggle::Toggle()
: sta::tacos::TacosThread{ "Toggle", osPriorityNormal }
{
}
void Toggle::init()
{
}
void Toggle::func()
{
osDelay(5000);
// Have we been requested to terminate while waiting?
if (isTerminationRequested())
return;
// Do some important stuff...
uint16_t state = sta::tacos::Statemachine::instance()->getCurrentState();
uint16_t next;
if (state != 2)
{
next = 1 - state;
STA_DEBUG_PRINTLN("Toggle!");
sta::tacos::Statemachine::instance()->requestStateTransition(state, next, 0);
}
}
}