CF/BF - Reinstate support for MSP_MISC and some older versions of
betaflight. Also fix missing save of GPS and Compass configuration.10.3.x-maintenance
parent
5ab9d07ff7
commit
2241f33ca2
12
js/fc.js
12
js/fc.js
|
@ -34,6 +34,7 @@ var BATTERY_STATE;
|
|||
var BATTERY_CONFIG;
|
||||
var ARMING_CONFIG;
|
||||
var FC_CONFIG;
|
||||
var MISC; // DEPRECATED
|
||||
var MOTOR_CONFIG;
|
||||
var GPS_CONFIG;
|
||||
var COMPASS_CONFIG;
|
||||
|
@ -211,6 +212,17 @@ var FC = {
|
|||
loopTime: 0
|
||||
};
|
||||
|
||||
MISC = {
|
||||
// DEPRECATED = only used to store values that are written back to the fc as-is, do NOT use for any other purpose
|
||||
failsafe_throttle: 0,
|
||||
gps_baudrate: 0,
|
||||
multiwiicurrentoutput: 0,
|
||||
placeholder2: 0,
|
||||
vbatscale: 0,
|
||||
vbatmincellvoltage: 0,
|
||||
vbatmaxcellvoltage: 0,
|
||||
vbatwarningcellvoltage: 0,
|
||||
};
|
||||
MOTOR_CONFIG = {
|
||||
minthrottle: 0,
|
||||
maxthrottle: 0,
|
||||
|
|
|
@ -44,8 +44,8 @@ var MSPCodes = {
|
|||
MSP_SET_ARMING_CONFIG: 62,
|
||||
MSP_RX_MAP: 64,
|
||||
MSP_SET_RX_MAP: 65,
|
||||
//MSP_BF_CONFIG: 66, // DEPRECATED
|
||||
//MSP_SET_BF_CONFIG: 67, // DEPRECATED
|
||||
MSP_BF_CONFIG: 66, // DEPRECATED
|
||||
MSP_SET_BF_CONFIG: 67, // DEPRECATED
|
||||
MSP_SET_REBOOT: 68,
|
||||
MSP_BF_BUILD_INFO: 69, // Not used
|
||||
MSP_DATAFLASH_SUMMARY: 70,
|
||||
|
@ -92,7 +92,7 @@ var MSPCodes = {
|
|||
MSP_RC_TUNING: 111,
|
||||
MSP_PID: 112,
|
||||
//MSP_BOX: 113, // DEPRECATED
|
||||
//MSP_MISC: 114, // DEPRECATED
|
||||
MSP_MISC: 114, // DEPRECATED
|
||||
MSP_BOXNAMES: 116,
|
||||
MSP_PIDNAMES: 117,
|
||||
MSP_WP: 118, // Not used
|
||||
|
@ -124,7 +124,7 @@ var MSPCodes = {
|
|||
MSP_SET_RC_TUNING: 204,
|
||||
MSP_ACC_CALIBRATION: 205,
|
||||
MSP_MAG_CALIBRATION: 206,
|
||||
//MSP_SET_MISC: 207, // DEPRECATED
|
||||
MSP_SET_MISC: 207, // DEPRECATED
|
||||
MSP_RESET_CONF: 208,
|
||||
MSP_SET_WP: 209, // Not used
|
||||
MSP_SELECT_SETTING: 210,
|
||||
|
|
|
@ -151,7 +151,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
|||
case MSPCodes.MSP_SONAR:
|
||||
SENSOR_DATA.sonar = data.read32();
|
||||
break;
|
||||
case MSPCodes.MSP_ANALOG:
|
||||
case MSPCodes.MSP_ANALOG:
|
||||
ANALOG.voltage = data.readU8() / 10.0;
|
||||
ANALOG.mAhdrawn = data.readU16();
|
||||
ANALOG.rssi = data.readU16(); // 0-1023
|
||||
|
@ -292,6 +292,32 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
|||
ARMING_CONFIG.disarm_kill_switch = data.readU8();
|
||||
}
|
||||
break;
|
||||
case MSPCodes.MSP_LOOP_TIME:
|
||||
if (semver.gte(CONFIG.apiVersion, "1.8.0")) {
|
||||
FC_CONFIG.loopTime = data.readU16();
|
||||
}
|
||||
break;
|
||||
case MSPCodes.MSP_MISC: // 22 bytes
|
||||
RX_CONFIG.midrc = data.readU16();
|
||||
MOTOR_CONFIG.minthrottle = data.readU16(); // 0-2000
|
||||
MOTOR_CONFIG.maxthrottle = data.readU16(); // 0-2000
|
||||
MOTOR_CONFIG.mincommand = data.readU16(); // 0-2000
|
||||
MISC.failsafe_throttle = data.readU16(); // 1000-2000
|
||||
GPS_CONFIG.provider = data.readU8();
|
||||
MISC.gps_baudrate = data.readU8();
|
||||
GPS_CONFIG.ublox_sbas = data.readU8();
|
||||
MISC.multiwiicurrentoutput = data.readU8();
|
||||
RSSI_CONFIG.channel = data.readU8();
|
||||
MISC.placeholder2 = data.readU8();
|
||||
if (semver.lt(CONFIG.apiVersion, "1.18.0"))
|
||||
COMPASS_CONFIG.mag_declination = data.read16() / 10; // -1800-1800
|
||||
else
|
||||
COMPASS_CONFIG.mag_declination = data.read16() / 100; // -18000-18000
|
||||
MISC.vbatscale = data.readU8(); // was MISC.vbatscale - 10-200
|
||||
MISC.vbatmincellvoltage = data.readU8() / 10; // 10-50
|
||||
MISC.vbatmaxcellvoltage = data.readU8() / 10; // 10-50
|
||||
MISC.vbatwarningcellvoltage = data.readU8() / 10; // 10-50
|
||||
break;
|
||||
case MSPCodes.MSP_MOTOR_CONFIG:
|
||||
MOTOR_CONFIG.minthrottle = data.readU16(); // 0-2000
|
||||
MOTOR_CONFIG.maxthrottle = data.readU16(); // 0-2000
|
||||
|
@ -1154,6 +1180,31 @@ MspHelper.prototype.crunch = function(code) {
|
|||
buffer.push8(ARMING_CONFIG.auto_disarm_delay)
|
||||
.push8(ARMING_CONFIG.disarm_kill_switch);
|
||||
break;
|
||||
case MSPCodes.MSP_SET_LOOP_TIME:
|
||||
buffer.push16(FC_CONFIG.loopTime);
|
||||
break;
|
||||
case MSPCodes.MSP_SET_MISC:
|
||||
buffer.push16(RX_CONFIG.midrc)
|
||||
.push16(MOTOR_CONFIG.minthrottle)
|
||||
.push16(MOTOR_CONFIG.maxthrottle)
|
||||
.push16(MOTOR_CONFIG.mincommand)
|
||||
.push16(MISC.failsafe_throttle)
|
||||
.push8(GPS_CONFIG.provider)
|
||||
.push8(MISC.gps_baudrate)
|
||||
.push8(GPS_CONFIG.ublox_sbas)
|
||||
.push8(MISC.multiwiicurrentoutput)
|
||||
.push8(RSSI_CONFIG.channel)
|
||||
.push8(MISC.placeholder2);
|
||||
if (semver.lt(CONFIG.apiVersion, "1.18.0")) {
|
||||
buffer.push16(Math.round(COMPASS_CONFIG.mag_declination * 10));
|
||||
} else {
|
||||
buffer.push16(Math.round(COMPASS_CONFIG.mag_declination * 100));
|
||||
}
|
||||
buffer.push8(MISC.vbatscale)
|
||||
.push8(Math.round(MISC.vbatmincellvoltage * 10))
|
||||
.push8(Math.round(MISC.vbatmaxcellvoltage * 10))
|
||||
.push8(Math.round(MISC.vbatwarningcellvoltage * 10));
|
||||
break;
|
||||
case MSPCodes.MSP_SET_MOTOR_CONFIG:
|
||||
buffer.push16(MOTOR_CONFIG.minthrottle)
|
||||
.push16(MOTOR_CONFIG.maxthrottle)
|
||||
|
|
|
@ -36,21 +36,45 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
}
|
||||
|
||||
function load_motor_config() {
|
||||
MSP.send_message(MSPCodes.MSP_MOTOR_CONFIG, false, false, load_compass_config);
|
||||
var next_callback = load_compass_config;
|
||||
if(semver.gte(CONFIG.apiVersion, "1.33.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_MOTOR_CONFIG, false, false, next_callback);
|
||||
} else {
|
||||
next_callback();
|
||||
}
|
||||
}
|
||||
|
||||
function load_compass_config() {
|
||||
MSP.send_message(MSPCodes.MSP_COMPASS_CONFIG, false, false, load_gps_config);
|
||||
var next_callback = load_gps_config;
|
||||
if(semver.gte(CONFIG.apiVersion, "1.33.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_COMPASS_CONFIG, false, false, load_gps_config);
|
||||
} else {
|
||||
next_callback();
|
||||
}
|
||||
}
|
||||
|
||||
function load_gps_config() {
|
||||
MSP.send_message(MSPCodes.MSP_GPS_CONFIG, false, false, load_acc_trim);
|
||||
var next_callback = load_acc_trim;
|
||||
if(semver.gte(CONFIG.apiVersion, "1.33.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_GPS_CONFIG, false, false, load_acc_trim);
|
||||
} else {
|
||||
next_callback();
|
||||
}
|
||||
}
|
||||
|
||||
function load_acc_trim() {
|
||||
MSP.send_message(MSPCodes.MSP_ACC_TRIM, false, false, load_arming_config);
|
||||
MSP.send_message(MSPCodes.MSP_ACC_TRIM, false, false, load_misc);
|
||||
}
|
||||
|
||||
function load_misc() {
|
||||
var next_callback = load_arming_config;
|
||||
if (semver.lt(CONFIG.apiVersion, "1.33.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_MISC, false, false, next_callback);
|
||||
} else {
|
||||
next_callback();
|
||||
}
|
||||
}
|
||||
|
||||
function load_arming_config() {
|
||||
var next_callback = load_3d;
|
||||
if (semver.gte(CONFIG.apiVersion, "1.8.0")) {
|
||||
|
@ -633,10 +657,19 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
}
|
||||
|
||||
function save_feature_config() {
|
||||
var next_callback = save_mixer_config;
|
||||
var next_callback = save_misc;
|
||||
MSP.send_message(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG), false, next_callback);
|
||||
}
|
||||
|
||||
function save_misc() {
|
||||
var next_callback = save_mixer_config;
|
||||
if(semver.lt(CONFIG.apiVersion, "1.33.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_SET_MISC, mspHelper.crunch(MSPCodes.MSP_SET_MISC), false, next_callback);
|
||||
} else {
|
||||
next_callback();
|
||||
}
|
||||
}
|
||||
|
||||
function save_mixer_config() {
|
||||
var next_callback = save_board_alignment_config;
|
||||
MSP.send_message(MSPCodes.MSP_SET_MIXER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_MIXER_CONFIG), false, next_callback);
|
||||
|
@ -648,8 +681,30 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
}
|
||||
|
||||
function save_motor_config() {
|
||||
var next_callback = save_gps_config;
|
||||
if(semver.gte(CONFIG.apiVersion, "1.33.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_SET_MOTOR_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_MOTOR_CONFIG), false, next_callback);
|
||||
} else {
|
||||
next_callback();
|
||||
}
|
||||
}
|
||||
|
||||
function save_gps_config() {
|
||||
var next_callback = save_compass_config;
|
||||
if(semver.gte(CONFIG.apiVersion, "1.33.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_SET_GPS_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_GPS_CONFIG), false, next_callback);
|
||||
} else {
|
||||
next_callback();
|
||||
}
|
||||
}
|
||||
|
||||
function save_compass_config() {
|
||||
var next_callback = save_motor_3d_config;
|
||||
MSP.send_message(MSPCodes.MSP_SET_MOTOR_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_MOTOR_CONFIG), false, next_callback);
|
||||
if(semver.gte(CONFIG.apiVersion, "1.33.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_SET_COMPASS_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_COMPASS_CONFIG), false, next_callback);
|
||||
} else {
|
||||
next_callback();
|
||||
}
|
||||
}
|
||||
|
||||
function save_motor_3d_config() {
|
||||
|
|
Loading…
Reference in New Issue