Skip to content

Commit

Permalink
Merge branch 'master' into wizard-gps-step
Browse files Browse the repository at this point in the history
  • Loading branch information
DzikuVx committed Jun 16, 2024
2 parents 497d0aa + 1887fe1 commit 5c7a6be
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 36 deletions.
20 changes: 10 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,6 @@ <h1 class="modal__title modal__title" data-i18n="appUpdateNotificationHeader"></
<div class="legend" i18n="sensorDataFlashFreeSpace"></div>
</li>
</ul>
<div id="mixer_profile_change">
<div class="dropdown dropdown-dark">
<form name="mixer-profile-change" id="mixer-profile-change">
<select class="dropdown-select" id="mixerprofilechange">
<option value="0" i18n="mixerProfile1"></option>
<option value="1" i18n="mixerProfile2"></option>
</select>
</form>
</div>
</div>
<div id="profile_change">
<div class="dropdown dropdown-dark">
<form name="profile-change" id="profile-change">
Expand All @@ -117,6 +107,16 @@ <h1 class="modal__title modal__title" data-i18n="appUpdateNotificationHeader"></
</form>
</div>
</div>
<div id="mixer_profile_change">
<div class="dropdown dropdown-dark">
<form name="mixer-profile-change" id="mixer-profile-change">
<select class="dropdown-select" id="mixerprofilechange">
<option value="0" i18n="mixerProfile1"></option>
<option value="1" i18n="mixerProfile2"></option>
</select>
</form>
</div>
</div>
<div id="battery_profile_change">
<div class="dropdown dropdown-dark">
<form name="battery-profile-change" id="battery-profile-change">
Expand Down
2 changes: 1 addition & 1 deletion js/bitHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var BitHelper = function() {
}

self.bit_check = function (num, bit) {
return ((num >> bit) % 2 != 0);
return ((1 << bit) & num) != 0;
}

