-
Notifications
You must be signed in to change notification settings - Fork 0
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
ヘッダーファイル #199
base: main
Are you sure you want to change the base?
ヘッダーファイル #199
Conversation
.cppファイルのほうで |
そもそもこのissueでやりたいのは、「ピン番号とセンサー・アクチュエーターとの対応関係を明示する」ということです。つまり、以下のようなリファクタリングを入れたいです。 // before
InputModules input_modules({A4, A5}, A6, {D4, D5}), output_modules({PB_4, PA_11}, {PA_9, PA_10});
// after
InputModules input_modules = InputModules::builder()
.joy_pins(A4, A5)
.volume_pin(A6)
.mpu_sda_pin(D4)
.mpu_scl_pin(D5)
.build(); ここまで書いたものは class Builder {
...
auto build() -> InputModules;
}; |
include/device/input.hpp
Outdated
public: | ||
auto joy_pins(const PinName& pin) -> Builder&; | ||
auto volume_pin(const PinName& pin) -> Builder&; | ||
auto mpu_pins(const PinName& pin) -> Builder&; |
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.
MPU6050のピン設定はSDA, SCLの2ピンなのでPinName
の値を2つ受け取る必要があります。これはjoyの方も同様です
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.
で、この2つも区別しづらいので別々に受け取りたいですね
auto joy_x_pin(...
auto joy_y_pin(...
auto mpu_sda_pin(...
auto mpu_scl_pin(...
// NOLINTBEGIN(bugprone-easily-swappable-parameters) | ||
device::InputModules::InputModules( | ||
/**device::InputModules::InputModules( | ||
const std::pair<PinName, PinName>& joy_pins, const PinName& volume_pin, | ||
const std::pair<PinName, PinName>& mpu_pins) : | ||
joy(joy_pins.first, joy_pins.second), | ||
volume(volume_pin), | ||
mpu(mpu_pins.first, mpu_pins.second) {} | ||
// NOLINTEND(bugprone-easily-swappable-parameters) | ||
*/ |
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.
これ消しちゃっていいです
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.
消してね
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.
かなり良くなってきてる!Machine
のコンストラクタを変える必要があるので、そこもお願いします
before:
omniboat_robokit/src/machine.cpp
Line 29 in 46c1b3c
input_modules({A4, A5}, A6, {D4, D5}), output_modules({PB_4, PA_11}, {PA_9, PA_10}), service() { |
after:
input_modules(InputModules::builder()....), ...
auto joy_pins(const std::pair<PinName, PinName>& pins) -> Builder&; | ||
auto volume_pin(const PinName& pin) -> Builder&; | ||
auto mpu_pins(const std::pair<PinName, PinName>& pins) -> Builder&; |
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.
pairのfirst, secondがそれぞれ何を意味しているのか明示した版も欲しいです
auto joy_x_pin(const PinName& pin) -> Builder&; // joy_pins.first
auto joy_y_pin(const PinName& pin) -> Builder&; // joy_pins.second
auto mpu_sda_pin(const PinName& pin) -> Builder&; // mpu_pins.first
auto mpu_scl_pin(const PinName& pin) -> Builder&; // mpu_pins.second
// NOLINTBEGIN(bugprone-easily-swappable-parameters) | ||
device::InputModules::InputModules( | ||
/**device::InputModules::InputModules( | ||
const std::pair<PinName, PinName>& joy_pins, const PinName& volume_pin, | ||
const std::pair<PinName, PinName>& mpu_pins) : | ||
joy(joy_pins.first, joy_pins.second), | ||
volume(volume_pin), | ||
mpu(mpu_pins.first, mpu_pins.second) {} | ||
// NOLINTEND(bugprone-easily-swappable-parameters) | ||
*/ |
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.
消してね
No description provided.