enabled triggering of event without pressing button

This commit is contained in:
puckoprutt 2026-07-13 21:33:25 +02:00
parent 2cf404da0b
commit ab0cc33c48

View File

@ -94,6 +94,15 @@ impl<OP: OutputPin, IP: InputPin> LedButton<OP, IP> {
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();