-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: master
Are you sure you want to change the base?
I2C Mux #121
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.
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++) { |
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
accelerometers[i] | ||
= std::make_unique<sensors::Accelerometer>(std::move(*optional_accelerometer)); | ||
} | ||
// sensors::I2cMux<core::RawAccelerationData, 4> mux(logger_, i2c, mux_address, accelerometers); |
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.
?
= 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 |
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.
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++) { |
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.
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); |
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.
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?
Added to debug binary and works with hardware now.
![Screenshot 2023-05-30 at 11 48 17](https://private-user-images.githubusercontent.com/48125086/241943561-7767d109-c5cd-40a1-9d52-8ee7c4b85289.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0ODM5NDAsIm5iZiI6MTczOTQ4MzY0MCwicGF0aCI6Ii80ODEyNTA4Ni8yNDE5NDM1NjEtNzc2N2QxMDktYzVjZC00MGExLTlkNTItOGVlN2M0Yjg1Mjg5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDIxNTQwMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY0Njc2MmZlYmMyYjhkNjBhNmU2MjYxMzVkYzZhZjlhZDRmZWM4ZTZkOWJlMGJmNjYxYzI3NzlkNjJlMTk3MTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.pk6huTOpbAWSE90PDySLRGoRtVn7e_rL71ZVHLN_hDo)