rahul-thakoor / rust_gpiozero

A library inspired by gpiozero written in Rust
https://crates.io/crates/rust_gpiozero
Apache License 2.0
233 stars 27 forks source link

Add Servo detach implementation #43

Closed llewelld closed 1 year ago

llewelld commented 1 year ago

This change adds a detach() method to the Servo class, which allows the servo to be "stopped". This can be important for software-PCM-controlled servos and for minimising CPU usage.

For comparison with the equivalent implementation in the Python GPIO Zero implementation, see the relevant:

  1. documentation;
  2. Python source, where detach calls value.setter which calls RPiGPIOPin._set_frequency() which then finally calls GPIO.PWM.stop();
  3. lower-level Rust source, where IoPin::clear_pwm() calls soft_pwm.stop().

I'd be grateful if you'd consider this for incorporation into the library. This PR builds on @RustyPro's nice #28 changes for adding a set_position() implementation, which I've also found to be a useful and important addition to the library.

rahul-thakoor commented 1 year ago

thanks for your contribution @llewelld !

unfortunately, I currently do not have the capacity to test this. see https://github.com/rahul-thakoor/rust_gpiozero/issues/11 I can add you as a maintainer if you are up for it :)

or, perhaps @dcroote is able to test this?

llewelld commented 1 year ago

Thanks @rahul-thakoor for your reply (I missed #11 so hadn't appreciated this was the situation).

If @dcroote is able to help then I'd appreciate the additional eyes.

More broadly if the objective is to ultimately try to replicate the functionality of Python GPIO Zero then that's something I'd be interested to help with. While I appreciate the offer as a way to move things forwards, I'd prefer to try to tackle some existing issues, or fill some gaps between this and the Python version, before you consider me as a maintainer.

dcroote commented 1 year ago

Thanks- I will need a few days but I'd be happy to have a look