Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
vegano1 committed Jan 20, 2024
1 parent a636eae commit d5aa4f6
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 33 deletions.
12 changes: 8 additions & 4 deletions hepa-uv/core/tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ void hepauv_tasks::start_tasks(
can_task::start_reader(can_bus);

// TODO: including led_hardware for testing, this should be a AssesorClient
auto& hepa_task = hepa_task_builder.start(5, "hepa_fan", gpio_drive_pins, led_hardware);
auto& uv_task = uv_task_builder.start(5, "uv_ballast", gpio_drive_pins, led_hardware);
auto& led_control_task = led_control_task_builder.start(5, "push_button_leds", led_hardware);
auto& hepa_task =
hepa_task_builder.start(5, "hepa_fan", gpio_drive_pins, led_hardware);
auto& uv_task =
uv_task_builder.start(5, "uv_ballast", gpio_drive_pins, led_hardware);
auto& led_control_task =
led_control_task_builder.start(5, "push_button_leds", led_hardware);

tasks.hepa_task_handler = &hepa_task;
tasks.uv_task_handler = &uv_task;
Expand All @@ -61,7 +64,8 @@ void hepauv_tasks::QueueClient::send_uv_message(const uv_task::TaskMessage& m) {
uv_queue->try_write(m);
}

void hepauv_tasks::QueueClient::send_led_control_message(const led_control_task::TaskMessage& m) {
void hepauv_tasks::QueueClient::send_led_control_message(
const led_control_task::TaskMessage& m) {
led_control_queue->try_write(m);
}

Expand Down
8 changes: 6 additions & 2 deletions hepa-uv/firmware/led_control_task/led_control_hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
using namespace led_control_hardware;

// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
auto LEDControlHardware::initialize() -> void { button_led_hw_initialize_leds(); }
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) {
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);
}
4 changes: 2 additions & 2 deletions hepa-uv/firmware/main_rev1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#include "common/firmware/utility_gpio.h"
#include "hepa-uv/core/messages.hpp"
#include "hepa-uv/core/tasks.hpp"
#include "hepa-uv/firmware/utility_gpio.h"
#include "hepa-uv/firmware/led_hardware.h"
#include "hepa-uv/firmware/led_control_hardware.hpp"
#include "hepa-uv/firmware/led_hardware.h"
#include "hepa-uv/firmware/utility_gpio.h"

static auto iWatchdog = iwdg::IndependentWatchDog{};

Expand Down
5 changes: 2 additions & 3 deletions include/hepa-uv/core/hepa_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include "common/core/logging.h"
#include "common/core/message_queue.hpp"
#include "common/firmware/gpio.hpp"
#include "hepa-uv/core/constants.h"
#include "hepa-uv/core/messages.hpp"
#include "hepa-uv/firmware/gpio_drive_hardware.hpp"
#include "hepa-uv/firmware/led_control_hardware.hpp"
#include "hepa-uv/core/constants.h"

namespace hepa_task {

Expand All @@ -18,8 +18,7 @@ class HepaMessageHandler {
public:
explicit HepaMessageHandler(
gpio_drive_hardware::GpioDrivePins &drive_pins,
led_control_hardware::LEDControlHardware &led_hardware
)
led_control_hardware::LEDControlHardware &led_hardware)
: drive_pins{drive_pins}, led_hardware{led_hardware} {
// get current state
hepa_push_button = gpio::is_set(drive_pins.hepa_push_button);
Expand Down
22 changes: 9 additions & 13 deletions include/hepa-uv/core/led_control_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class LEDControlInterface {
LEDControlInterface(const LEDControlInterface&) = delete;
LEDControlInterface(LEDControlInterface&&) = delete;
auto operator=(LEDControlInterface&&) -> LEDControlInterface& = delete;
auto operator=(const 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;
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 {
Expand All @@ -36,14 +36,11 @@ class LEDControlMessageHandler {
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)
);
// 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;
Expand All @@ -69,8 +66,7 @@ class LEDControlTask {
* Task entry point.
*/
[[noreturn]] void operator()(LEDControlInterface* hardware_handle) {
auto handler =
LEDControlMessageHandler(*hardware_handle);
auto handler = LEDControlMessageHandler(*hardware_handle);
TaskMessage message{};

for (;;) {
Expand Down
2 changes: 1 addition & 1 deletion include/hepa-uv/core/messages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace led_control_task_messages {
* A message to change the leds on the push buttons
*/
struct PushButtonLED {
PUSH_BUTTON_TYPE button;
PUSH_BUTTON_TYPE button;
double r = 0, g = 0, b = 0, w = 0;
};

Expand Down
9 changes: 5 additions & 4 deletions include/hepa-uv/core/tasks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#include "can/core/message_writer.hpp"
#include "common/core/freertos_timer.hpp"
#include "hepa-uv/core/hepa_task.hpp"
#include "hepa-uv/core/uv_task.hpp"
#include "hepa-uv/core/led_control_task.hpp"
#include "hepa-uv/firmware/led_control_hardware.hpp"
#include "hepa-uv/core/uv_task.hpp"
#include "hepa-uv/firmware/gpio_drive_hardware.hpp"
#include "hepa-uv/firmware/led_control_hardware.hpp"

namespace hepauv_tasks {

Expand Down Expand Up @@ -49,8 +49,9 @@ struct AllTask {
uv_task::UVTask<freertos_message_queue::FreeRTOSMessageQueue>*
uv_task_handler{nullptr};

led_control_task::LEDControlTask<freertos_message_queue::FreeRTOSMessageQueue>*
led_control_task_handler{nullptr};
led_control_task::LEDControlTask<
freertos_message_queue::FreeRTOSMessageQueue>* led_control_task_handler{
nullptr};
};

/**
Expand Down
2 changes: 1 addition & 1 deletion include/hepa-uv/core/uv_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class UVMessageHandler {
gpio_drive_hardware::GpioDrivePins &drive_pins,
led_control_hardware::LEDControlHardware &led_hardware)
: drive_pins{drive_pins},
led_hardware{led_hardware},
led_hardware{led_hardware},
_timer(
"UVTask", [ThisPtr = this] { ThisPtr->timer_callback(); },
DELAY_MS) {
Expand Down
6 changes: 3 additions & 3 deletions include/hepa-uv/firmware/led_control_hardware.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ class LEDControlHardware : public led_control_task::LEDControlInterface {
LEDControlHardware(const LEDControlHardware&) = delete;
LEDControlHardware(LEDControlHardware&&) = delete;
auto operator=(LEDControlHardware&&) -> LEDControlHardware& = delete;
auto operator=(const LEDControlHardware&)
-> LEDControlHardware& = delete;
auto operator=(const LEDControlHardware&) -> LEDControlHardware& = delete;
~LEDControlHardware() final = default;

auto initialize() -> void;
void set_button_led_power(uint8_t button, uint32_t r, uint32_t g, uint32_t b, uint32_t w) final;
void set_button_led_power(uint8_t button, uint32_t r, uint32_t g,
uint32_t b, uint32_t w) final;
};

} // namespace led_control_hardware

0 comments on commit d5aa4f6

Please sign in to comment.