-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add LedBlinkTask class def. for blinking an LED
- Loading branch information
Showing
2 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#ifndef __LED_BLINK_TASK__ | ||
#define __LED_BLINK_TASK__ | ||
|
||
#include "kernel/Task.h" | ||
#include "components/api/Light.h" | ||
|
||
/** | ||
* @brief Represents a task for blinking an LED. | ||
* | ||
* This class extends the Task class and provides functionalities to initialize and perform the task. | ||
*/ | ||
class LedBlinkTask : public Task | ||
{ | ||
public: | ||
/** | ||
* @brief Construct a new LedBlinkTask object. | ||
* | ||
* @param ledPin The pin number where the LED is connected. | ||
*/ | ||
LedBlinkTask(int ledPin); | ||
|
||
/** | ||
* @brief Initialize the LedBlinkTask. | ||
* | ||
* @param period The period of the task in milliseconds. | ||
*/ | ||
void init(int period); | ||
|
||
/** | ||
* @brief Perform the LedBlinkTask. | ||
* | ||
* This method is called periodically based on the period of the task. | ||
*/ | ||
void tick(); | ||
|
||
private: | ||
/** | ||
* @brief The pin number where the LED is connected. | ||
*/ | ||
int ledPin; | ||
|
||
/** | ||
* @brief Pointer to the Light object representing the LED. | ||
*/ | ||
Light *led; | ||
|
||
/** | ||
* @brief The current state of the LED (SWITCH_ON if the LED is on, SWITCH_OFF if the LED is off). | ||
*/ | ||
enum State | ||
{ | ||
SWITCH_ON, | ||
SWITCH_OFF | ||
} state; | ||
}; | ||
|
||
#endif // __LED_BLINK_TASK__ |