better puppy animation calculation
This commit is contained in:
@@ -48,14 +48,14 @@ pub async fn run_display(display: &mut Option<Display>) -> Option<()> {
|
||||
loop {
|
||||
// Choose state based on wpm
|
||||
let (state, frame_delay_ms) = if wpm == 0 {
|
||||
(PuppyAnim::Sleep, 250)
|
||||
} else if wpm < 60 {
|
||||
(PuppyAnim::Sleep, 400)
|
||||
} else if wpm < 80 {
|
||||
// faster tail wagging, connected to wpm
|
||||
let delay = (3000 / wpm.max(10)).clamp(100, 300);
|
||||
let delay = (250 - (wpm * 170 / 80)).max(80);
|
||||
(PuppyAnim::Idle, delay)
|
||||
} else {
|
||||
// even faster tail wagging!!
|
||||
let delay = (4000 / wpm).clamp(16, 100);
|
||||
let delay = (80 - ((wpm - 80) * 50 / 70)).max(30);
|
||||
(PuppyAnim::Happy, delay)
|
||||
};
|
||||
|
||||
@@ -121,7 +121,7 @@ pub async fn run_display(display: &mut Option<Display>) -> Option<()> {
|
||||
|
||||
display.flush().ok()?;
|
||||
|
||||
Timer::after(Duration::from_millis(16)).await;
|
||||
Timer::after(Duration::from_millis(8)).await;
|
||||
}
|
||||
} else {
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user