Skip to content

Commit 5ddc317

Browse files
committed
add a getter for checking the state of enable
1 parent c3c0d3e commit 5ddc317

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,17 @@ impl Pwm {
158158
Ok(())
159159
}
160160

161+
/// Query the state of enable for a given PWM pin
162+
pub fn get_enabled(&self) -> Result<bool> {
163+
pwm_file_parse::<u32>(&self.chip, self.number, "enable").map(|enable_state| {
164+
match enable_state {
165+
1 => true,
166+
0 => false,
167+
_ => panic!("enable != 1|0 should be unreachable")
168+
}
169+
})
170+
}
171+
161172
/// Get the currently configured duty_cycle in nanoseconds
162173
pub fn get_duty_cycle_ns(&self) -> Result<u32> {
163174
pwm_file_parse::<u32>(&self.chip, self.number, "duty_cycle")

0 commit comments

Comments
 (0)