mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-14 20:10:11 +03:00
fix mixer_profie configurator issue
This commit is contained in:
parent
0435eb732b
commit
c41129b156
6 changed files with 75 additions and 14 deletions
|
@ -4397,6 +4397,9 @@
|
|||
"no_waypoints_to_save": {
|
||||
"message": "No waypoints to save !"
|
||||
},
|
||||
"mixerThrottleWarning": {
|
||||
"message": "Warning:value beyond normal operation range."
|
||||
},
|
||||
"servoMixer": {
|
||||
"message": "Servo mixer"
|
||||
},
|
||||
|
|
|
@ -6,7 +6,7 @@ var MotorMixRule = function (throttle, roll, pitch, yaw) {
|
|||
var self = {};
|
||||
|
||||
self.fromMsp = function (mspThrottle, mspRoll, mspPitch, mspYaw) {
|
||||
throttle = mspThrottle / 1000;
|
||||
throttle = Math.round(((mspThrottle / 1000) - 2) * 1000) / 1000;
|
||||
roll = Math.round(((mspRoll / 1000) - 2) * 1000) / 1000;
|
||||
pitch = Math.round(((mspPitch / 1000) - 2) * 1000) / 1000;
|
||||
yaw = Math.round(((mspYaw / 1000) - 2) * 1000) / 1000;
|
||||
|
@ -17,11 +17,11 @@ var MotorMixRule = function (throttle, roll, pitch, yaw) {
|
|||
};
|
||||
|
||||
self.getThrottle = function () {
|
||||
return constrain(parseFloat(throttle, 10), 0, 1);
|
||||
return constrain(parseFloat(throttle, 10), -2, 2);
|
||||
};
|
||||
|
||||
self.getThrottleForMsp = function () {
|
||||
return self.getThrottle() * 1000;
|
||||
return (self.getThrottle()+2) * 1000;
|
||||
};
|
||||
|
||||
self.setThrottle = function (data) {
|
||||
|
|
|
@ -5,6 +5,7 @@ var MotorMixerRuleCollection = function () {
|
|||
|
||||
let self = {},
|
||||
data = [],
|
||||
inactiveData = [],
|
||||
maxMotorCount = 8;
|
||||
|
||||
self.setMotorCount = function (value) {
|
||||
|
@ -16,7 +17,11 @@ var MotorMixerRuleCollection = function () {
|
|||
};
|
||||
|
||||
self.put = function (element) {
|
||||
data.push(element);
|
||||
if (data.length < self.getMotorCount()){
|
||||
data.push(element);
|
||||
}else{
|
||||
inactiveData.push(element); //store the data for mixer_profile 2
|
||||
}
|
||||
};
|
||||
|
||||
self.get = function () {
|
||||
|
@ -30,18 +35,25 @@ var MotorMixerRuleCollection = function () {
|
|||
|
||||
self.flush = function () {
|
||||
data = [];
|
||||
inactiveData = [];
|
||||
};
|
||||
|
||||
self.cleanup = function () {
|
||||
var tmpData = [];
|
||||
var tmpInactiveData = [];
|
||||
|
||||
data.forEach(function (element) {
|
||||
if (element.isUsed()) {
|
||||
tmpData.push(element);
|
||||
}
|
||||
});
|
||||
|
||||
inactiveData.forEach(function (element) {
|
||||
if (element.isUsed()) {
|
||||
tmpInactiveData.push(element);
|
||||
}
|
||||
});
|
||||
data = tmpData;
|
||||
inactiveData = tmpInactiveData;
|
||||
};
|
||||
|
||||
self.inflate = function () {
|
||||
|
@ -55,7 +67,7 @@ var MotorMixerRuleCollection = function () {
|
|||
};
|
||||
|
||||
self.getNumberOfConfiguredMotors = function () {
|
||||
return data.length;
|
||||
return data.length > inactiveData.length ? data.length : inactiveData.length;
|
||||
};
|
||||
|
||||
return self;
|
||||
|
|
|
@ -1454,7 +1454,7 @@ var mspHelper = (function (gui) {
|
|||
case MSPCodes.MSP2_INAV_MIXER:
|
||||
MIXER_CONFIG.yawMotorDirection = data.getInt8(0);
|
||||
MIXER_CONFIG.yawJumpPreventionLimit = data.getUint8(1, true);
|
||||
MIXER_CONFIG.motorStopOnLow = data.getUint8(2, true);
|
||||
MIXER_CONFIG.motorStopOnLow = data.getUint8(1, true);
|
||||
MIXER_CONFIG.platformType = data.getInt8(3);
|
||||
MIXER_CONFIG.hasFlaps = data.getInt8(4);
|
||||
MIXER_CONFIG.appliedMixerPreset = data.getInt16(5, true);
|
||||
|
|
|
@ -5,6 +5,7 @@ let ServoMixerRuleCollection = function () {
|
|||
|
||||
let self = {},
|
||||
data = [],
|
||||
inactiveData = [],
|
||||
maxServoCount = 16;
|
||||
|
||||
self.setServoCount = function (value) {
|
||||
|
@ -20,7 +21,11 @@ let ServoMixerRuleCollection = function () {
|
|||
}
|
||||
|
||||
self.put = function (element) {
|
||||
data.push(element);
|
||||
if (data.length < self.getServoRulesCount()) {
|
||||
data.push(element);
|
||||
}else{
|
||||
inactiveData.push(element); //store the data for mixer_profile 2
|
||||
}
|
||||
};
|
||||
|
||||
self.get = function () {
|
||||
|
@ -34,18 +39,24 @@ let ServoMixerRuleCollection = function () {
|
|||
|
||||
self.flush = function () {
|
||||
data = [];
|
||||
inactiveData = [];
|
||||
};
|
||||
|
||||
self.cleanup = function () {
|
||||
var tmpData = [];
|
||||
|
||||
var tmpInactiveData = [];
|
||||
data.forEach(function (element) {
|
||||
if (element.isUsed()) {
|
||||
tmpData.push(element);
|
||||
}
|
||||
});
|
||||
|
||||
inactiveData.forEach(function (element) {
|
||||
if (element.isUsed()) {
|
||||
tmpInactiveData.push(element);
|
||||
}
|
||||
});
|
||||
data = tmpData;
|
||||
inactiveData = tmpInactiveData;
|
||||
};
|
||||
|
||||
self.inflate = function () {
|
||||
|
@ -69,6 +80,15 @@ let ServoMixerRuleCollection = function () {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (let ruleIndex in inactiveData) {
|
||||
if (inactiveData.hasOwnProperty(ruleIndex)) {
|
||||
let rule = inactiveData[ruleIndex];
|
||||
|
||||
if (rule.getTarget() == servoId && rule.isUsed()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
|
@ -106,6 +126,12 @@ let ServoMixerRuleCollection = function () {
|
|||
out.push(rule.getTarget());
|
||||
}
|
||||
}
|
||||
for (let ruleIndex in inactiveData) {
|
||||
if (inactiveData.hasOwnProperty(ruleIndex)) {
|
||||
let rule = inactiveData[ruleIndex];
|
||||
out.push(rule.getTarget());
|
||||
}
|
||||
}
|
||||
|
||||
let unique = [...new Set(out)];
|
||||
|
||||
|
|
|
@ -435,7 +435,10 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
|
|||
$motorMixTableBody.append('\
|
||||
<tr>\
|
||||
<td><span class="mix-rule-motor"></span></td>\
|
||||
<td><input type="number" class="mix-rule-throttle" step="0.001" min="0" max="1" /></td>\
|
||||
<td>\
|
||||
<input type="number" class="mix-rule-throttle" step="0.001" min="-2" max="2" />\
|
||||
<div class="throttle-warning-text" data-i18n="mixerThrottleWarning" ></div>\
|
||||
</td>\
|
||||
<td><input type="number" class="mix-rule-roll" step="0.001" min="-2" max="2" /></td>\
|
||||
<td><input type="number" class="mix-rule-pitch" step="0.001" min="-2" max="2" /></td>\
|
||||
<td><input type="number" class="mix-rule-yaw" step="0.001" min="-2" max="2" /></td>\
|
||||
|
@ -446,9 +449,26 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
|
|||
const $row = $motorMixTableBody.find('tr:last');
|
||||
|
||||
$row.find('.mix-rule-motor').html(index);
|
||||
$row.find('.mix-rule-throttle').val(rule.getThrottle()).change(function () {
|
||||
rule.setThrottle($(this).val());
|
||||
});
|
||||
const $throttleInput = $row.find('.mix-rule-throttle').val(rule.getThrottle());
|
||||
const $warningBox = $row.find('.throttle-warning-text');
|
||||
|
||||
// Function to update throttle and show/hide warning box
|
||||
function updateThrottle() {
|
||||
rule.setThrottle($throttleInput.val());
|
||||
// Change color if value exceeds 1
|
||||
if (parseFloat($throttleInput.val()) > 1 || parseFloat($throttleInput.val()) < 0) {
|
||||
$throttleInput.css('background-color', 'orange');
|
||||
// Show warning box
|
||||
$warningBox.show();
|
||||
} else {
|
||||
$throttleInput.css('background-color', ''); // Reset to default
|
||||
// Hide warning box
|
||||
$warningBox.hide();
|
||||
}
|
||||
}
|
||||
updateThrottle();
|
||||
$throttleInput.change(updateThrottle);
|
||||
|
||||
$row.find('.mix-rule-roll').val(rule.getRoll()).change(function () {
|
||||
rule.setRoll($(this).val());
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue