1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-20 14:55:15 +03:00

Merge pull request #1113 from mikeller/add_bootloader_msc_button

Added buttons for reboot into boot loader and MSC modes.
This commit is contained in:
Michael Keller 2018-07-18 01:54:47 +12:00 committed by GitHub
commit 606e4045d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 155 additions and 5 deletions

View file

@ -642,4 +642,16 @@ function openNewWindowsInExternalBrowser() {
} catch (ex) {
console.log("require does not exist, maybe inside chrome");
}
}
}
function showErrorDialog(message) {
var dialog = $('.dialogError')[0];
$('.dialogError-content').html(message);
$('.dialogError-closebtn').click(function() {
dialog.close();
});
dialog.showModal();
}

View file

@ -27,6 +27,12 @@ function MspHelper () {
'RUNCAM_DEVICE_CONTROL': 14, // support communitate with RunCam Device
'LIDAR_TF': 15
};
self.REBOOT_TYPES = {
FIRMWARE: 0,
BOOTLOADER: 1,
MSC: 2
};
}
MspHelper.prototype.reorderPwmProtocols = function (protocol) {
@ -617,6 +623,17 @@ MspHelper.prototype.process_data = function(dataHandler) {
break;
case MSPCodes.MSP_SET_REBOOT:
if (semver.gte(CONFIG.apiVersion, "1.40.0")) {
var rebootType = data.read8();
if (rebootType === self.REBOOT_TYPES.MSC) {
if (data.read8() === 0) {
console.log('Storage device not ready.');
showErrorDialog(i18n.getMessage('storageDeviceNotReady'));
break;
}
}
}
console.log('Reboot request accepted');
break;
@ -1187,6 +1204,11 @@ MspHelper.prototype.process_data = function(dataHandler) {
console.log('Unknown code detected: ' + code);
} else {
console.log('FC reports unsupported message error: ' + code);
switch (code) {
case MSPCodes.MSP_SET_REBOOT:
showErrorDialog(i18n.getMessage('operationNotSupported'));
}
}
}
// trigger callbacks, cleanup/remove callback after trigger
@ -1209,7 +1231,6 @@ MspHelper.prototype.process_data = function(dataHandler) {
}
}
/**
* Encode the request body for the MSP request with the given code and return it as an array of bytes.
*/

View file

@ -145,6 +145,20 @@ TABS.onboard_logging.initialize = function (callback) {
$("div.blackboxRate").show();
}
}).change();
if (semver.gte(CONFIG.apiVersion, "1.40.0")) {
if (SDCARD.supported || DATAFLASH.supported) {
$(".tab-onboard_logging")
.toggleClass("msc-supported", true);
$('a.onboardLoggingRebootMsc').click(function () {
var buffer = [];
buffer.push(2);
MSP.send_message(MSPCodes.MSP_SET_REBOOT, buffer, false);
});
}
}
update_html();
@ -296,6 +310,18 @@ TABS.onboard_logging.initialize = function (callback) {
.toggleClass("sdcard-error", SDCARD.state === MSP.SDCARD_STATE_FATAL)
.toggleClass("sdcard-initializing", SDCARD.state === MSP.SDCARD_STATE_CARD_INIT || SDCARD.state === MSP.SDCARD_STATE_FS_INIT)
.toggleClass("sdcard-ready", SDCARD.state === MSP.SDCARD_STATE_READY);
if (semver.gte(CONFIG.apiVersion, "1.40.0")) {
var mscIsReady = (DATAFLASH.totalSize > 0) || (SDCARD.state === MSP.SDCARD_STATE_READY);
$(".tab-onboard_logging")
.toggleClass("msc-not-ready", !mscIsReady);
if (!mscIsReady) {
$('a.onboardLoggingRebootMsc').addClass('disabled');
} else {
$('a.onboardLoggingRebootMsc').removeClass('disabled');
}
}
switch (SDCARD.state) {
case MSP.SDCARD_STATE_NOT_PRESENT:

View file

@ -59,9 +59,24 @@ TABS.setup.initialize = function (callback) {
self.initializeInstruments();
$('#arming-disable-flag-row').attr('title', i18n.getMessage('initialSetupArmingDisableFlagsTooltip'));
if (semver.gte(CONFIG.apiVersion, "1.40.0")) {
if (isExpertModeEnabled()) {
$('.initialSetupRebootBootloader').show();
} else {
$('.initialSetupRebootBootloader').hide();
}
$('a.rebootBootloader').click(function () {
var buffer = [];
buffer.push(1);
MSP.send_message(MSPCodes.MSP_SET_REBOOT, buffer, false);
});
} else {
$('.initialSetupRebootBootloader').hide();
}
// UI Hooks
$('a.calibrateAccel').click(function () {
var self = $(this);