-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this extends the `Pin::Mock` to also cover the [`PwmPin`] trait. some observations on this commit: * i took the liberty of just hardcoding the `PwmPin::Duty` to be an `u16` (wrapped in the `PwmDuty` type because it's used in other places here in the module as well). i don't see an easy way to make this configurable because i'd have to add it as a generic attribute to `Pin` and then it'd have to be defined by everyone using it (unnecessary for all non-PWM use-cases). but i think this should be acceptable as `u16` probably covers most/all use-cases. * the current code features quite some code duplication (essentially the method check implementations are all the same for all setters / all getters). i've continued this for now but it might be worth a refactoring in the future (i haven't touched it because i'm not sure if there's some strategic decision behind this?) * there's a `TransactionKind::is_get` API for which i don't really see the reason (why not just check it directly?). i've decided to not copy that approach for the others as it'd IMHO just bloat the code and i'd instead suggest to remove `TransactionKind::is_get` at a later point. * `PwmPin` only exists on `embedded-hal` 0.x, it is currently missing from the planned 1.0 release. see rust-embedded/embedded-hal#358 for the discussion on this. once it has (hopefully) been re-added there a corresponding mock can be provided here also for 1.x. [`PwmPin`]: https://docs.rs/embedded-hal/0.2.7/embedded_hal/trait.PwmPin.html
- Loading branch information
Showing
1 changed file
with
134 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters