mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-16 04:45:20 +03:00
Added disabling of arming when connected to the configurator.
This commit is contained in:
parent
7672fcf064
commit
8246b0728d
4 changed files with 76 additions and 36 deletions
|
@ -198,6 +198,12 @@
|
|||
"craftNameReceived": {
|
||||
"message": "Craft name: <strong>$1</strong>"
|
||||
},
|
||||
"armingDisabled": {
|
||||
"message": "<strong>Arming Disabled</strong>"
|
||||
},
|
||||
"armingEnabled": {
|
||||
"message": "<strong>Arming Enabled</strong>"
|
||||
},
|
||||
"boardInfoReceived": {
|
||||
"message": "Board: <strong>$1</strong>, version: <strong>$2</strong>"
|
||||
},
|
||||
|
|
|
@ -77,6 +77,7 @@ var MSPCodes = {
|
|||
MSP_SENSOR_CONFIG: 96,
|
||||
MSP_SET_SENSOR_CONFIG: 97,
|
||||
//MSP_SPECIAL_PARAMETERS: 98, // DEPRECATED
|
||||
MSP_ARMING_DISABLE: 99,
|
||||
//MSP_SET_SPECIAL_PARAMETERS: 99, // DEPRECATED
|
||||
//MSP_IDENT: 100, // DEPRECTED
|
||||
MSP_STATUS: 101,
|
||||
|
|
|
@ -1153,6 +1153,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
|||
case MSPCodes.MSP_COPY_PROFILE:
|
||||
console.log('Copy profile');
|
||||
break;
|
||||
case MSPCodes.MSP_ARMING_DISABLE:
|
||||
console.log('Arming disable');
|
||||
break;
|
||||
default:
|
||||
console.log('Unknown code detected: ' + code);
|
||||
} else {
|
||||
|
@ -1512,9 +1515,17 @@ MspHelper.prototype.crunch = function(code) {
|
|||
case MSPCodes.MSP_COPY_PROFILE:
|
||||
buffer.push8(COPY_PROFILE.type)
|
||||
.push8(COPY_PROFILE.dstProfile)
|
||||
.push8(COPY_PROFILE.srcProfile)
|
||||
.push8(COPY_PROFILE.srcProfile);
|
||||
break;
|
||||
case MSPCodes.MSP_ARMING_DISABLE:
|
||||
var value;
|
||||
if (CONFIG.arming_disabled) {
|
||||
value = 1;
|
||||
} else {
|
||||
value = 0;
|
||||
}
|
||||
buffer.push8(value);
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -61,38 +61,17 @@ $(document).ready(function () {
|
|||
GUI.tab_switch_cleanup();
|
||||
GUI.tab_switch_in_progress = false;
|
||||
|
||||
var wasConnected = CONFIGURATOR.connectionValid;
|
||||
if (semver.gte(CONFIG.apiVersion, "1.37.0")) {
|
||||
CONFIG.arming_disabled = false;
|
||||
|
||||
serial.disconnect(onClosed);
|
||||
MSP.send_message(MSPCodes.MSP_ARMING_DISABLE, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('armingEnabled'));
|
||||
|
||||
GUI.connected_to = false;
|
||||
GUI.allowedTabs = GUI.defaultAllowedTabsWhenDisconnected.slice();
|
||||
MSP.disconnect_cleanup();
|
||||
PortUsage.reset();
|
||||
|
||||
// Reset various UI elements
|
||||
$('span.i2c-error').text(0);
|
||||
$('span.cycle-time').text(0);
|
||||
if (semver.gte(CONFIG.apiVersion, "1.20.0"))
|
||||
$('span.cpu-load').text('');
|
||||
|
||||
// unlock port select & baud
|
||||
$('div#port-picker #port').prop('disabled', false);
|
||||
if (!GUI.auto_connect) $('div#port-picker #baud').prop('disabled', false);
|
||||
|
||||
// reset connect / disconnect button
|
||||
$('div.connect_controls a.connect').removeClass('active');
|
||||
$('div.connect_controls a.connect_state').text(chrome.i18n.getMessage('connect'));
|
||||
|
||||
// reset active sensor indicators
|
||||
sensor_status(0);
|
||||
|
||||
if (wasConnected) {
|
||||
// detach listeners and remove element data
|
||||
$('#content').empty();
|
||||
finishClose(clicks);
|
||||
});
|
||||
} else {
|
||||
finishClose(clicks);
|
||||
}
|
||||
|
||||
$('#tabs .tab_landing a').click();
|
||||
}
|
||||
|
||||
$(this).data("clicks", !clicks);
|
||||
|
@ -143,7 +122,40 @@ $(document).ready(function () {
|
|||
PortUsage.initialize();
|
||||
});
|
||||
|
||||
function finishClose(clicks) {
|
||||
var wasConnected = CONFIGURATOR.connectionValid;
|
||||
|
||||
serial.disconnect(onClosed);
|
||||
|
||||
MSP.disconnect_cleanup();
|
||||
PortUsage.reset();
|
||||
|
||||
GUI.connected_to = false;
|
||||
GUI.allowedTabs = GUI.defaultAllowedTabsWhenDisconnected.slice();
|
||||
// Reset various UI elements
|
||||
$('span.i2c-error').text(0);
|
||||
$('span.cycle-time').text(0);
|
||||
if (semver.gte(CONFIG.apiVersion, "1.20.0"))
|
||||
$('span.cpu-load').text('');
|
||||
|
||||
// unlock port select & baud
|
||||
$('div#port-picker #port').prop('disabled', false);
|
||||
if (!GUI.auto_connect) $('div#port-picker #baud').prop('disabled', false);
|
||||
|
||||
// reset connect / disconnect button
|
||||
$('div.connect_controls a.connect').removeClass('active');
|
||||
$('div.connect_controls a.connect_state').text(chrome.i18n.getMessage('connect'));
|
||||
|
||||
// reset active sensor indicators
|
||||
sensor_status(0);
|
||||
|
||||
if (wasConnected) {
|
||||
// detach listeners and remove element data
|
||||
$('#content').empty();
|
||||
}
|
||||
|
||||
$('#tabs .tab_landing a').click();
|
||||
}
|
||||
|
||||
|
||||
function onOpen(openInfo) {
|
||||
|
@ -214,12 +226,22 @@ function onOpen(openInfo) {
|
|||
MSP.send_message(MSPCodes.MSP_NAME, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('craftNameReceived', [CONFIG.name]));
|
||||
|
||||
if (semver.gte(CONFIG.apiVersion, "1.37.0")) {
|
||||
CONFIG.arming_disabled = true;
|
||||
|
||||
MSP.send_message(MSPCodes.MSP_ARMING_DISABLE, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('armingDisabled'));
|
||||
|
||||
finishOpen();
|
||||
});
|
||||
} else {
|
||||
finishOpen();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
finishOpen();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue