Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
vegano1 committed Dec 16, 2024
1 parent dcca990 commit da7745c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 32 deletions.
33 changes: 8 additions & 25 deletions stm32-modules/flex-stacker/firmware/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,49 +20,36 @@ using EntryPoint = std::function<void(tasks::FirmwareTasks::QueueAggregator *)>;
using EntryPointUI = std::function<void(tasks::FirmwareTasks::QueueAggregator *,
i2c::hardware::I2C *)>;

// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
// NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables)
static auto motor_driver_task_entry = EntryPoint(motor_driver_task::run);

// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static auto motor_task_entry = EntryPoint(motor_control_task::run);

// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static auto ui_task_entry = EntryPointUI(ui_control_task::run);

// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static auto host_comms_entry = EntryPoint(host_comms_control_task::run);

// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static auto system_task_entry = EntryPoint(system_control_task::run);

// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static auto aggregator = tasks::FirmwareTasks::QueueAggregator();

// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static auto driver_task =
ot_utils::freertos_task::FreeRTOSTask<tasks::MOTOR_DRIVER_STACK_SIZE,
EntryPoint>(motor_driver_task_entry);

// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static auto motor_task =
ot_utils::freertos_task::FreeRTOSTask<tasks::MOTOR_STACK_SIZE, EntryPoint>(
motor_task_entry);

// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static auto host_comms_task =
ot_utils::freertos_task::FreeRTOSTask<tasks::COMMS_STACK_SIZE, EntryPoint>(
host_comms_entry);

// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static auto ui_task =
ot_utils::freertos_task::FreeRTOSTask<tasks::UI_STACK_SIZE, EntryPointUI>(
ui_task_entry);

// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static auto system_task =
ot_utils::freertos_task::FreeRTOSTask<tasks::SYSTEM_STACK_SIZE, EntryPoint>(
system_task_entry);

static auto aggregator = tasks::FirmwareTasks::QueueAggregator();

static auto i2c2_comms = i2c::hardware::I2C();
static auto i2c3_comms = i2c::hardware::I2C();
static auto i2c_handles = I2CHandlerStruct{};
// NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables)

extern "C" void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
switch (GPIO_Pin) {
case MOTOR_DIAG0_PIN:
Expand All @@ -75,10 +62,6 @@ extern "C" void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
}
}

static auto i2c2_comms = i2c::hardware::I2C();
static auto i2c3_comms = i2c::hardware::I2C();
static auto i2c_handles = I2CHandlerStruct{};

auto main() -> int {
HardwareInit();

Expand Down
2 changes: 1 addition & 1 deletion stm32-modules/flex-stacker/firmware/system/i2c_comms.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "firmware/i2c_comms.hpp"

#include <stdint.h>
#include <cstdint>

#include "firmware/i2c_hardware.h"
#include "systemwide.h"
Expand Down
20 changes: 14 additions & 6 deletions stm32-modules/include/flex-stacker/flex-stacker/ui_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ static constexpr uint8_t LED_DRIVER1_I2C_ADDRESS = 0x6F << 1; // External
static constexpr auto DEFAULT_COLOR = StatusBarColor::Green;
static constexpr auto DEFAULT_POWER = 0.5F;

typedef struct StatusBarState {
struct StatusBarState {
StatusBarID kind;
StatusBarColor color;
float power;
} StatusBarState;
};

const StatusBarState led_bar_internal = {
.kind = StatusBarID::Internal,
Expand Down Expand Up @@ -166,13 +166,21 @@ class UITask {
const auto& channels = color_to_channels(color);

// clear the current leds
if (bar == Internal) _led_driver0.set_current(0);
if (bar == External) _led_driver1.set_current(0);
if (bar == Internal) {
_led_driver0.set_current(0);
}
if (bar == External) {
_led_driver1.set_current(0);
}

return std::ranges::all_of(
channels.cbegin(), channels.cend(), [bar, power, this](size_t c) {
if (bar == Internal) return _led_driver0.set_current(c, power);
if (bar == External) return _led_driver1.set_current(c, power);
if (bar == Internal) {
return _led_driver0.set_current(c, power);
}
if (bar == External) {
return _led_driver1.set_current(c, power);
}
return false;
});
}
Expand Down

0 comments on commit da7745c

Please sign in to comment.