self.bit_set = function (num, bit) {
Expand Down
9 changes: 5 additions & 4 deletions js/logicConditionOperantTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,16 @@ const OPERAND_TYPES = {
30: "CRSF SNR",
31: "GPS Valid Fix",
32: "Loiter Radius [cm]",
33: "Active PIDProfile",
33: "Active Control Profile",
34: "Battery cells",
35: "AGL status [0/1]",
36: "AGL [cm]",
37: "Rangefinder [cm]",
38: "Active MixerProfile",
39: "MixerTransition Active",
38: "Active Mixer Profile",
39: "Mixer Transition Active",
40: "Yaw [deg]",
41: "FW Land State"
41: "FW Land State",
42: "Active Battery Profile",
}
},
3: {
Expand Down
9 changes: 8 additions & 1 deletion js/logicConditionOperators.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,21 @@ const LOGIC_OPERATORS = {
output: "boolean"
},

39: {
name: "Set Heading Target",
operandType: "Set Flight Parameter",
hasOperand: [true, false],
output: "raw"
},

41: {
name: "Override Loiter Radius",
operandType: "Set Flight Parameter",
hasOperand: [true, false],
output: "boolean"
},
42: {
name: "Set Profile",
name: "Set Control Profile",
operandType: "Set Flight Parameter",
hasOperand: [true, false],
output: "boolean"
Expand Down
1 change: 1 addition & 0 deletions js/msp/MSPCodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ var MSPCodes = {
MSP2_INAV_MC_BRAKING: 0x200B,
MSP2_INAV_SET_MC_BRAKING: 0x200C,
MSPV2_INAV_OUTPUT_MAPPING_EXT: 0x200D,
MSPV2_INAV_OUTPUT_MAPPING_EXT2: 0x210D,
MSP2_INAV_TIMER_OUTPUT_MODE: 0x200E,
MSP2_INAV_SET_TIMER_OUTPUT_MODE: 0x200F,

Expand Down
17 changes: 11 additions & 6 deletions js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ var mspHelper = (function () {
console.log('Looptime saved');
break;
case MSPCodes.MSP_SET_RESET_CURR_PID:
console.log('Current PID profile reset');
console.log('Current Control profile reset');
break;
case MSPCodes.MSP_SET_3D:
console.log('3D settings saved');
Expand Down Expand Up @@ -1409,22 +1409,26 @@ var mspHelper = (function () {
case MSPCodes.MSP2_INAV_SET_CUSTOM_OSD_ELEMENTS:
console.log('OSD custom elements preferences saved');
break;
/*
case MSPCodes.MSPV2_INAV_OUTPUT_MAPPING:
FC.OUTPUT_MAPPING.flush();
for (let i = 0; i < data.byteLength; ++i)
FC.OUTPUT_MAPPING.put({
'timerId': i,
'usageFlags': data.getUint8(i)});
break;
case MSPCodes.MSPV2_INAV_OUTPUT_MAPPING_EXT:
*/
case MSPCodes.MSPV2_INAV_OUTPUT_MAPPING_EXT2:
FC.OUTPUT_MAPPING.flush();
for (let i = 0; i < data.byteLength; i += 2) {
for (let i = 0; i < data.byteLength; i += 6) {
let timerId = data.getUint8(i);
let usageFlags = data.getUint8(i + 1);
let usageFlags = data.getUint32(i + 1, true);
let specialLabels = data.getUint8(i + 5);
FC.OUTPUT_MAPPING.put(
{
'timerId': timerId,
'usageFlags': usageFlags
'usageFlags': usageFlags,
'specialLabels': specialLabels
});
}
break;
Expand Down Expand Up @@ -2771,11 +2775,12 @@ var mspHelper = (function () {
};

self.loadOutputMapping = function (callback) {
alert('Obsolete MSPHelper.loadOutputMapping call');
MSP.send_message(MSPCodes.MSPV2_INAV_OUTPUT_MAPPING, false, false, 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) {
Expand Down
27 changes: 23 additions & 4 deletions js/outputMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ var OutputMappingCollection = function () {

const OUTPUT_TYPE_MOTOR = 0;
const OUTPUT_TYPE_SERVO = 1;
const OUTPUT_TYPE_LED = 2;

const SPECIAL_LABEL_LED = 1;

self.TIMER_OUTPUT_MODE_AUTO = 0;
self.TIMER_OUTPUT_MODE_MOTORS = 1;
self.TIMER_OUTPUT_MODE_SERVOS = 2;
self.TIMER_OUTPUT_MODE_LED = 3;

self.flushTimerOverrides = function() {
timerOverrides = {};
Expand All @@ -53,6 +57,10 @@ var OutputMappingCollection = function () {
return colorTable[timerIndex % colorTable.length];
}

self.isLedPin = function(timer) {
return data[timer].specialLabels == SPECIAL_LABEL_LED;
}

self.getOutputTimerColor = function (output) {
let timerId = self.getTimerId(output);

Expand All @@ -79,10 +87,15 @@ var OutputMappingCollection = function () {
for (let i = 0; i < data.length; i++) {
timerMap[i] = null;

if (servosToGo > 0 && BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_SERVO)) {
if (servosToGo > 0 && BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_LED)) {
console.log(i + ": LED");
timerMap[i] = OUTPUT_TYPE_LED;
} else if (servosToGo > 0 && BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_SERVO)) {
console.log(i + ": SERVO");
servosToGo--;
timerMap[i] = OUTPUT_TYPE_SERVO;
} else if (motorsToGo > 0 && BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_MOTOR)) {
console.log(i + ": MOTOR");
motorsToGo--;
timerMap[i] = OUTPUT_TYPE_MOTOR;
}
Expand All @@ -98,6 +111,7 @@ var OutputMappingCollection = function () {
outputMap = [],
offset = getFirstOutputOffset();

console.log("Offset: " + offset)
for (let i = 0; i < self.getOutputCount(); i++) {

let assignment = timerMap[i + offset];
Expand All @@ -110,6 +124,8 @@ var OutputMappingCollection = function () {
} else if (assignment == OUTPUT_TYPE_SERVO) {
outputMap[i] = "Servo " + servos[currentServoIndex];
currentServoIndex++;
} else if (assignment == OUTPUT_TYPE_LED) {
outputMap[i] = "Led";
}
}

Expand All @@ -128,9 +144,11 @@ var OutputMappingCollection = function () {
let retVal = 0;

for (let i = 0; i < data.length; i++) {
let flags = data[i]['usageFlags'];
if (
BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_MOTOR) ||
BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_SERVO)
BitHelper.bit_check(flags, TIM_USE_MOTOR) ||
BitHelper.bit_check(flags, TIM_USE_SERVO) ||
BitHelper.bit_check(flags, TIM_USE_LED)
) {
retVal++;
};
Expand All @@ -143,7 +161,8 @@ var OutputMappingCollection = function () {
for (let i = 0; i < data.length; i++) {
if (
BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_MOTOR) ||
BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_SERVO)
BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_SERVO) ||
BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_LED)
) {
return i;
}
Expand Down
10 changes: 5 additions & 5 deletions locale/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -5132,10 +5132,10 @@
"message": "Enable if the motor direction is reversed and the props are mounted in the opposite direction."
},
"mixer_pid_profile_linking": {
"message": "PID Profile will use same index as Mixer Profile index"
"message": "Control Profile will use same index as Mixer Profile index"
},
"mixer_pid_profile_linking_hint": {
"message": "mixer_pid_profile_linking: Enable on both Mixer Profile if you want PID Profile switching handled by Mixer Profile switching(Recommend in vtol/mixed plaform type setup)"
"message": "mixer_pid_profile_linking: Enable on both Mixer Profile if you want Control Profile switching handled by Mixer Profile switching(Recommend in vtol/mixed plaform type setup)"
},
"blackboxFields": {
"message": "Blackbox fields"
Expand Down Expand Up @@ -5459,13 +5459,13 @@
"message": "Mixer Profile 2"
},
"sensorProfile1": {
"message": "PID Profile 1"
"message": "Control Profile 1"
},
"sensorProfile2": {
"message": "PID Profile 2"
"message": "Control Profile 2"
},
"sensorProfile3": {
"message": "PID Profile 3"
"message": "Control Profile 3"
},
"sensorBatteryProfile1": {
"message": "Battery Profile 1"
Expand Down
4 changes: 2 additions & 2 deletions src/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1700,7 +1700,7 @@ dialog {

}

#mixer_profile_change {
#profile_change {
color: white;
margin-top: 16px;
width: 130px;
Expand All @@ -1709,7 +1709,7 @@ dialog {
line-height: 12px;
}

#profile_change {
#mixer_profile_change {
color: white;
margin-top: 16px;
width: 130px;
Expand Down
6 changes: 4 additions & 2 deletions tabs/mixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ TABS.mixer.initialize = function (callback, scrollPosition) {

let timerId = FC.OUTPUT_MAPPING.getTimerId(i - 1);
let color = FC.OUTPUT_MAPPING.getOutputTimerColor(i - 1);
let isLed = FC.OUTPUT_MAPPING.isLedPin(i - 1);

$outputRow.append('<td style="background-color: ' + color + '">S' + i + ' (Timer ' + (timerId + 1) + ')</td>');
$outputRow.append('<td style="background-color: ' + color + '">S' + i + (isLed ? '/LED' : '') + ' (Timer&nbsp;' + (timerId + 1) + ')</td>');
$functionRow.append('<td id="function-' + i +'">-</td>');
}

Expand Down Expand Up @@ -131,6 +132,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_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_LED + '' + (usageMode == FC.OUTPUT_MAPPING.TIMER_OUTPUT_MODE_LED ? ' selected' : '')+ '>LED</option>'+
'</select>' +
'<label for="timer-output-' + t + '">' +
'<span> Timer ' + (parseInt(t) + 1) + '</span>' +
Expand Down Expand Up @@ -654,7 +656,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {

const updateMotorDirection = function () {
let motorDirectionCheckbox = $('input[name=motor_direction_inverted]:checked');
const isReversed = motorDirectionCheckbox.val() == 1 && (MIXER_CONFIG.platformType == PLATFORM_MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM_TRICOPTER);
const isReversed = motorDirectionCheckbox.val() == 1 && (FC.MIXER_CONFIG.platformType == PLATFORM.MULTIROTOR || FC.MIXER_CONFIG.platformType == PLATFORM.TRICOPTER);

const path = './resources/motor_order/'
+ currentMixerPreset.image + (isReversed ? "_reverse" : "") + '.svg';
Expand Down
2 changes: 1 addition & 1 deletion tabs/outputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ TABS.outputs.initialize = function (callback) {
mspHelper.loadServoMixRules,
mspHelper.loadMixerConfig,
mspHelper.loadServoConfiguration,
mspHelper.loadOutputMapping,
mspHelper.loadOutputMappingExt,
mspHelper.loadRcData,
mspHelper.loadAdvancedConfig,
function(callback) {
Expand Down

0 comments on commit 5c7a6be

Please sign in to comment.