fixed bug where led state got wrong state.
This commit is contained in:
parent
ab0cc33c48
commit
a1d0aae6c8
@ -77,16 +77,19 @@ impl<OP: OutputPin, IP: InputPin> LedButton<OP, IP> {
|
|||||||
/// set the LED to "On"-state.
|
/// set the LED to "On"-state.
|
||||||
pub fn on(&mut self) {
|
pub fn on(&mut self) {
|
||||||
let _ = self.led.on();
|
let _ = self.led.on();
|
||||||
|
self.led_state == LedState::On;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// set the LED to "Off"-state.
|
/// set the LED to "Off"-state.
|
||||||
pub fn off(&mut self) {
|
pub fn off(&mut self) {
|
||||||
let _ = self.led.off();
|
let _ = self.led.off();
|
||||||
|
self.led_state == LedState::Off;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// toggle the LED.
|
/// toggle the LED.
|
||||||
pub fn toggle(&mut self) {
|
pub fn toggle(&mut self) {
|
||||||
let _ = self.led.toggle();
|
let _ = self.led.toggle();
|
||||||
|
self.led_state = !self.led_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// the current counter value of the button.
|
/// the current counter value of the button.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user