periph / conn

Go·Hardware·Lean - Interfaces
https://periph.io
Apache License 2.0
65 stars 11 forks source link

gpio: refactor PWM to be context based #3

Open maruel opened 3 years ago

maruel commented 3 years ago

Users forget to stop the PWM at the end of the program, causing user reports like #286 and #363.

We must design an API that makes it clear that the PWM blocking operation must be canceled before the termination of the program.

Discussion about this change is done in https://docs.google.com/document/d/1vQdZdoOMaIan7dKwcAzqHbfM_LCnnSMUQvqypRkjohM.

(ported from https://github.com/google/periph/issues/384)

1995parham commented 2 years ago

I have an idea about this, we can have a start function that is blocking and starting PWM so people need to close this function before the program's end and we can there defer the cancelation.

I can create a PR for this. also because we don't have any context in the periph package so using context for this specific function may be not a good idea.