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 5d73a08 commit bb39f49
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#include <stdint.h>

#include <cstdint>
#include <optional>
#include <tuple>
Expand Down
6 changes: 2 additions & 4 deletions stm32-modules/include/flex-stacker/firmware/i2c_comms.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#include <stdint.h>

#include <algorithm>
#include <cstdint>
#include <optional>
Expand All @@ -21,9 +19,9 @@ class I2C : public I2CBase {
auto operator=(const I2C &) = delete;
auto operator=(const I2C &&) = delete;

auto i2c_read(uint16_t dev_addr, uint16_t reg, uint16_t size) -> RxTxReturn;
auto i2c_read(uint16_t dev_addr, uint16_t reg, uint16_t size) -> RxTxReturn final;
auto i2c_write(uint16_t dev_addr, uint16_t reg, uint8_t *data,
uint16_t size) -> RxTxReturn;
uint16_t size) -> RxTxReturn final;
auto set_handle(HAL_I2C_HANDLE i2c_handle, I2C_BUS bus) -> void;

private:
Expand Down
2 changes: 2 additions & 0 deletions stm32-modules/include/flex-stacker/firmware/ui_policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class UIPolicy {
UIPolicy(const UIPolicy &&) = delete;
auto operator=(const UIPolicy &) = delete;
auto operator=(const UIPolicy &&) = delete;
// TODO: need destructor
//~UIPolicy() = delete;

auto set_heartbeat_led(bool value) -> void;
template <size_t Len>
Expand Down
33 changes: 17 additions & 16 deletions stm32-modules/include/flex-stacker/flex-stacker/ui_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,31 @@ static auto color_to_channels(StatusBarColor color) -> const ChannelMapping& {
}
}

// The timer driving LED update frequency should run at this period
static constexpr uint32_t UPDATE_PERIOD_MS = 1000;
static constexpr uint8_t LED_DRIVER0_I2C_ADDRESS = 0x6C << 1; // Internal
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 {
StatusBarID kind;
StatusBarColor color;
float power;
} StatusBarState;

StatusBarState led_bar_internal = {
const StatusBarState led_bar_internal = {
.kind = StatusBarID::Internal,
.color = StatusBarColor::Blue,
.power = 0.5F,
.color = DEFAULT_COLOR,
.power = DEFAULT_POWER,
};

StatusBarState led_bar_external = {
const StatusBarState led_bar_external = {
.kind = StatusBarID::External,
.color = StatusBarColor::Blue,
.power = 0.5F,
.color = DEFAULT_COLOR,
.power = DEFAULT_POWER,
};

// The timer driving LED update frequency should run at this period
static constexpr uint32_t UPDATE_PERIOD_MS = 1000;
static constexpr uint8_t LED_DRIVER0_I2C_ADDRESS = 0x6C << 1; // Internal
static constexpr uint8_t LED_DRIVER1_I2C_ADDRESS = 0x6F << 1; // External

using Message = messages::UIMessage;

template <template <class> class QueueImpl>
Expand All @@ -82,8 +84,6 @@ class UITask {
: _message_queue(q),
_task_registry(aggregator),
_policy(policy),
_led_driver0(),
_led_driver1(),
_ui_timer(
"UI Timer", [ThisPtr = this] { ThisPtr->heartbeat_led(); },
UPDATE_PERIOD_MS) {
Expand Down Expand Up @@ -206,7 +206,8 @@ class UITask {
if (bar == Internal) {
_led_driver0.set_pwm(power);
return _led_driver0.send_update(*_policy);
} else if (bar == External) {
}
if (bar == External) {
_led_driver1.set_pwm(power);
return _led_driver1.send_update(*_policy);
}
Expand All @@ -216,8 +217,8 @@ class UITask {
Queue& _message_queue;
Aggregator* _task_registry;
UIPolicy* _policy;
is31fl::IS31FL<LED_DRIVER0_I2C_ADDRESS> _led_driver0;
is31fl::IS31FL<LED_DRIVER1_I2C_ADDRESS> _led_driver1;
is31fl::IS31FL<LED_DRIVER0_I2C_ADDRESS> _led_driver0{};
is31fl::IS31FL<LED_DRIVER1_I2C_ADDRESS> _led_driver1{};
FreeRTOSTimer _ui_timer;

StatusBarState _led_bar_internal = led_bar_internal;
Expand Down

0 comments on commit bb39f49

Please sign in to comment.