|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
#[cfg(feature = "haptic")]
|
|
|
|
|
use crate::trezorhal::haptic::{self, play, HapticEffect};
|
|
|
|
|
use crate::trezorhal::haptic::{self, HapticEffect};
|
|
|
|
|
use crate::{
|
|
|
|
|
time::{Duration, Instant},
|
|
|
|
|
ui::{
|
|
|
|
@ -18,6 +18,9 @@ use super::theme;
|
|
|
|
|
const GROWING_DURATION_MS: u32 = 1000;
|
|
|
|
|
const SHRINKING_DURATION_MS: u32 = 500;
|
|
|
|
|
|
|
|
|
|
const HAPTIC_AMPLITUDE_MAX_PCT: i16 = 16;
|
|
|
|
|
const HAPTIC_AMPLITUDE_DURATION_MS: u16 = 100;
|
|
|
|
|
|
|
|
|
|
pub enum LoaderMsg {
|
|
|
|
|
GrownCompletely,
|
|
|
|
|
ShrunkCompletely,
|
|
|
|
@ -169,14 +172,20 @@ impl Component for Loader {
|
|
|
|
|
|
|
|
|
|
if self.is_completely_grown(now) {
|
|
|
|
|
#[cfg(feature = "haptic")]
|
|
|
|
|
play(HapticEffect::HoldToConfirm);
|
|
|
|
|
haptic::play(HapticEffect::HoldToConfirm);
|
|
|
|
|
return Some(LoaderMsg::GrownCompletely);
|
|
|
|
|
} else if self.is_completely_shrunk(now) {
|
|
|
|
|
return Some(LoaderMsg::ShrunkCompletely);
|
|
|
|
|
} else {
|
|
|
|
|
let progress = self.progress(now).unwrap() as f32 / 1000.0;
|
|
|
|
|
let ampl = i16::lerp(0, 76, progress);
|
|
|
|
|
haptic::play_rtp(ampl as i8, 100);
|
|
|
|
|
#[cfg(feature = "haptic")]
|
|
|
|
|
{
|
|
|
|
|
if matches!(self.state, State::Growing(_)) {
|
|
|
|
|
let progress =
|
|
|
|
|
self.progress(now).unwrap() as f32 / display::LOADER_MAX as f32;
|
|
|
|
|
let ampl = i16::lerp(0, HAPTIC_AMPLITUDE_MAX_PCT, progress);
|
|
|
|
|
haptic::play_custom(ampl as i8, HAPTIC_AMPLITUDE_DURATION_MS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// There is further progress in the animation, request an animation frame event.
|
|
|
|
|
ctx.request_anim_frame();
|
|
|
|
|