Skip to content

Commit

Permalink
Mixer passthrough: resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gongtao0607 committed Dec 27, 2024
1 parent ca7b606 commit 874cb62
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/main/flight/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,13 @@ static inline void mixerApplyInputLimit(int index, float value)
}
}

static float mixerGetPassthroughInput(int index, float value)
/*
* Check if the mixer index is one of the stabilized axes. If so,
* return the overriden value (directly from RC). Otherwise, return original
* value.
*/
static float mixerGetPassthroughInput(const int index,
const float original_value)
{
float rc = 0;
switch (index) {
Expand All @@ -211,19 +217,16 @@ static float mixerGetPassthroughInput(int index, float value)
rc = getRcDeflection(COLLECTIVE);
break;
default:
return value;
return original_value;
}

// Scale rc by 120% for easier observing endpoints.
rc *= 1.2f;

if (rc > 0) {
value = scaleRangef(rc, 0, 1.0f, 0, mixerInputs(index)->max / 1000.0f);
} else {
value = scaleRangef(rc, 0, -1.0f, 0, mixerInputs(index)->min / 1000.0f);
return scaleRangef(rc, 0, 1.0f, 0, mixerInputs(index)->max / 1000.0f);
}

return value;
return scaleRangef(rc, 0, -1.0f, 0, mixerInputs(index)->min / 1000.0f);
}

static void mixerSetInput(int index, float value)
Expand Down

0 comments on commit 874cb62

Please sign in to comment.