diff --git a/locales/en/messages.json b/locales/en/messages.json index d78f69b6..25bbfa31 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -506,9 +506,12 @@ "reportProblemsDialogFooter": { "message": "Please fix these problems before attempting to fly your craft." }, - "reportProblemsDialogAccCalibrationNeeded": { + "reportProblemsDialogACC_NEEDS_CALIBRATION": { "message": "the accelerometer is enabled but it is not calibrated. If you plan to use the accelerometer, please follow the instructions for '$t(initialSetupButtonCalibrateAccel.message)' on the '$t(tabSetup.message)' tab. If any function that requires the accelerometer (auto level modes, GPS rescue, ...) is enabled, arming of the craft will be disabled until the accelerometer has been calibrated. If you are not planning on using the accelerometer it is recommended that you disable it in '$t(configurationSystem.message)' on the '$t(tabConfiguration.message)' tab." }, + "reportProblemsDialogMOTOR_PROTOCOL_DISABLED": { + "message": "there is no motor output protocol selected. Please select a motor output protocol appropriate for your ESCs in '$t(configurationEscFeatures.message)' on the '$t(tabConfiguration.message)' tab. $t(escProtocolDisabledMessage.message)" + }, "infoVersions": { "message" : "Running - OS: {{operatingSystem}}, Chrome: {{chromeVersion}}, Configurator: {{configuratorVersion}}", @@ -1266,6 +1269,12 @@ "configurationThrottleMinimumCommandHelp": { "message": "This is the value that is sent to the ESCs when the craft is disarmed. Set this to a value that has the motors stopped (1000 for most ESCs)." }, + "configurationEscProtocolDisabled": { + "message": "Please select a motor output protocol appropriate for your ESCs. $t(escProtocolDisabledMessage.message)" + }, + "escProtocolDisabledMessage": { + "message": "Caution: Selecting a motor output protocol that is not supported by your ESCs can lead to the ESCs spinning up as soon as a battery is connected. For this reason, always make sure to remove the props before connecting a battery for the first time after changing the motor output protocol." + }, "configurationDshotBeeper": { "message": "Dshot Beacon Configuration" }, diff --git a/src/js/Features.js b/src/js/Features.js index 359215c0..45fbf24e 100644 --- a/src/js/Features.js +++ b/src/js/Features.js @@ -7,7 +7,7 @@ var Features = function (config) { {bit: 0, group: 'rxMode', mode: 'select', name: 'RX_PPM'}, {bit: 2, group: 'other', name: 'INFLIGHT_ACC_CAL'}, {bit: 3, group: 'rxMode', mode: 'select', name: 'RX_SERIAL'}, - {bit: 4, group: 'esc', name: 'MOTOR_STOP'}, + {bit: 4, group: 'escMotorStop', name: 'MOTOR_STOP'}, {bit: 5, group: 'other', name: 'SERVO_TILT', haveTip: true}, {bit: 6, group: 'other', name: 'SOFTSERIAL', haveTip: true}, {bit: 7, group: 'gps', name: 'GPS', haveTip: true}, diff --git a/src/js/fc.js b/src/js/fc.js index c0a92e2f..d848789d 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -105,6 +105,7 @@ var FC = { mcuTypeId: 255, configurationState: 0, sampleRateHz: 0, + configurationProblems: 0, }; BF_CONFIG = { @@ -638,7 +639,11 @@ var FC = { SUPPORTS_CUSTOM_DEFAULTS: 4, HAS_CUSTOM_DEFAULTS: 5, SUPPORTS_RX_BIND: 6, - ACC_NEEDS_CALIBRATION: 7, + }, + + CONFIGURATION_PROBLEM_FLAGS: { + ACC_NEEDS_CALIBRATION: 0, + MOTOR_PROTOCOL_DISABLED: 1, }, boardHasVcp: function () { diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index 9e3dd60d..5d34b3a4 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -767,7 +767,6 @@ MspHelper.prototype.process_data = function(dataHandler) { CONFIG.boardType = 0; } - CONFIG.targetName = ""; if (semver.gte(CONFIG.apiVersion, "1.37.0")) { CONFIG.targetCapabilities = data.readU8(); @@ -777,11 +776,9 @@ MspHelper.prototype.process_data = function(dataHandler) { } } else { CONFIG.targetCapabilities = 0; + CONFIG.targetName = ""; } - CONFIG.boardName = ""; - CONFIG.manufacturerId = ""; - CONFIG.signature = []; if (semver.gte(CONFIG.apiVersion, "1.39.0")) { let length = data.readU8(); for (let i = 0; i < length; i++) { @@ -796,22 +793,29 @@ MspHelper.prototype.process_data = function(dataHandler) { for (let i = 0; i < self.SIGNATURE_LENGTH; i++) { CONFIG.signature.push(data.readU8()); } + } else { + CONFIG.boardName = ""; + CONFIG.manufacturerId = ""; + CONFIG.signature = []; } if (semver.gte(CONFIG.apiVersion, "1.41.0")) { CONFIG.mcuTypeId = data.readU8(); - - if (semver.gte(CONFIG.apiVersion, "1.42.0")) { - CONFIG.configurationState = data.readU8(); - - if (semver.gte(CONFIG.apiVersion, "1.43.0")) { - CONFIG.sampleRateHz = data.readU16(); - } - - } } else { CONFIG.mcuTypeId = 255; } + + if (semver.gte(CONFIG.apiVersion, "1.42.0")) { + CONFIG.configurationState = data.readU8(); + } + + if (semver.gte(CONFIG.apiVersion, "1.43.0")) { + CONFIG.sampleRateHz = data.readU16(); + CONFIG.configurationProblems = data.readU32(); + } else { + CONFIG.configurationProblems = 0; + } + break; case MSPCodes.MSP_NAME: diff --git a/src/js/serial_backend.js b/src/js/serial_backend.js index 2cc203f3..44679d83 100644 --- a/src/js/serial_backend.js +++ b/src/js/serial_backend.js @@ -353,20 +353,32 @@ function processBoardInfo() { } function checkReportProblems() { + const PROBLEM_ANALYTICS_EVENT = 'ProblemFound'; + const problemItemTemplate = $('#dialogReportProblems-listItemTemplate'); + + function checkReportProblem(problemName, problemDialogList) { + if (bit_check(CONFIG.configurationProblems, FC.CONFIGURATION_PROBLEM_FLAGS[problemName])) { + problemItemTemplate.clone().html(i18n.getMessage(`reportProblemsDialog${problemName}`)).appendTo(problemDialogList); + + analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, PROBLEM_ANALYTICS_EVENT, problemName); + + return true; + } + + return false; + } + MSP.send_message(MSPCodes.MSP_STATUS, false, false, function () { let needsProblemReportingDialog = false; const problemDialogList = $('#dialogReportProblems-list'); problemDialogList.empty(); - const problemItemTemplate = $('.dialogReportProblems-listItem'); - const PROBLEM_ANALYTICS_EVENT = 'ProblemFound'; - if (have_sensor(CONFIG.activeSensors, 'acc') && bit_check(CONFIG.targetCapabilities, FC.TARGET_CAPABILITIES_FLAGS.ACC_NEEDS_CALIBRATION)) { - needsProblemReportingDialog = true; - problemDialogList.append(problemItemTemplate.clone().html(i18n.getMessage('reportProblemsDialogAccCalibrationNeeded'))); - - analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, PROBLEM_ANALYTICS_EVENT, 'AccNotCalibrated'); + if (have_sensor(CONFIG.activeSensors, 'acc')) { + needsProblemReportingDialog = checkReportProblem('ACC_NEEDS_CALIBRATION', problemDialogList) || needsProblemReportingDialog; } + needsProblemReportingDialog = checkReportProblem('MOTOR_PROTOCOL_DISABLED', problemDialogList) || needsProblemReportingDialog; + if (needsProblemReportingDialog) { const problemDialog = $('#dialogReportProblems')[0]; $('#dialogReportProblems-closebtn').click(function() { diff --git a/src/js/tabs/configuration.js b/src/js/tabs/configuration.js index 9f23cb1d..e50536c7 100644 --- a/src/js/tabs/configuration.js +++ b/src/js/tabs/configuration.js @@ -1,7 +1,6 @@ 'use strict'; TABS.configuration = { - DSHOT_PROTOCOL_MIN_VALUE: 5, SHOW_OLD_BATTERY_CONFIG: false, analyticsChanges: {}, }; @@ -457,7 +456,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) { } // ESC protocols - var escprotocols = [ + const escProtocols = [ 'PWM', 'ONESHOT125', 'ONESHOT42', @@ -465,25 +464,31 @@ TABS.configuration.initialize = function (callback, scrollPosition) { ]; if (semver.gte(CONFIG.apiVersion, "1.20.0")) { - escprotocols.push('BRUSHED'); + escProtocols.push('BRUSHED'); } if (semver.gte(CONFIG.apiVersion, "1.31.0")) { - escprotocols.push('DSHOT150'); - escprotocols.push('DSHOT300'); - escprotocols.push('DSHOT600'); + escProtocols.push('DSHOT150'); + escProtocols.push('DSHOT300'); + escProtocols.push('DSHOT600'); + if (semver.lt(CONFIG.apiVersion, "1.42.0")) { - escprotocols.push('DSHOT1200'); - } - if (semver.gte(CONFIG.apiVersion, "1.36.0")) { - escprotocols.push('PROSHOT1000'); + escProtocols.push('DSHOT1200'); } } + if (semver.gte(CONFIG.apiVersion, "1.36.0")) { + escProtocols.push('PROSHOT1000'); + } + + if (semver.gte(CONFIG.apiVersion, "1.43.0")) { + escProtocols.push('DISABLED'); + } + var esc_protocol_e = $('select.escprotocol'); - for (var i = 0; i < escprotocols.length; i++) { - esc_protocol_e.append(''); + for (let j = 0; j < escProtocols.length; j++) { + esc_protocol_e.append(``); } $("input[id='unsyncedPWMSwitch']").change(function() { @@ -516,47 +521,67 @@ TABS.configuration.initialize = function (callback, scrollPosition) { $('input[name="motorPoles"]').val(MOTOR_CONFIG.motor_poles); } - function hideRpmFeatures() { - let rpmFeaturesVisible = $("input[id='dshotBidir']").is(':checked') || $("input[name='ESC_SENSOR']").is(':checked'); - $('div.motorPoles').toggle(rpmFeaturesVisible); - } - $('#escProtocolTooltip').toggle(semver.lt(CONFIG.apiVersion, "1.42.0")); $('#escProtocolTooltipNoDSHOT1200').toggle(semver.gte(CONFIG.apiVersion, "1.42.0")); + function updateVisibility() { + // Hide unused settings + const protocolName = $('select.escprotocol option:selected').text(); + const protocolConfigured = protocolName !== 'DISABLED'; + let digitalProtocol = false; + switch (protocolName) { + case 'DSHOT150': + case 'DSHOT300': + case 'DSHOT600': + case 'DSHOT1200': + case 'PROSHOT1000': + digitalProtocol = true; + + break; + default: + + break; + } + + const rpmFeaturesVisible = digitalProtocol && ($("input[id='dshotBidir']").is(':checked') || $("input[name='ESC_SENSOR']").is(':checked')); + + $('div.minthrottle').toggle(protocolConfigured && !digitalProtocol); + $('div.maxthrottle').toggle(protocolConfigured && !digitalProtocol); + $('div.mincommand').toggle(protocolConfigured && !digitalProtocol); + $('div.checkboxPwm').toggle(protocolConfigured && !digitalProtocol); + $('div.unsyncedpwmfreq').toggle(protocolConfigured && !digitalProtocol); + + $('div.digitalIdlePercent').toggle(protocolConfigured && digitalProtocol); + $('.escSensor').toggle(protocolConfigured && digitalProtocol); + + $('div.checkboxDshotBidir').toggle(protocolConfigured && semver.gte(CONFIG.apiVersion, "1.42.0") && digitalProtocol); + $('div.motorPoles').toggle(protocolConfigured && rpmFeaturesVisible && semver.gte(CONFIG.apiVersion, "1.42.0")); + + $('.escMotorStop').toggle(protocolConfigured); + + $('#escProtocolDisabled').toggle(!protocolConfigured); + + //trigger change unsyncedPWMSwitch to show/hide Motor PWM freq input + $("input[id='unsyncedPWMSwitch']").change(); + } + esc_protocol_e.val(PID_ADVANCED_CONFIG.fast_pwm_protocol + 1); esc_protocol_e.change(function () { - var escProtocolValue = parseInt($(this).val()) - 1; + const escProtocolValue = parseInt($(this).val()) - 1; - var newValue; + let newValue = undefined; if (escProtocolValue !== PID_ADVANCED_CONFIG.fast_pwm_protocol) { newValue = $(this).find('option:selected').text(); } self.analyticsChanges['EscProtocol'] = newValue; - //hide not used setting for DSHOT protocol - let digitalProtocol = (escProtocolValue >= self.DSHOT_PROTOCOL_MIN_VALUE); - - $('div.minthrottle').toggle(!digitalProtocol); - $('div.maxthrottle').toggle(!digitalProtocol); - $('div.mincommand').toggle(!digitalProtocol); - $('div.checkboxPwm').toggle(!digitalProtocol); - $('div.unsyncedpwmfreq').toggle(!digitalProtocol); - - $('div.digitalIdlePercent').toggle(digitalProtocol); - $('.escSensor').toggle(digitalProtocol); - - $('div.checkboxDshotBidir').toggle(semver.gte(CONFIG.apiVersion, "1.42.0") && digitalProtocol); - $('div.motorPoles').toggle(semver.gte(CONFIG.apiVersion, "1.42.0")); - //trigger change dshotBidir and ESC_SENSOR to show/hide Motor Poles tab - $("input[id='dshotBidir']").change(hideRpmFeatures).change(); - $("input[name='ESC_SENSOR']").change(hideRpmFeatures); - - //trigger change unsyncedPWMSwitch to show/hide Motor PWM freq input - $("input[id='unsyncedPWMSwitch']").change(); - + updateVisibility(); }).change(); + //trigger change dshotBidir and ESC_SENSOR to show/hide Motor Poles tab + $("input[id='dshotBidir']").change(updateVisibility).change(); + $("input[name='ESC_SENSOR']").change(updateVisibility).change(); + // Gyro and PID update const gyroUse32kHzElement = $('input[id="gyroUse32kHz"]'); const gyroTextElement = $('input.gyroFrequency'); @@ -706,7 +731,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) { i18n.getMessage('gpsSbasEuropeanEGNOS'), i18n.getMessage('gpsSbasNorthAmericanWAAS'), i18n.getMessage('gpsSbasJapaneseMSAS'), - i18n.getMessage('gpsSbasIndianGAGAN') + i18n.getMessage('gpsSbasIndianGAGAN'), ]; if (semver.gte(CONFIG.apiVersion, "1.43.0")) { gpsSbas.push(i18n.getMessage('gpsSbasNone')); diff --git a/src/js/tabs/setup.js b/src/js/tabs/setup.js index bba5ba40..b9250b53 100644 --- a/src/js/tabs/setup.js +++ b/src/js/tabs/setup.js @@ -240,7 +240,7 @@ TABS.setup.initialize = function (callback) { 'DSHOT_BBANG']); } if (semver.gte(CONFIG.apiVersion, "1.43.0")) { - disarmFlagElements = disarmFlagElements.concat(['NO_ACC_CAL']); + disarmFlagElements = disarmFlagElements.concat(['NO_ACC_CAL', 'MOTOR_PROTO']); } // Always the latest element diff --git a/src/main.html b/src/main.html index fc934332..d83f632a 100644 --- a/src/main.html +++ b/src/main.html @@ -388,7 +388,7 @@ diff --git a/src/tabs/configuration.html b/src/tabs/configuration.html index fe799191..061bf578 100644 --- a/src/tabs/configuration.html +++ b/src/tabs/configuration.html @@ -132,6 +132,9 @@
+
+

+