1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-14 03:49:53 +03:00

fix mixer_profie configurator issue

This commit is contained in:
shota 2023-10-12 22:33:49 +09:00
parent 0435eb732b
commit c41129b156
6 changed files with 75 additions and 14 deletions

View file

@ -4397,6 +4397,9 @@
"no_waypoints_to_save": { "no_waypoints_to_save": {
"message": "No waypoints to save !" "message": "No waypoints to save !"
}, },
"mixerThrottleWarning": {
"message": "Warning:value beyond normal operation range."
},
"servoMixer": { "servoMixer": {
"message": "Servo mixer" "message": "Servo mixer"
}, },

View file

@ -6,7 +6,7 @@ var MotorMixRule = function (throttle, roll, pitch, yaw) {
var self = {}; var self = {};
self.fromMsp = function (mspThrottle, mspRoll, mspPitch, mspYaw) { 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; roll = Math.round(((mspRoll / 1000) - 2) * 1000) / 1000;
pitch = Math.round(((mspPitch / 1000) - 2) * 1000) / 1000; pitch = Math.round(((mspPitch / 1000) - 2) * 1000) / 1000;
yaw = Math.round(((mspYaw / 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 () { self.getThrottle = function () {
return constrain(parseFloat(throttle, 10), 0, 1); return constrain(parseFloat(throttle, 10), -2, 2);
}; };
self.getThrottleForMsp = function () { self.getThrottleForMsp = function () {
return self.getThrottle() * 1000; return (self.getThrottle()+2) * 1000;
}; };
self.setThrottle = function (data) { self.setThrottle = function (data) {

View file

@ -5,6 +5,7 @@ var MotorMixerRuleCollection = function () {
let self = {}, let self = {},
data = [], data = [],
inactiveData = [],
maxMotorCount = 8; maxMotorCount = 8;
self.setMotorCount = function (value) { self.setMotorCount = function (value) {
@ -16,7 +17,11 @@ var MotorMixerRuleCollection = function () {
}; };
self.put = function (element) { 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 () { self.get = function () {
@ -30,18 +35,25 @@ var MotorMixerRuleCollection = function () {
self.flush = function () { self.flush = function () {
data = []; data = [];
inactiveData = [];
}; };
self.cleanup = function () { self.cleanup = function () {
var tmpData = []; var tmpData = [];
var tmpInactiveData = [];
data.forEach(function (element) { data.forEach(function (element) {
if (element.isUsed()) { if (element.isUsed()) {
tmpData.push(element); tmpData.push(element);
} }
}); });
inactiveData.forEach(function (element) {
if (element.isUsed()) {
tmpInactiveData.push(element);
}
});
data = tmpData; data = tmpData;
inactiveData = tmpInactiveData;
}; };
self.inflate = function () { self.inflate = function () {
@ -55,7 +67,7 @@ var MotorMixerRuleCollection = function () {
}; };
self.getNumberOfConfiguredMotors = function () { self.getNumberOfConfiguredMotors = function () {
return data.length; return data.length > inactiveData.length ? data.length : inactiveData.length;
}; };
return self; return self;

View file

@ -1454,7 +1454,7 @@ var mspHelper = (function (gui) {
case MSPCodes.MSP2_INAV_MIXER: case MSPCodes.MSP2_INAV_MIXER:
MIXER_CONFIG.yawMotorDirection = data.getInt8(0); MIXER_CONFIG.yawMotorDirection = data.getInt8(0);
MIXER_CONFIG.yawJumpPreventionLimit = data.getUint8(1, true); 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.platformType = data.getInt8(3);
MIXER_CONFIG.hasFlaps = data.getInt8(4); MIXER_CONFIG.hasFlaps = data.getInt8(4);
MIXER_CONFIG.appliedMixerPreset = data.getInt16(5, true); MIXER_CONFIG.appliedMixerPreset = data.getInt16(5, true);

View file

@ -5,6 +5,7 @@ let ServoMixerRuleCollection = function () {
let self = {}, let self = {},
data = [], data = [],
inactiveData = [],
maxServoCount = 16; maxServoCount = 16;
self.setServoCount = function (value) { self.setServoCount = function (value) {
@ -20,7 +21,11 @@ let ServoMixerRuleCollection = function () {
} }
self.put = function (element) { 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 () { self.get = function () {
@ -34,18 +39,24 @@ let ServoMixerRuleCollection = function () {
self.flush = function () { self.flush = function () {
data = []; data = [];
inactiveData = [];
}; };
self.cleanup = function () { self.cleanup = function () {
var tmpData = []; var tmpData = [];
var tmpInactiveData = [];
data.forEach(function (element) { data.forEach(function (element) {
if (element.isUsed()) { if (element.isUsed()) {
tmpData.push(element); tmpData.push(element);
} }
}); });
inactiveData.forEach(function (element) {
if (element.isUsed()) {
tmpInactiveData.push(element);
}
});
data = tmpData; data = tmpData;
inactiveData = tmpInactiveData;
}; };
self.inflate = function () { 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; return false;
}; };
@ -106,6 +126,12 @@ let ServoMixerRuleCollection = function () {
out.push(rule.getTarget()); 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)]; let unique = [...new Set(out)];

View file

@ -435,7 +435,10 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
$motorMixTableBody.append('\ $motorMixTableBody.append('\
<tr>\ <tr>\
<td><span class="mix-rule-motor"></span></td>\ <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-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-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>\ <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'); const $row = $motorMixTableBody.find('tr:last');
$row.find('.mix-rule-motor').html(index); $row.find('.mix-rule-motor').html(index);
$row.find('.mix-rule-throttle').val(rule.getThrottle()).change(function () { const $throttleInput = $row.find('.mix-rule-throttle').val(rule.getThrottle());
rule.setThrottle($(this).val()); 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 () { $row.find('.mix-rule-roll').val(rule.getRoll()).change(function () {
rule.setRoll($(this).val()); rule.setRoll($(this).val());
}); });