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

Merge branch 'master' into rc_smoothing

This commit is contained in:
Sean M 2018-08-11 20:59:00 -04:00
commit f4ea605685
45 changed files with 18196 additions and 463 deletions

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;
@ -871,7 +888,11 @@ MspHelper.prototype.process_data = function(dataHandler) {
ADVANCED_TUNING.deltaMethod = data.readU8();
ADVANCED_TUNING.vbatPidCompensation = data.readU8();
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
ADVANCED_TUNING.dtermSetpointTransition = data.readU8();
if (semver.gte(CONFIG.apiVersion, "1.40.0")) {
ADVANCED_TUNING.feedforwardTransition = data.readU8();
} else {
ADVANCED_TUNING.dtermSetpointTransition = data.readU8();
}
ADVANCED_TUNING.dtermSetpointWeight = data.readU8();
ADVANCED_TUNING.toleranceBand = data.readU8();
ADVANCED_TUNING.toleranceBandReduction = data.readU8();
@ -881,13 +902,29 @@ MspHelper.prototype.process_data = function(dataHandler) {
if (semver.gte(CONFIG.apiVersion, "1.24.0")) {
ADVANCED_TUNING.levelAngleLimit = data.readU8();
ADVANCED_TUNING.levelSensitivity = data.readU8();
}
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
ADVANCED_TUNING.itermThrottleThreshold = data.readU16();
ADVANCED_TUNING.itermAcceleratorGain = data.readU16();
}
if (semver.gte(CONFIG.apiVersion, "1.39.0")) {
ADVANCED_TUNING.dtermSetpointWeight = data.readU16();
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
ADVANCED_TUNING.itermThrottleThreshold = data.readU16();
ADVANCED_TUNING.itermAcceleratorGain = data.readU16();
if (semver.gte(CONFIG.apiVersion, "1.39.0")) {
ADVANCED_TUNING.dtermSetpointWeight = data.readU16();
if (semver.gte(CONFIG.apiVersion, "1.40.0")) {
ADVANCED_TUNING.itermRotation = data.readU8();
ADVANCED_TUNING.smartFeedforward = data.readU8();
ADVANCED_TUNING.itermRelax = data.readU8();
ADVANCED_TUNING.itermRelaxType = data.readU8();
ADVANCED_TUNING.absoluteControlGain = data.readU8();
ADVANCED_TUNING.throttleBoost = data.readU8();
ADVANCED_TUNING.acroTrainerAngleLimit = data.readU8();
ADVANCED_TUNING.feedforwardRoll = data.readU16();
ADVANCED_TUNING.feedforwardPitch = data.readU16();
ADVANCED_TUNING.feedforwardYaw = data.readU16();
ADVANCED_TUNING.antiGravityMode = data.readU8();
}
}
}
}
}
break;
@ -1119,7 +1156,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
case MSPCodes.MSP_SET_ADJUSTMENT_RANGE:
console.log('Adjustment range saved');
break;
case MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG:
console.log('Board alignment saved');
break;
case MSPCodes.MSP_PID_CONTROLLER:
PID.controller = data.readU8();
break;
@ -1195,6 +1234,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
@ -1217,7 +1261,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.
*/
@ -1526,24 +1569,47 @@ MspHelper.prototype.crunch = function(code) {
.push16(ADVANCED_TUNING.yawItermIgnoreRate)
.push16(ADVANCED_TUNING.yaw_p_limit)
.push8(ADVANCED_TUNING.deltaMethod)
.push8(ADVANCED_TUNING.vbatPidCompensation)
.push8(ADVANCED_TUNING.dtermSetpointTransition)
.push8(Math.min(ADVANCED_TUNING.dtermSetpointWeight, 254))
.push8(ADVANCED_TUNING.toleranceBand)
.push8(ADVANCED_TUNING.toleranceBandReduction)
.push8(ADVANCED_TUNING.itermThrottleGain)
.push16(ADVANCED_TUNING.pidMaxVelocity)
.push16(ADVANCED_TUNING.pidMaxVelocityYaw);
.push8(ADVANCED_TUNING.vbatPidCompensation);
if (semver.gte(CONFIG.apiVersion, "1.40.0")) {
buffer.push8(ADVANCED_TUNING.feedforwardTransition);
} else {
buffer.push8(ADVANCED_TUNING.dtermSetpointTransition);
}
buffer.push8(Math.min(ADVANCED_TUNING.dtermSetpointWeight, 254))
.push8(ADVANCED_TUNING.toleranceBand)
.push8(ADVANCED_TUNING.toleranceBandReduction)
.push8(ADVANCED_TUNING.itermThrottleGain)
.push16(ADVANCED_TUNING.pidMaxVelocity)
.push16(ADVANCED_TUNING.pidMaxVelocityYaw);
if (semver.gte(CONFIG.apiVersion, "1.24.0")) {
buffer.push8(ADVANCED_TUNING.levelAngleLimit)
.push8(ADVANCED_TUNING.levelSensitivity);
}
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
buffer.push16(ADVANCED_TUNING.itermThrottleThreshold)
.push16(ADVANCED_TUNING.itermAcceleratorGain);
}
if (semver.gte(CONFIG.apiVersion, "1.39.0")) {
buffer.push16(ADVANCED_TUNING.dtermSetpointWeight);
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
buffer.push16(ADVANCED_TUNING.itermThrottleThreshold)
.push16(ADVANCED_TUNING.itermAcceleratorGain);
if (semver.gte(CONFIG.apiVersion, "1.39.0")) {
buffer.push16(ADVANCED_TUNING.dtermSetpointWeight);
if (semver.gte(CONFIG.apiVersion, "1.40.0")) {
buffer.push8(ADVANCED_TUNING.itermRotation)
.push8(ADVANCED_TUNING.smartFeedforward)
.push8(ADVANCED_TUNING.itermRelax)
.push8(ADVANCED_TUNING.itermRelaxType)
.push8(ADVANCED_TUNING.absoluteControlGain)
.push8(ADVANCED_TUNING.throttleBoost)
.push8(ADVANCED_TUNING.acroTrainerAngleLimit)
.push16(ADVANCED_TUNING.feedforwardRoll)
.push16(ADVANCED_TUNING.feedforwardPitch)
.push16(ADVANCED_TUNING.feedforwardYaw)
.push8(ADVANCED_TUNING.antiGravityMode);
}
}
}
}
}
// only supports 1 version pre bf 3.0
@ -1894,7 +1960,6 @@ MspHelper.prototype.sendCurrentConfig = function(onCompleteCallback) {
}
MspHelper.prototype.sendLedStripConfig = function(onCompleteCallback) {
var nextFunction = send_next_led_strip_config;