From bc0abcc53c4c4ce24e24037e3d3465e1a2c1924c Mon Sep 17 00:00:00 2001 From: Michele Bini Date: Sat, 2 Apr 2022 21:17:07 +0200 Subject: Hopefully improve jump detection diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp index 0b9aab7..e667d52 100644 --- a/src/displayapp/screens/Motion.cpp +++ b/src/displayapp/screens/Motion.cpp @@ -76,14 +76,16 @@ void Motion::Refresh() { if (started) { TickType_t current_frame_ms = current_time - last_frame_time; double G_scaled = G * G_SCALE; - if (G_scaled < 0.382) { + if (G_scaled < 1.000) { if (!jumping) { jump_started_or_ended = true; current_jump_speed = 0; current_jump_length = 0; jumping = true; } - double current_jump_accel = (1.0 - G_scaled) * 9.8; + double jump_ratio = 1.0 - G_scaled; + double jump_ratio *= jump_ratio; + double current_jump_accel = jump_ratio * 9.8; double current_frame_s = current_frame_ms * 0.001; current_jump_speed += current_jump_accel * current_frame_s; current_jump_length += current_jump_speed * current_frame_s; -- cgit v0.10.2