diff --git a/src/lib.rs b/src/lib.rs index 05184c1..1e57097 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -94,6 +94,15 @@ impl LedButton { self.button.counter } + pub fn trigger(&mut self, long: bool) { + if long { + self.state = ButtonState::LongPress; + } + else { + self.state = ButtonState::Pressed; + } + } + /// polls the button and read the current state pub fn poll_and_read(&mut self, led_while_pressed: bool) -> ButtonState { self.button.poll();