fix: shorten steady-hand wait before progress starts

This commit is contained in:
2026-11-08 14:15:13 +01:00
parent ef4ae15abb
commit 4acec0c87e

View File

@@ -8,6 +8,7 @@ use opencv::{
pub const DETECTION_INTERVAL: Duration = Duration::from_millis(250);
pub const STALE_AFTER: Duration = Duration::from_millis(750);
const STEADY_WAIT: Duration = Duration::from_millis(500);
#[derive(Clone, Copy, Debug)]
pub struct Palm {
@@ -190,7 +191,10 @@ impl Tracker {
let elapsed = self
.steady_since
.map_or(0.0, |since| now.duration_since(since).as_secs_f64());
Some((self.palm?, (elapsed - 1.0).clamp(0.0, 1.0)))
Some((
self.palm?,
(elapsed - STEADY_WAIT.as_secs_f64()).clamp(0.0, 1.0),
))
}
pub fn complete(&self, now: Instant) -> bool {
@@ -284,10 +288,10 @@ mod tests {
for ms in [0, 250, 500, 750, 1000, 1250, 1500, 1750, 2000] {
let now = start + Duration::from_millis(ms);
tracker.update(palm(100.0), now);
assert_eq!(tracker.complete(now), ms >= 2000);
assert_eq!(tracker.complete(now), ms >= 1500);
assert_eq!(
tracker.visible(now).unwrap().1,
((ms as f64 / 1000.0) - 1.0).clamp(0.0, 1.0)
((ms as f64 / 1000.0) - 0.5).clamp(0.0, 1.0)
);
}
let now = start + Duration::from_millis(2250);