mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/TACOS.git
synced 2025-06-12 01:25:59 +00:00
53 lines
756 B
C++
53 lines
756 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 (!isRunning())
|
|
return;
|
|
|
|
// Do some important stuff...
|
|
|
|
uint16_t state = sta::tacos::Statemachine::instance()->getCurrentState();
|
|
uint16_t next;
|
|
|
|
if (state != 2)
|
|
{
|
|
next = 1 - state;
|
|
}
|
|
else
|
|
{
|
|
next = 0;
|
|
}
|
|
|
|
STA_DEBUG_PRINTLN("Toggle!");
|
|
sta::tacos::Statemachine::instance()->requestStateTransition(state, next, 0);
|
|
}
|
|
}
|
|
|
|
|