Skip to content

Commit

Permalink
add the Tb6612fng::current_standby() method
Browse files Browse the repository at this point in the history
  • Loading branch information
ripytide committed Mar 8, 2024
1 parent bd213c8 commit c8eb002
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- next-header -->
## [Unreleased] - ReleaseDate
### Added
* Add a `current_standby()` method to check if the driver is currently in standby mode.

### Changed

* `Motor::new()` and `Driver::new()` methods now set the outputs upon their
Expand Down
12 changes: 11 additions & 1 deletion 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 when calling [`Motor::drive()`].
Expand Down Expand Up @@ -197,6 +197,16 @@ where
pub fn disable_standby(&mut self) -> Result<(), STBY::Error> {
self.standby.set_high()
}

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

/// Represents a single motor (either motor A or motor B) hooked up to a TB6612FNG controller.
Expand Down

0 comments on commit c8eb002

Please sign in to comment.