1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-24 00:35:26 +03:00

Added dialog to offer resetting to custom defaults. (#1651)

Added dialog to offer resetting to custom defaults.
This commit is contained in:
Michael Keller 2019-09-15 10:23:32 +12:00 committed by GitHub
commit 93e4cf83b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 82 additions and 10 deletions

View file

@ -56,6 +56,9 @@
"close": { "close": {
"message": "Close" "message": "Close"
}, },
"cancel": {
"message": "Cancel"
},
"autoConnectEnabled": { "autoConnectEnabled": {
"message": "Auto-Connect: Enabled - Configurator automatically tries to connect when new port is detected" "message": "Auto-Connect: Enabled - Configurator automatically tries to connect when new port is detected"
}, },
@ -467,6 +470,12 @@
"firmwareUpgradeRequired": { "firmwareUpgradeRequired": {
"message": "The firmware on this device needs upgrading to a newer version. Use CLI for backup before flashing. CLI backup/restore procedure is in the documention.<br />Alternatively download and use an old version of the configurator if you are not ready to upgrade." "message": "The firmware on this device needs upgrading to a newer version. Use CLI for backup before flashing. CLI backup/restore procedure is in the documention.<br />Alternatively download and use an old version of the configurator if you are not ready to upgrade."
}, },
"resetToCustomDefaultsDialog": {
"message": "There are custom defaults for this board available. Normally, a board will not work properly unless custom defaults are applied.<br />Do you want to apply the custom defaults for this board?"
},
"resetToCustomDefaultsAccept": {
"message": "Apply Custom Defaults"
},
"infoVersions": { "infoVersions": {
"message" : "Running - OS: <strong>{{operatingSystem}}</strong>, Chrome: <strong>{{chromeVersion}}</strong>, Configurator: <strong>{{configuratorVersion}}</strong>", "message" : "Running - OS: <strong>{{operatingSystem}}</strong>, Chrome: <strong>{{chromeVersion}}</strong>, Configurator: <strong>{{configuratorVersion}}</strong>",

View file

@ -2113,3 +2113,8 @@ input {
height: 9px; height: 9px;
border:1px solid var(--accent); border:1px solid var(--accent);
} }
#dialogResetToCustomDefaults-content {
margin-top: 10px;
margin-bottom: 10px;
}

View file

@ -95,12 +95,13 @@ var FC = {
runawayTakeoffPreventionDisabled: false, runawayTakeoffPreventionDisabled: false,
boardIdentifier: "", boardIdentifier: "",
boardVersion: 0, boardVersion: 0,
commCapabilities: 0, targetCapabilities: 0,
targetName: "", targetName: "",
boardName: "", boardName: "",
manufacturerId: "", manufacturerId: "",
signature: [], signature: [],
mcuTypeId: 255, mcuTypeId: 255,
configurationState: 0,
}; };
BF_CONFIG = { BF_CONFIG = {
@ -607,15 +608,25 @@ var FC = {
return FC.MCU_TYPES[CONFIG.mcuTypeId]; return FC.MCU_TYPES[CONFIG.mcuTypeId];
}, },
COMM_CAPABILITIES_FLAGS: { CONFIGURATION_STATES: {
HAS_VCP: 0x01, DEFAULTS_BARE: 0,
HAS_SOFTSERIAL: 0x02, DEFAULTS_CUSTOM: 1,
CONFIGURED: 2,
},
TARGET_CAPABILITIES_FLAGS: {
HAS_VCP: 0,
HAS_SOFTSERIAL: 1,
IS_UNIFIED: 2,
HAS_FLASH_BOOTLOADER: 3,
SUPPORTS_CUSTOM_DEFAULTS: 4,
HAS_CUSTOM_DEFAULTS: 5,
}, },
boardHasVcp: function () { boardHasVcp: function () {
var hasVcp = false; var hasVcp = false;
if (semver.gte(CONFIG.apiVersion, "1.37.0")) { if (semver.gte(CONFIG.apiVersion, "1.37.0")) {
hasVcp = (CONFIG.commCapabilities & FC.COMM_CAPABILITIES_FLAGS.HAS_VCP) !== 0; hasVcp = bit_check(CONFIG.targetCapabilities, FC.TARGET_CAPABILITIES_FLAGS.HAS_VCP);
} else { } else {
hasVcp = BOARD.find_board_definition(CONFIG.boardIdentifier).vcp; hasVcp = BOARD.find_board_definition(CONFIG.boardIdentifier).vcp;
} }

View file

@ -34,6 +34,11 @@ function MspHelper () {
MSC_UTC: 3 MSC_UTC: 3
}; };
self.RESET_TYPES = {
BASE_DEFAULTS: 0,
CUSTOM_DEFAULTS: 1,
};
self.SIGNATURE_LENGTH = 32; self.SIGNATURE_LENGTH = 32;
self.mspMultipleCache = []; self.mspMultipleCache = [];
@ -751,14 +756,14 @@ MspHelper.prototype.process_data = function(dataHandler) {
CONFIG.targetName = ""; CONFIG.targetName = "";
if (semver.gte(CONFIG.apiVersion, "1.37.0")) { if (semver.gte(CONFIG.apiVersion, "1.37.0")) {
CONFIG.commCapabilities = data.readU8(); CONFIG.targetCapabilities = data.readU8();
let length = data.readU8(); let length = data.readU8();
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
CONFIG.targetName += String.fromCharCode(data.readU8()); CONFIG.targetName += String.fromCharCode(data.readU8());
} }
} else { } else {
CONFIG.commCapabilities = 0; CONFIG.targetCapabilities = 0;
} }
CONFIG.boardName = ""; CONFIG.boardName = "";
@ -782,6 +787,10 @@ MspHelper.prototype.process_data = function(dataHandler) {
if (semver.gte(CONFIG.apiVersion, "1.41.0")) { if (semver.gte(CONFIG.apiVersion, "1.41.0")) {
CONFIG.mcuTypeId = data.readU8(); CONFIG.mcuTypeId = data.readU8();
if (semver.gte(CONFIG.apiVersion, "1.42.0")) {
CONFIG.configurationState = data.readU8();
}
} else { } else {
CONFIG.mcuTypeId = 255; CONFIG.mcuTypeId = 255;
} }

View file

@ -153,7 +153,7 @@ STM32_protocol.prototype.connect = function (port, baud, hex, options, callback)
MSP.send_message(MSPCodes.MSP_BOARD_INFO, false, false, function () { MSP.send_message(MSPCodes.MSP_BOARD_INFO, false, false, function () {
var rebootMode = 0; // FIRMWARE var rebootMode = 0; // FIRMWARE
if (bit_check(CONFIG.commCapabilities, 3)) { if (bit_check(CONFIG.targetCapabilities, FC.TARGET_CAPABILITIES_FLAGS.HAS_FLASH_BOOTLOADER)) {
// Board has flash bootloader // Board has flash bootloader
GUI.log(i18n.getMessage('deviceRebooting_flashBootloader')); GUI.log(i18n.getMessage('deviceRebooting_flashBootloader'));
console.log('flash bootloader detected'); console.log('flash bootloader detected');

View file

@ -258,6 +258,29 @@ function onOpen(openInfo) {
updateStatusBarVersion(CONFIG.flightControllerVersion, CONFIG.flightControllerIdentifier, FC.getHardwareName()); updateStatusBarVersion(CONFIG.flightControllerVersion, CONFIG.flightControllerIdentifier, FC.getHardwareName());
updateTopBarVersion(CONFIG.flightControllerVersion, CONFIG.flightControllerIdentifier, FC.getHardwareName()); updateTopBarVersion(CONFIG.flightControllerVersion, CONFIG.flightControllerIdentifier, FC.getHardwareName());
if (bit_check(CONFIG.targetCapabilities, FC.TARGET_CAPABILITIES_FLAGS.SUPPORTS_CUSTOM_DEFAULTS) && bit_check(CONFIG.targetCapabilities, FC.TARGET_CAPABILITIES_FLAGS.HAS_CUSTOM_DEFAULTS) && CONFIG.configurationState === FC.CONFIGURATION_STATES.DEFAULTS_BARE) {
var dialog = $('#dialogResetToCustomDefaults')[0];
$('#dialogResetToCustomDefaults-content').html(i18n.getMessage('resetToCustomDefaultsDialog'));
$('#dialogResetToCustomDefaults-acceptbtn').click(function() {
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'AcceptResetToCustomDefaults');
var buffer = [];
buffer.push(mspHelper.RESET_TYPES.CUSTOM_DEFAULTS);
MSP.send_message(MSPCodes.MSP_RESET_CONF, buffer, false);
dialog.close();
});
$('#dialogResetToCustomDefaults-cancelbtn').click(function() {
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'CancelResetToCustomDefaults');
dialog.close();
});
dialog.showModal();
}
MSP.send_message(MSPCodes.MSP_UID, false, false, function () { MSP.send_message(MSPCodes.MSP_UID, false, false, function () {
var uniqueDeviceIdentifier = CONFIG.uid[0].toString(16) + CONFIG.uid[1].toString(16) + CONFIG.uid[2].toString(16); var uniqueDeviceIdentifier = CONFIG.uid[0].toString(16) + CONFIG.uid[1].toString(16) + CONFIG.uid[2].toString(16);
@ -281,7 +304,7 @@ function onOpen(openInfo) {
}); });
}); });
} else { } else {
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'ConnectionRefused'); analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'ConnectionRefusedFirmwareType');
var dialog = $('.dialogConnectWarning')[0]; var dialog = $('.dialogConnectWarning')[0];
@ -297,7 +320,7 @@ function onOpen(openInfo) {
} }
}); });
} else { } else {
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'ConnectionRefused'); analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'ConnectionRefusedFirmwareVersion');
var dialog = $('.dialogConnectWarning')[0]; var dialog = $('.dialogConnectWarning')[0];

View file

@ -403,6 +403,21 @@
</div> </div>
</dialog> </dialog>
<dialog id="dialogResetToCustomDefaults">
<h3 i18n="noticeTitle"></h3>
<div class="content">
<div id="dialogResetToCustomDefaults-content"></div>
</div>
<div>
<span class="buttons">
<a href="#" id="dialogResetToCustomDefaults-acceptbtn" class="regular-button" i18n="resetToCustomDefaultsAccept"></a>
</span>
<span class="buttons">
<a href="#" id="dialogResetToCustomDefaults-cancelbtn" class="regular-button" i18n="cancel"></a>
</span>
</div>
</dialog>
<dialog class="dialogError"> <dialog class="dialogError">
<h3 i18n="errorTitle"></h3> <h3 i18n="errorTitle"></h3>
<div class="content"> <div class="content">