From 001acc770c85f2e1348e49c7959f6f35467f8e16 Mon Sep 17 00:00:00 2001 From: cepetr Date: Thu, 16 May 2024 16:12:44 +0200 Subject: [PATCH] feat(core/rust): use f32 angles in ui components [no changelog] --- core/embed/rust/src/ui/model_mercury/bootloader/mod.rs | 2 +- core/embed/rust/src/ui/model_mercury/component/loader.rs | 2 +- core/embed/rust/src/ui/model_tt/bootloader/mod.rs | 2 +- .../rust/src/ui/model_tt/component/coinjoin_progress.rs | 4 ++-- core/embed/rust/src/ui/model_tt/component/loader.rs | 2 +- core/embed/rust/src/ui/model_tt/component/progress.rs | 8 ++++---- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/embed/rust/src/ui/model_mercury/bootloader/mod.rs b/core/embed/rust/src/ui/model_mercury/bootloader/mod.rs index 50184934ee..78d3d95c12 100644 --- a/core/embed/rust/src/ui/model_mercury/bootloader/mod.rs +++ b/core/embed/rust/src/ui/model_mercury/bootloader/mod.rs @@ -129,7 +129,7 @@ impl ModelMercuryFeatures { shape::Circle::new(center, constant::LOADER_OUTER) .with_bg(fg_color) - .with_end_angle(((progress as i32 * shape::PI4 as i32 * 8) / 1000) as i16) + .with_end_angle(360.0 * progress as f32 / 1000.0) .render(target); shape::Circle::new(center, constant::LOADER_INNER + 2) diff --git a/core/embed/rust/src/ui/model_mercury/component/loader.rs b/core/embed/rust/src/ui/model_mercury/component/loader.rs index 68ac609336..8531f2a631 100644 --- a/core/embed/rust/src/ui/model_mercury/component/loader.rs +++ b/core/embed/rust/src/ui/model_mercury/component/loader.rs @@ -234,7 +234,7 @@ impl Component for Loader { shape::Circle::new(center, constant::LOADER_OUTER) .with_bg(style.loader_color) - .with_end_angle(((progress as i32 * shape::PI4 as i32 * 8) / 1000) as i16) + .with_end_angle(360.0 * progress as f32 / 1000.0) .render(target); shape::Circle::new(center, constant::LOADER_INNER) diff --git a/core/embed/rust/src/ui/model_tt/bootloader/mod.rs b/core/embed/rust/src/ui/model_tt/bootloader/mod.rs index de6bbf49d6..1c248531f9 100644 --- a/core/embed/rust/src/ui/model_tt/bootloader/mod.rs +++ b/core/embed/rust/src/ui/model_tt/bootloader/mod.rs @@ -121,7 +121,7 @@ impl ModelTTFeatures { shape::Circle::new(center, constant::LOADER_OUTER) .with_bg(fg_color) - .with_end_angle(((progress as i32 * shape::PI4 as i32 * 8) / 1000) as i16) + .with_end_angle(360.0 * progress as f32 / 1000.0) .render(target); shape::Circle::new(center, constant::LOADER_INNER + 2) diff --git a/core/embed/rust/src/ui/model_tt/component/coinjoin_progress.rs b/core/embed/rust/src/ui/model_tt/component/coinjoin_progress.rs index d53d075b1a..411c91d355 100644 --- a/core/embed/rust/src/ui/model_tt/component/coinjoin_progress.rs +++ b/core/embed/rust/src/ui/model_tt/component/coinjoin_progress.rs @@ -135,8 +135,8 @@ where let start = (self.value as i16 - 100) % 1000; let end = (self.value as i16 + 100) % 1000; - let start = ((start as i32 * 8 * shape::PI4 as i32) / 1000) as i16; - let end = ((end as i32 * 8 * shape::PI4 as i32) / 1000) as i16; + let start = 360.0 * start as f32 / 1000.0; + let end = 360.0 * end as f32 / 1000.0; shape::Circle::new(center, LOADER_OUTER) .with_bg(inactive_color) diff --git a/core/embed/rust/src/ui/model_tt/component/loader.rs b/core/embed/rust/src/ui/model_tt/component/loader.rs index 22efb9abd4..11429ec61d 100644 --- a/core/embed/rust/src/ui/model_tt/component/loader.rs +++ b/core/embed/rust/src/ui/model_tt/component/loader.rs @@ -250,7 +250,7 @@ impl Component for Loader { shape::Circle::new(center, constant::LOADER_OUTER) .with_bg(style.loader_color) - .with_end_angle(((progress as i32 * shape::PI4 as i32 * 8) / 1000) as i16) + .with_end_angle(360.0 * progress as f32 / 1000.0) .render(target); shape::Circle::new(center, constant::LOADER_INNER + 2) diff --git a/core/embed/rust/src/ui/model_tt/component/progress.rs b/core/embed/rust/src/ui/model_tt/component/progress.rs index bdb8f7fa70..1d4f133279 100644 --- a/core/embed/rust/src/ui/model_tt/component/progress.rs +++ b/core/embed/rust/src/ui/model_tt/component/progress.rs @@ -119,12 +119,12 @@ impl Component for Progress { let (start, end) = if self.indeterminate { let start = (self.value as i16 - 100) % 1000; let end = (self.value as i16 + 100) % 1000; - let start = ((start as i32 * 8 * shape::PI4 as i32) / 1000) as i16; - let end = ((end as i32 * 8 * shape::PI4 as i32) / 1000) as i16; + let start = 360.0 * start as f32 / 1000.0; + let end = 360.0 * end as f32 / 1000.0; (start, end) } else { - let end = ((self.value as i32 * 8 * shape::PI4 as i32) / 1000) as i16; - (0, end) + let end = 360.0 * self.value as f32 / 1000.0; + (0.0, end) }; shape::Circle::new(center, constant::LOADER_OUTER)