Skip to content

Commit 987826f

Browse files
MaEtUgRbkueng
authored andcommitted
mixer_module/tap_esc: fix usage of constrain() on input
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.
1 parent 650b601 commit 987826f

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

src/drivers/tap_esc/tap_esc.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -639,12 +639,7 @@ int TAP_ESC::control_callback(uint8_t control_group, uint8_t control_index, floa
639639
input = _controls[control_group].control[control_index];
640640

641641
/* limit control input */
642-
if (input > 1.0f) {
643-
input = 1.0f;
644-
645-
} else if (input < -1.0f) {
646-
input = -1.0f;
647-
}
642+
input = math::constrain(input, -1.f, 1.f);
648643

649644
/* throttle not arming - mark throttle input as invalid */
650645
if (_armed.prearmed && !_armed.armed) {

src/lib/mixer_module/mixer_module.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ int MixingOutput::controlCallback(uintptr_t handle, uint8_t control_group, uint8
499499
input = output->_controls[control_group].control[control_index];
500500

501501
/* limit control input */
502-
math::constrain(input, -1.f, 1.f);
502+
input = math::constrain(input, -1.f, 1.f);
503503

504504
/* motor spinup phase - lock throttle to zero */
505505
if (output->_output_limit.state == OUTPUT_LIMIT_STATE_RAMP) {

0 commit comments

Comments
 (0)