diff --git a/src/capture.rs b/src/capture.rs index d9798eb..5c7aa4c 100644 --- a/src/capture.rs +++ b/src/capture.rs @@ -31,7 +31,7 @@ impl Sequence { pub fn tick(&mut self, complete: bool, hand_present: bool, now: Instant) -> bool { match self.phase { Phase::Tracking if complete => self.phase = Phase::Countdown(now), - Phase::Countdown(start) if now.duration_since(start) >= Duration::from_secs(3) => { + Phase::Countdown(start) if now.duration_since(start) >= Duration::from_secs(5) => { self.phase = Phase::AwaitingRelease; return true; } @@ -50,7 +50,7 @@ impl Sequence { Phase::Countdown(start) => { let elapsed = now.duration_since(start).as_secs_f32(); Presentation { - countdown: (3 - elapsed as i32).clamp(1, 3), + countdown: (5 - elapsed as i32).clamp(1, 5), // The monitor lights the room: hold white illumination until // the clean frame is captured and queued after the countdown. flash_opacity: 0.95, @@ -229,7 +229,7 @@ mod tests { assert!(sequence.tracking()); assert!(!sequence.tick(true, true, start)); assert!(!sequence.tracking()); - assert_eq!(sequence.presentation(start).countdown, 3); + assert_eq!(sequence.presentation(start).countdown, 5); assert_eq!(sequence.presentation(start).flash_opacity, 0.95); assert_eq!( sequence @@ -237,34 +237,44 @@ mod tests { .flash_opacity, 0.95 ); - for (ms, number) in [(999, 3), (1000, 2), (1999, 2), (2000, 1), (2999, 1)] { + for (ms, number) in [ + (999, 5), + (1000, 4), + (1999, 4), + (2000, 3), + (2999, 3), + (3000, 2), + (3999, 2), + (4000, 1), + (4999, 1), + ] { let now = start + Duration::from_millis(ms); // Lowering the hand must not cancel an already-started countdown. assert!(!sequence.tick(false, false, now)); assert_eq!(sequence.presentation(now).countdown, number); assert_eq!(sequence.presentation(now).flash_opacity, 0.95); } - assert!(sequence.tick(true, true, start + Duration::from_secs(3))); + assert!(sequence.tick(true, true, start + Duration::from_secs(5))); assert!( sequence - .presentation(start + Duration::from_secs(3)) + .presentation(start + Duration::from_secs(5)) .awaiting_release ); assert_eq!( sequence - .presentation(start + Duration::from_secs(3)) + .presentation(start + Duration::from_secs(5)) .countdown, 0 ); assert_eq!( sequence - .presentation(start + Duration::from_secs(3)) + .presentation(start + Duration::from_secs(5)) .flash_opacity, 0.0 ); - assert!(!sequence.tick(true, true, start + Duration::from_secs(4))); + assert!(!sequence.tick(true, true, start + Duration::from_secs(6))); assert!(!sequence.tracking()); - assert!(!sequence.tick(false, false, start + Duration::from_secs(5))); + assert!(!sequence.tick(false, false, start + Duration::from_secs(7))); assert!(sequence.tracking()); }