diff --git a/commands2/button/trigger.py b/commands2/button/trigger.py index 400a188..03431df 100644 --- a/commands2/button/trigger.py +++ b/commands2/button/trigger.py @@ -129,16 +129,17 @@ def onChange(self, command: Command) -> Self: :param command: the command t start :returns: this trigger, so calls can be chained """ - self._last_pressed = self._condition() + + state = SimpleNamespace(pressed_last=self._condition()) @self._loop.bind def _(): pressed = self._condition() - if this._last_pressed != pressed: + if self.pressed_last != pressed: command.schedule() - this._last_pressed = pressed + self.pressed_last = pressed return self