diff --git a/python_payload/st3m/input.py b/python_payload/st3m/input.py index 06a2660073e8cdfe210ac078097bc76669342b6e..63b2fd91ae808c7418eb34bdbe92745a0e11aa9a 100644 --- a/python_payload/st3m/input.py +++ b/python_payload/st3m/input.py @@ -72,7 +72,7 @@ class Pressable: def __init__(self, state: bool) -> None: self._state = state self._prev_state = state - self._repeat = RepeatSettings(400, 200) + self._repeat: Optional[RepeatSettings] = RepeatSettings(400, 200) self._pressed_at: Optional[float] = None self._repeating = False @@ -80,6 +80,21 @@ class Pressable: self._ignoring = 0 + def repeat_enable(self, first: int = 400, subsequent: int = 200) -> None: + """ + Enable key repeat functionality. Arguments are amount to wait in ms + until first repeat is emitted and until subsequent repeats are emitted. + + Repeat is enabled by default on Pressables. + """ + self._repeat = RepeatSettings(first, subsequent) + + def repeat_disable(self) -> None: + """ + Disable repeat functionality on this Pressable. + """ + self._repeat = None + def _update(self, ts: int, state: bool) -> None: if self._ignoring > 0: self._ignoring -= 1