-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SNS - LED Driver #44
base: master
Are you sure you want to change the base?
SNS - LED Driver #44
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good, mostly stylistic changes
lib/sensors/led_driver.cpp
Outdated
std::shared_ptr<io::II2c> i2c, | ||
const std::uint8_t device_address) | ||
{ | ||
if (device_address != kDefaultLedDriverAddress) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the point of taking an argument for the LED driver if it must match the default?
lib/sensors/led_driver.cpp
Outdated
logger.log(core::LogLevel::kFatal, "Invalid device address for LED driver"); | ||
return std::nullopt; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using whitespace (see the style guide here). the metaphor is that whitespace in code is similar to whitespace in an essay, it should separate paragraphs but you wouldn't have a line break after every sentence
lib/sensors/led_driver.cpp
Outdated
{ | ||
} | ||
|
||
std::optional<core::Result> LedDriver::initialise() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't need to be optional
, just return core::Result::kFailure
/core::Result::kSuccess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for all the others that currently return std::optional<core::Result>
lib/sensors/led_driver.cpp
Outdated
std::optional<core::Result> LedDriver::set_colour(std::uint8_t channel, | ||
std::uint8_t red, | ||
std::uint8_t green, | ||
std::uint8_t blue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all these args should be const
lib/sensors/led_driver.hpp
Outdated
#include <core/logger.hpp> | ||
#include <io/i2c.hpp> | ||
|
||
int kDefaultLedDriverAddress = 0x30; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be static constexpr std::uint8_t
lib/sensors/led_driver.hpp
Outdated
static std::optional<LedDriver> create(core::ILogger &logger, | ||
std::shared_ptr<io::II2c> i2c, | ||
const std::uint8_t device_address | ||
= kDefaultLedDriverAddress); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't use default parameters, but here we don't need the param at all so it's a kinda meaningless point to make
lib/sensors/led_driver.hpp
Outdated
= kDefaultLedDriverAddress); | ||
~LedDriver(); | ||
|
||
std::optional<core::Result> initialise(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be private i think
lib/sensors/led_driver.hpp
Outdated
~LedDriver(); | ||
|
||
std::optional<core::Result> initialise(); | ||
std::optional<core::Result> set_colour(std::uint8_t channel, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functions names should be in lowerCamelCase
lib/sensors/led_driver.hpp
Outdated
std::uint8_t green, | ||
std::uint8_t blue); | ||
std::optional<core::Result> set_intensity(std::uint8_t channel, std::uint8_t intensity); | ||
std::optional<core::Result> reset(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you write a docstring for all of these methods, especially reset as it is a little unclear what it does
|
||
LedDriver::LedDriver(core::ILogger &logger, std::shared_ptr<io::II2c> i2c) | ||
: logger_(logger), | ||
i2c_(i2c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might need a std::move
here?
core::Result setIntensity(std::uint8_t channel, std::uint8_t intensity); | ||
core::Result reset(); | ||
|
||
private: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need multiple private
's
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at some point someone decided we have a second one separating variables from methods, idk if i like it tho
core::Result reset(); | ||
|
||
private: | ||
LedDriver(core::ILogger &logger, std::shared_ptr<io::II2c> i2c); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constructor should be public
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
although I'm not sure it needs to be if it is only called from create
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i feel like it has had to be public even with the create, but i dont remembeer why. if it builds it builds
logger.log(core::LogLevel::kFatal, "Failed to initialise LED driver"); | ||
return std::nullopt; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the whitespace, same throughout the PR
No description provided.