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

Implementation requires PwmPin<Duty=u16> but any Duty value would work #8

Closed
jasta opened this issue Mar 29, 2023 · 2 comments
Closed

Comments

@jasta
Copy link

jasta commented Mar 29, 2023

We can generalize further by only changing a few lines of code I believe:

let max_duty = self.pwm.get_max_duty();
let duty_f = (f64::from(speed) / 100.0) * f64::from(max_duty);
let duty = duty_f.round() as PWM::Duty;
@rursprung
Copy link
Collaborator

i remember ending in generics hell when i tried this (but also didn't invest a lot of time, either). but if you get it to work feel free to provide a PR!

please note that with e-h 1.0 this will be a lot cleaner, see rust-embedded/embedded-hal#430
once there's a new alpha release of e-h 1.0 which includes the new PWM APIs i plan to add support for it here

rursprung added a commit that referenced this issue Jul 2, 2023
as this version of embedded-hal has added `SetDutyCycle` as the
equivalent / successor of the old `PwmPin` support for it can now be
added here.

open points:
* wait for a release of stm32f4xx-hal which includes the `SetDutyCycle`
  implementation (PR already merged)
* wait for a release of embedded-hal-mock which includes the
  `SetDutyCycle` implementation (PR currently open)

fixes #3
fixes #8
@rursprung rursprung linked a pull request Jul 2, 2023 that will close this issue
rursprung added a commit that referenced this issue Jul 6, 2023
as this version of embedded-hal has added `SetDutyCycle` as the
equivalent / successor of the old `PwmPin` support for it can now be
added here.

open points:
* wait for a release of stm32f4xx-hal which includes the `SetDutyCycle`
  implementation (PR already merged)
* wait for a release of embedded-hal-mock which includes the
  `SetDutyCycle` implementation (PR currently open)

fixes #3
fixes #8
@rursprung
Copy link
Collaborator

@jasta: i just released v0.2.0 which is now based on embedded-hal=1.0.0-rc.1 (see #25 for details). in this version the data type for Duty is gone due to the new PWM-related APIs in e-h 1.0

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

Successfully merging a pull request may close this issue.

2 participants