mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-23 16:25:19 +03:00
Servo output in Servo tab
This commit is contained in:
parent
3b4c4f00cc
commit
f5e60cc40e
7 changed files with 115 additions and 8 deletions
|
@ -1226,6 +1226,9 @@
|
||||||
"servosReverse": {
|
"servosReverse": {
|
||||||
"message": "Reverse"
|
"message": "Reverse"
|
||||||
},
|
},
|
||||||
|
"servoOutput": {
|
||||||
|
"message": "Output"
|
||||||
|
},
|
||||||
"servosRate": {
|
"servosRate": {
|
||||||
"message": "Rate (%)"
|
"message": "Rate (%)"
|
||||||
},
|
},
|
||||||
|
|
|
@ -84,6 +84,7 @@ sources.js = [
|
||||||
'./js/serial.js',
|
'./js/serial.js',
|
||||||
'./js/servoMixRule.js',
|
'./js/servoMixRule.js',
|
||||||
'./js/motorMixRule.js',
|
'./js/motorMixRule.js',
|
||||||
|
'./js/outputMapping.js',
|
||||||
'./js/model.js',
|
'./js/model.js',
|
||||||
'./js/serial_backend.js',
|
'./js/serial_backend.js',
|
||||||
'./js/data_storage.js',
|
'./js/data_storage.js',
|
||||||
|
|
2
js/fc.js
2
js/fc.js
|
@ -495,7 +495,7 @@ var FC = {
|
||||||
|
|
||||||
RXFAIL_CONFIG = [];
|
RXFAIL_CONFIG = [];
|
||||||
|
|
||||||
OUTPUT_MAPPING = [];
|
OUTPUT_MAPPING = new OutputMappingCollection();
|
||||||
},
|
},
|
||||||
getOutputUsages: function() {
|
getOutputUsages: function() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -1339,9 +1339,9 @@ var mspHelper = (function (gui) {
|
||||||
console.log('OSD preferences saved');
|
console.log('OSD preferences saved');
|
||||||
break;
|
break;
|
||||||
case MSPCodes.MSPV2_INAV_OUTPUT_MAPPING:
|
case MSPCodes.MSPV2_INAV_OUTPUT_MAPPING:
|
||||||
OUTPUT_MAPPING = [];
|
OUTPUT_MAPPING.flush();
|
||||||
for (i = 0; i < data.byteLength; ++i)
|
for (i = 0; i < data.byteLength; ++i)
|
||||||
OUTPUT_MAPPING.push(data.getUint8(i));
|
OUTPUT_MAPPING.put(data.getUint8(i));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log('Unknown code detected: ' + dataHandler.code);
|
console.log('Unknown code detected: ' + dataHandler.code);
|
||||||
|
@ -2546,7 +2546,7 @@ var mspHelper = (function (gui) {
|
||||||
if (semver.gte(CONFIG.flightControllerVersion, '2.0.0'))
|
if (semver.gte(CONFIG.flightControllerVersion, '2.0.0'))
|
||||||
MSP.send_message(MSPCodes.MSPV2_INAV_OUTPUT_MAPPING, false, false, callback);
|
MSP.send_message(MSPCodes.MSPV2_INAV_OUTPUT_MAPPING, false, false, callback);
|
||||||
else {
|
else {
|
||||||
OUTPUT_MAPPING = [];
|
OUTPUT_MAPPING.flush();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
77
js/outputMapping.js
Normal file
77
js/outputMapping.js
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
/*global bit_check*/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
let OutputMappingCollection = function () {
|
||||||
|
let self = {},
|
||||||
|
data = [];
|
||||||
|
|
||||||
|
const TIM_USE_ANY = 0;
|
||||||
|
const TIM_USE_PPM = 0;
|
||||||
|
const TIM_USE_PWM = 1;
|
||||||
|
const TIM_USE_MC_MOTOR = 2; // Multicopter motor output
|
||||||
|
const TIM_USE_MC_SERVO = 3; // Multicopter servo output (i.e. TRI)
|
||||||
|
const TIM_USE_MC_CHNFW = 4; // Deprecated and not used after removal of CHANNEL_FORWARDING feature
|
||||||
|
const TIM_USE_FW_MOTOR = 5;
|
||||||
|
const TIM_USE_FW_SERVO = 6;
|
||||||
|
const TIM_USE_LED = 24;
|
||||||
|
const TIM_USE_BEEPER = 25;
|
||||||
|
|
||||||
|
self.flush = function () {
|
||||||
|
data = [];
|
||||||
|
};
|
||||||
|
|
||||||
|
self.put = function (element) {
|
||||||
|
data.push(element);
|
||||||
|
};
|
||||||
|
|
||||||
|
function getFirstOutputOffset() {
|
||||||
|
for (let i = 0; i < data.length; i++) {
|
||||||
|
if (
|
||||||
|
bit_check(data[i], TIM_USE_MC_MOTOR) ||
|
||||||
|
bit_check(data[i], TIM_USE_MC_SERVO) ||
|
||||||
|
bit_check(data[i], TIM_USE_FW_MOTOR) ||
|
||||||
|
bit_check(data[i], TIM_USE_FW_SERVO)
|
||||||
|
) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOutput(servoIndex, bit) {
|
||||||
|
|
||||||
|
let offset = getFirstOutputOffset();
|
||||||
|
|
||||||
|
let lastFound = 0;
|
||||||
|
|
||||||
|
for (let i = offset; i < data.length; i++) {
|
||||||
|
if (bit_check(data[i], bit)) {
|
||||||
|
if (lastFound == servoIndex) {
|
||||||
|
return i - offset + 1;
|
||||||
|
} else {
|
||||||
|
lastFound++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.getFwServoOutput = function (servoIndex) {
|
||||||
|
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) {
|
||||||
|
return getOutput(index, TIM_USE_MC_SERVO);
|
||||||
|
};
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
/*global $, ServoMixRule*/
|
/*global ServoMixRule*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var ServoMixerRuleCollection = function () {
|
var ServoMixerRuleCollection = function () {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*global fc,mspHelper,TABS*/
|
/*global $,fc,mspHelper,TABS*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
TABS.servos = {};
|
TABS.servos = {};
|
||||||
|
@ -14,6 +14,8 @@ TABS.servos.initialize = function (callback) {
|
||||||
loadChainer.setChain([
|
loadChainer.setChain([
|
||||||
mspHelper.loadServoMixRules,
|
mspHelper.loadServoMixRules,
|
||||||
mspHelper.loadServoConfiguration,
|
mspHelper.loadServoConfiguration,
|
||||||
|
mspHelper.loadOutputMapping,
|
||||||
|
mspHelper.loadMixerConfig,
|
||||||
mspHelper.loadRcData,
|
mspHelper.loadRcData,
|
||||||
mspHelper.loadBfConfig,
|
mspHelper.loadBfConfig,
|
||||||
]);
|
]);
|
||||||
|
@ -74,6 +76,7 @@ TABS.servos.initialize = function (callback) {
|
||||||
<th data-i18n="servosMax"></th>\
|
<th data-i18n="servosMax"></th>\
|
||||||
<th data-i18n="servosRate"></th>\
|
<th data-i18n="servosRate"></th>\
|
||||||
<th data-i18n="servosReverse"></th>\
|
<th data-i18n="servosReverse"></th>\
|
||||||
|
<th data-i18n="servoOutput"></th>\
|
||||||
');
|
');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,9 +121,30 @@ TABS.servos.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
$currentRow.append('<td class="text-center output"></td>');
|
||||||
|
|
||||||
|
let output,
|
||||||
|
outputString;
|
||||||
|
|
||||||
|
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) {
|
||||||
|
outputString = "-";
|
||||||
|
} else {
|
||||||
|
outputString = "S" + output;
|
||||||
|
}
|
||||||
|
|
||||||
|
$currentRow.find('.output').html(outputString);
|
||||||
//For 2.0 and above hide a row when servo is not configured
|
//For 2.0 and above hide a row when servo is not configured
|
||||||
if (!SERVO_RULES.isServoConfigured(obj)) {
|
if (!SERVO_RULES.isServoConfigured(obj)) {
|
||||||
$servoConfigTable.find('tr:last').hide();
|
$currentRow.hide();
|
||||||
|
} else {
|
||||||
|
usedServoIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,8 +178,10 @@ TABS.servos.initialize = function (callback) {
|
||||||
// drop previous table
|
// drop previous table
|
||||||
$servoConfigTable.find('tr:not(:first)').remove();
|
$servoConfigTable.find('tr:not(:first)').remove();
|
||||||
|
|
||||||
|
let usedServoIndex = 0;
|
||||||
|
|
||||||
for (let servoIndex = 0; servoIndex < 8; servoIndex++) {
|
for (let servoIndex = 0; servoIndex < 8; servoIndex++) {
|
||||||
process_servos('Servo ' + servoIndex, '', servoIndex, false);
|
process_servos('Servo ' + servoIndex, '', servoIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI hooks for dynamically generated elements
|
// UI hooks for dynamically generated elements
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue