pub struct Tb6612fng<MAIN1, MAIN2, MAPWM, MBIN1, MBIN2, MBPWM, STBY> {
pub motor_a: Motor<MAIN1, MAIN2, MAPWM>,
pub motor_b: Motor<MBIN1, MBIN2, MBPWM>,
/* private fields */
}
Expand description
Represents a TB6612FNG controller.
Use the Motor
struct directly if you only have one motor.
See the crate-level comment for further details on when to use what.
Fields
motor_a: Motor<MAIN1, MAIN2, MAPWM>
The first motor, labelled as ‘A’ on the chip
motor_b: Motor<MBIN1, MBIN2, MBPWM>
The second motor, labelled as ‘B’ on the chip
Implementations
sourceimpl<MAIN1, MAIN2, MAPWM, MBIN1, MBIN2, MBPWM, STBY> Tb6612fng<MAIN1, MAIN2, MAPWM, MBIN1, MBIN2, MBPWM, STBY>where
MAIN1: OutputPin,
MAIN2: OutputPin,
MAPWM: PwmPin<Duty = u16>,
MBIN1: OutputPin,
MBIN2: OutputPin,
MBPWM: PwmPin<Duty = u16>,
STBY: OutputPin,
impl<MAIN1, MAIN2, MAPWM, MBIN1, MBIN2, MBPWM, STBY> Tb6612fng<MAIN1, MAIN2, MAPWM, MBIN1, MBIN2, MBPWM, STBY>where
MAIN1: OutputPin,
MAIN2: OutputPin,
MAPWM: PwmPin<Duty = u16>,
MBIN1: OutputPin,
MBIN2: OutputPin,
MBPWM: PwmPin<Duty = u16>,
STBY: OutputPin,
sourcepub fn new(
motor_a_in1: MAIN1,
motor_a_in2: MAIN2,
motor_a_pwm: MAPWM,
motor_b_in1: MBIN1,
motor_b_in2: MBIN2,
motor_b_pwm: MBPWM,
standby: STBY
) -> Tb6612fng<MAIN1, MAIN2, MAPWM, MBIN1, MBIN2, MBPWM, STBY>
pub fn new(
motor_a_in1: MAIN1,
motor_a_in2: MAIN2,
motor_a_pwm: MAPWM,
motor_b_in1: MBIN1,
motor_b_in2: MBIN2,
motor_b_pwm: MBPWM,
standby: STBY
) -> Tb6612fng<MAIN1, MAIN2, MAPWM, MBIN1, MBIN2, MBPWM, STBY>
Instantiate a new Tb6612fng
with the defined pins.
This also automatically enables the two PWM pins.
The initial state of the motors will be stopped.
Usage example:
use tb6612fng::Tb6612fng;
let controller = Tb6612fng::new(
motor_a_in1,
motor_a_in2,
motor_a_pwm,
motor_b_in1,
motor_b_in2,
motor_b_pwm,
standby,
);
sourcepub fn enable_standby(&mut self)
pub fn enable_standby(&mut self)
Enable standby. This ignores any other setting currently done on the motors and puts them into standby.
Note that this does not change any commands on the motors, i.e. the PWM signal will continue
and once Tb6612fng::disable_standby
is called the motor will pick up where it left off (unless the command was changed in-between).
sourcepub fn disable_standby(&mut self)
pub fn disable_standby(&mut self)
Disable standby. Note that the last active commands on the motors will resume.