diff --git a/core/embed/rust/src/ui/component/base.rs b/core/embed/rust/src/ui/component/base.rs index 9432d05bc8..0309feb836 100644 --- a/core/embed/rust/src/ui/component/base.rs +++ b/core/embed/rust/src/ui/component/base.rs @@ -430,7 +430,7 @@ impl EventCtx { pub const ANIM_FRAME_TIMER: TimerToken = TimerToken(1); /// How long into the future we should schedule the animation frame timer. - const ANIM_FRAME_DEADLINE: Duration = Duration::from_millis(1); + const ANIM_FRAME_DURATION: Duration = Duration::from_millis(1); // 0 == `TimerToken::INVALID`, // 1 == `Self::ANIM_FRAME_TIMER`. @@ -476,10 +476,10 @@ impl EventCtx { self.paint_requested = true; } - /// Request a timer event to be delivered after `deadline` elapses. - pub fn request_timer(&mut self, deadline: Duration) -> TimerToken { + /// Request a timer event to be delivered after `duration` elapses. + pub fn request_timer(&mut self, duration: Duration) -> TimerToken { let token = self.next_timer_token(); - self.register_timer(token, deadline); + self.register_timer(token, duration); token } @@ -487,7 +487,7 @@ impl EventCtx { pub fn request_anim_frame(&mut self) { if !self.anim_frame_scheduled { self.anim_frame_scheduled = true; - self.register_timer(Self::ANIM_FRAME_TIMER, Self::ANIM_FRAME_DEADLINE); + self.register_timer(Self::ANIM_FRAME_TIMER, Self::ANIM_FRAME_DURATION); } } @@ -561,8 +561,8 @@ impl EventCtx { self.transition_out = None; } - fn register_timer(&mut self, token: TimerToken, deadline: Duration) { - if self.timers.push((token, deadline)).is_err() { + fn register_timer(&mut self, token: TimerToken, duration: Duration) { + if self.timers.push((token, duration)).is_err() { // The timer queue is full, this would be a development error in the layout // layer. Let's panic in the debug env. #[cfg(feature = "ui_debug")] diff --git a/core/embed/rust/src/ui/layout/obj.rs b/core/embed/rust/src/ui/layout/obj.rs index cad01cbba1..e27ddf8df2 100644 --- a/core/embed/rust/src/ui/layout/obj.rs +++ b/core/embed/rust/src/ui/layout/obj.rs @@ -173,7 +173,7 @@ impl LayoutObjInner { } /// Timer callback is expected to be a callable object of the following - /// form: `def timer(token: int, deadline_in_ms: int)`. + /// form: `def timer(token: int, duration_ms: int)`. fn obj_set_timer_fn(&mut self, timer_fn: Obj) { self.timer_fn = timer_fn; } @@ -226,13 +226,13 @@ impl LayoutObjInner { // painting by now, and we're prepared for a paint pass. // Drain any pending timers into the callback. - while let Some((token, deadline)) = self.event_ctx.pop_timer() { + while let Some((token, duration)) = self.event_ctx.pop_timer() { let token = token.try_into(); - let deadline = deadline.try_into(); - if let (Ok(token), Ok(deadline)) = (token, deadline) { - self.timer_fn.call_with_n_args(&[token, deadline])?; + let duration = duration.try_into(); + if let (Ok(token), Ok(duration)) = (token, duration) { + self.timer_fn.call_with_n_args(&[token, duration])?; } else { - // Failed to convert token or deadline into `Obj`, skip. + // Failed to convert token or duration into `Obj`, skip. } } diff --git a/core/embed/rust/src/ui/model_mercury/component/keyboard/common.rs b/core/embed/rust/src/ui/model_mercury/component/keyboard/common.rs index 58544b75a1..628e0705fd 100644 --- a/core/embed/rust/src/ui/model_mercury/component/keyboard/common.rs +++ b/core/embed/rust/src/ui/model_mercury/component/keyboard/common.rs @@ -90,7 +90,7 @@ impl MultiTapKeyboard { // If the key has more then one character, we need to set it as pending, so we // can cycle through on the repeated clicks. We also request a timer so we can - // reset the pending state after a deadline. + // reset the pending state after a timeout. // // Note: It might seem that we should make sure to `request_paint` in case we // progress into a pending state (to display the pending marker), but such diff --git a/core/embed/rust/src/ui/model_mercury/layout.rs b/core/embed/rust/src/ui/model_mercury/layout.rs index 6b2176a187..07fa72dc75 100644 --- a/core/embed/rust/src/ui/model_mercury/layout.rs +++ b/core/embed/rust/src/ui/model_mercury/layout.rs @@ -1140,7 +1140,7 @@ pub static mp_module_trezorui2: Module = obj_module! { /// """Attach a timer setter function. /// /// The layout object can call the timer setter with two arguments, - /// `token` and `deadline`. When `deadline` is reached, the layout object + /// `token` and `duration_ms`. When `duration_ms` is reached, the layout object /// expects a callback to `self.timer(token)`. /// """ /// @@ -1162,7 +1162,7 @@ pub static mp_module_trezorui2: Module = obj_module! { /// """Callback for the timer set by `attach_timer_fn`. /// /// This function should be called by the executor after the corresponding - /// deadline is reached. + /// duration has expired. /// """ /// /// def paint(self) -> bool: diff --git a/core/embed/rust/src/ui/model_tt/component/keyboard/common.rs b/core/embed/rust/src/ui/model_tt/component/keyboard/common.rs index 9868770bc4..d4dcb7b787 100644 --- a/core/embed/rust/src/ui/model_tt/component/keyboard/common.rs +++ b/core/embed/rust/src/ui/model_tt/component/keyboard/common.rs @@ -88,7 +88,7 @@ impl MultiTapKeyboard { // If the key has more then one character, we need to set it as pending, so we // can cycle through on the repeated clicks. We also request a timer so we can - // reset the pending state after a deadline. + // reset the pending state after it elapses. // // Note: It might seem that we should make sure to `request_paint` in case we // progress into a pending state (to display the pending marker), but such diff --git a/core/embed/rust/src/ui/model_tt/layout.rs b/core/embed/rust/src/ui/model_tt/layout.rs index c423e18bba..3d93259412 100644 --- a/core/embed/rust/src/ui/model_tt/layout.rs +++ b/core/embed/rust/src/ui/model_tt/layout.rs @@ -1636,7 +1636,7 @@ pub static mp_module_trezorui2: Module = obj_module! { /// """Attach a timer setter function. /// /// The layout object can call the timer setter with two arguments, - /// `token` and `deadline`. When `deadline` is reached, the layout object + /// `token` and `duration`. When `duration` elapses, the layout object /// expects a callback to `self.timer(token)`. /// """ /// @@ -1658,7 +1658,7 @@ pub static mp_module_trezorui2: Module = obj_module! { /// """Callback for the timer set by `attach_timer_fn`. /// /// This function should be called by the executor after the corresponding - /// deadline is reached. + /// duration elapses. /// """ /// /// def paint(self) -> bool: diff --git a/core/mocks/generated/trezorui2.pyi b/core/mocks/generated/trezorui2.pyi index 59e58ca27d..9e443ed895 100644 --- a/core/mocks/generated/trezorui2.pyi +++ b/core/mocks/generated/trezorui2.pyi @@ -11,7 +11,7 @@ class LayoutObj(Generic[T]): def attach_timer_fn(self, fn: Callable[[int, int], None], attach_type: AttachType | None) -> None: """Attach a timer setter function. The layout object can call the timer setter with two arguments, - `token` and `deadline`. When `deadline` is reached, the layout object + `token` and `duration_ms`. When `duration_ms` is reached, the layout object expects a callback to `self.timer(token)`. """ if utils.USE_TOUCH: @@ -27,7 +27,7 @@ class LayoutObj(Generic[T]): def timer(self, token: int) -> T | None: """Callback for the timer set by `attach_timer_fn`. This function should be called by the executor after the corresponding - deadline is reached. + duration has expired. """ def paint(self) -> bool: """Paint the layout object on screen. @@ -1118,7 +1118,7 @@ class LayoutObj(Generic[T]): def attach_timer_fn(self, fn: Callable[[int, int], None], attach_type: AttachType | None) -> None: """Attach a timer setter function. The layout object can call the timer setter with two arguments, - `token` and `deadline`. When `deadline` is reached, the layout object + `token` and `duration`. When `duration` elapses, the layout object expects a callback to `self.timer(token)`. """ if utils.USE_TOUCH: @@ -1134,7 +1134,7 @@ class LayoutObj(Generic[T]): def timer(self, token: int) -> T | None: """Callback for the timer set by `attach_timer_fn`. This function should be called by the executor after the corresponding - deadline is reached. + duration elapses. """ def paint(self) -> bool: """Paint the layout object on screen. diff --git a/core/src/trezor/ui/layouts/mercury/__init__.py b/core/src/trezor/ui/layouts/mercury/__init__.py index 96adf2e2ed..f8b74ee0f3 100644 --- a/core/src/trezor/ui/layouts/mercury/__init__.py +++ b/core/src/trezor/ui/layouts/mercury/__init__.py @@ -46,8 +46,8 @@ class RustLayout(ui.Layout): def __del__(self): self.layout.__del__() - def set_timer(self, token: int, deadline: int) -> None: - self.timer.schedule(deadline, token) + def set_timer(self, token: int, duration_ms: int) -> None: + self.timer.schedule(duration_ms, token) def request_complete_repaint(self) -> None: msg = self.layout.request_complete_repaint() @@ -270,7 +270,7 @@ class RustLayout(ui.Layout): def draw_simple(layout: Any) -> None: # Simple drawing not supported for layouts that set timers. - def dummy_set_timer(token: int, deadline: int) -> None: + def dummy_set_timer(token: int, duration: int) -> None: raise RuntimeError layout.attach_timer_fn(dummy_set_timer, None) diff --git a/core/src/trezor/ui/layouts/progress.py b/core/src/trezor/ui/layouts/progress.py index 497da3d28e..053acbc3da 100644 --- a/core/src/trezor/ui/layouts/progress.py +++ b/core/src/trezor/ui/layouts/progress.py @@ -40,7 +40,7 @@ class RustProgress: ui.refresh() ui.backlight_fade(ui.BacklightLevels.NORMAL) - def set_timer(self, token: int, deadline: int) -> None: + def set_timer(self, token: int, duration_ms: int) -> None: raise RuntimeError # progress layouts should not set timers def report(self, value: int, description: str | None = None): diff --git a/core/src/trezor/ui/layouts/tr/__init__.py b/core/src/trezor/ui/layouts/tr/__init__.py index 389fcaa7a2..4134f46aec 100644 --- a/core/src/trezor/ui/layouts/tr/__init__.py +++ b/core/src/trezor/ui/layouts/tr/__init__.py @@ -47,8 +47,8 @@ class RustLayout(LayoutParentType[T]): def __del__(self): self.layout.__del__() - def set_timer(self, token: int, deadline: int) -> None: - self.timer.schedule(deadline, token) + def set_timer(self, token: int, duration_ms: int) -> None: + self.timer.schedule(duration_ms, token) def request_complete_repaint(self) -> None: msg = self.layout.request_complete_repaint() @@ -308,7 +308,7 @@ class RustLayout(LayoutParentType[T]): def draw_simple(layout: trezorui2.LayoutObj[Any]) -> None: # Simple drawing not supported for layouts that set timers. - def dummy_set_timer(token: int, deadline: int) -> None: + def dummy_set_timer(token: int, duration: int) -> None: raise RuntimeError layout.attach_timer_fn(dummy_set_timer, None) diff --git a/core/src/trezor/ui/layouts/tt/__init__.py b/core/src/trezor/ui/layouts/tt/__init__.py index 2d6ad00b45..dce95f4af9 100644 --- a/core/src/trezor/ui/layouts/tt/__init__.py +++ b/core/src/trezor/ui/layouts/tt/__init__.py @@ -49,8 +49,8 @@ class RustLayout(LayoutParentType[T]): def __del__(self): self.layout.__del__() - def set_timer(self, token: int, deadline: int) -> None: - self.timer.schedule(deadline, token) + def set_timer(self, token: int, duration_ms: int) -> None: + self.timer.schedule(duration_ms, token) def request_complete_repaint(self) -> None: msg = self.layout.request_complete_repaint() @@ -271,7 +271,7 @@ class RustLayout(LayoutParentType[T]): def draw_simple(layout: trezorui2.LayoutObj[Any]) -> None: # Simple drawing not supported for layouts that set timers. - def dummy_set_timer(token: int, deadline: int) -> None: + def dummy_set_timer(token: int, duration: int) -> None: raise RuntimeError layout.attach_timer_fn(dummy_set_timer, None)