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

SNS - Optical Flow #32

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

prakhars0206
Copy link

No description provided.

Copy link

linear bot commented Oct 14, 2024

@davidbeechey davidbeechey changed the title SNS - Optical Flow (HYPE33) SNS - Optical Flow Oct 15, 2024
@davidbeechey davidbeechey marked this pull request as draft October 15, 2024 10:16
Copy link
Collaborator

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>> {
Copy link
Collaborator

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)

Comment on lines +21 to +24
impl<SPI> PMW3901<SPI>
where
SPI: HypedSpi,
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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

Copy link
Collaborator

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>{
Copy link
Collaborator

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

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.

2 participants