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

Allow reassignment of led pin to servos or motors

This commit is contained in:
Marcelo Bezerra 2024-05-11 23:47:19 +02:00
parent 71ac169df6
commit c98bf6e013
5 changed files with 21 additions and 7 deletions

View file

@ -17,7 +17,7 @@ var BitHelper = function() {
} }
self.bit_check = function (num, bit) { self.bit_check = function (num, bit) {
return ((num >> bit) % 2 != 0); return ((1 << bit) & num) != 0;
} }
self.bit_set = function (num, bit) { self.bit_set = function (num, bit) {

View file

@ -166,6 +166,7 @@ var MSPCodes = {
MSP2_INAV_MC_BRAKING: 0x200B, MSP2_INAV_MC_BRAKING: 0x200B,
MSP2_INAV_SET_MC_BRAKING: 0x200C, MSP2_INAV_SET_MC_BRAKING: 0x200C,
MSPV2_INAV_OUTPUT_MAPPING_EXT: 0x200D, MSPV2_INAV_OUTPUT_MAPPING_EXT: 0x200D,
MSPV2_INAV_OUTPUT_MAPPING_EXT2: 0x210D,
MSP2_INAV_TIMER_OUTPUT_MODE: 0x200E, MSP2_INAV_TIMER_OUTPUT_MODE: 0x200E,
MSP2_INAV_SET_TIMER_OUTPUT_MODE: 0x200F, MSP2_INAV_SET_TIMER_OUTPUT_MODE: 0x200F,

View file

@ -1423,6 +1423,7 @@ var mspHelper = (function () {
case MSPCodes.MSP2_INAV_SET_CUSTOM_OSD_ELEMENTS: case MSPCodes.MSP2_INAV_SET_CUSTOM_OSD_ELEMENTS:
console.log('OSD custom elements preferences saved'); console.log('OSD custom elements preferences saved');
break; break;
/*
case MSPCodes.MSPV2_INAV_OUTPUT_MAPPING: case MSPCodes.MSPV2_INAV_OUTPUT_MAPPING:
FC.OUTPUT_MAPPING.flush(); FC.OUTPUT_MAPPING.flush();
for (let i = 0; i < data.byteLength; ++i) for (let i = 0; i < data.byteLength; ++i)
@ -1430,11 +1431,12 @@ var mspHelper = (function () {
'timerId': i, 'timerId': i,
'usageFlags': data.getUint8(i)}); 'usageFlags': data.getUint8(i)});
break; break;
case MSPCodes.MSPV2_INAV_OUTPUT_MAPPING_EXT: */
case MSPCodes.MSPV2_INAV_OUTPUT_MAPPING_EXT2:
FC.OUTPUT_MAPPING.flush(); FC.OUTPUT_MAPPING.flush();
for (let i = 0; i < data.byteLength; i += 2) { for (let i = 0; i < data.byteLength; i += 5) {
let timerId = data.getUint8(i); let timerId = data.getUint8(i);
let usageFlags = data.getUint8(i + 1); let usageFlags = data.getUint32(i + 1, true);
FC.OUTPUT_MAPPING.put( FC.OUTPUT_MAPPING.put(
{ {
'timerId': timerId, 'timerId': timerId,
@ -2784,11 +2786,12 @@ var mspHelper = (function () {
}; };
self.loadOutputMapping = function (callback) { self.loadOutputMapping = function (callback) {
alert('Obsolete MSPHelper.loadOutputMapping call');
MSP.send_message(MSPCodes.MSPV2_INAV_OUTPUT_MAPPING, false, false, callback); MSP.send_message(MSPCodes.MSPV2_INAV_OUTPUT_MAPPING, false, false, callback);
}; };
self.loadOutputMappingExt = function (callback) { self.loadOutputMappingExt = function (callback) {
MSP.send_message(MSPCodes.MSPV2_INAV_OUTPUT_MAPPING_EXT, false, false, callback); MSP.send_message(MSPCodes.MSPV2_INAV_OUTPUT_MAPPING_EXT2, false, false, callback);
}; };
self.loadTimerOutputModes = function(callback) { self.loadTimerOutputModes = function(callback) {

View file

@ -30,6 +30,7 @@ var OutputMappingCollection = function () {
const OUTPUT_TYPE_MOTOR = 0; const OUTPUT_TYPE_MOTOR = 0;
const OUTPUT_TYPE_SERVO = 1; const OUTPUT_TYPE_SERVO = 1;
const OUTPUT_TYPE_LED = 2;
self.TIMER_OUTPUT_MODE_AUTO = 0; self.TIMER_OUTPUT_MODE_AUTO = 0;
self.TIMER_OUTPUT_MODE_MOTORS = 1; self.TIMER_OUTPUT_MODE_MOTORS = 1;
@ -98,6 +99,7 @@ var OutputMappingCollection = function () {
outputMap = [], outputMap = [],
offset = getFirstOutputOffset(); offset = getFirstOutputOffset();
for (let i = 0; i < self.getOutputCount(); i++) { for (let i = 0; i < self.getOutputCount(); i++) {
let assignment = timerMap[i + offset]; let assignment = timerMap[i + offset];
@ -110,6 +112,8 @@ var OutputMappingCollection = function () {
} else if (assignment == OUTPUT_TYPE_SERVO) { } else if (assignment == OUTPUT_TYPE_SERVO) {
outputMap[i] = "Servo " + servos[currentServoIndex]; outputMap[i] = "Servo " + servos[currentServoIndex];
currentServoIndex++; currentServoIndex++;
} else if (assignment == OUTPUT_TYPE_LED) {
outputMap[i] = "Led";
} }
} }
@ -126,12 +130,17 @@ var OutputMappingCollection = function () {
self.getOutputCount = function () { self.getOutputCount = function () {
let retVal = 0; let retVal = 0;
let testFlag = 1 << TIM_USE_LED;
testFlag = testFlag + 1;
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
let flags = data[i]['usageFlags'];
if ( if (
BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_MOTOR) || BitHelper.bit_check(flags, TIM_USE_MOTOR) ||
BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_SERVO) BitHelper.bit_check(flags, TIM_USE_SERVO) ||
BitHelper.bit_check(flags, TIM_USE_LED)
) { ) {
//alert("Found motor, servo or led");
retVal++; retVal++;
}; };
} }

View file

@ -129,6 +129,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
'<option value=' + FC.OUTPUT_MAPPING.TIMER_OUTPUT_MODE_AUTO + '' + (usageMode == FC.OUTPUT_MAPPING.TIMER_OUTPUT_MODE_AUTO ? ' selected' : '')+ '>AUTO</option>'+ '<option value=' + FC.OUTPUT_MAPPING.TIMER_OUTPUT_MODE_AUTO + '' + (usageMode == FC.OUTPUT_MAPPING.TIMER_OUTPUT_MODE_AUTO ? ' selected' : '')+ '>AUTO</option>'+
'<option value=' + FC.OUTPUT_MAPPING.TIMER_OUTPUT_MODE_MOTORS + '' + (usageMode == FC.OUTPUT_MAPPING.TIMER_OUTPUT_MODE_MOTORS ? ' selected' : '')+ '>MOTORS</option>'+ '<option value=' + FC.OUTPUT_MAPPING.TIMER_OUTPUT_MODE_MOTORS + '' + (usageMode == FC.OUTPUT_MAPPING.TIMER_OUTPUT_MODE_MOTORS ? ' selected' : '')+ '>MOTORS</option>'+
'<option value=' + FC.OUTPUT_MAPPING.TIMER_OUTPUT_MODE_SERVOS + '' + (usageMode == FC.OUTPUT_MAPPING.TIMER_OUTPUT_MODE_SERVOS ? ' selected' : '')+ '>SERVOS</option>'+ '<option value=' + FC.OUTPUT_MAPPING.TIMER_OUTPUT_MODE_SERVOS + '' + (usageMode == FC.OUTPUT_MAPPING.TIMER_OUTPUT_MODE_SERVOS ? ' selected' : '')+ '>SERVOS</option>'+
'<option value=' + FC.OUTPUT_MAPPING.TIMER_OUTPUT_MODE_LED + '' + (usageMode == FC.OUTPUT_MAPPING.TIMER_OUTPUT_MODE_LED ? ' selected' : '')+ '>LED</option>'+
'</select>' + '</select>' +
'<label for="timer-output-' + t + '">' + '<label for="timer-output-' + t + '">' +
'<span> Timer ' + (parseInt(t) + 1) + '</span>' + '<span> Timer ' + (parseInt(t) + 1) + '</span>' +