From 37f39fb1d881ba387cf656461fc4e3464ee7b614 Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Mon, 20 Jul 2020 09:01:48 +0200 Subject: [PATCH] mixer_module/tap_esc: fix usage of constrain() on input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I changed the input constraint in #15349 but screwed up the usage because I was convinced it's püass by reference. I'll double check for sure next time. --- src/drivers/tap_esc/tap_esc.cpp | 7 +------ src/lib/mixer_module/mixer_module.cpp | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/drivers/tap_esc/tap_esc.cpp b/src/drivers/tap_esc/tap_esc.cpp index 51b1a06cc018..ce782f81c350 100644 --- a/src/drivers/tap_esc/tap_esc.cpp +++ b/src/drivers/tap_esc/tap_esc.cpp @@ -639,12 +639,7 @@ int TAP_ESC::control_callback(uint8_t control_group, uint8_t control_index, floa input = _controls[control_group].control[control_index]; /* limit control input */ - if (input > 1.0f) { - input = 1.0f; - - } else if (input < -1.0f) { - input = -1.0f; - } + input = math::constrain(input, -1.f, 1.f); /* throttle not arming - mark throttle input as invalid */ if (_armed.prearmed && !_armed.armed) { diff --git a/src/lib/mixer_module/mixer_module.cpp b/src/lib/mixer_module/mixer_module.cpp index 610f0093eabe..da74f697ddc3 100644 --- a/src/lib/mixer_module/mixer_module.cpp +++ b/src/lib/mixer_module/mixer_module.cpp @@ -499,7 +499,7 @@ int MixingOutput::controlCallback(uintptr_t handle, uint8_t control_group, uint8 input = output->_controls[control_group].control[control_index]; /* limit control input */ - math::constrain(input, -1.f, 1.f); + input = math::constrain(input, -1.f, 1.f); /* motor spinup phase - lock throttle to zero */ if (output->_output_limit.state == OUTPUT_LIMIT_STATE_RAMP) {