From da142269aa5d999d836eae938ca4bbafc23869fc Mon Sep 17 00:00:00 2001 From: Alessandro Monticelli Date: Fri, 24 Nov 2023 14:34:13 +0100 Subject: [PATCH] [TASKS] Create TaskWithState --- smart_bridge/src/kernel/TaskWithState.h | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 smart_bridge/src/kernel/TaskWithState.h 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