-
Notifications
You must be signed in to change notification settings - Fork 1
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 - Optical Flow #32
base: main
Are you sure you want to change the base?
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.
Move to lib/sensors/src/optical_flow.rs
(you'll need to add it to lib/sensors/src/lib.rs
too
|
||
|
||
// Make main function with flexible error handling | ||
pub fn main() -> Result<(), Box<dyn std::error::Error>> { |
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 function won't live here, it'll be in one of the board/{board_name}/tasks
folders as a task. Have a look at boards/stm32l476rg/src/tasks/temperature.rs
as an example. (Just copy this code into a structure similar to that for now)
impl<SPI> PMW3901<SPI> | ||
where | ||
SPI: HypedSpi, | ||
{ |
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.
impl<SPI> PMW3901<SPI> | |
where | |
SPI: HypedSpi, | |
{ | |
impl<SPI: HypedSpi> PMW3901<SPI> |
You should be able to do something shorter like this instead
const TIMEOUT: Duration = Duration::from_secs(5); | ||
|
||
|
||
pub struct PMW3901<SPI> { |
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.
pub struct PMW3901<SPI> { | |
pub struct PMW3901<SPI: HypedSpi> { |
It's also standard to have single uppercase characters as type parameters, like T
. But I don't mind SPI
for now
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.
Probs better to call this OpticalFlow
also
} | ||
|
||
// **ATTEMPTED PYTHON IMPLEMENTATION OF get_motion** | ||
pub fn get_motion(&mut self) -> Result<(i16, i16), &'static str>{ |
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.
You'll want to define an error enum type like OpticalFlowError
instead of returning a string here. Have a look at TemperatureError
as an example (you'll probably want to have an enum variant for SpiError
for example
No description provided.