Skip to content
Discussion options

You must be logged in to vote

I don't think we implement the PwmPin trait from embedded-hal right now. So you'll have to be generic over the PwmPinOps instead, as you noticed. Maybe this works:

use arduino_hal::port::{Pin, PinOps, mode};
use arduino_hal::simple_pwm::PwmPinOps;

#[derive(Default)]
struct Config;

pub struct DiffDrive<TC, E, P1, P2> {
    en: Pin<mode::PwmOutput<TC>, E>,
    p1: Pin<mode::Output, P1>,
    p2: Pin<mode::Output, P2>,
    config: Config,
}

impl<TC, E: PwmPinOps<TC>, P1: PinOps, P2: PinOps> DiffDrive<TC, E, P1, P2> {
    pub fn new(
        en: Pin<mode::PwmOutput<TC>, E>,
        p1: Pin<mode::Output, P1>,
        p2: Pin<mode::Output, P2>,
    ) -> Self {
        let config = Config::def…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@zignig
Comment options

Answer selected by zignig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants