Skip to content
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

I2C Mux #121

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

I2C Mux #121

wants to merge 8 commits into from

Conversation

kshxtij
Copy link
Contributor

@kshxtij kshxtij commented May 30, 2023

Added to debug binary and works with hardware now.
Screenshot 2023-05-30 at 11 48 17

@kshxtij kshxtij requested a review from ishmis as a code owner May 30, 2023 10:48
Copy link
Contributor

@ishmis ishmis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor changes only

// TODOLater: Figure out how to not hardcode this
std::array<std::unique_ptr<sensors::II2cMuxSensor<core::RawAccelerationData>>, 4>
accelerometers;
for (int i = 0; i < channels.size(); i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++i

accelerometers[i]
= std::make_unique<sensors::Accelerometer>(std::move(*optional_accelerometer));
}
// sensors::I2cMux<core::RawAccelerationData, 4> mux(logger_, i2c, mux_address, accelerometers);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

= std::make_unique<sensors::Accelerometer>(std::move(*optional_accelerometer));
}
// sensors::I2cMux<core::RawAccelerationData, 4> mux(logger_, i2c, mux_address, accelerometers);
std::shared_ptr<sensors::I2cMux<core::RawAccelerationData, 4>> mux_ptr
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

core::kNumAccelerometers?

logger_.log(core::LogLevel::kFatal, "Failed to read the mux from bus %d", bus);
} else {
const std::array<core::RawAccelerationData, 4> mux_result = *value;
for (int i = 0; i < mux_result.size(); i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::size_t, ++i

logger_.log(core::LogLevel::kFatal, "Failure, mismatched device ID for accelerometer");
return std::nullopt;
}
const auto ctrl1_result = i2c_->writeByteToRegister(device_address_, kCtrl1Address, kCtrl1Value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this auto when we directly check it against failure state 2 lines later? Especially since we wouldn't fail if the return type got changed for whatever reason but would still compile?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants