-
-
Notifications
You must be signed in to change notification settings - Fork 669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Success animation for Model R #2339
Conversation
1a14b28
to
275ddcb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
partial review so far
Overall, i worry about performance of the new functions, esp. generating the overlay pixel by pixel that incurs glyph lookup per every pixel. This might be good enough for 1bpp Trezor R, but I strongly suspect that it won't be good enough for the T.
Still, probably OK to keep it and worry about performance only when we need to.
@@ -136,3 +143,12 @@ pub fn set_window(x0: u16, y0: u16, x1: u16, y1: u16) { | |||
ffi::display_set_window(x0, y0, x1, y1); | |||
} | |||
} | |||
|
|||
pub fn get_offset() -> (i32, i32) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the purpose of this (and the original display_offset
function)?
does it ever return non-zero?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Purpose of this is to be consistent with the C functions, what is/was the purpose of the original i don't know, as far as i can tell its not being set anywhere. (function setting the offset is also exposed to python, but even that does not seem to be called anywhere).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's ask @prusnak
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC it was for some sort of scrolling / panning animation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good but will need a few mostly cosmetic changes. Especially please use the higher-level geometric types as much as possible.
Please note that after rebase the animation doesn't work probably because I broke the timer handling in 3dcdffe and will change it again in #2335. This patch can be used in the meantime. With this workaround the animation is working fine!
core/embed/rust/src/ui/display.rs
Outdated
} | ||
} | ||
|
||
fn get_point_on_line(v0: (i32, i32), v1: (i32, i32), position: f32) -> (i32, i32) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use geometry::Point
instead of (i32, i32)
wherever possible. Then you can take advantage of helper methods like Rect::contains
which will simplify several if conditions in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done here b964e7e , hopefully i didn't miss much.
i also tried adding and iterator to Rect, which returned directly Point, to eliminate repetitive nested loop iterating: but it came with non negligible performance downgrade, so i left it as it was.
d74b5fa
to
b964e7e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, left some comments but otherwise don't see any issues.
ui/display.rs
is growing quite large and it would be nice to split it into multiple files but we can do it in another PR since this one is pretty large already.
core/embed/rust/src/ui/display.rs
Outdated
match angle % 360 { | ||
0..=44 => Point::lerp(v[0], v[1], (angle) as f32 / 45_f32), | ||
45..=89 => Point::lerp(v[1], v[2], (angle - 45) as f32 / 45_f32), | ||
90..=134 => Point::lerp(v[2], v[3], (angle - 90) as f32 / 45_f32), | ||
135..=179 => Point::lerp(v[3], v[4], (angle - 135) as f32 / 45_f32), | ||
180..=224 => Point::lerp(v[4], v[5], (angle - 180) as f32 / 45_f32), | ||
225..=269 => Point::lerp(v[5], v[6], (angle - 225) as f32 / 45_f32), | ||
270..=314 => Point::lerp(v[6], v[7], (angle - 270) as f32 / 45_f32), | ||
315..=359 => Point::lerp(v[7], v[0], (angle - 315) as f32 / 45_f32), | ||
_ => Point::new(1000, 0), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So many constants scare me, what about something like:
let angle %= 360;
let vertices = v.len();
let sector = angle / vertices;
let sector_angle = angle % verticse as f32;
let sector_length = 360 / vertices as f32; // only works if 360 is divisible by vertices
let v1 = v[sector as usize];
let v2 = v[(sector + 1) % vertices as usize];
Point::lerp(v1, v2, inner_angle / sector_length)
Does using sin()
/cos()
cost us anything btw?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using your suggestion: e18e0fb
about sin/con: one thing is that we don't satisfy #[lang = "f32_runtime"]
so we don't have these available (and i don't know how to enable this and what other implications there might be if any). Then we would need to evaluate flash usage and execution time. But if we are gonna do some more animations and graphics, these might come handy, so it would be worth experimenting with at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried it with sin/cos: we don't have these function in rust since they are part of std, which we don't use. Tried using rust crate libm, which worked but it produced about 7kB larger binary. Tried also compiling&exposing C sin/cos functions, which is a bit better - about 4kB more. Didn't check the performance as the size is imo blocker until we really need it.
f6685c7
to
c6e8aaf
Compare
looks good from my side. please rebase, squash as appropriate, and implement #2339 (comment) |
ce97b64
to
449cbc2
Compare
Squashed, rebased, fixed #2339 (comment) Also changed the animation end detection in e32aaf6 and 413ac64 since the issue has been fixed in meantime. Open points:
|
Let's keep it for now and create an issue.
That is true. How about
Let's keep it for now. I would like to do more in this direction, in particular, introduce a |
Yes, I am already using
|
It could be also relevant here - I have made a |
413ac64
to
6646250
Compare
Imeplements #2293
Implements also popup screen from design, but text is not centered (limitation of Paragraph implementation in rust, seems out of scope for this PR to implement that). Button in the popup also differs, since out current button implementation does not follow design. Fonts used in design are also not available.
Builds on #2276 which should be merged first.