Skip to content

Commit 37e41a0

Browse files
authored
Auto merged - #2563 at Wed, 01 Sep 2021 07:17:17 GMT
Change mixer
2 parents a2d0fa9 + 54820d4 commit 37e41a0

File tree

3 files changed

+35
-30
lines changed

3 files changed

+35
-30
lines changed

locales/en/messages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2559,7 +2559,7 @@
25592559
"message": "<strong>I understand the risks</strong>, the propellers are removed - enable motor control and arming, and disable Runaway Takeoff Prevention."
25602560
},
25612561
"motorsDialogMixerReset": {
2562-
"message": "<strong>Invalid mixer mode selected.</strong><br /><br />The {{mixerName}} model needs {{mixerMotors}} motor resources.<br /><br />If using a custom mixer mode you need to define a custom mmix before changing mixer mode. If you come back to the motor tab after setting a mmix for your mode it won't reset the mode anymore. Please see the wiki for more information how to set this up.<br /><br />You are not able to test any motors or fly because firmware has {{outputs}} outputs for the selected mode.<br /><br />Resetting to default mixer mode"
2562+
"message": "<strong>Mixer mode problem detected</strong><br /><br />The {{mixerName}} model needs <strong class=\"message-positive\">{{mixerMotors}}</strong> motor resources and the current configuration of the firmware provides <strong class=\"message-positive\">{{outputs}}</strong> usable output(s) for the selected mode.<br /><br />If using a custom mixer mode you need to define a custom mmix before changing mixer mode.<br /><br />Please check your configuration and add the required motor resources."
25632563
},
25642564
"motorsDialogSettingsChanged": {
25652565
"message": "Configuration changes have been detected.<br /><br /><strong class=\"message-negative-italic\">Motor Test Mode is disabled until the settings have seen saved.</strong>"

src/js/tabs/motors.js

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ TABS.motors.initialize = function (callback) {
330330
});
331331
}
332332

