diff --git a/smart_bridge/src/kernel/TaskWithState.h b/smart_bridge/src/kernel/TaskWithState.h new file mode 100644 index 0000000..2b23a1d --- /dev/null +++ b/smart_bridge/src/kernel/TaskWithState.h @@ -0,0 +1,28 @@ +#ifndef __TASK_WITH_STATE__ +#define __TASK_WITH_STATE__ + +#include "Task.h" +#include + +class TaskWithState : public Task +{ +public: + TaskWithState() : Task(){}; // Default constructor + + void setState(const int state) + { + this->state = state; + this->stateTimestamp = millis(); + } + + long timeInState() + { + return millis() - stateTimestamp; + } + +private: + int state; + long stateTimestamp; +}; + +#endif \ No newline at end of file