Merge pull request #1933 from mikeller/support_disabled_motor_protocol

Added support for disabling the motor output protocol.
10.7.0-preview
Michael Keller 2020-04-11 12:41:50 +12:00 committed by GitHub
commit efe82eccc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 125 additions and 67 deletions

View File

@ -506,9 +506,12 @@
"reportProblemsDialogFooter": {
"message": "Please <strong>fix these problems before attempting to fly your craft</strong>."
},
"reportProblemsDialogAccCalibrationNeeded": {
"reportProblemsDialogACC_NEEDS_CALIBRATION": {
"message": "<strong>the accelerometer is enabled but it is not calibrated</strong>. 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": "<strong>there is no motor output protocol selected</strong>. 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: <strong>{{operatingSystem}}</strong>, Chrome: <strong>{{chromeVersion}}</strong>, Configurator: <strong>{{configuratorVersion}}</strong>",
@ -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": "<strong>Caution:</strong> Selecting a motor output protocol that is not supported by your ESCs can lead to the <strong>ESCs spinning up as soon as a battery is connected</strong>. For this reason, <strong>always make sure to remove the props before connecting a battery for the first time after changing the motor output protocol</strong>."
},
"configurationDshotBeeper": {
"message": "Dshot Beacon Configuration"
},

View File

@ -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},

View File

@ -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 () {

View File

@ -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:

View File

@ -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() {

View File

@ -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');
escProtocols.push('DSHOT1200');
}
}
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
escprotocols.push('PROSHOT1000');
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('<option value="' + (i + 1) + '">'+ escprotocols[i] + '</option>');
for (let j = 0; j < escProtocols.length; j++) {
esc_protocol_e.append(`<option value="${j + 1}">${escProtocols[j]}</option>`);
}
$("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'));

View File

@ -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

View File

@ -389,7 +389,7 @@
</dialog>
<ul class="hidden"> <!-- Sonar says so -->
<li class="dialogReportProblems-listItem"></li>
<li id="dialogReportProblems-listItemTemplate" class="dialogReportProblems-listItem"></li>
</ul>
<dialog class="dialogError">

View File

@ -132,6 +132,9 @@
<div class="spacer_box_title" i18n="configurationEscFeatures"></div>
</div>
<div class="spacer_box">
<div id="escProtocolDisabled" class="note">
<p i18n="configurationEscProtocolDisabled"/>
</div>
<div class="selectProtocol">
<label>
<select class="escprotocol">
@ -174,7 +177,7 @@
</div>
</div>
<table class="featuresMultiple">
<tbody class="features esc">
<tbody class="features escMotorStop">
<!-- table generated here -->
</tbody>
</table>