Skip to content

Commit

Permalink
Add LedBlinkTask class impl. for controlling LED
Browse files Browse the repository at this point in the history
blinking
  • Loading branch information
23Emaaaa committed Nov 25, 2023
1 parent 0176402 commit e5d41a4
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions smart_bridge/src/tasks/LedBlinkTask.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "LedBlinkTask.h"

/**
* @brief Construct a new LedBlinkTask object.
*
* @param ledPin The pin number where the LED is connected.
*/
LedBlinkTask::LedBlinkTask(int ledPin)
{
this->ledPin = ledPin;
}

/**
* @brief Initialize the LedBlinkTask.
*
* @param period The period of the task in milliseconds.
*/
void LedBlinkTask::init(int period)
{
Task::init(period);
state = SWITCH_OFF;
}

/**
* @brief Perform the LedBlinkTask.
*
* This method is called periodically based on the period of the task.
* It switches the state of the LED from on to off, or from off to on.
*/
void LedBlinkTask::tick()
{
switch (state)
{
case State::SWITCH_OFF:
state = State::SWITCH_ON;
break;
case State::SWITCH_ON:
state = State::SWITCH_OFF;
break;
}
}

0 comments on commit e5d41a4

Please sign in to comment.