Commit 4f86dfa9 authored by Pawel Spychalski (DzikuVx)'s avatar Pawel Spychalski (DzikuVx)
Browse files

MSP layer

parent 0173efd8
......@@ -55,7 +55,8 @@ var CONFIG,
MIXER_CONFIG,
BATTERY_CONFIG,
OUTPUT_MAPPING,
SETTINGS;
SETTINGS,
BRAKING_CONFIG;
var FC = {
MAX_SERVO_RATE: 125,
......@@ -506,6 +507,17 @@ var FC = {
loiterRadius: null
};
BRAKING_CONFIG = {
speedThreshold: null,
disengageSpeed: null,
timeout: null,
boostFactor: null,
boostTimeout: null,
boostSpeedThreshold: null,
boostDisengageSpeed: null,
bankAngle: null
}
RXFAIL_CONFIG = [];
OUTPUT_MAPPING = new OutputMappingCollection();
......
......@@ -186,5 +186,8 @@ var MSPCodes = {
MSP2_INAV_OSD_PREFERENCES: 0x2016,
MSP2_INAV_OSD_SET_PREFERENCES: 0x2017,
MSP2_INAV_MC_BRAKING: 0x200B,
MSP2_INAV_SET_MC_BRAKING: 0x200C,
MSP2_INAV_SELECT_BATTERY_PROFILE: 0x2018
};
......@@ -1401,6 +1401,22 @@ var mspHelper = (function (gui) {
for (i = 0; i < data.byteLength; ++i)
OUTPUT_MAPPING.put(data.getUint8(i));
break;
case MSPCodes.MSP2_INAV_MC_BRAKING:
BRAKING_CONFIG.speedThreshold = data.getUint16(0, true);
BRAKING_CONFIG.disengageSpeed = data.getUint16(2, true);
BRAKING_CONFIG.timeout = data.getUint16(4, true);
BRAKING_CONFIG.boostFactor = data.getInt8(6);
BRAKING_CONFIG.boostTimeout = data.getUint16(7, true);
BRAKING_CONFIG.boostSpeedThreshold = data.getUint16(9, true);
BRAKING_CONFIG.boostDisengageSpeed = data.getUint16(11, true);
BRAKING_CONFIG.bankAngle = data.getInt8(13);
break;
case MSPCodes.MSP2_INAV_SET_MC_BRAKING:
console.log('Braking config saved');
break;
default:
console.log('Unknown code detected: ' + dataHandler.code);
} else {
......@@ -2038,6 +2054,26 @@ var mspHelper = (function (gui) {
buffer.push(highByte(MIXER_CONFIG.appliedMixerPreset));
break;
case MSPCodes.MSP2_INAV_SET_MC_BRAKING:
buffer.push(lowByte(BRAKING_CONFIG.speedThreshold));
buffer.push(highByte(BRAKING_CONFIG.speedThreshold));
buffer.push(lowByte(BRAKING_CONFIG.disengageSpeed));
buffer.push(highByte(BRAKING_CONFIG.disengageSpeed));
buffer.push(lowByte(BRAKING_CONFIG.timeout));
buffer.push(highByte(BRAKING_CONFIG.timeout));
buffer.push(BRAKING_CONFIG.boostFactor);
buffer.push(lowByte(BRAKING_CONFIG.boostTimeout));
buffer.push(highByte(BRAKING_CONFIG.boostTimeout));
buffer.push(lowByte(BRAKING_CONFIG.boostSpeedThreshold));
buffer.push(highByte(BRAKING_CONFIG.boostSpeedThreshold));
buffer.push(lowByte(BRAKING_CONFIG.boostDisengageSpeed));
buffer.push(highByte(BRAKING_CONFIG.boostDisengageSpeed));
buffer.push(BRAKING_CONFIG.bankAngle);
break;
default:
return false;
}
......@@ -3146,6 +3182,22 @@ var mspHelper = (function (gui) {
}
};
self.loadBrakingConfig = function(callback) {
if (semver.gte(CONFIG.flightControllerVersion, "2.1.0")) {
MSP.send_message(MSPCodes.MSP2_INAV_MC_BRAKING, false, false, callback);
} else {
callback();
}
}
self.saveBrakingConfig = function(callback) {
if (semver.gte(CONFIG.flightControllerVersion, "2.1.0")) {
MSP.send_message(MSPCodes.MSP2_INAV_SET_MC_BRAKING, mspHelper.crunch(MSPCodes.MSP2_INAV_SET_MC_BRAKING), false, callback);
} else {
callback();
}
};
self.loadParameterGroups = function(callback) {
if (semver.gte(CONFIG.flightControllerVersion, "2.0.0")) {
MSP.send_message(MSPCodes.MSP2_COMMON_PG_LIST, false, false, function (resp) {
......
This diff is collapsed.
......@@ -16,7 +16,8 @@ TABS.advanced_tuning.initialize = function (callback) {
mspHelper.loadNavPosholdConfig,
mspHelper.loadPositionEstimationConfig,
mspHelper.loadRthAndLandConfig,
mspHelper.loadFwConfig
mspHelper.loadFwConfig,
mspHelper.loadBrakingConfig
]);
loadChainer.setExitPoint(loadHtml);
loadChainer.execute();
......@@ -26,6 +27,7 @@ TABS.advanced_tuning.initialize = function (callback) {
mspHelper.savePositionEstimationConfig,
mspHelper.saveRthAndLandConfig,
mspHelper.saveFwConfig,
mspHelper.saveBrakingConfig,
mspHelper.saveToEeprom
]);
saveChainer.setExitPoint(reboot);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment