esp-hal icon indicating copy to clipboard operation
esp-hal copied to clipboard

Add example reading a rotary encoder

Open faern opened this issue 3 years ago • 7 comments
trafficstars

I wrote this with inspiration from both gpio_interrupt.rs and the rotary-encoder-embedded readme example. I figured it could be nice with a publicly available example.

Maybe there is a better way to implement this. I'm pretty new to esp-hal. Feedback welcome.

Ping @ostenning who are the author of rotary-encoder-embedded

faern avatar Aug 27 '22 13:08 faern

Thanks a lot for your contribution!

The only thing I am not sure about: Maybe we want higher-level examples like this go into (the still empty) https://github.com/esp-rs/esp-hal-examples repository as a stand-alone example.

The idea is to have very simple examples here - each just showing basic usage of a peripheral and ideally without the need for additional components and library crates. We are violating that rule already with the I2C example (since it needs a display) and maybe with the hello_rgb example (while many dev-boards actually include an addressable LED).

Also ideally here we should have the examples for all chips if supported - I think we don't have that requirement in the esp-hal-examples repository

But that is just my opinion - lets wait for what @jessebraham thinks

But definitely an interesting and valuable example

bjoernQ avatar Aug 29 '22 06:08 bjoernQ

Nice! I did not know there were/was going to be a separate examples repository. I think that makes a lot of sense to have more advanced examples there. It makes a lot of sense to not have a huge dev-dependency tree here just for the examples!

I'm all for that, and can create a new PR on the other repository once you got the initial layout there set up.

faern avatar Aug 29 '22 07:08 faern

Thanks for this, I think this is a very common use case so it'd be great to have this. As @bjoernQ said I think it'd be best to include in the esp-hal-examples repository (which is currently empty) for the reasons already mentioned. It's easy for the number of dev-dependencies to grow and in turn increase our CI runtime, so I'd like to keep as few as needed. If you wouldn't mind PRing to the other repository that would be very much appreciated!

Since we don't have any instructions or anything there (I will add these when I get a chance), maybe let's just call the application esp32c3_rotary_encoder or something to that effect, @bjoernQ sound reasonable?

jessebraham avatar Aug 29 '22 15:08 jessebraham

Sounds good to me

bjoernQ avatar Aug 29 '22 15:08 bjoernQ

What kind of base structure would you want in that repository? A single crate with a bunch of example binaries? I can wait until you set up the base over there. I'm not in a rush or anything, I got my rotary encoders working :)

faern avatar Aug 29 '22 15:08 faern

I've added a quick README outlining how I originally envisioned that repository would look. This isn't law, but I think is reasonable. If you have any issues with the points laid out please feel free to argue your case in your PR :)

jessebraham avatar Aug 29 '22 15:08 jessebraham

Each example should be its own binary package placed within the root of this repository

A downside of this is that there will be a lot of duplication. That will lead to maintenance to upgrade for example esp-hal in all the example crates. I imagine we don't want the examples to be out of sync with latest and greatest upstream esp-* crates and the embedded ecosystem in general.

faern avatar Aug 30 '22 10:08 faern

Sorry for the radio silence on my end, there's been a lot going on these last few months 😅

Thank you for the contribution but I'm going to close this PR at this time. We've decided against using the examples repository like previously planned and have chosen instead to just link to things in our Awesome ESP Rust list. You're obviously welcome to put this example in a repository and link to it there if you'd like.

jessebraham avatar Dec 21 '22 16:12 jessebraham