Skip to content

Commit

Permalink
[TEST TASK] Add a simple blinking task
Browse files Browse the repository at this point in the history
  • Loading branch information
aleemont1 committed Nov 25, 2023
1 parent 64d61dc commit 032ba81
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
28 changes: 28 additions & 0 deletions smart_bridge/src/tasks/BlinkTask.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "BlinkTask.h"

BlinkTask::BlinkTask(int pin)
{
this->pin = pin;
}

void BlinkTask::init(int period)
{
Task::init(period);
led = new Led(pin);
state = OFF;
}

void BlinkTask::tick()
{
switch (state)
{
case OFF:
led->switchOn();
state = ON;
break;
case ON:
led->switchOff();
state = OFF;
break;
}
}
20 changes: 20 additions & 0 deletions smart_bridge/src/tasks/BlinkTask.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef __BLINK_TASK__
#define __BLINK_TASK__

#include "kernel/Task.h"
#include "components/api/Led.h"

class BlinkTask: public Task {

int pin;
Light* led;
enum { ON, OFF} state;

public:

BlinkTask(int pin);
void init(int period);
void tick();
};

#endif

0 comments on commit 032ba81

Please sign in to comment.