implement verison checking in conflicting msp commands

10.3.x-maintenance
nathan 2016-07-30 02:27:34 -07:00
parent efa10099d2
commit f9dbdf661d
2 changed files with 24 additions and 5 deletions

View File

@ -962,8 +962,8 @@ var MSP = {
break;
case MSP_codes.MSP_PID_ADVANCED:
if (semver.gte(CONFIG.flightControllerVersion, "2.8.2")) {
var offset = 0;
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
ADVANCED_TUNING.rollPitchItermIgnoreRate = data.getUint16(offset, 1);
offset += 2;
ADVANCED_TUNING.yawItermIgnoreRate = data.getUint16(offset, 1);
@ -982,6 +982,17 @@ var MSP = {
ADVANCED_TUNING.pidMaxVelocityYaw = data.getUint16(offset, 1);
offset += 2;
}
// intentionally supports only 1 version previous to 3.0.0
else {
ADVANCED_TUNING.rollPitchItermIgnoreRate = data.getUint16(offset, 1);
offset += 2;
ADVANCED_TUNING.yawItermIgnoreRate = data.getUint16(offset, 1);
offset += 2;
ADVANCED_TUNING.yaw_p_limit = data.getUint16(offset, 1);
offset += 2;
ADVANCED_TUNING.deltaMethod = data.getUint8(offset++, 1);
ADVANCED_TUNING.vbatPidCompensation = data.getUint8(offset++, 1);
}
break;
case MSP_codes.MSP_SPECIAL_PARAMETERS:
var offset = 0;
@ -1651,7 +1662,7 @@ MSP.crunch = function (code) {
.push16(FILTER_CONFIG.yaw_lpf_hz);
break;
case MSP_codes.MSP_SET_PID_ADVANCED:
if (semver.gte(CONFIG.flightControllerVersion, "2.8.2")) {
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
buffer.push16(ADVANCED_TUNING.rollPitchItermIgnoreRate)
.push16(ADVANCED_TUNING.yawItermIgnoreRate)
.push16(ADVANCED_TUNING.yaw_p_limit)
@ -1665,6 +1676,14 @@ MSP.crunch = function (code) {
.push16(ADVANCED_TUNING.pidMaxVelocity)
.push16(ADVANCED_TUNING.pidMaxVelocityYaw);
}
// only supports 1 version pre bf 3.0
else {
buffer.push16(ADVANCED_TUNING.rollPitchItermIgnoreRate)
.push16(ADVANCED_TUNING.yawItermIgnoreRate)
.push16(ADVANCED_TUNING.yaw_p_limit)
.push8(ADVANCED_TUNING.deltaMethod)
.push8(ADVANCED_TUNING.vbatPidCompensation);
}
break;
case MSP_codes.MSP_SET_SPECIAL_PARAMETERS:
buffer.push(Math.round(RC_tuning.yaw_rate * 100));

View File

@ -26,7 +26,7 @@ TABS.pid_tuning.initialize = function (callback) {
return MSP.promise(MSP_codes.MSP_SPECIAL_PARAMETERS);
}
}).then(function() {
if (semver.gte(CONFIG.apiVersion, "3.0.0")) {
if (semver.gte(CONFIG.apiVersion, "2.8.2")) {
return MSP.promise(MSP_codes.MSP_PID_ADVANCED);
}
}).then(function() {
@ -707,7 +707,7 @@ TABS.pid_tuning.initialize = function (callback) {
return MSP.promise(MSP_codes.MSP_SET_SPECIAL_PARAMETERS, MSP.crunch(MSP_codes.MSP_SET_SPECIAL_PARAMETERS));
}
}).then(function () {
if (semver.gte(CONFIG.apiVersion, "3.0.0")) {
if (semver.gte(CONFIG.apiVersion, "2.8.2")) {
return MSP.promise(MSP_codes.MSP_SET_PID_ADVANCED, MSP.crunch(MSP_codes.MSP_SET_PID_ADVANCED));
}
}).then(function () {