diff --git a/src/lib.rs b/src/lib.rs index 9b98049..05184c1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,13 +26,16 @@ pub enum PullConfig { /// Represents a button with built in led. pub struct LedButton { /// the pin from mcu to LED - pub led : StatefulLed, + pub led : StatefulLed, /// the pin from mcu to button - pub button : StatefulButton, + pub button : StatefulButton, /// 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 LedButton { @@ -64,17 +67,13 @@ impl LedButton { /// pub fn create(led_pin: OP, led_state: LedState, led_pullconf: PullConfig, button_pin: IP, button_config: ButtonConfig, fn_refresh: f32 ) -> Self { Self { - led : StatefulLed::create(led_pin, led_pullconf, led_state), - button : StatefulButton::create(button_pin, button_config, fn_refresh), - state : ButtonState::NotPressed + led : StatefulLed::create(led_pin, led_pullconf, led_state), + button : StatefulButton::create(button_pin, button_config, fn_refresh), + 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. pub fn on(&mut self) { let _ = self.led.on();