Merge pull request #810 from iNavFlight/dzikuvx-alternative-output-allocation-preview

Output allocation method that is more aligned with FC counterpart
pull/812/head
Paweł Spychalski 5 years ago committed by GitHub
commit 6b06d431fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,6 +16,66 @@ let OutputMappingCollection = function () {
const TIM_USE_LED = 24; const TIM_USE_LED = 24;
const TIM_USE_BEEPER = 25; const TIM_USE_BEEPER = 25;
const OUTPUT_TYPE_MOTOR = 0;
const OUTPUT_TYPE_SERVO = 1;
function getTimerMap(isMR, motors, servos) {
let timerMap = [],
motorsToGo = motors,
servosToGo = servos;
for (let i = 0; i < data.length; i++) {
timerMap[i] = null;
if (isMR) {
if (servosToGo > 0 && bit_check(data[i], TIM_USE_MC_SERVO)) {
servosToGo--;
timerMap[i] = OUTPUT_TYPE_SERVO;
} else if (motorsToGo > 0 && bit_check(data[i], TIM_USE_MC_MOTOR)) {
motorsToGo--;
timerMap[i] = OUTPUT_TYPE_MOTOR;
}
} else {
if (servosToGo > 0 && bit_check(data[i], TIM_USE_FW_SERVO)) {
servosToGo--;
timerMap[i] = OUTPUT_TYPE_SERVO;
} else if (motorsToGo > 0 && bit_check(data[i], TIM_USE_FW_MOTOR)) {
motorsToGo--;
timerMap[i] = OUTPUT_TYPE_MOTOR;
}
}
}
return timerMap;
};
self.getOutputTable = function (isMR, motors, servos) {
let currentMotorIndex = 1,
currentServoIndex = 0,
timerMap = getTimerMap(isMR, motors, servos),
outputMap = [],
offset = getFirstOutputOffset();
for (let i = 0; i < self.getOutputCount(); i++) {
let assignment = timerMap[i + offset];
if (assignment === null) {
outputMap[i] = "-";
} else if (assignment == OUTPUT_TYPE_MOTOR) {
outputMap[i] = "Motor " + currentMotorIndex;
currentMotorIndex++;
} else if (assignment == OUTPUT_TYPE_SERVO) {
outputMap[i] = "Servo " + currentServoIndex;
currentServoIndex++;
}
}
return outputMap;
};
self.flush = function () { self.flush = function () {
data = []; data = [];
}; };
@ -78,14 +138,6 @@ let OutputMappingCollection = function () {
return getOutput(servoIndex, TIM_USE_FW_SERVO); return getOutput(servoIndex, TIM_USE_FW_SERVO);
}; };
self.getFwMotorOutput = function (index) {
return getOutput(index, TIM_USE_FW_MOTOR);
};
self.getMrMotorOutput = function (index) {
return getOutput(index, TIM_USE_MC_MOTOR);
};
self.getMrServoOutput = function (index) { self.getMrServoOutput = function (index) {
return getOutput(index, TIM_USE_MC_SERVO); return getOutput(index, TIM_USE_MC_SERVO);
}; };

@ -70,7 +70,17 @@ let ServoMixerRuleCollection = function () {
} }
} }
return false; return false;
} };
self.getNumberOfConfiguredServos = function () {
let count = 0;
for (let i = 0; i < self.getServoCount(); i ++) {
if (self.isServoConfigured(i)) {
count++;
}
}
return count;
};
return self; return self;
}; };

@ -75,36 +75,14 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
} }
function renderOutputMapping() { function renderOutputMapping() {
let motorRules = MOTOR_RULES.get(), let outputMap = OUTPUT_MAPPING.getOutputTable(
servoRules = SERVO_RULES.get(), MIXER_CONFIG.platformType == PLATFORM_MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM_TRICOPTER,
output; MOTOR_RULES.getNumberOfConfiguredMotors(),
SERVO_RULES.getNumberOfConfiguredServos()
for (var index = 0; index < motorRules.length; index++) { );
if (motorRules[index].isUsed()) {
if (MIXER_CONFIG.platformType == PLATFORM_MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM_TRICOPTER) { for (let i = 1; i <= OUTPUT_MAPPING.getOutputCount(); i++) {
output = OUTPUT_MAPPING.getMrMotorOutput(index); $('#function-' + i).html(outputMap[i - 1]);
} else {
output = OUTPUT_MAPPING.getFwMotorOutput(index);
}
if (output !== null) {
$('#function-' + output).html("Motor " + (index + 1));
}
}
}
let usedServoIndex = 0;
for (let i = 0; i < MIXER_CONFIG.numberOfServos; i++) {
if (SERVO_RULES.isServoConfigured(i)) {
if (MIXER_CONFIG.platformType == PLATFORM_MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM_TRICOPTER) {
output = OUTPUT_MAPPING.getMrServoOutput(usedServoIndex);
} else {
output = OUTPUT_MAPPING.getFwServoOutput(usedServoIndex);
}
if (output !== null) {
$('#function-' + output).html("Servo " + i);
}
usedServoIndex++;
}
} }
} }

Loading…
Cancel
Save