fix(radio): mix line not working if source is a global variable (#6304)
This commit is contained in:
+12
-11
@@ -833,8 +833,10 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
|||||||
activeMixes[i] = 0;
|
activeMixes[i] = 0;
|
||||||
|
|
||||||
MixData * md = mixAddress(i);
|
MixData * md = mixAddress(i);
|
||||||
|
mixsrc_t srcRaw = md->srcRaw;
|
||||||
|
mixsrc_t srcRawAbs = abs(srcRaw);
|
||||||
|
|
||||||
if (md->srcRaw == 0) {
|
if (srcRaw == 0) {
|
||||||
#if defined(COLORLCD)
|
#if defined(COLORLCD)
|
||||||
continue;
|
continue;
|
||||||
#else
|
#else
|
||||||
@@ -858,16 +860,16 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
|||||||
|
|
||||||
if (mixLineActive) {
|
if (mixLineActive) {
|
||||||
// disable mixer using trainer channels if not connected
|
// disable mixer using trainer channels if not connected
|
||||||
if (md->srcRaw >= MIXSRC_FIRST_TRAINER &&
|
if (srcRawAbs >= MIXSRC_FIRST_TRAINER &&
|
||||||
md->srcRaw <= MIXSRC_LAST_TRAINER && !isTrainerValid()) {
|
srcRawAbs <= MIXSRC_LAST_TRAINER && !isTrainerValid()) {
|
||||||
mixCondition = true;
|
mixCondition = true;
|
||||||
mixEnabled = 0;
|
mixEnabled = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(LUA_MODEL_SCRIPTS)
|
#if defined(LUA_MODEL_SCRIPTS)
|
||||||
// disable mixer if Lua script is used as source and script was killed
|
// disable mixer if Lua script is used as source and script was killed
|
||||||
if (md->srcRaw >= MIXSRC_FIRST_LUA && md->srcRaw <= MIXSRC_LAST_LUA) {
|
if (srcRawAbs >= MIXSRC_FIRST_LUA && srcRawAbs <= MIXSRC_LAST_LUA) {
|
||||||
div_t qr = div(md->srcRaw - MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS);
|
div_t qr = div(int(srcRawAbs - MIXSRC_FIRST_LUA), MAX_SCRIPT_OUTPUTS);
|
||||||
if (scriptInternalData[qr.quot].state != SCRIPT_OK) {
|
if (scriptInternalData[qr.quot].state != SCRIPT_OK) {
|
||||||
mixCondition = true;
|
mixCondition = true;
|
||||||
mixEnabled = 0;
|
mixEnabled = 0;
|
||||||
@@ -881,16 +883,15 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
|||||||
|
|
||||||
if (mode > e_perout_mode_inactive_flight_mode) {
|
if (mode > e_perout_mode_inactive_flight_mode) {
|
||||||
if (mixEnabled)
|
if (mixEnabled)
|
||||||
v = getValue(md->srcRaw);
|
v = getValue(srcRaw);
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
mixsrc_t srcRaw = md->srcRaw;
|
|
||||||
v = getValue(srcRaw);
|
v = getValue(srcRaw);
|
||||||
|
|
||||||
if (srcRaw >= MIXSRC_FIRST_CH) {
|
if (srcRawAbs >= MIXSRC_FIRST_CH && srcRawAbs <= MIXSRC_LAST_CH) {
|
||||||
|
|
||||||
auto srcChan = srcRaw - MIXSRC_FIRST_CH;
|
auto srcChan = srcRawAbs - MIXSRC_FIRST_CH;
|
||||||
if (srcChan <= MAX_OUTPUT_CHANNELS && md->destCh != srcChan) {
|
if (srcChan <= MAX_OUTPUT_CHANNELS && md->destCh != srcChan) {
|
||||||
|
|
||||||
// check whether we need to recompute the current channel later
|
// check whether we need to recompute the current channel later
|
||||||
@@ -962,13 +963,13 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
|||||||
if (applyOffsetAndCurve) {
|
if (applyOffsetAndCurve) {
|
||||||
bool applyTrims = !(mode & e_perout_mode_notrims);
|
bool applyTrims = !(mode & e_perout_mode_notrims);
|
||||||
if (!applyTrims && g_model.thrTrim) {
|
if (!applyTrims && g_model.thrTrim) {
|
||||||
auto origin = getSourceTrimOrigin(md->srcRaw);
|
auto origin = getSourceTrimOrigin(srcRaw);
|
||||||
if (origin == g_model.getThrottleStickTrimSource() - MIXSRC_FIRST_TRIM) {
|
if (origin == g_model.getThrottleStickTrimSource() - MIXSRC_FIRST_TRIM) {
|
||||||
applyTrims = true;
|
applyTrims = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (applyTrims && md->carryTrim == 0) {
|
if (applyTrims && md->carryTrim == 0) {
|
||||||
v += getSourceTrimValue(md->srcRaw, v);
|
v += getSourceTrimValue(srcRaw, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user