From ab0cc33c48d06187d063d00fbf89b28d4cb6a2c4 Mon Sep 17 00:00:00 2001 From: puckoprutt Date: Mon, 13 Jul 2026 21:33:25 +0200 Subject: [PATCH] enabled triggering of event without pressing button --- src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) 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();