333+
sortElement('select.mixerList');
334+
333335
function refreshMixerPreview() {
334336
const mixer = FC.MIXER_CONFIG.mixer;
335337
const reverse = FC.MIXER_CONFIG.reverseMotorDir ? "_reversed" : "";
@@ -608,6 +610,12 @@ TABS.motors.initialize = function (callback) {
608610
neutral3d = (FC.MOTOR_3D_CONFIG.neutral > 1575 || FC.MOTOR_3D_CONFIG.neutral < 1425) ? 1500 : FC.MOTOR_3D_CONFIG.neutral;
609611
}
610612

613+
let zeroThrottleValue = rangeMin;
614+
615+
if (self.feature3DEnabled) {
616+
zeroThrottleValue = neutral3d;
617+
}
618+
611619
const motorsWrapper = $('.motors .bar-wrapper');
612620

613621
for (let i = 0; i < 8; i++) {
@@ -643,6 +651,8 @@ TABS.motors.initialize = function (callback) {
643651
escProtocolElement.append(`<option value="${j + 1}">${escProtocols[j]}</option>`);
644652
}
645653

654+
sortElement('select.escprotocol');
655+
646656
const unsyncedPWMSwitchElement = $("input[id='unsyncedPWMSwitch']");
647657
const divUnsyncedPWMFreq = $('div.unsyncedpwmfreq');
648658

@@ -743,7 +753,7 @@ TABS.motors.initialize = function (callback) {
743753
}
744754

745755
escProtocolElement.val(FC.PID_ADVANCED_CONFIG.fast_pwm_protocol + 1);
746-
console.log(FC.PID_ADVANCED_CONFIG.fast_pwm_protocol);
756+
747757
escProtocolElement.on("change", function () {
748758
const escProtocolValue = parseInt($(this).val()) - 1;
749759

@@ -818,11 +828,7 @@ TABS.motors.initialize = function (callback) {
818828

819829
function setSlidersDefault() {
820830
// change all values to default
821-
if (self.feature3DEnabled) {
822-
$('div.sliders input').val(neutral3d);
823-
} else {
824-
$('div.sliders input').val(rangeMin);
825-
}
831+
$('div.sliders input').val(zeroThrottleValue);
826832
}
827833

828834
function setSlidersEnabled(isEnabled) {
@@ -903,7 +909,7 @@ TABS.motors.initialize = function (callback) {
903909

904910
for (let i = 0; i < self.numberOfValidOutputs; i++) {
905911
if (!self.feature3DEnabled) {
906-
if (FC.MOTOR_DATA[i] > rangeMin) {
912+
if (FC.MOTOR_DATA[i] > zeroThrottleValue) {
907913
motorsRunning = true;
908914
}
909915
} else {
@@ -965,7 +971,7 @@ TABS.motors.initialize = function (callback) {
965971
const motorsTesting = motorsEnableTestModeElement.is(':checked');
966972

967973
for (let i = 0; i < self.numberOfValidOutputs; i++) {
968-
motorData[i] = motorsTesting ? FC.MOTOR_DATA[i] : rangeMin;
974+
motorData[i] = motorsTesting ? FC.MOTOR_DATA[i] : zeroThrottleValue;
969975
}
970976

971977
return motorData;
@@ -1034,7 +1040,7 @@ TABS.motors.initialize = function (callback) {
10341040
//keep the following here so at least we get a visual cue of our motor setup
10351041
update_arm_status();
10361042

1037-
if (previousArmState != self.armed) {
1043+
if (previousArmState !== self.armed) {
10381044
console.log('arm state change detected');
10391045

10401046
motorsEnableTestModeElement.change();
@@ -1083,12 +1089,6 @@ TABS.motors.initialize = function (callback) {
10831089
// enable Status and Motor data pulling
10841090
GUI.interval_add('motor_and_status_pull', get_status, 50, true);
10851091

1086-
let zeroThrottleValue = rangeMin;
1087-
1088-
if (self.feature3DEnabled) {
1089-
zeroThrottleValue = neutral3d;
1090-
}
1091-
10921092
setup_motor_output_reordering_dialog(SetupEscDshotDirectionDialogCallback, zeroThrottleValue);
10931093

10941094
function SetupEscDshotDirectionDialogCallback() {
@@ -1116,12 +1116,6 @@ TABS.motors.initialize = function (callback) {
11161116
dialogMixerReset.showModal();
11171117
$('#dialog-mixer-reset-confirmbtn').click(function() {
11181118
dialogMixerReset.close();
1119-
1120-
FC.MIXER_CONFIG.mixer = 3;
1121-
1122-
MSP.promise(MSPCodes.MSP_SET_MIXER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_MIXER_CONFIG))
1123-
.then(() => MSP.promise(MSPCodes.MSP_EEPROM_WRITE))
1124-
.then(() => reboot());
11251119
});
11261120
}
11271121
}

src/js/utils/common.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@ export function bytesToSize(bytes) {
3232

3333
export function checkChromeRuntimeError() {
3434
if (chrome.runtime.lastError) {
35-
console.error(
36-
`Chrome API Error: ${chrome.runtime.lastError.message}.\n Traced ${
37-
new Error().stack
38-
}`
39-
);
35+
console.error(`Chrome API Error: ${chrome.runtime.lastError.message}.\n Traced ${new Error().stack}`);
36+
4037
return true;
4138
}
4239
return false;
@@ -54,9 +51,7 @@ const majorFirmwareVersions = {
5451
};
5552

5653
export function generateVirtualApiVersions() {
57-
const firmwareVersionDropdown = document.getElementById(
58-
"firmware-version-dropdown"
59-
);
54+
const firmwareVersionDropdown = document.getElementById("firmware-version-dropdown");
6055
const max = semver.minor(CONFIGURATOR.API_VERSION_MAX_SUPPORTED);
6156

6257
for (let i = max; i > 0; i--) {
@@ -94,10 +89,26 @@ export function getTextWidth(text) {
9489
return Math.ceil(context.measureText(text).width);
9590
}
9691

92+
export function sortElement(element, keepDown = "DISABLED") {
93+
const list = document.querySelector(element);
94+
[...list.children]
95+
.sort((a, b) => {
96+
if (a.innerText === keepDown) {
97+
return 1;
98+
} else if (b.innerText === keepDown) {
99+
return -1;
100+
} else {
101+
return a.innerText > b.innerText ? 1 : -1;
102+
}
103+
})
104+
.forEach(node => list.appendChild(node));
105+
}
106+
97107
// TODO: these are temp binding while transition to module happens
98108
window.degToRad = degToRad;
99109
window.bytesToSize = bytesToSize;
100110
window.checkChromeRuntimeError = checkChromeRuntimeError;
101111
window.generateVirtualApiVersions = generateVirtualApiVersions;
102112
window.getMixerImageSrc = getMixerImageSrc;
103113
window.getTextWidth = getTextWidth;
114+
window.sortElement = sortElement;

0 commit comments

Comments
 (0)