Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2559,7 +2559,7 @@
"message": "<strong>I understand the risks</strong>, the propellers are removed - enable motor control and arming, and disable Runaway Takeoff Prevention."
},
"motorsDialogMixerReset": {
"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"
"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."
},
"motorsDialogSettingsChanged": {
"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>"
Expand Down
36 changes: 15 additions & 21 deletions src/js/tabs/motors.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ TABS.motors.initialize = function (callback) {
});
}

sortElement('select.mixerList');

function refreshMixerPreview() {
const mixer = FC.MIXER_CONFIG.mixer;
const reverse = FC.MIXER_CONFIG.reverseMotorDir ? "_reversed" : "";
Expand Down Expand Up @@ -608,6 +610,12 @@ TABS.motors.initialize = function (callback) {
neutral3d = (FC.MOTOR_3D_CONFIG.neutral > 1575 || FC.MOTOR_3D_CONFIG.neutral < 1425) ? 1500 : FC.MOTOR_3D_CONFIG.neutral;
}

let zeroThrottleValue = rangeMin;

if (self.feature3DEnabled) {
zeroThrottleValue = neutral3d;
}

const motorsWrapper = $('.motors .bar-wrapper');

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

sortElement('select.escprotocol');

const unsyncedPWMSwitchElement = $("input[id='unsyncedPWMSwitch']");
const divUnsyncedPWMFreq = $('div.unsyncedpwmfreq');

Expand Down Expand Up @@ -743,7 +753,7 @@ TABS.motors.initialize = function (callback) {
}

escProtocolElement.val(FC.PID_ADVANCED_CONFIG.fast_pwm_protocol + 1);
console.log(FC.PID_ADVANCED_CONFIG.fast_pwm_protocol);

escProtocolElement.on("change", function () {
const escProtocolValue = parseInt($(this).val()) - 1;

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

function setSlidersDefault() {
// change all values to default
if (self.feature3DEnabled) {
$('div.sliders input').val(neutral3d);
} else {
$('div.sliders input').val(rangeMin);
}
$('div.sliders input').val(zeroThrottleValue);
}

function setSlidersEnabled(isEnabled) {
Expand Down Expand Up @@ -903,7 +909,7 @@ TABS.motors.initialize = function (callback) {

for (let i = 0; i < self.numberOfValidOutputs; i++) {
if (!self.feature3DEnabled) {
if (FC.MOTOR_DATA[i] > rangeMin) {
if (FC.MOTOR_DATA[i] > zeroThrottleValue) {
motorsRunning = true;
}
} else {
Expand Down Expand Up @@ -965,7 +971,7 @@ TABS.motors.initialize = function (callback) {
const motorsTesting = motorsEnableTestModeElement.is(':checked');

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

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

if (previousArmState != self.armed) {
if (previousArmState !== self.armed) {
console.log('arm state change detected');

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

let zeroThrottleValue = rangeMin;

if (self.feature3DEnabled) {
zeroThrottleValue = neutral3d;
}

setup_motor_output_reordering_dialog(SetupEscDshotDirectionDialogCallback, zeroThrottleValue);

function SetupEscDshotDirectionDialogCallback() {
Expand Down Expand Up @@ -1116,12 +1116,6 @@ TABS.motors.initialize = function (callback) {
dialogMixerReset.showModal();
$('#dialog-mixer-reset-confirmbtn').click(function() {
dialogMixerReset.close();

FC.MIXER_CONFIG.mixer = 3;

MSP.promise(MSPCodes.MSP_SET_MIXER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_MIXER_CONFIG))
.then(() => MSP.promise(MSPCodes.MSP_EEPROM_WRITE))
.then(() => reboot());
});
}
}
Expand Down
27 changes: 19 additions & 8 deletions src/js/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@ export function bytesToSize(bytes) {

export function checkChromeRuntimeError() {
if (chrome.runtime.lastError) {
console.error(
`Chrome API Error: ${chrome.runtime.lastError.message}.\n Traced ${
new Error().stack
}`
);
console.error(`Chrome API Error: ${chrome.runtime.lastError.message}.\n Traced ${new Error().stack}`);

return true;
}
return false;
Expand All @@ -54,9 +51,7 @@ const majorFirmwareVersions = {
};

export function generateVirtualApiVersions() {
const firmwareVersionDropdown = document.getElementById(
"firmware-version-dropdown"
);
const firmwareVersionDropdown = document.getElementById("firmware-version-dropdown");
const max = semver.minor(CONFIGURATOR.API_VERSION_MAX_SUPPORTED);

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

export function sortElement(element, keepDown = "DISABLED") {
const list = document.querySelector(element);
[...list.children]
.sort((a, b) => {
if (a.innerText === keepDown) {
return 1;
} else if (b.innerText === keepDown) {
return -1;
} else {
return a.innerText > b.innerText ? 1 : -1;
}
})
.forEach(node => list.appendChild(node));
}

// TODO: these are temp binding while transition to module happens
window.degToRad = degToRad;
window.bytesToSize = bytesToSize;
window.checkChromeRuntimeError = checkChromeRuntimeError;
window.generateVirtualApiVersions = generateVirtualApiVersions;
window.getMixerImageSrc = getMixerImageSrc;
window.getTextWidth = getTextWidth;
window.sortElement = sortElement;