diff --git a/src/lib.rs b/src/lib.rs index c37dbfa..893cbeb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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. @@ -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. @@ -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!(