diff --git a/src/conf/datatypes.h b/src/conf/datatypes.h index 83b60d6..54c5110 100644 --- a/src/conf/datatypes.h +++ b/src/conf/datatypes.h @@ -189,7 +189,6 @@ typedef struct { FLOAT_INPUTTILT_REMOTE_TYPE inputtilt_remote_type; float inputtilt_speed; float inputtilt_angle_limit; - uint16_t inputtilt_smoothing_factor; bool inputtilt_invert_throttle; float inputtilt_deadband; float remote_throttle_current_max; diff --git a/src/conf/settings.xml b/src/conf/settings.xml index 78de829..9a7905a 100644 --- a/src/conf/settings.xml +++ b/src/conf/settings.xml @@ -948,31 +948,6 @@ p, li { white-space: pre-wrap; } °/s 7 - - Tiltback Smoothing Factor - 2 - 1 - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Roboto'; ; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Determines how much smoothing is added to Remote Tilt, such as when you start tilting and as you approach the target angle.</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">0 = No Smoothing</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">3 = Maximum Smoothing</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Recommended Values: 1-2</span></p></body></html> - CFG_DFLT_INPUTTILT_SMOOTHING_FACTOR - 1 - 0 - 3 - 0 - 1 - 1 - 1 - - 1 - Invert Throttle 5 @@ -3343,7 +3318,6 @@ p, li { white-space: pre-wrap; } inputtilt_remote_type inputtilt_angle_limit inputtilt_speed - inputtilt_smoothing_factor inputtilt_invert_throttle inputtilt_deadband remote_throttle_current_max @@ -3581,7 +3555,6 @@ p, li { white-space: pre-wrap; } inputtilt_remote_type inputtilt_angle_limit inputtilt_speed - inputtilt_smoothing_factor inputtilt_invert_throttle inputtilt_deadband ::sep::Remote Throttle diff --git a/src/main.c b/src/main.c index f83775e..1eb4dd7 100644 --- a/src/main.c +++ b/src/main.c @@ -870,48 +870,33 @@ 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 - if (d->float_conf.inputtilt_smoothing_factor > 0) { - float smoothing_factor = 0.02; - for (int i = 1; i < d->float_conf.inputtilt_smoothing_factor; i++) { - smoothing_factor /= 2; - } - - // Sets the angle away from Target that step size begins ramping down - float smooth_center_window = 1.5 + (0.5 * d->float_conf.inputtilt_smoothing_factor); - - // Within X degrees of Target Angle, start ramping down step size - if (fabsf(input_tiltback_target_diff) < smooth_center_window) { - // 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; - } - } 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; - } - } else { - // Constant step size; no smoothing - if (fabsf(input_tiltback_target_diff) < d->inputtilt_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 += d->inputtilt_step_size * sign(input_tiltback_target_diff); + d->inputtilt_interpolated += centering_step_size; } + } 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->setpoint += d->inputtilt_interpolated;