Skip to content

Commit

Permalink
add Tb6612fng::current_standby() method
Browse files Browse the repository at this point in the history
  • Loading branch information
ripytide committed Dec 11, 2023
1 parent cc7c994 commit 729d2b7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#[cfg(feature = "defmt")]
use defmt::Format;
use embedded_hal::digital::OutputPin;
use embedded_hal::digital::{OutputPin, StatefulOutputPin};
use embedded_hal::pwm::SetDutyCycle;

/// Defines errors which can happen while trying to set a speed.
Expand Down Expand Up @@ -143,6 +143,16 @@ where
pub fn disable_standby(&mut self) {
self.standby.set_high().ok();
}

/// Returns whether the standby mode is enabled.
///
/// *NOTE* this does *not* read the electrical state of the pin, see [`StatefulOutputPin`]
pub fn current_standby(&self) -> bool
where
STBY: StatefulOutputPin,
{
self.standby.is_set_high().unwrap()
}
}

/// Represents a single motor (either motor A or motor B) hooked up to a TB6612FNG controller.
Expand Down Expand Up @@ -406,7 +416,7 @@ mod tests {

let mut motor = Motor::new(motor_in1.clone(), motor_in2.clone(), motor_pwm.clone());

let current_drive_command = motor.current_drive_command().clone();
let current_drive_command = *motor.current_drive_command();
let current_speed = motor.current_speed();

assert_eq!(
Expand Down

0 comments on commit 729d2b7

Please sign in to comment.