Skip to content

Commit 700dd00

Browse files
committed
Change mixer
1 parent 6f3b50d commit 700dd00

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
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: 5 additions & 7 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" : "";
@@ -643,6 +645,8 @@ TABS.motors.initialize = function (callback) {
643645
escProtocolElement.append(`<option value="${j + 1}">${escProtocols[j]}</option>`);
644646
}
645647

648+
sortElement('select.escprotocol');
649+
646650
const unsyncedPWMSwitchElement = $("input[id='unsyncedPWMSwitch']");
647651
const divUnsyncedPWMFreq = $('div.unsyncedpwmfreq');
648652

@@ -743,7 +747,7 @@ TABS.motors.initialize = function (callback) {
743747
}
744748

745749
escProtocolElement.val(FC.PID_ADVANCED_CONFIG.fast_pwm_protocol + 1);
746-
console.log(FC.PID_ADVANCED_CONFIG.fast_pwm_protocol);
750+
747751
escProtocolElement.on("change", function () {
748752
const escProtocolValue = parseInt($(this).val()) - 1;
749753

@@ -1116,12 +1120,6 @@ TABS.motors.initialize = function (callback) {
11161120
dialogMixerReset.showModal();
11171121
$('#dialog-mixer-reset-confirmbtn').click(function() {
11181122
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());
11251123
});
11261124
}
11271125
}

src/js/utils/common.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,26 @@ export function getTextWidth(text) {
9494
return Math.ceil(context.measureText(text).width);
9595
}
9696

97+
export function sortElement(element, keepDown = "DISABLED") {
98+
const list = document.querySelector(element);
99+
[...list.children]
100+
.sort((a, b) => {
101+
if (a.innerText === keepDown) {
102+
return 1;
103+
} else if (b.innerText === keepDown) {
104+
return -1;
105+
} else {
106+
return a.innerText > b.innerText ? 1 : -1;
107+
}
108+
})
109+
.forEach(node => list.appendChild(node));
110+
}
111+
97112
// TODO: these are temp binding while transition to module happens
98113
window.degToRad = degToRad;
99114
window.bytesToSize = bytesToSize;
100115
window.checkChromeRuntimeError = checkChromeRuntimeError;
101116
window.generateVirtualApiVersions = generateVirtualApiVersions;
102117
window.getMixerImageSrc = getMixerImageSrc;
103118
window.getTextWidth = getTextWidth;
119+
window.sortElement = sortElement;

0 commit comments

Comments
 (0)