added led_state to LedButton
This commit is contained in:
parent
3bb23b50ff
commit
2cf404da0b
13
src/lib.rs
13
src/lib.rs
@ -32,7 +32,10 @@ pub struct LedButton<OP, IP> {
|
|||||||
pub button : StatefulButton<IP>,
|
pub button : StatefulButton<IP>,
|
||||||
|
|
||||||
/// the state of the button, always initialised to NotPressed.
|
/// the state of the button, always initialised to NotPressed.
|
||||||
pub state : ButtonState
|
pub state : ButtonState,
|
||||||
|
|
||||||
|
/// the state of the led, always initialised to Off.
|
||||||
|
pub led_state : LedState
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<OP: OutputPin, IP: InputPin> LedButton<OP, IP> {
|
impl<OP: OutputPin, IP: InputPin> LedButton<OP, IP> {
|
||||||
@ -66,15 +69,11 @@ impl<OP: OutputPin, IP: InputPin> LedButton<OP, IP> {
|
|||||||
Self {
|
Self {
|
||||||
led : StatefulLed::create(led_pin, led_pullconf, led_state),
|
led : StatefulLed::create(led_pin, led_pullconf, led_state),
|
||||||
button : StatefulButton::create(button_pin, button_config, fn_refresh),
|
button : StatefulButton::create(button_pin, button_config, fn_refresh),
|
||||||
state : ButtonState::NotPressed
|
state : ButtonState::NotPressed,
|
||||||
|
led_state : LedState::Off
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// get the current state of the LED.
|
|
||||||
pub fn led_state(self) -> LedState {
|
|
||||||
self.led.current_state
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 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();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user