Skip to content

Commit

Permalink
Add LedBlinkTask class def. for blinking an LED
Browse files Browse the repository at this point in the history
  • Loading branch information
23Emaaaa committed Nov 25, 2023
1 parent e1123eb commit 0176402
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 4 deletions.
8 changes: 4 additions & 4 deletions smart_bridge/src/components/api/Button.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ class Button

/**
* @brief Check if the button is pressed.
*
*
* @return true if the button is pressed, false otherwise.
*/
virtual bool checkButtonPressStatus() = 0;

/**
* @brief Check if the button is released.
*
*
* @return true if the button is released, false otherwise.
*/
virtual bool checkButtonReleaseStatus() = 0;
Expand All @@ -43,15 +43,15 @@ class Button

/**
* @brief Retrieves the last time the button state was synchronized.
*
*
* @return The last synchronization time.
*/
long retrieveLastButtonSyncTime();

protected:
/**
* @brief Set the last synchronization time.
*
*
* @param time The new synchronization time.
*/
void setLastButtonSyncTime(long time);
Expand Down
57 changes: 57 additions & 0 deletions smart_bridge/src/tasks/LedBlinkTask.h
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__

0 comments on commit 0176402

Please sign in to comment.