mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-26 01:35:28 +03:00
Merge branch 'development' into thenickdude-private-development
Conflicts: js/msp.js
This commit is contained in:
commit
251712c85d
11 changed files with 165 additions and 70 deletions
|
@ -984,6 +984,12 @@
|
|||
"cliInputPlaceholder": {
|
||||
"message": "Write your command here"
|
||||
},
|
||||
"cliEnter": {
|
||||
"message": "CLI mode detected"
|
||||
},
|
||||
"cliReboot": {
|
||||
"message": "CLI reboot detected"
|
||||
},
|
||||
|
||||
"loggingNote": {
|
||||
"message": "Data will be logged in this tab <span style=\"color: red\">only</span>, leaving the tab will <span style=\"color: red\">cancel</span> logging and application will return to its normal <strong>\"configurator\"</strong> state.<br /> You are free to select the global update period, data will be written into the log file every <strong>1</strong> second for performance reasons."
|
||||
|
|
|
@ -676,7 +676,6 @@ function configuration_restore(callback) {
|
|||
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
|
||||
uniqueData.push(MSP_codes.MSP_SET_RX_CONFIG);
|
||||
uniqueData.push(MSP_codes.MSP_SET_FAILSAFE_CONFIG);
|
||||
uniqueData.push(MSP_codes.MSP_SET_RXFAIL_CONFIG);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -701,7 +700,7 @@ function configuration_restore(callback) {
|
|||
send_unique_data_item();
|
||||
});
|
||||
} else {
|
||||
MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, send_led_strip_config);
|
||||
send_led_strip_config();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -714,7 +713,19 @@ function configuration_restore(callback) {
|
|||
}
|
||||
|
||||
function send_led_strip_config() {
|
||||
MSP.sendLedStripConfig(reboot);
|
||||
MSP.sendLedStripConfig(send_rxfail_config);
|
||||
}
|
||||
|
||||
function send_rxfail_config() {
|
||||
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
|
||||
MSP.sendRxFailConfig(save_to_eeprom);
|
||||
} else {
|
||||
save_to_eeprom();
|
||||
}
|
||||
}
|
||||
|
||||
function save_to_eeprom() {
|
||||
MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, reboot);
|
||||
}
|
||||
|
||||
function reboot() {
|
||||
|
|
61
js/msp.js
61
js/msp.js
|
@ -803,12 +803,14 @@ var MSP = {
|
|||
offset++;
|
||||
FAILSAFE_CONFIG.failsafe_throttle = data.getUint16(offset, 1);
|
||||
offset += 2;
|
||||
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
|
||||
FAILSAFE_CONFIG.failsafe_kill_switch = data.getUint8(offset, 1);
|
||||
offset++;
|
||||
FAILSAFE_CONFIG.failsafe_throttle_low_delay = data.getUint16(offset, 1);
|
||||
offset += 2;
|
||||
FAILSAFE_CONFIG.failsafe_procedure = data.getUint8(offset, 1);
|
||||
offset++;
|
||||
}
|
||||
break;
|
||||
|
||||
case MSP_codes.MSP_RXFAIL_CONFIG:
|
||||
|
@ -1203,17 +1205,11 @@ MSP.crunch = function (code) {
|
|||
buffer.push(FAILSAFE_CONFIG.failsafe_off_delay);
|
||||
buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_throttle));
|
||||
buffer.push(highByte(FAILSAFE_CONFIG.failsafe_throttle));
|
||||
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
|
||||
buffer.push(FAILSAFE_CONFIG.failsafe_kill_switch);
|
||||
buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_throttle_low_delay));
|
||||
buffer.push(highByte(FAILSAFE_CONFIG.failsafe_throttle_low_delay));
|
||||
buffer.push(FAILSAFE_CONFIG.failsafe_procedure);
|
||||
break;
|
||||
|
||||
case MSP_codes.MSP_SET_RXFAIL_CONFIG:
|
||||
for (var i = 0; i < RXFAIL_CONFIG.length; i++) {
|
||||
buffer.push(RXFAIL_CONFIG[i].mode);
|
||||
buffer.push(lowByte(RXFAIL_CONFIG[i].value));
|
||||
buffer.push(highByte(RXFAIL_CONFIG[i].value));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1350,9 +1346,9 @@ MSP.sendServoConfigurations = function(onCompleteCallback) {
|
|||
|
||||
if (SERVO_CONFIG.length == 0) {
|
||||
onCompleteCallback();
|
||||
}
|
||||
|
||||
} else {
|
||||
nextFunction();
|
||||
}
|
||||
|
||||
function send_next_servo_configuration() {
|
||||
|
||||
|
@ -1440,10 +1436,9 @@ MSP.sendModeRanges = function(onCompleteCallback) {
|
|||
|
||||
if (MODE_RANGES.length == 0) {
|
||||
onCompleteCallback();
|
||||
}
|
||||
|
||||
} else {
|
||||
send_next_mode_range();
|
||||
|
||||
}
|
||||
|
||||
function send_next_mode_range() {
|
||||
|
||||
|
@ -1473,10 +1468,9 @@ MSP.sendAdjustmentRanges = function(onCompleteCallback) {
|
|||
|
||||
if (ADJUSTMENT_RANGES.length == 0) {
|
||||
onCompleteCallback();
|
||||
}
|
||||
|
||||
} else {
|
||||
send_next_adjustment_range();
|
||||
|
||||
}
|
||||
|
||||
function send_next_adjustment_range() {
|
||||
|
||||
|
@ -1509,9 +1503,9 @@ MSP.sendLedStripConfig = function(onCompleteCallback) {
|
|||
|
||||
if (LED_STRIP.length == 0) {
|
||||
onCompleteCallback();
|
||||
}
|
||||
|
||||
} else {
|
||||
send_next_led_strip_config();
|
||||
}
|
||||
|
||||
function send_next_led_strip_config() {
|
||||
|
||||
|
@ -1579,8 +1573,41 @@ MSP.serialPortFunctionsToMask = function(functions) {
|
|||
return mask;
|
||||
}
|
||||
|
||||
MSP.sendRxFailConfig = function(onCompleteCallback) {
|
||||
var nextFunction = send_next_rxfail_config;
|
||||
|
||||
var rxFailIndex = 0;
|
||||
|
||||
if (RXFAIL_CONFIG.length == 0) {
|
||||
onCompleteCallback();
|
||||
} else {
|
||||
send_next_rxfail_config();
|
||||
}
|
||||
|
||||
function send_next_rxfail_config() {
|
||||
|
||||
var rxFail = RXFAIL_CONFIG[rxFailIndex];
|
||||
|
||||
var buffer = [];
|
||||
buffer.push(rxFailIndex);
|
||||
buffer.push(rxFail.mode);
|
||||
buffer.push(lowByte(rxFail.value));
|
||||
buffer.push(highByte(rxFail.value));
|
||||
|
||||
// prepare for next iteration
|
||||
rxFailIndex++;
|
||||
if (rxFailIndex == RXFAIL_CONFIG.length) {
|
||||
nextFunction = onCompleteCallback;
|
||||
|
||||
}
|
||||
MSP.send_message(MSP_codes.MSP_SET_RXFAIL_CONFIG, buffer, false, nextFunction);
|
||||
}
|
||||
};
|
||||
|
||||
MSP.SDCARD_STATE_NOT_PRESENT = 0;
|
||||
MSP.SDCARD_STATE_FATAL = 1;
|
||||
MSP.SDCARD_STATE_CARD_INIT = 2;
|
||||
MSP.SDCARD_STATE_FS_INIT = 3;
|
||||
MSP.SDCARD_STATE_READY = 4;
|
||||
|
||||
|
||||
|
|
|
@ -68,6 +68,12 @@ var serial = {
|
|||
});
|
||||
}
|
||||
break;
|
||||
case 'break':
|
||||
// This occurs on F1 boards with old firmware.
|
||||
if (GUI.connected_to || GUI.connecting_to) {
|
||||
$('a.connect').click();
|
||||
}
|
||||
break;
|
||||
case 'timeout':
|
||||
// TODO
|
||||
break;
|
||||
|
|
54
tabs/cli.js
54
tabs/cli.js
|
@ -2,6 +2,7 @@
|
|||
|
||||
TABS.cli = {
|
||||
'validateText': "",
|
||||
'currentLine': "",
|
||||
'sequenceElements': 0
|
||||
};
|
||||
|
||||
|
@ -19,14 +20,6 @@ TABS.cli.initialize = function (callback) {
|
|||
|
||||
CONFIGURATOR.cliActive = true;
|
||||
|
||||
// Enter CLI mode
|
||||
var bufferOut = new ArrayBuffer(1);
|
||||
var bufView = new Uint8Array(bufferOut);
|
||||
|
||||
bufView[0] = 0x23; // #
|
||||
|
||||
serial.send(bufferOut);
|
||||
|
||||
var textarea = $('.tab-cli textarea');
|
||||
|
||||
textarea.keypress(function (event) {
|
||||
|
@ -62,6 +55,16 @@ TABS.cli.initialize = function (callback) {
|
|||
// give input element user focus
|
||||
textarea.focus();
|
||||
|
||||
GUI.timeout_add('enter_cli', function enter_cli() {
|
||||
// Enter CLI mode
|
||||
var bufferOut = new ArrayBuffer(1);
|
||||
var bufView = new Uint8Array(bufferOut);
|
||||
|
||||
bufView[0] = 0x23; // #
|
||||
|
||||
serial.send(bufferOut);
|
||||
}, 250);
|
||||
|
||||
GUI.content_ready(callback);
|
||||
});
|
||||
};
|
||||
|
@ -135,11 +138,13 @@ TABS.cli.read = function (readInfo) {
|
|||
if (GUI.operating_system != "MacOS") {
|
||||
text += "<br />";
|
||||
}
|
||||
this.currentLine = "";
|
||||
break;
|
||||
case 13: // carriage return
|
||||
if (GUI.operating_system == "MacOS") {
|
||||
text += "<br />";
|
||||
}
|
||||
this.currentLine = "";
|
||||
break;
|
||||
case 60:
|
||||
text += '<';
|
||||
|
@ -150,19 +155,41 @@ TABS.cli.read = function (readInfo) {
|
|||
|
||||
default:
|
||||
text += String.fromCharCode(data[i]);
|
||||
this.currentLine += String.fromCharCode(data[i]);
|
||||
}
|
||||
}
|
||||
if (this.currentLine == 'Rebooting') {
|
||||
CONFIGURATOR.cliActive = false;
|
||||
CONFIGURATOR.cliValid = false;
|
||||
GUI.log(chrome.i18n.getMessage('cliReboot'));
|
||||
GUI.log(chrome.i18n.getMessage('deviceRebooting'));
|
||||
|
||||
if (BOARD.find_board_definition(CONFIG.boardIdentifier).vcp) { // VCP-based flight controls may crash old drivers, we catch and reconnect
|
||||
$('a.connect').click();
|
||||
GUI.timeout_add('start_connection',function start_connection() {
|
||||
$('a.connect').click();
|
||||
},2500);
|
||||
} else {
|
||||
|
||||
GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() {
|
||||
MSP.send_message(MSP_codes.MSP_IDENT, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('deviceReady'));
|
||||
$('#tabs ul.mode-connected .tab_setup a').click();
|
||||
});
|
||||
},1500); // 1500 ms seems to be just the right amount of delay to prevent data request timeouts
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// try to catch part of valid CLI enter message
|
||||
this.validateText += String.fromCharCode(data[i]);
|
||||
text += String.fromCharCode(data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!CONFIGURATOR.cliValid && this.validateText.indexOf('CLI') != -1) {
|
||||
GUI.log(chrome.i18n.getMessage('cliEnter'));
|
||||
CONFIGURATOR.cliValid = true;
|
||||
this.validateText = "";
|
||||
|
||||
text = "Entering CLI Mode, type 'exit' to return, or 'help'<br /><br /># ";
|
||||
}
|
||||
|
||||
$('.tab-cli .window .wrapper').append(text);
|
||||
|
@ -170,7 +197,7 @@ TABS.cli.read = function (readInfo) {
|
|||
};
|
||||
|
||||
TABS.cli.cleanup = function (callback) {
|
||||
if (!CONFIGURATOR.connectionValid) {
|
||||
if (!CONFIGURATOR.connectionValid || !CONFIGURATOR.cliValid) {
|
||||
if (callback) callback();
|
||||
return;
|
||||
}
|
||||
|
@ -190,10 +217,7 @@ TABS.cli.cleanup = function (callback) {
|
|||
// we can setup an interval asking for data lets say every 200ms, when data arrives, callback will be triggered and tab switched
|
||||
// we could probably implement this someday
|
||||
GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() {
|
||||
CONFIGURATOR.cliActive = false;
|
||||
CONFIGURATOR.cliValid = false;
|
||||
|
||||
if (callback) callback();
|
||||
}, 5000); // if we dont allow enough time to reboot, CRC of "first" command sent will fail, keep an eye for this one
|
||||
}, 1000); // if we dont allow enough time to reboot, CRC of "first" command sent will fail, keep an eye for this one
|
||||
});
|
||||
};
|
||||
|
|
|
@ -493,7 +493,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
$('a.connect').click();
|
||||
GUI.timeout_add('start_connection',function start_connection() {
|
||||
$('a.connect').click();
|
||||
},2000);
|
||||
},2500);
|
||||
} else {
|
||||
|
||||
GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() {
|
||||
|
|
|
@ -317,7 +317,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
|
|||
}
|
||||
|
||||
function save_rxfail_config() {
|
||||
MSP.send_message(MSP_codes.MSP_SET_RXFAIL_CONFIG, MSP.crunch(MSP_codes.MSP_SET_RXFAIL_CONFIG), false, save_bf_config);
|
||||
MSP.sendRxFailConfig(save_bf_config);
|
||||
}
|
||||
|
||||
function save_bf_config() {
|
||||
|
@ -349,7 +349,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
|
|||
$('a.connect').click();
|
||||
GUI.timeout_add('start_connection',function start_connection() {
|
||||
$('a.connect').click();
|
||||
},2000);
|
||||
},2500);
|
||||
} else {
|
||||
|
||||
GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() {
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
<li><a href="http://www.scorpionsystem.com" title="www.scorpionsystem.com" target="_blank">Scorpion
|
||||
Power Systems</a></li>
|
||||
<li><a href="http://www.multigp.com" title="www.multigp.com" target="_blank">MultiGP</a></li>
|
||||
<li><a href="makeitbuildit.co.uk" title="makeitbuildit.co.uk" target="_blank">MakeItBuildIt</a></li>
|
||||
<li><a href="http://makeitbuildit.co.uk" title="makeitbuildit.co.uk" target="_blank">MakeItBuildIt</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -118,7 +118,7 @@
|
|||
</div>
|
||||
<div class="notice">
|
||||
<p i18n="motorsNotice"></p>
|
||||
<label><input id="motorsEnableTestMode" class="togglesmall" type="checkbox" /><span
|
||||
<label><input id="motorsEnableTestMode" type="checkbox" /><span
|
||||
class="motorsEnableTestMode" i18n="motorsEnableControl"></span></label>
|
||||
</div>
|
||||
<div class="cler-both"></div>
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
'use strict';
|
||||
|
||||
TABS.motors = {};
|
||||
TABS.motors = {
|
||||
allowTestMode: false,
|
||||
feature3DEnabled: false,
|
||||
feature3DSupported: false
|
||||
};
|
||||
TABS.motors.initialize = function (callback) {
|
||||
var self = this;
|
||||
|
||||
self.armed = false;
|
||||
self.feature3DSupported = false;
|
||||
self.allowTestMode = true;
|
||||
|
||||
if (GUI.active_tab != 'motors') {
|
||||
GUI.active_tab = 'motors';
|
||||
|
@ -20,11 +26,14 @@ TABS.motors.initialize = function (callback) {
|
|||
}
|
||||
|
||||
function load_3d() {
|
||||
MSP.send_message(MSP_codes.MSP_3D, false, false, get_motor_data);
|
||||
var next_callback = get_motor_data;
|
||||
if (semver.gte(CONFIG.apiVersion, "1.14.0")) {
|
||||
self.feature3DSupported = true;
|
||||
MSP.send_message(MSP_codes.MSP_3D, false, false, next_callback);
|
||||
} else {
|
||||
next_callback();
|
||||
}
|
||||
|
||||
function update_arm_status() {
|
||||
self.armed = bit_check(CONFIG.mode, 0);
|
||||
}
|
||||
|
||||
function get_motor_data() {
|
||||
|
@ -38,6 +47,10 @@ TABS.motors.initialize = function (callback) {
|
|||
|
||||
MSP.send_message(MSP_codes.MSP_MISC, false, false, get_arm_status);
|
||||
|
||||
function update_arm_status() {
|
||||
self.armed = bit_check(CONFIG.mode, 0);
|
||||
}
|
||||
|
||||
function initSensorData() {
|
||||
for (var i = 0; i < 3; i++) {
|
||||
SENSOR_DATA.accelerometer[i] = 0;
|
||||
|
@ -164,6 +177,12 @@ TABS.motors.initialize = function (callback) {
|
|||
// translate to user-selected language
|
||||
localize();
|
||||
|
||||
self.feature3DEnabled = bit_check(BF_CONFIG.features, 12);
|
||||
|
||||
if (self.feature3DEnabled && !self.feature3DSupported) {
|
||||
self.allowTestMode = false;
|
||||
}
|
||||
|
||||
$('#motorsEnableTestMode').prop('disabled', 'true');
|
||||
|
||||
update_model(CONFIG.multiType);
|
||||
|
@ -297,9 +316,9 @@ TABS.motors.initialize = function (callback) {
|
|||
$('div.sliders input').prop('max', MISC.maxthrottle);
|
||||
$('div.values li:not(:last)').text(MISC.mincommand);
|
||||
|
||||
if(bit_check(BF_CONFIG.features,12)){
|
||||
if(self.feature3DEnabled && self.feature3DSupported) {
|
||||
$('div.sliders input').val(_3D.neutral3d);
|
||||
}else{
|
||||
} else {
|
||||
$('div.sliders input').val(MISC.mincommand);
|
||||
}
|
||||
|
||||
|
@ -354,10 +373,10 @@ TABS.motors.initialize = function (callback) {
|
|||
$('div.sliders input').prop('disabled', true);
|
||||
|
||||
// change all values to default
|
||||
if (! bit_check(BF_CONFIG.features,12)) {
|
||||
$('div.sliders input').val(MISC.mincommand);
|
||||
} else {
|
||||
if (self.feature3DEnabled && self.feature3DSupported) {
|
||||
$('div.sliders input').val(_3D.neutral3d);
|
||||
} else {
|
||||
$('div.sliders input').val(MISC.mincommand);
|
||||
}
|
||||
|
||||
// trigger change event so values are sent to mcu
|
||||
|
@ -439,8 +458,10 @@ TABS.motors.initialize = function (callback) {
|
|||
$('#motorsEnableTestMode').prop('disabled', true);
|
||||
$('#motorsEnableTestMode').prop('checked', false);
|
||||
} else {
|
||||
if (self.allowTestMode) {
|
||||
$('#motorsEnableTestMode').prop('disabled', false);
|
||||
}
|
||||
}
|
||||
|
||||
if (previousArmState != self.armed) {
|
||||
console.log('arm state change detected');
|
||||
|
|
|
@ -266,7 +266,7 @@ TABS.ports.initialize = function (callback, scrollPosition) {
|
|||
$('a.connect').click();
|
||||
GUI.timeout_add('start_connection',function start_connection() {
|
||||
$('a.connect').click();
|
||||
},2000);
|
||||
},2500);
|
||||
} else {
|
||||
GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() {
|
||||
MSP.send_message(MSP_codes.MSP_IDENT, false, false, function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue