From 2257f846afeb930c572e57963311a115843968ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= Date: Mon, 21 Oct 2024 20:50:05 +0200 Subject: [PATCH] Remove Inputtilt smoothing --- src/main.c | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/src/main.c b/src/main.c index e4aac2d..f8a79d7 100644 --- a/src/main.c +++ b/src/main.c @@ -895,34 +895,11 @@ static void apply_inputtilt(data *d) { float input_tiltback_target_diff = input_tiltback_target - d->inputtilt_interpolated; - // Smoothen changes in tilt angle by ramping the step size - const float smoothing_factor = 0.02; - - // Within X degrees of Target Angle, start ramping down step size - if (fabsf(input_tiltback_target_diff) < 2.0f) { - // Target step size is reduced the closer to center you are (needed for smoothly - // transitioning away from center) - d->inputtilt_ramped_step_size = - (smoothing_factor * d->inputtilt_step_size * (input_tiltback_target_diff / 2)) + - ((1 - smoothing_factor) * d->inputtilt_ramped_step_size); - // Linearly ramped down step size is provided as minimum to prevent overshoot - float centering_step_size = - fminf( - fabsf(d->inputtilt_ramped_step_size), - fabsf(input_tiltback_target_diff / 2) * d->inputtilt_step_size - ) * - sign(input_tiltback_target_diff); - if (fabsf(input_tiltback_target_diff) < fabsf(centering_step_size)) { - d->inputtilt_interpolated = input_tiltback_target; - } else { - d->inputtilt_interpolated += centering_step_size; - } + // Constant step size; no smoothing + if (fabsf(input_tiltback_target_diff) < d->inputtilt_step_size) { + d->inputtilt_interpolated = input_tiltback_target; } else { - // Ramp up step size until the configured tilt speed is reached - d->inputtilt_ramped_step_size = - (smoothing_factor * d->inputtilt_step_size * sign(input_tiltback_target_diff)) + - ((1 - smoothing_factor) * d->inputtilt_ramped_step_size); - d->inputtilt_interpolated += d->inputtilt_ramped_step_size; + d->inputtilt_interpolated += d->inputtilt_step_size * sign(input_tiltback_target_diff); } }