-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename light_control_task to led_control_task
- Loading branch information
Showing
12 changed files
with
159 additions
and
156 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
13 changes: 13 additions & 0 deletions
13
hepa-uv/firmware/led_control_task/led_control_hardware.cpp
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,13 @@ | ||
#include "hepa-uv/firmware/led_control_hardware.hpp" | ||
|
||
#include "hepa-uv/core/led_control_task.hpp" | ||
#include "hepa-uv/firmware/led_hardware.h" | ||
|
||
using namespace led_control_hardware; | ||
|
||
// NOLINTNEXTLINE(readability-convert-member-functions-to-static) | ||
auto LEDControlHardware::initialize() -> void { button_led_hw_initialize_leds(); } | ||
|
||
void LEDControlHardware::set_button_led_power(uint8_t button, uint32_t r, uint32_t g, uint32_t b, uint32_t w) { | ||
set_button_led_pwm(static_cast<PUSH_BUTTON_TYPE>(button), r, g, b, w); | ||
} |
17 changes: 0 additions & 17 deletions
17
hepa-uv/firmware/light_control_task/light_control_hardware.cpp
This file was deleted.
Oops, something went wrong.
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
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,89 @@ | ||
#pragma once | ||
|
||
#include <concepts> | ||
|
||
#include "common/core/message_queue.hpp" | ||
#include "hepa-uv/core/constants.h" | ||
#include "hepa-uv/core/messages.hpp" | ||
|
||
namespace led_control_task { | ||
|
||
using TaskMessage = led_control_task_messages::TaskMessage; | ||
|
||
class LEDControlInterface { | ||
public: | ||
LEDControlInterface() = default; | ||
LEDControlInterface(const LEDControlInterface&) = delete; | ||
LEDControlInterface(LEDControlInterface&&) = delete; | ||
auto operator=(LEDControlInterface&&) -> LEDControlInterface& = delete; | ||
auto operator=(const LEDControlInterface&) | ||
-> LEDControlInterface& = delete; | ||
virtual ~LEDControlInterface() = default; | ||
|
||
virtual auto set_button_led_power(uint8_t button, uint32_t r, uint32_t g, uint32_t b, uint32_t w) -> void = 0; | ||
}; | ||
|
||
class LEDControlMessageHandler { | ||
public: | ||
LEDControlMessageHandler(LEDControlInterface& hardware) | ||
: _hardware(hardware) {} | ||
|
||
auto handle_message(const TaskMessage& message) -> void { | ||
std::visit([this](auto m) { this->handle(m); }, message); | ||
} | ||
|
||
private: | ||
auto handle(std::monostate&) -> void {} | ||
|
||
auto handle(const led_control_task_messages::PushButtonLED& msg) -> void { | ||
// Sets the Push button LED colors | ||
_hardware.set_button_led_power( | ||
msg.button, | ||
static_cast<uint32_t>(msg.r), | ||
static_cast<uint32_t>(msg.g), | ||
static_cast<uint32_t>(msg.b), | ||
static_cast<uint32_t>(msg.w) | ||
); | ||
} | ||
|
||
LEDControlInterface& _hardware; | ||
}; | ||
|
||
/** | ||
* The task entry point. | ||
*/ | ||
template <template <class> class QueueImpl> | ||
requires MessageQueue<QueueImpl<TaskMessage>, TaskMessage> | ||
class LEDControlTask { | ||
public: | ||
using Messages = TaskMessage; | ||
using QueueType = QueueImpl<TaskMessage>; | ||
LEDControlTask(QueueType& queue) : queue{queue} {} | ||
LEDControlTask(const LEDControlTask& c) = delete; | ||
LEDControlTask(const LEDControlTask&& c) = delete; | ||
auto operator=(const LEDControlTask& c) = delete; | ||
auto operator=(const LEDControlTask&& c) = delete; | ||
~LEDControlTask() = default; | ||
|
||
/** | ||
* Task entry point. | ||
*/ | ||
[[noreturn]] void operator()(LEDControlInterface* hardware_handle) { | ||
auto handler = | ||
LEDControlMessageHandler(*hardware_handle); | ||
TaskMessage message{}; | ||
|
||
for (;;) { | ||
if (queue.try_read(&message, queue.max_delay)) { | ||
handler.handle_message(message); | ||
} | ||
} | ||
} | ||
|
||
[[nodiscard]] auto get_queue() const -> QueueType& { return queue; } | ||
|
||
private: | ||
QueueType& queue; | ||
}; | ||
|
||
} // namespace led_control_task |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.