Skip to content

Commit 1b5f718

Browse files
authored
Merge pull request #26 from ripytide/master
add a `current_standby()` method when the pin implements `StatefulOututPin`
2 parents bd213c8 + c8eb002 commit 1b5f718

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
<!-- next-header -->
88
## [Unreleased] - ReleaseDate
9+
### Added
10+
* Add a `current_standby()` method to check if the driver is currently in standby mode.
11+
912
### Changed
1013

1114
* `Motor::new()` and `Driver::new()` methods now set the outputs upon their

src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#[cfg(feature = "defmt")]
2424
use defmt::Format;
25-
use embedded_hal::digital::OutputPin;
25+
use embedded_hal::digital::{OutputPin, StatefulOutputPin};
2626
use embedded_hal::pwm::SetDutyCycle;
2727

2828
/// Defines errors which can happen when calling [`Motor::drive()`].
@@ -197,6 +197,16 @@ where
197197
pub fn disable_standby(&mut self) -> Result<(), STBY::Error> {
198198
self.standby.set_high()
199199
}
200+
201+
/// Returns whether the standby mode is enabled.
202+
///
203+
/// *NOTE* this does *not* read the electrical state of the pin, see [`StatefulOutputPin`]
204+
pub fn current_standby(&mut self) -> Result<bool, STBY::Error>
205+
where
206+
STBY: StatefulOutputPin,
207+
{
208+
self.standby.is_set_high()
209+
}
200210
}
201211

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

0 commit comments

Comments
 (0)