Skip to content

Qei API #8

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

Open
japaric opened this issue Jun 9, 2017 · 2 comments
Open

Qei API #8

japaric opened this issue Jun 9, 2017 · 2 comments

Comments

@japaric
Copy link
Member

japaric commented Jun 9, 2017

  • What is missing in this API?
  • Can this API be implemented for different devices?
@japaric japaric added the RFC label Jun 9, 2017
@japaric
Copy link
Member Author

japaric commented Jan 20, 2018

Update: this trait is available in release v0.1.0 behind the "unproven" Cargo feature.

@leshow
Copy link

leshow commented Nov 5, 2019

I wrote a library for a simple rotary encoder library, and after posting about it in the rust-embedded/awesome-rust thread, someone directed me to this trait, that I had no idea existed.

I'm having trouble for seeing how to map to the methods provided in the trait. Particularly the direction method.

Direction in embedded-hal has 2 variants, and the direction() function returns Direction. However, in my case, it's possible there is no change in direction, and the Count type itself has no inherent direction. The only thing I can think of is returning Updirection if the count is above zero and Down in the other case, but that doesn't really provide anything useful for a rotary encoder

It's very possible I'm just not understanding something, but I can't see how it fits together at all.

In my case, something like this would make a lot more sense:

pub trait Qei {
type Count;
    fn count(&self) -> Self::Count;
    fn direction(&self) -> Option<Direction>;
}

or even,

fn direction(&mut self) -> Option<Direction>

In this case, I can put the code that does the transformation of state -> Direction (and updates the internal count) in the direction() function

peckpeck pushed a commit to peckpeck/embedded-hal that referenced this issue Nov 10, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
9: Add serial::Read/Write implementation r=ryankurte a=rnestler

So this is just a quick PoC to implement rust-embedded#8.
@japaric Do you think it would be OK to implement it in that way? If yes I can finish it up.

Co-authored-by: Raphael Nestler <[email protected]>
Co-authored-by: Raphael Nestler <[email protected]>
Co-authored-by: Danilo Bargen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants