1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-15 20:35:19 +03:00

Fix colours and labels bug in the mixer

This commit is contained in:
Darren Lines 2022-05-13 23:35:07 +01:00
parent 705c8fe88b
commit 1eb9ad6639
2 changed files with 48 additions and 21 deletions

View file

@ -799,6 +799,22 @@ helper.mixer = (function (mixerList) {
} }
} }
publicScope.countSurfaceType = function(mixer, surface) {
let count = 0;
for (const i in mixer.servoMixer) {
if (mixer.servoMixer.hasOwnProperty(i)) {
const s = mixer.servoMixer[i];
if (s.getInput() === surface) {
count++;
}
}
}
return count;
}
return publicScope; return publicScope;
})(mixerList); })(mixerList);

View file

@ -111,10 +111,10 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
let outputPad = 1; let outputPad = 1;
let outputArea = null; let outputArea = null;
let inputBoxes = null; let inputBoxes = null;
let surfaceSet = { let surfaces = {
aileron: false, aileronSet: helper.mixer.countSurfaceType(currentMixerPreset, INPUT_STABILIZED_ROLL),
elevator: false, elevatorSet: helper.mixer.countSurfaceType(currentMixerPreset, INPUT_STABILIZED_PITCH),
rudder: false, rudderSet: helper.mixer.countSurfaceType(currentMixerPreset, INPUT_STABILIZED_YAW),
}; };
let motors = []; let motors = [];
let servoRules = SERVO_RULES; let servoRules = SERVO_RULES;
@ -131,7 +131,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
switch (parseInt(servo.getInput())) { switch (parseInt(servo.getInput())) {
case INPUT_STABILIZED_PITCH: case INPUT_STABILIZED_PITCH:
case INPUT_RC_PITCH: case INPUT_RC_PITCH:
outputArea = getOutputImageArea(currentMixerPreset.imageOutputsNumbers, INPUT_STABILIZED_PITCH, surfaceSet.elevator); outputArea = getOutputImageArea(currentMixerPreset.imageOutputsNumbers, INPUT_STABILIZED_PITCH, surfaces.elevatorSet);
if (outputArea != null) { if (outputArea != null) {
mixerPreview.append('<div id="' + divID + '" class="outputImageNumber">S' + outputPad + '</div>'); mixerPreview.append('<div id="' + divID + '" class="outputImageNumber">S' + outputPad + '</div>');
@ -148,12 +148,12 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
}); });
} }
surfaceSet.elevator = true; surfaces.elevatorSet--;
} }
break; break;
case INPUT_STABILIZED_ROLL: case INPUT_STABILIZED_ROLL:
case INPUT_RC_ROLL: case INPUT_RC_ROLL:
outputArea = getOutputImageArea(currentMixerPreset.imageOutputsNumbers, INPUT_STABILIZED_ROLL, surfaceSet.aileron); outputArea = getOutputImageArea(currentMixerPreset.imageOutputsNumbers, INPUT_STABILIZED_ROLL, surfaces.aileronSet);
if (outputArea != null) { if (outputArea != null) {
mixerPreview.append('<div id="' + divID + '" class="outputImageNumber">S' + outputPad + '</div>'); mixerPreview.append('<div id="' + divID + '" class="outputImageNumber">S' + outputPad + '</div>');
@ -170,12 +170,12 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
}); });
} }
surfaceSet.aileron = true; surfaces.aileronSet--;
} }
break; break;
case INPUT_STABILIZED_YAW: case INPUT_STABILIZED_YAW:
case INPUT_RC_YAW: case INPUT_RC_YAW:
outputArea = getOutputImageArea(currentMixerPreset.imageOutputsNumbers, INPUT_STABILIZED_YAW, surfaceSet.rudder); outputArea = getOutputImageArea(currentMixerPreset.imageOutputsNumbers, INPUT_STABILIZED_YAW, surfaces.rudderSet);
if (outputArea != null) { if (outputArea != null) {
mixerPreview.append('<div id="' + divID + '" class="outputImageNumber">S' + outputPad + '</div>'); mixerPreview.append('<div id="' + divID + '" class="outputImageNumber">S' + outputPad + '</div>');
@ -192,7 +192,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
}); });
} }
surfaceSet.rudder = true; surfaces.rudderSet--;
} }
break; break;
} }
@ -205,7 +205,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
if (motors.length > 0) { if (motors.length > 0) {
mixerPreview.append('<div id="motorsPreview" class="outputImageNumber isMotor">S' + motors.join('/') + '</div>'); mixerPreview.append('<div id="motorsPreview" class="outputImageNumber isMotor">S' + motors.join('/') + '</div>');
outputArea = getOutputImageArea(currentMixerPreset.imageOutputsNumbers, INPUT_STABILIZED_THROTTLE, false); outputArea = getOutputImageArea(currentMixerPreset.imageOutputsNumbers, INPUT_STABILIZED_THROTTLE, 0);
if (outputArea != null) { if (outputArea != null) {
$("#motorsPreview").css("top", outputArea.top + "px"); $("#motorsPreview").css("top", outputArea.top + "px");
$("#motorsPreview").css("left", outputArea.left + "px"); $("#motorsPreview").css("left", outputArea.left + "px");
@ -216,24 +216,35 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
} }
} }
function getOutputImageArea(outputImageAreas, input, secondSurface) { var lastRoll = -1;
var lastPitch = -1;
var lastYaw = -1;
function getOutputImageArea(outputImageAreas, input, surfacesSet) {
let returnArea = null; let returnArea = null;
let firstAileronFound = false;
let firstRuddervatorFound = false;
for (let area of outputImageAreas) { for (let area of outputImageAreas) {
if (area.input == input) { if (area.input == input) {
if ( input === INPUT_STABILIZED_THROTTLE if ( input === INPUT_STABILIZED_THROTTLE
|| (input === INPUT_STABILIZED_YAW && !secondSurface) || (surfacesSet > 0 &&
|| ((input === INPUT_STABILIZED_ROLL && !secondSurface) || (input === INPUT_STABILIZED_ROLL && secondSurface && firstAileronFound)) ((input === INPUT_STABILIZED_YAW && surfacesSet !== lastYaw)
|| ((input === INPUT_STABILIZED_PITCH && !secondSurface) || (input === INPUT_STABILIZED_PITCH && secondSurface && firstRuddervatorFound)) || (input === INPUT_STABILIZED_ROLL && surfacesSet !== lastRoll)
|| (input === INPUT_STABILIZED_PITCH && surfacesSet !== lastPitch))
)
) { ) {
returnArea = area; returnArea = area;
break; }
} else if (input === INPUT_STABILIZED_ROLL) {
firstAileronFound = true; if (input === INPUT_STABILIZED_ROLL) {
lastRoll = surfacesSet-1;
} else if (input === INPUT_STABILIZED_PITCH) { } else if (input === INPUT_STABILIZED_PITCH) {
firstRuddervatorFound = true; lastPitch = surfacesSet-1;
} else if (input === INPUT_STABILIZED_YAW) {
lastYaw = surfacesSet-1;
}
if (returnArea !== null) {
break;
} }
} }
} }