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

ServoArray constructor #41

Open
tcr opened this issue Sep 17, 2016 · 5 comments
Open

ServoArray constructor #41

tcr opened this issue Sep 17, 2016 · 5 comments

Comments

@tcr
Copy link
Member

tcr commented Sep 17, 2016

Right now we pass in two false flags for the I2C constructor, since we control two address bits.

Is there a way we can:

  • Do the normal thing by default
  • Optionally pass in what the I2C ID should be
  • Restrict it to IDs that we can support in a type-safe way
@rwaldron
Copy link

Side question: Why is this called ServoArray? It doesn't appear to be an array Servos...?

@tcr
Copy link
Member Author

tcr commented Sep 20, 2016

@rwaldron You'll want to read... #40 ;)

@Dr-Emann
Copy link
Contributor

It might be helpful to link to the specific line(s) you're referring to.

@tcr
Copy link
Member Author

tcr commented Sep 20, 2016

The code in question is the ServoArray::new constructor, which sets the two GPIO address lines which modify the PCA9685 address itself.

@Dr-Emann
Copy link
Contributor

The usual way to do something like this in rust would be to have two functions:
ServoArray::new() and ServoArray::with_something(something: Something).

I'm not sure how those bits should be used, is it something like address = I2C_ID | (addr2 << 2) | (addr3 << 3)? (assuming addr2/3 are 0/1 at that point)

Where would the user find information about what those bits should be for their particular device? That might determine what they should pass in (e.g, if they would know the full address, that's probably what should be passed, but panic if it doesn't match what we expect)

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

No branches or pull requests

3 participants