Skip to content

Commit

Permalink
[TASKS] Create TaskWithState
Browse files Browse the repository at this point in the history
  • Loading branch information
aleemont1 committed Nov 24, 2023
1 parent a853916 commit da14226
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions smart_bridge/src/kernel/TaskWithState.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef __TASK_WITH_STATE__
#define __TASK_WITH_STATE__

#include "Task.h"
#include <Arduino.h>

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

0 comments on commit da14226

Please sign in to comment.