2014-09-17 08:31:36 +00:00
|
|
|
'use strict';
|
|
|
|
|
2017-01-05 00:28:09 +00:00
|
|
|
TABS.configuration = {
|
|
|
|
DSHOT_PROTOCOL_MIN_VALUE: 5
|
|
|
|
};
|
2014-09-17 08:31:36 +00:00
|
|
|
|
2014-10-07 22:30:54 +00:00
|
|
|
TABS.configuration.initialize = function (callback, scrollPosition) {
|
2014-09-17 08:31:36 +00:00
|
|
|
var self = this;
|
2014-10-01 10:58:09 +00:00
|
|
|
|
2014-10-01 11:16:22 +00:00
|
|
|
if (GUI.active_tab != 'configuration') {
|
|
|
|
GUI.active_tab = 'configuration';
|
|
|
|
}
|
2014-09-17 08:31:36 +00:00
|
|
|
|
|
|
|
function load_config() {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_BF_CONFIG, false, false, load_serial_config);
|
2015-01-04 10:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function load_serial_config() {
|
2015-11-16 22:28:21 +00:00
|
|
|
var next_callback = load_rc_map;
|
2015-05-07 21:10:26 +00:00
|
|
|
if (semver.lt(CONFIG.apiVersion, "1.6.0")) {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_CF_SERIAL_CONFIG, false, false, next_callback);
|
2015-02-27 01:15:37 +00:00
|
|
|
} else {
|
2015-11-16 22:28:21 +00:00
|
|
|
next_callback();
|
2015-02-27 01:15:37 +00:00
|
|
|
}
|
2014-09-17 08:31:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function load_rc_map() {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_RX_MAP, false, false, load_misc);
|
2014-09-17 08:31:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function load_misc() {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_MISC, false, false, load_acc_trim);
|
2015-11-11 21:05:24 +00:00
|
|
|
}
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2014-09-17 08:31:36 +00:00
|
|
|
function load_acc_trim() {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_ACC_TRIM, false, false, load_arming_config);
|
2015-03-18 03:17:20 +00:00
|
|
|
}
|
|
|
|
|
2015-03-28 21:42:30 +00:00
|
|
|
function load_arming_config() {
|
2015-11-16 22:28:21 +00:00
|
|
|
var next_callback = load_loop_time;
|
|
|
|
if (semver.gte(CONFIG.apiVersion, "1.8.0")) {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_ARMING_CONFIG, false, false, next_callback);
|
2015-11-16 22:28:21 +00:00
|
|
|
} else {
|
|
|
|
next_callback();
|
|
|
|
}
|
2015-10-23 13:42:32 +00:00
|
|
|
}
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2015-10-23 13:42:32 +00:00
|
|
|
function load_loop_time() {
|
2015-11-16 22:28:21 +00:00
|
|
|
var next_callback = load_3d;
|
|
|
|
if (semver.gte(CONFIG.apiVersion, "1.8.0")) {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_LOOP_TIME, false, false, next_callback);
|
2015-11-16 22:28:21 +00:00
|
|
|
} else {
|
|
|
|
next_callback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function load_3d() {
|
2016-09-01 12:56:50 +00:00
|
|
|
var next_callback = load_rc_deadband;
|
2015-12-14 23:06:25 +00:00
|
|
|
if (semver.gte(CONFIG.apiVersion, "1.14.0")) {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_3D, false, false, next_callback);
|
2015-11-16 22:28:21 +00:00
|
|
|
} else {
|
|
|
|
next_callback();
|
|
|
|
}
|
2014-09-17 08:31:36 +00:00
|
|
|
}
|
2016-06-20 18:26:00 +00:00
|
|
|
|
2016-09-01 12:56:50 +00:00
|
|
|
function load_rc_deadband() {
|
|
|
|
var next_callback = esc_protocol;
|
|
|
|
if (semver.gte(CONFIG.apiVersion, "1.17.0")) {
|
|
|
|
MSP.send_message(MSPCodes.MSP_RC_DEADBAND, false, false, next_callback);
|
|
|
|
} else {
|
|
|
|
next_callback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-20 18:26:00 +00:00
|
|
|
function esc_protocol() {
|
2016-06-25 14:56:43 +00:00
|
|
|
var next_callback = sensor_config;
|
2016-12-08 19:59:54 +00:00
|
|
|
if (semver.gte(CONFIG.flightControllerVersion, "2.8.1")) {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_ADVANCED_CONFIG, false, false, next_callback);
|
2016-06-20 18:26:00 +00:00
|
|
|
} else {
|
|
|
|
next_callback();
|
2016-12-07 22:29:17 +00:00
|
|
|
}
|
2016-06-20 18:26:00 +00:00
|
|
|
}
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2016-06-25 14:56:43 +00:00
|
|
|
function sensor_config() {
|
|
|
|
var next_callback = load_sensor_alignment;
|
2016-12-08 19:59:54 +00:00
|
|
|
if (semver.gte(CONFIG.flightControllerVersion, "2.8.2")) {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_SENSOR_CONFIG, false, false, next_callback);
|
2016-06-25 14:56:43 +00:00
|
|
|
} else {
|
|
|
|
next_callback();
|
|
|
|
}
|
|
|
|
}
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2015-12-14 23:06:25 +00:00
|
|
|
function load_sensor_alignment() {
|
2016-07-22 11:55:50 +00:00
|
|
|
var next_callback = load_name;
|
2015-12-14 23:06:25 +00:00
|
|
|
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_SENSOR_ALIGNMENT, false, false, next_callback);
|
2015-12-14 23:06:25 +00:00
|
|
|
} else {
|
|
|
|
next_callback();
|
|
|
|
}
|
|
|
|
}
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2016-07-13 21:32:18 +00:00
|
|
|
function load_name() {
|
2016-12-07 22:29:17 +00:00
|
|
|
var next_callback = load_battery;
|
2016-12-08 19:59:54 +00:00
|
|
|
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_NAME, false, false, next_callback);
|
2016-07-13 21:32:18 +00:00
|
|
|
} else {
|
|
|
|
next_callback();
|
|
|
|
}
|
|
|
|
}
|
2016-06-20 18:26:00 +00:00
|
|
|
|
2016-12-07 22:29:17 +00:00
|
|
|
function load_battery() {
|
|
|
|
var next_callback = load_current;
|
2016-12-08 19:59:54 +00:00
|
|
|
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
|
2016-12-07 22:29:17 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_VOLTAGE_METER_CONFIG, false, false, next_callback);
|
|
|
|
} else {
|
|
|
|
next_callback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function load_current() {
|
|
|
|
var next_callback = load_html;
|
2016-12-08 19:59:54 +00:00
|
|
|
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
|
2016-12-07 22:29:17 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_CURRENT_METER_CONFIG, false, false, next_callback);
|
|
|
|
} else {
|
|
|
|
next_callback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-21 10:54:51 +00:00
|
|
|
//Update Analog/Battery Data
|
|
|
|
function load_analog() {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_ANALOG, false, false, function () {
|
2016-01-21 10:54:51 +00:00
|
|
|
$('input[name="batteryvoltage"]').val([ANALOG.voltage.toFixed(1)]);
|
|
|
|
$('input[name="batterycurrent"]').val([ANALOG.amperage.toFixed(2)]);
|
|
|
|
});
|
|
|
|
}
|
2014-09-17 08:31:36 +00:00
|
|
|
|
|
|
|
function load_html() {
|
|
|
|
$('#content').load("./tabs/configuration.html", process_html);
|
|
|
|
}
|
|
|
|
|
2016-08-05 10:54:33 +00:00
|
|
|
load_config();
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2014-09-17 08:31:36 +00:00
|
|
|
function process_html() {
|
2015-11-09 23:01:42 +00:00
|
|
|
var mixer_list_e = $('select.mixerList');
|
2017-01-22 05:08:58 +00:00
|
|
|
for (var selectIndex = 0; selectIndex < mixerList.length; selectIndex++) {
|
|
|
|
mixerList.forEach(function (mixerEntry, mixerIndex) {
|
|
|
|
if (mixerEntry.pos === selectIndex) {
|
|
|
|
mixer_list_e.append('<option value="' + (mixerIndex + 1) + '">' + mixerEntry.name + '</option>');
|
|
|
|
}
|
|
|
|
});
|
2014-09-17 12:22:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mixer_list_e.change(function () {
|
|
|
|
var val = parseInt($(this).val());
|
|
|
|
|
|
|
|
BF_CONFIG.mixerConfiguration = val;
|
|
|
|
|
2014-10-02 11:11:25 +00:00
|
|
|
$('.mixerPreview img').attr('src', './resources/motor_order/' + mixerList[val - 1].image + '.svg');
|
2014-09-17 12:22:16 +00:00
|
|
|
});
|
|
|
|
|
2014-09-17 15:02:16 +00:00
|
|
|
// select current mixer configuration
|
2014-09-17 12:22:16 +00:00
|
|
|
mixer_list_e.val(BF_CONFIG.mixerConfiguration).change();
|
|
|
|
|
2016-07-27 01:14:00 +00:00
|
|
|
var features_e = $('.tab-configuration .features');
|
2015-01-04 08:09:10 +00:00
|
|
|
|
2016-07-24 11:09:51 +00:00
|
|
|
BF_CONFIG.features.generateElements(features_e);
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2016-01-08 11:47:54 +00:00
|
|
|
// translate to user-selected language
|
|
|
|
localize();
|
2014-09-17 11:01:46 +00:00
|
|
|
|
2015-12-14 23:06:25 +00:00
|
|
|
var alignments = [
|
2015-12-15 21:37:40 +00:00
|
|
|
'CW 0°',
|
|
|
|
'CW 90°',
|
|
|
|
'CW 180°',
|
|
|
|
'CW 270°',
|
|
|
|
'CW 0° flip',
|
|
|
|
'CW 90° flip',
|
|
|
|
'CW 180° flip',
|
|
|
|
'CW 270° flip'
|
2015-12-14 23:06:25 +00:00
|
|
|
];
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2015-12-16 20:41:52 +00:00
|
|
|
var orientation_gyro_e = $('select.gyroalign');
|
|
|
|
var orientation_acc_e = $('select.accalign');
|
|
|
|
var orientation_mag_e = $('select.magalign');
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2015-12-14 23:06:25 +00:00
|
|
|
if (semver.lt(CONFIG.apiVersion, "1.15.0")) {
|
|
|
|
$('.tab-configuration .sensoralignment').hide();
|
|
|
|
} else {
|
|
|
|
for (var i = 0; i < alignments.length; i++) {
|
2016-01-06 23:29:31 +00:00
|
|
|
orientation_gyro_e.append('<option value="' + (i+1) + '">'+ alignments[i] + '</option>');
|
|
|
|
orientation_acc_e.append('<option value="' + (i+1) + '">'+ alignments[i] + '</option>');
|
|
|
|
orientation_mag_e.append('<option value="' + (i+1) + '">'+ alignments[i] + '</option>');
|
2015-12-14 23:06:25 +00:00
|
|
|
}
|
|
|
|
orientation_gyro_e.val(SENSOR_ALIGNMENT.align_gyro);
|
|
|
|
orientation_acc_e.val(SENSOR_ALIGNMENT.align_acc);
|
|
|
|
orientation_mag_e.val(SENSOR_ALIGNMENT.align_mag);
|
|
|
|
}
|
2016-12-07 22:29:17 +00:00
|
|
|
|
|
|
|
// ESC protocols
|
2016-06-20 18:26:00 +00:00
|
|
|
var escprotocols = [
|
|
|
|
'PWM',
|
|
|
|
'ONESHOT125',
|
|
|
|
'ONESHOT42',
|
|
|
|
'MULTISHOT'
|
|
|
|
];
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2016-10-10 21:51:58 +00:00
|
|
|
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
|
2016-07-03 21:32:53 +00:00
|
|
|
escprotocols.push('BRUSHED');
|
|
|
|
}
|
|
|
|
|
2016-10-10 21:51:58 +00:00
|
|
|
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
|
2016-10-12 22:48:38 +00:00
|
|
|
escprotocols.push('DSHOT150');
|
2017-01-09 11:15:52 +00:00
|
|
|
escprotocols.push('DSHOT300');
|
|
|
|
escprotocols.push('DSHOT600');
|
2017-01-09 23:37:20 +00:00
|
|
|
if (semver.gte(CONFIG.apiVersion, "1.26.0")) {
|
2017-01-29 11:46:26 +00:00
|
|
|
if (PID_ADVANCED_CONFIG.fast_pwm_protocol === 8) {
|
|
|
|
escprotocols.push('DSHOT1200');
|
|
|
|
}
|
2017-01-09 23:37:20 +00:00
|
|
|
}
|
2016-10-10 21:39:13 +00:00
|
|
|
}
|
|
|
|
|
2016-06-20 18:26:00 +00:00
|
|
|
var esc_protocol_e = $('select.escprotocol');
|
|
|
|
|
|
|
|
for (var i = 0; i < escprotocols.length; i++) {
|
2017-01-09 11:15:52 +00:00
|
|
|
esc_protocol_e.append('<option value="' + (i + 1) + '">'+ escprotocols[i] + '</option>');
|
2016-06-20 18:26:00 +00:00
|
|
|
}
|
2017-01-09 11:15:52 +00:00
|
|
|
|
|
|
|
esc_protocol_e.val(PID_ADVANCED_CONFIG.fast_pwm_protocol + 1);
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2017-01-05 00:28:09 +00:00
|
|
|
esc_protocol_e.change(function () {
|
|
|
|
if ($(this).val() - 1 >= self.DSHOT_PROTOCOL_MIN_VALUE) {
|
|
|
|
$('div.minthrottle').hide();
|
|
|
|
$('div.maxthrottle').hide();
|
|
|
|
$('div.mincommand').hide();
|
2017-01-09 22:41:45 +00:00
|
|
|
$('div.checkboxPwm').hide();
|
|
|
|
$('div.unsyncedpwmfreq').hide();
|
2017-01-05 00:28:09 +00:00
|
|
|
|
|
|
|
$('div.digitalIdlePercent').show();
|
|
|
|
} else {
|
|
|
|
$('div.minthrottle').show();
|
|
|
|
$('div.maxthrottle').show();
|
|
|
|
$('div.mincommand').show();
|
2017-01-09 22:41:45 +00:00
|
|
|
$('div.checkboxPwm').show();
|
2017-01-05 00:28:09 +00:00
|
|
|
|
|
|
|
$('div.digitalIdlePercent').hide();
|
|
|
|
}
|
|
|
|
}).change();
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2016-09-01 12:56:50 +00:00
|
|
|
$('input[id="unsyncedPWMSwitch"]').prop('checked', PID_ADVANCED_CONFIG.use_unsyncedPwm !== 0);
|
2016-06-20 18:26:00 +00:00
|
|
|
$('input[name="unsyncedpwmfreq"]').val(PID_ADVANCED_CONFIG.motor_pwm_rate);
|
2017-01-05 00:28:09 +00:00
|
|
|
$('input[name="digitalIdlePercent"]').val(PID_ADVANCED_CONFIG.digitalIdlePercent);
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2016-06-20 19:49:18 +00:00
|
|
|
// Gyro and PID update
|
2017-01-05 00:28:09 +00:00
|
|
|
var gyroUse32kHz_e = $('input[id="gyroUse32kHz"]');
|
2016-06-20 19:49:18 +00:00
|
|
|
var gyro_select_e = $('select.gyroSyncDenom');
|
2017-01-05 00:28:09 +00:00
|
|
|
var pid_select_e = $('select.pidProcessDenom');
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2017-01-26 21:37:51 +00:00
|
|
|
function addDenomOption(element, denom, baseFreq) {
|
|
|
|
element.append('<option value="' + denom + '">' + ((baseFreq / denom * 100).toFixed(0) / 100) + ' kHz</option>');
|
|
|
|
}
|
|
|
|
|
2017-01-05 00:28:09 +00:00
|
|
|
var updateGyroDenom = function (gyroBaseFreq) {
|
|
|
|
var originalGyroDenom = gyro_select_e.val();
|
|
|
|
|
|
|
|
gyro_select_e.empty();
|
|
|
|
|
2017-01-26 21:37:51 +00:00
|
|
|
var denom = 1;
|
|
|
|
while (denom <= 8) {
|
|
|
|
addDenomOption(gyro_select_e, denom, gyroBaseFreq);
|
|
|
|
denom ++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (semver.gte(CONFIG.apiVersion, "1.25.0")) {
|
|
|
|
while (denom <= 32) {
|
|
|
|
addDenomOption(gyro_select_e, denom, gyroBaseFreq);
|
|
|
|
|
|
|
|
denom ++;
|
|
|
|
}
|
2017-01-05 00:28:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gyro_select_e.val(originalGyroDenom);
|
|
|
|
|
|
|
|
gyro_select_e.change();
|
|
|
|
};
|
|
|
|
|
|
|
|
if (semver.gte(CONFIG.apiVersion, "1.25.0")) {
|
|
|
|
gyroUse32kHz_e.prop('checked', PID_ADVANCED_CONFIG.gyroUse32kHz !== 0);
|
|
|
|
|
|
|
|
gyroUse32kHz_e.change(function () {
|
|
|
|
var gyroBaseFreq;
|
|
|
|
if ($(this).is(':checked')) {
|
|
|
|
gyroBaseFreq = 32;
|
|
|
|
} else {
|
|
|
|
gyroBaseFreq = 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
updateGyroDenom(gyroBaseFreq);
|
|
|
|
}).change();
|
|
|
|
} else {
|
|
|
|
$('div.gyroUse32kHz').hide();
|
|
|
|
|
|
|
|
updateGyroDenom(8);
|
2016-06-20 19:49:18 +00:00
|
|
|
}
|
2017-01-05 00:28:09 +00:00
|
|
|
|
2016-06-20 19:49:18 +00:00
|
|
|
gyro_select_e.val(PID_ADVANCED_CONFIG.gyro_sync_denom);
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2017-01-05 00:28:09 +00:00
|
|
|
gyro_select_e.change(function () {
|
|
|
|
var originalPidDenom = pid_select_e.val();
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2017-01-05 00:28:09 +00:00
|
|
|
var pidBaseFreq = 8;
|
|
|
|
if (semver.gte(CONFIG.apiVersion, "1.25.0") && gyroUse32kHz_e.is(':checked')) {
|
|
|
|
pidBaseFreq = 32;
|
|
|
|
}
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2017-01-05 00:28:09 +00:00
|
|
|
pidBaseFreq = pidBaseFreq / parseInt($(this).val());
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2017-01-05 00:28:09 +00:00
|
|
|
pid_select_e.empty();
|
|
|
|
|
2017-01-26 21:37:51 +00:00
|
|
|
var denom = 1;
|
|
|
|
|
|
|
|
while (denom <= 8) {
|
|
|
|
addDenomOption(pid_select_e, denom, pidBaseFreq);
|
|
|
|
denom ++;
|
2017-01-05 00:28:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (semver.gte(CONFIG.apiVersion, "1.24.0")) {
|
2017-01-26 21:37:51 +00:00
|
|
|
while (denom <= 16) {
|
|
|
|
addDenomOption(pid_select_e, denom, pidBaseFreq);
|
|
|
|
|
|
|
|
denom ++;
|
2017-01-05 00:28:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pid_select_e.val(originalPidDenom);
|
|
|
|
}).change();
|
|
|
|
|
|
|
|
pid_select_e.val(PID_ADVANCED_CONFIG.pid_process_denom);
|
2016-06-24 23:27:32 +00:00
|
|
|
|
2016-09-01 12:56:50 +00:00
|
|
|
$('input[id="accHardwareSwitch"]').prop('checked', SENSOR_CONFIG.acc_hardware !== 1);
|
|
|
|
$('input[id="baroHardwareSwitch"]').prop('checked', SENSOR_CONFIG.baro_hardware !== 1);
|
|
|
|
$('input[id="magHardwareSwitch"]').prop('checked', SENSOR_CONFIG.mag_hardware !== 1);
|
2016-06-25 14:56:43 +00:00
|
|
|
|
|
|
|
// Only show these sections for supported FW
|
2016-12-08 19:59:54 +00:00
|
|
|
if (semver.lt(CONFIG.flightControllerVersion, "2.8.1")) {
|
2016-06-24 23:27:32 +00:00
|
|
|
$('.selectProtocol').hide();
|
|
|
|
$('.checkboxPwm').hide();
|
|
|
|
$('.selectPidProcessDenom').hide();
|
|
|
|
}
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2016-12-08 19:59:54 +00:00
|
|
|
if (semver.lt(CONFIG.flightControllerVersion, "2.8.2")) {
|
2016-06-25 14:56:43 +00:00
|
|
|
$('.hardwareSelection').hide();
|
|
|
|
}
|
|
|
|
|
2016-07-13 21:32:18 +00:00
|
|
|
$('input[name="vesselName"]').val(CONFIG.name);
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2016-12-08 19:59:54 +00:00
|
|
|
if (semver.lt(CONFIG.flightControllerVersion, "3.0.0")) {
|
2016-07-13 21:47:15 +00:00
|
|
|
$('.miscSettings').hide();
|
|
|
|
}
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2014-09-17 15:46:21 +00:00
|
|
|
// generate GPS
|
2015-01-04 08:09:10 +00:00
|
|
|
var gpsProtocols = [
|
2014-09-17 15:46:21 +00:00
|
|
|
'NMEA',
|
2014-12-20 02:50:36 +00:00
|
|
|
'UBLOX'
|
2014-09-17 15:46:21 +00:00
|
|
|
];
|
|
|
|
|
2015-01-04 10:28:32 +00:00
|
|
|
var gpsBaudRates = [
|
2014-09-17 15:46:21 +00:00
|
|
|
'115200',
|
|
|
|
'57600',
|
|
|
|
'38400',
|
|
|
|
'19200',
|
|
|
|
'9600'
|
|
|
|
];
|
|
|
|
|
|
|
|
var gpsSbas = [
|
|
|
|
'Auto-detect',
|
|
|
|
'European EGNOS',
|
|
|
|
'North American WAAS',
|
|
|
|
'Japanese MSAS',
|
|
|
|
'Indian GAGAN'
|
|
|
|
];
|
|
|
|
|
2015-12-14 23:06:25 +00:00
|
|
|
|
2015-01-04 08:09:10 +00:00
|
|
|
var gps_protocol_e = $('select.gps_protocol');
|
|
|
|
for (var i = 0; i < gpsProtocols.length; i++) {
|
|
|
|
gps_protocol_e.append('<option value="' + i + '">' + gpsProtocols[i] + '</option>');
|
2014-09-17 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
2015-01-04 08:09:10 +00:00
|
|
|
gps_protocol_e.change(function () {
|
2014-09-18 10:32:27 +00:00
|
|
|
MISC.gps_type = parseInt($(this).val());
|
2014-09-17 15:46:21 +00:00
|
|
|
});
|
|
|
|
|
2015-02-27 01:15:37 +00:00
|
|
|
gps_protocol_e.val(MISC.gps_type);
|
2016-12-07 22:29:17 +00:00
|
|
|
|
|
|
|
|
2014-09-17 15:46:21 +00:00
|
|
|
var gps_baudrate_e = $('select.gps_baudrate');
|
2015-01-04 10:28:32 +00:00
|
|
|
for (var i = 0; i < gpsBaudRates.length; i++) {
|
|
|
|
gps_baudrate_e.append('<option value="' + gpsBaudRates[i] + '">' + gpsBaudRates[i] + '</option>');
|
2014-09-17 15:46:21 +00:00
|
|
|
}
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2015-05-07 21:10:26 +00:00
|
|
|
if (semver.lt(CONFIG.apiVersion, "1.6.0")) {
|
2015-02-27 01:15:37 +00:00
|
|
|
gps_baudrate_e.change(function () {
|
|
|
|
SERIAL_CONFIG.gpsBaudRate = parseInt($(this).val());
|
|
|
|
});
|
|
|
|
gps_baudrate_e.val(SERIAL_CONFIG.gpsBaudRate);
|
|
|
|
} else {
|
|
|
|
gps_baudrate_e.prop("disabled", true);
|
|
|
|
gps_baudrate_e.parent().hide();
|
|
|
|
}
|
2016-12-07 22:29:17 +00:00
|
|
|
|
|
|
|
|
2014-09-17 15:46:21 +00:00
|
|
|
var gps_ubx_sbas_e = $('select.gps_ubx_sbas');
|
|
|
|
for (var i = 0; i < gpsSbas.length; i++) {
|
2016-01-12 10:24:53 +00:00
|
|
|
gps_ubx_sbas_e.append('<option value="' + i + '">' + gpsSbas[i] + '</option>');
|
2014-09-17 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gps_ubx_sbas_e.change(function () {
|
2014-09-18 10:32:27 +00:00
|
|
|
MISC.gps_ubx_sbas = parseInt($(this).val());
|
2014-09-17 15:46:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
gps_ubx_sbas_e.val(MISC.gps_ubx_sbas);
|
|
|
|
|
2015-02-27 01:15:37 +00:00
|
|
|
|
2014-09-17 15:02:16 +00:00
|
|
|
// generate serial RX
|
|
|
|
var serialRXtypes = [
|
|
|
|
'SPEKTRUM1024',
|
|
|
|
'SPEKTRUM2048',
|
|
|
|
'SBUS',
|
2014-11-29 20:44:28 +00:00
|
|
|
'SUMD',
|
2014-12-25 11:25:23 +00:00
|
|
|
'SUMH',
|
2015-01-25 13:48:58 +00:00
|
|
|
'XBUS_MODE_B',
|
|
|
|
'XBUS_MODE_B_RJ01'
|
2014-09-17 15:02:16 +00:00
|
|
|
];
|
|
|
|
|
2015-12-14 23:53:01 +00:00
|
|
|
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
|
|
|
|
serialRXtypes.push('IBUS');
|
|
|
|
}
|
|
|
|
|
2016-11-29 09:44:15 +00:00
|
|
|
if (semver.gte(CONFIG.flightControllerVersion, "2.6.0")) {
|
2016-07-05 13:54:40 +00:00
|
|
|
serialRXtypes.push('JETIEXBUS');
|
|
|
|
}
|
|
|
|
|
2016-11-29 09:44:15 +00:00
|
|
|
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
|
|
|
|
serialRXtypes.push('CRSF');
|
|
|
|
}
|
|
|
|
|
2017-01-17 12:30:06 +00:00
|
|
|
if (semver.gte(CONFIG.apiVersion, "1.24.0")) {
|
|
|
|
serialRXtypes.push('SRXL');
|
|
|
|
}
|
|
|
|
|
2014-09-17 15:02:16 +00:00
|
|
|
var serialRX_e = $('select.serialRX');
|
|
|
|
for (var i = 0; i < serialRXtypes.length; i++) {
|
2014-09-17 15:46:21 +00:00
|
|
|
serialRX_e.append('<option value="' + i + '">' + serialRXtypes[i] + '</option>');
|
2014-09-17 15:02:16 +00:00
|
|
|
}
|
|
|
|
|
2014-09-17 15:46:21 +00:00
|
|
|
serialRX_e.change(function () {
|
2014-09-18 10:32:27 +00:00
|
|
|
BF_CONFIG.serialrx_type = parseInt($(this).val());
|
2014-09-17 15:02:16 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// select current serial RX type
|
|
|
|
serialRX_e.val(BF_CONFIG.serialrx_type);
|
|
|
|
|
2014-10-07 22:30:54 +00:00
|
|
|
// for some odd reason chrome 38+ changes scroll according to the touched select element
|
|
|
|
// i am guessing this is a bug, since this wasn't happening on 37
|
|
|
|
// code below is a temporary fix, which we will be able to remove in the future (hopefully)
|
|
|
|
$('#content').scrollTop((scrollPosition) ? scrollPosition : 0);
|
|
|
|
|
2014-09-17 13:44:28 +00:00
|
|
|
// fill board alignment
|
|
|
|
$('input[name="board_align_roll"]').val(BF_CONFIG.board_align_roll);
|
|
|
|
$('input[name="board_align_pitch"]').val(BF_CONFIG.board_align_pitch);
|
|
|
|
$('input[name="board_align_yaw"]').val(BF_CONFIG.board_align_yaw);
|
|
|
|
|
|
|
|
// fill accel trims
|
|
|
|
$('input[name="roll"]').val(CONFIG.accelerometerTrims[1]);
|
2014-09-17 14:08:40 +00:00
|
|
|
$('input[name="pitch"]').val(CONFIG.accelerometerTrims[0]);
|
2014-09-17 13:44:28 +00:00
|
|
|
|
|
|
|
// fill magnetometer
|
2016-04-18 21:19:07 +00:00
|
|
|
$('input[name="mag_declination"]').val(MISC.mag_declination.toFixed(2));
|
2014-09-17 13:44:28 +00:00
|
|
|
|
2016-12-07 22:29:17 +00:00
|
|
|
//fill motor disarm params and FC loop time
|
2015-05-07 21:10:26 +00:00
|
|
|
if(semver.gte(CONFIG.apiVersion, "1.8.0")) {
|
2015-03-28 21:42:30 +00:00
|
|
|
$('input[name="autodisarmdelay"]').val(ARMING_CONFIG.auto_disarm_delay);
|
2016-09-01 12:56:50 +00:00
|
|
|
$('input[id="disarmkillswitch"]').prop('checked', ARMING_CONFIG.disarm_kill_switch !== 0);
|
2016-12-07 22:29:17 +00:00
|
|
|
$('div.disarm').show();
|
2015-10-23 13:42:32 +00:00
|
|
|
|
|
|
|
$('div.cycles').show();
|
2015-03-18 03:17:20 +00:00
|
|
|
}
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2014-09-17 13:44:28 +00:00
|
|
|
// fill throttle
|
2017-01-18 20:16:38 +00:00
|
|
|
$('input[name="minthrottle"]').val(MISC.minthrottle);
|
2014-09-17 13:20:21 +00:00
|
|
|
$('input[name="maxthrottle"]').val(MISC.maxthrottle);
|
|
|
|
$('input[name="mincommand"]').val(MISC.mincommand);
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2014-09-17 13:44:28 +00:00
|
|
|
// fill battery
|
2017-01-03 21:54:28 +00:00
|
|
|
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
|
|
|
|
var batteryMeterTypes = [
|
|
|
|
'Onboard ADC',
|
|
|
|
'ESC Sensor'
|
|
|
|
];
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2017-01-03 21:54:28 +00:00
|
|
|
var batteryMeterType_e = $('select.batterymetertype');
|
|
|
|
for (i = 0; i < batteryMeterTypes.length; i++) {
|
|
|
|
batteryMeterType_e.append('<option value="' + i + '">' + batteryMeterTypes[i] + '</option>');
|
|
|
|
}
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2017-01-03 21:54:28 +00:00
|
|
|
batteryMeterType_e.change(function () {
|
|
|
|
MISC.batterymetertype = parseInt($(this).val());
|
2017-01-13 07:47:52 +00:00
|
|
|
checkUpdateVbatControls();
|
2017-01-03 21:54:28 +00:00
|
|
|
});
|
|
|
|
batteryMeterType_e.val(MISC.batterymetertype).change();
|
|
|
|
} else {
|
|
|
|
$('div.batterymetertype').hide();
|
|
|
|
}
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2014-09-17 13:20:21 +00:00
|
|
|
$('input[name="mincellvoltage"]').val(MISC.vbatmincellvoltage);
|
|
|
|
$('input[name="maxcellvoltage"]').val(MISC.vbatmaxcellvoltage);
|
2014-12-21 12:29:36 +00:00
|
|
|
$('input[name="warningcellvoltage"]').val(MISC.vbatwarningcellvoltage);
|
2014-09-17 13:20:21 +00:00
|
|
|
$('input[name="voltagescale"]').val(MISC.vbatscale);
|
2014-09-18 11:21:48 +00:00
|
|
|
|
|
|
|
// fill current
|
2016-12-07 22:29:17 +00:00
|
|
|
var currentMeterTypes = [
|
2016-12-08 19:59:54 +00:00
|
|
|
'None',
|
2016-12-07 22:29:17 +00:00
|
|
|
'Onboard ADC',
|
2017-01-03 21:54:28 +00:00
|
|
|
'Virtual'
|
2016-12-07 22:29:17 +00:00
|
|
|
];
|
|
|
|
|
2017-01-03 21:54:28 +00:00
|
|
|
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
|
|
|
|
currentMeterTypes.push('ESC Sensor');
|
|
|
|
}
|
|
|
|
|
2016-12-07 22:29:17 +00:00
|
|
|
var currentMeterType_e = $('select.currentmetertype');
|
2016-12-08 19:59:54 +00:00
|
|
|
for (i = 0; i < currentMeterTypes.length; i++) {
|
2016-12-07 22:29:17 +00:00
|
|
|
currentMeterType_e.append('<option value="' + i + '">' + currentMeterTypes[i] + '</option>');
|
|
|
|
}
|
|
|
|
|
|
|
|
currentMeterType_e.change(function () {
|
|
|
|
BF_CONFIG.currentmetertype = parseInt($(this).val());
|
2017-01-13 07:47:52 +00:00
|
|
|
checkUpdateCurrentControls();
|
2016-12-07 22:29:17 +00:00
|
|
|
});
|
2016-12-08 22:02:06 +00:00
|
|
|
currentMeterType_e.val(BF_CONFIG.currentmetertype).change();
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2014-09-18 11:21:48 +00:00
|
|
|
$('input[name="currentscale"]').val(BF_CONFIG.currentscale);
|
|
|
|
$('input[name="currentoffset"]').val(BF_CONFIG.currentoffset);
|
2016-09-01 12:56:50 +00:00
|
|
|
$('input[name="multiwiicurrentoutput"]').prop('checked', MISC.multiwiicurrentoutput !== 0);
|
2014-09-17 13:20:21 +00:00
|
|
|
|
2015-11-11 21:05:24 +00:00
|
|
|
//fill 3D
|
2015-11-16 22:28:21 +00:00
|
|
|
if (semver.lt(CONFIG.apiVersion, "1.14.0")) {
|
2016-09-01 12:56:50 +00:00
|
|
|
$('.tab-configuration ._3d').hide();
|
2015-11-16 22:28:21 +00:00
|
|
|
} else {
|
|
|
|
$('input[name="3ddeadbandlow"]').val(_3D.deadband3d_low);
|
|
|
|
$('input[name="3ddeadbandhigh"]').val(_3D.deadband3d_high);
|
|
|
|
$('input[name="3dneutral"]').val(_3D.neutral3d);
|
2016-09-01 12:56:50 +00:00
|
|
|
$('input[name="3ddeadbandthrottle"]').val(_3D.deadband3d_throttle);
|
2015-11-16 22:28:21 +00:00
|
|
|
}
|
2014-09-17 11:01:46 +00:00
|
|
|
|
2016-07-23 14:46:47 +00:00
|
|
|
// UI hooks
|
2016-10-17 12:18:20 +00:00
|
|
|
function checkShowDisarmDelay() {
|
|
|
|
if (BF_CONFIG.features.isEnabled('MOTOR_STOP')) {
|
|
|
|
$('div.disarmdelay').show();
|
|
|
|
} else {
|
|
|
|
$('div.disarmdelay').hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkShowSerialRxBox() {
|
|
|
|
if (BF_CONFIG.features.isEnabled('RX_SERIAL')) {
|
|
|
|
$('div.serialRXBox').show();
|
|
|
|
} else {
|
|
|
|
$('div.serialRXBox').hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-13 07:47:52 +00:00
|
|
|
function checkUpdateVbatControls() {
|
|
|
|
if (BF_CONFIG.features.isEnabled('VBAT')) {
|
|
|
|
$('.vbatmonitoring').show();
|
2017-01-03 21:54:28 +00:00
|
|
|
|
2017-01-13 07:47:52 +00:00
|
|
|
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
|
|
|
|
$('select.batterymetertype').show();
|
2017-01-03 21:54:28 +00:00
|
|
|
|
2017-01-13 07:47:52 +00:00
|
|
|
if (MISC.batterymetertype !== 0) {
|
|
|
|
$('.vbatCalibration').hide();
|
|
|
|
}
|
2016-12-08 22:02:06 +00:00
|
|
|
} else {
|
2017-01-13 07:47:52 +00:00
|
|
|
$('select.batterymetertype').hide();
|
2016-12-08 22:02:06 +00:00
|
|
|
}
|
|
|
|
} else {
|
2017-01-13 07:47:52 +00:00
|
|
|
$('.vbatmonitoring').hide();
|
2016-12-08 22:02:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-13 07:47:52 +00:00
|
|
|
function checkUpdateCurrentControls() {
|
2016-12-08 22:02:06 +00:00
|
|
|
if (BF_CONFIG.features.isEnabled('CURRENT_METER')) {
|
2017-01-13 07:47:52 +00:00
|
|
|
$('.currentMonitoring').show();
|
|
|
|
|
|
|
|
switch(BF_CONFIG.currentmetertype) {
|
|
|
|
case 0:
|
|
|
|
$('.currentCalibration').hide();
|
|
|
|
$('.currentOutput').hide();
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
$('.currentCalibration').hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BF_CONFIG.currentmetertype !== 1 && BF_CONFIG.currentmetertype !== 2) {
|
|
|
|
$('.currentCalibration').hide();
|
2016-12-08 22:02:06 +00:00
|
|
|
}
|
|
|
|
} else {
|
2017-01-13 07:47:52 +00:00
|
|
|
$('.currentMonitoring').hide();
|
2016-12-08 22:02:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-11 11:35:59 +00:00
|
|
|
function checkUpdateGpsControls() {
|
|
|
|
if (BF_CONFIG.features.isEnabled('GPS')) {
|
|
|
|
$('.gpsSettings').show();
|
|
|
|
} else {
|
|
|
|
$('.gpsSettings').hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkUpdate3dControls() {
|
|
|
|
if (BF_CONFIG.features.isEnabled('3D')) {
|
|
|
|
$('._3dSettings').show();
|
|
|
|
} else {
|
|
|
|
$('._3dSettings').hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$('input.feature', features_e).change(function () {
|
2016-10-17 12:18:20 +00:00
|
|
|
var element = $(this);
|
|
|
|
|
|
|
|
BF_CONFIG.features.updateData(element);
|
|
|
|
updateTabList(BF_CONFIG.features);
|
|
|
|
|
2017-02-11 11:35:59 +00:00
|
|
|
switch (element.attr('name')) {
|
|
|
|
case 'MOTOR_STOP':
|
|
|
|
checkShowDisarmDelay();
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 'VBAT':
|
|
|
|
checkUpdateVbatControls();
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 'CURRENT_METER':
|
|
|
|
checkUpdateCurrentControls();
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 'GPS':
|
|
|
|
checkUpdateGpsControls();
|
|
|
|
|
|
|
|
break;
|
|
|
|
case '3D':
|
|
|
|
checkUpdate3dControls();
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-09-17 11:01:46 +00:00
|
|
|
}
|
|
|
|
});
|
2016-12-08 22:02:06 +00:00
|
|
|
|
2017-02-11 11:35:59 +00:00
|
|
|
$(features_e).filter('select').change(function () {
|
|
|
|
var element = $(this);
|
2016-12-08 22:02:06 +00:00
|
|
|
|
2017-02-11 11:35:59 +00:00
|
|
|
BF_CONFIG.features.updateData(element);
|
|
|
|
updateTabList(BF_CONFIG.features);
|
|
|
|
|
|
|
|
switch (element.attr('name')) {
|
|
|
|
case 'rxMode':
|
|
|
|
checkShowSerialRxBox();
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2016-12-08 22:02:06 +00:00
|
|
|
});
|
|
|
|
|
2017-02-11 11:35:59 +00:00
|
|
|
checkShowDisarmDelay();
|
2016-10-17 12:18:20 +00:00
|
|
|
checkShowSerialRxBox();
|
2017-01-13 07:47:52 +00:00
|
|
|
checkUpdateVbatControls();
|
|
|
|
checkUpdateCurrentControls();
|
2017-02-11 11:35:59 +00:00
|
|
|
checkUpdateGpsControls();
|
|
|
|
checkUpdate3dControls();
|
2014-09-17 09:23:31 +00:00
|
|
|
|
2016-09-01 12:56:50 +00:00
|
|
|
$("input[id='unsyncedPWMSwitch']").change(function() {
|
2016-07-23 14:46:47 +00:00
|
|
|
if ($(this).is(':checked')) {
|
|
|
|
$('div.unsyncedpwmfreq').show();
|
|
|
|
} else {
|
|
|
|
$('div.unsyncedpwmfreq').hide();
|
2016-06-20 18:26:00 +00:00
|
|
|
}
|
2017-01-05 00:28:09 +00:00
|
|
|
}).change();
|
2016-06-20 18:26:00 +00:00
|
|
|
|
2014-09-17 11:01:46 +00:00
|
|
|
$('a.save').click(function () {
|
2014-09-17 13:20:21 +00:00
|
|
|
// gather data that doesn't have automatic change event bound
|
2014-09-17 13:44:28 +00:00
|
|
|
BF_CONFIG.board_align_roll = parseInt($('input[name="board_align_roll"]').val());
|
|
|
|
BF_CONFIG.board_align_pitch = parseInt($('input[name="board_align_pitch"]').val());
|
|
|
|
BF_CONFIG.board_align_yaw = parseInt($('input[name="board_align_yaw"]').val());
|
|
|
|
|
|
|
|
CONFIG.accelerometerTrims[1] = parseInt($('input[name="roll"]').val());
|
2014-09-17 14:08:40 +00:00
|
|
|
CONFIG.accelerometerTrims[0] = parseInt($('input[name="pitch"]').val());
|
2014-11-03 17:36:29 +00:00
|
|
|
MISC.mag_declination = parseFloat($('input[name="mag_declination"]').val());
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2015-03-14 00:02:05 +00:00
|
|
|
// motor disarm
|
2015-05-07 21:10:26 +00:00
|
|
|
if(semver.gte(CONFIG.apiVersion, "1.8.0")) {
|
2015-03-29 00:24:32 +00:00
|
|
|
ARMING_CONFIG.auto_disarm_delay = parseInt($('input[name="autodisarmdelay"]').val());
|
2016-09-01 12:56:50 +00:00
|
|
|
ARMING_CONFIG.disarm_kill_switch = $('input[id="disarmkillswitch"]').is(':checked') ? 1 : 0;
|
2015-03-29 00:24:32 +00:00
|
|
|
}
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2014-09-17 13:20:21 +00:00
|
|
|
MISC.minthrottle = parseInt($('input[name="minthrottle"]').val());
|
|
|
|
MISC.maxthrottle = parseInt($('input[name="maxthrottle"]').val());
|
|
|
|
MISC.mincommand = parseInt($('input[name="mincommand"]').val());
|
|
|
|
|
2014-11-03 17:36:29 +00:00
|
|
|
MISC.vbatmincellvoltage = parseFloat($('input[name="mincellvoltage"]').val());
|
|
|
|
MISC.vbatmaxcellvoltage = parseFloat($('input[name="maxcellvoltage"]').val());
|
2014-12-21 12:29:36 +00:00
|
|
|
MISC.vbatwarningcellvoltage = parseFloat($('input[name="warningcellvoltage"]').val());
|
2014-09-17 13:44:28 +00:00
|
|
|
MISC.vbatscale = parseInt($('input[name="voltagescale"]').val());
|
2014-09-18 11:21:48 +00:00
|
|
|
|
|
|
|
BF_CONFIG.currentscale = parseInt($('input[name="currentscale"]').val());
|
|
|
|
BF_CONFIG.currentoffset = parseInt($('input[name="currentoffset"]').val());
|
2016-09-01 12:56:50 +00:00
|
|
|
MISC.multiwiicurrentoutput = $('input[name="multiwiicurrentoutput"]').is(':checked') ? 1 : 0;
|
2014-09-17 13:44:28 +00:00
|
|
|
|
2016-09-01 12:56:50 +00:00
|
|
|
if(semver.gte(CONFIG.apiVersion, "1.14.0")) {
|
|
|
|
_3D.deadband3d_low = parseInt($('input[name="3ddeadbandlow"]').val());
|
|
|
|
_3D.deadband3d_high = parseInt($('input[name="3ddeadbandhigh"]').val());
|
|
|
|
_3D.neutral3d = parseInt($('input[name="3dneutral"]').val());
|
2016-04-01 10:32:19 +00:00
|
|
|
_3D.deadband3d_throttle = ($('input[name="3ddeadbandthrottle"]').val());
|
|
|
|
}
|
2015-11-12 22:33:17 +00:00
|
|
|
|
2015-12-14 23:06:25 +00:00
|
|
|
SENSOR_ALIGNMENT.align_gyro = parseInt(orientation_gyro_e.val());
|
|
|
|
SENSOR_ALIGNMENT.align_acc = parseInt(orientation_acc_e.val());
|
|
|
|
SENSOR_ALIGNMENT.align_mag = parseInt(orientation_mag_e.val());
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2016-06-20 18:26:00 +00:00
|
|
|
PID_ADVANCED_CONFIG.fast_pwm_protocol = parseInt(esc_protocol_e.val()-1);
|
2016-09-01 12:56:50 +00:00
|
|
|
PID_ADVANCED_CONFIG.use_unsyncedPwm = $('input[id="unsyncedPWMSwitch"]').is(':checked') ? 1 : 0;
|
2016-06-20 18:26:00 +00:00
|
|
|
PID_ADVANCED_CONFIG.motor_pwm_rate = parseInt($('input[name="unsyncedpwmfreq"]').val());
|
2016-06-20 19:49:18 +00:00
|
|
|
PID_ADVANCED_CONFIG.gyro_sync_denom = parseInt(gyro_select_e.val());
|
|
|
|
PID_ADVANCED_CONFIG.pid_process_denom = parseInt(pid_select_e.val());
|
2017-01-05 00:28:09 +00:00
|
|
|
PID_ADVANCED_CONFIG.digitalIdlePercent = parseFloat($('input[name="digitalIdlePercent"]').val());
|
|
|
|
if (semver.gte(CONFIG.apiVersion, "1.25.0")) {
|
|
|
|
PID_ADVANCED_CONFIG.gyroUse32kHz = $('input[id="gyroUse32kHz"]').is(':checked') ? 1 : 0;
|
|
|
|
}
|
2015-12-14 23:06:25 +00:00
|
|
|
|
2015-01-04 10:28:32 +00:00
|
|
|
function save_serial_config() {
|
2015-05-07 21:10:26 +00:00
|
|
|
if (semver.lt(CONFIG.apiVersion, "1.6.0")) {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_SET_CF_SERIAL_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_CF_SERIAL_CONFIG), false, save_misc);
|
2015-02-27 01:15:37 +00:00
|
|
|
} else {
|
|
|
|
save_misc();
|
|
|
|
}
|
2015-01-04 10:28:32 +00:00
|
|
|
}
|
|
|
|
|
2014-09-17 13:20:21 +00:00
|
|
|
function save_misc() {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_SET_MISC, mspHelper.crunch(MSPCodes.MSP_SET_MISC), false, save_3d);
|
2015-11-11 21:05:24 +00:00
|
|
|
}
|
2016-09-01 12:56:50 +00:00
|
|
|
|
2015-11-11 21:05:24 +00:00
|
|
|
function save_3d() {
|
2016-09-01 12:56:50 +00:00
|
|
|
var next_callback = save_rc_deadband;
|
2015-12-16 20:41:52 +00:00
|
|
|
if(semver.gte(CONFIG.apiVersion, "1.14.0")) {
|
2016-09-01 12:56:50 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_SET_3D, mspHelper.crunch(MSPCodes.MSP_SET_3D), false, next_callback);
|
2015-12-16 20:41:52 +00:00
|
|
|
} else {
|
2016-09-01 12:56:50 +00:00
|
|
|
next_callback();
|
|
|
|
}
|
2015-12-14 23:06:25 +00:00
|
|
|
}
|
2016-09-01 12:56:50 +00:00
|
|
|
|
|
|
|
function save_rc_deadband() {
|
|
|
|
var next_callback = save_sensor_alignment;
|
|
|
|
if(semver.gte(CONFIG.apiVersion, "1.17.0")) {
|
|
|
|
MSP.send_message(MSPCodes.MSP_SET_RC_DEADBAND, mspHelper.crunch(MSPCodes.MSP_SET_RC_DEADBAND), false, next_callback);
|
|
|
|
} else {
|
|
|
|
next_callback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-14 23:06:25 +00:00
|
|
|
function save_sensor_alignment() {
|
2016-06-20 18:26:00 +00:00
|
|
|
var next_callback = save_esc_protocol;
|
2015-12-16 20:41:52 +00:00
|
|
|
if(semver.gte(CONFIG.apiVersion, "1.15.0")) {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_SET_SENSOR_ALIGNMENT, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_ALIGNMENT), false, next_callback);
|
2015-12-16 20:41:52 +00:00
|
|
|
} else {
|
|
|
|
next_callback();
|
2016-12-07 22:29:17 +00:00
|
|
|
}
|
2014-09-17 13:20:21 +00:00
|
|
|
}
|
2016-06-20 18:26:00 +00:00
|
|
|
function save_esc_protocol() {
|
|
|
|
var next_callback = save_acc_trim;
|
2016-12-08 19:59:54 +00:00
|
|
|
if (semver.gte(CONFIG.flightControllerVersion, "2.8.1")) {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_SET_ADVANCED_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ADVANCED_CONFIG), false, next_callback);
|
2016-06-20 18:26:00 +00:00
|
|
|
} else {
|
|
|
|
next_callback();
|
|
|
|
}
|
|
|
|
}
|
2014-09-17 13:20:21 +00:00
|
|
|
|
|
|
|
function save_acc_trim() {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_SET_ACC_TRIM, mspHelper.crunch(MSPCodes.MSP_SET_ACC_TRIM), false
|
2015-05-07 21:10:26 +00:00
|
|
|
, semver.gte(CONFIG.apiVersion, "1.8.0") ? save_arming_config : save_to_eeprom);
|
2015-03-18 03:17:20 +00:00
|
|
|
}
|
|
|
|
|
2015-03-28 21:42:30 +00:00
|
|
|
function save_arming_config() {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_SET_ARMING_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ARMING_CONFIG), false, save_looptime_config);
|
2016-06-24 23:27:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function save_looptime_config() {
|
2016-06-25 14:56:43 +00:00
|
|
|
var next_callback = save_sensor_config;
|
2016-12-08 19:59:54 +00:00
|
|
|
if (semver.lt(CONFIG.flightControllerVersion, "2.8.1")) {
|
2016-06-24 23:27:32 +00:00
|
|
|
FC_CONFIG.loopTime = PID_ADVANCED_CONFIG.gyro_sync_denom * 125;
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_SET_LOOP_TIME, mspHelper.crunch(MSPCodes.MSP_SET_LOOP_TIME), false, next_callback);
|
2016-06-24 23:27:32 +00:00
|
|
|
} else {
|
|
|
|
next_callback();
|
2016-06-25 14:56:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
function save_sensor_config() {
|
2016-07-22 11:55:50 +00:00
|
|
|
var next_callback = save_name;
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2016-12-08 19:59:54 +00:00
|
|
|
if (semver.gte(CONFIG.flightControllerVersion, "2.8.2")) {
|
2017-01-08 21:57:14 +00:00
|
|
|
SENSOR_CONFIG.acc_hardware = $('input[id="accHardwareSwitch"]').is(':checked') ? 0 : 1;
|
2016-09-01 12:56:50 +00:00
|
|
|
SENSOR_CONFIG.baro_hardware = $('input[id="baroHardwareSwitch"]').is(':checked') ? 0 : 1;
|
|
|
|
SENSOR_CONFIG.mag_hardware = $('input[id="magHardwareSwitch"]').is(':checked') ? 0 : 1;
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_SET_SENSOR_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_CONFIG), false, next_callback);
|
2016-06-25 14:56:43 +00:00
|
|
|
} else {
|
|
|
|
next_callback();
|
2016-07-12 12:06:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-13 21:32:18 +00:00
|
|
|
function save_name() {
|
2016-12-07 22:29:17 +00:00
|
|
|
var next_callback = save_battery;
|
|
|
|
|
2016-12-08 19:59:54 +00:00
|
|
|
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
|
2016-07-13 21:32:18 +00:00
|
|
|
CONFIG.name = $.trim($('input[name="vesselName"]').val());
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_SET_NAME, mspHelper.crunch(MSPCodes.MSP_SET_NAME), false, next_callback);
|
2016-07-13 21:32:18 +00:00
|
|
|
} else {
|
|
|
|
next_callback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-07 22:29:17 +00:00
|
|
|
function save_battery() {
|
|
|
|
var next_callback = save_current;
|
2016-12-08 19:59:54 +00:00
|
|
|
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
|
2016-12-07 22:29:17 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG), false, next_callback);
|
|
|
|
} else {
|
|
|
|
next_callback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function save_current() {
|
|
|
|
var next_callback = save_to_eeprom;
|
2016-12-08 19:59:54 +00:00
|
|
|
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
|
2016-12-07 22:29:17 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_SET_CURRENT_METER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_CURRENT_METER_CONFIG), false, next_callback);
|
|
|
|
} else {
|
|
|
|
next_callback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-17 11:01:46 +00:00
|
|
|
function save_to_eeprom() {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, reboot);
|
2014-09-17 11:01:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function reboot() {
|
|
|
|
GUI.log(chrome.i18n.getMessage('configurationEepromSaved'));
|
|
|
|
|
|
|
|
GUI.tab_switch_cleanup(function() {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize);
|
2014-09-17 11:01:46 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function reinitialize() {
|
|
|
|
GUI.log(chrome.i18n.getMessage('deviceRebooting'));
|
|
|
|
|
2015-11-10 01:28:05 +00:00
|
|
|
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();
|
2015-12-17 08:52:10 +00:00
|
|
|
},2500);
|
2015-11-10 01:28:05 +00:00
|
|
|
} else {
|
|
|
|
|
|
|
|
GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_STATUS, false, false, function() {
|
2015-11-10 01:28:05 +00:00
|
|
|
GUI.log(chrome.i18n.getMessage('deviceReady'));
|
|
|
|
TABS.configuration.initialize(false, $('#content').scrollTop());
|
|
|
|
});
|
|
|
|
},1500); // 1500 ms seems to be just the right amount of delay to prevent data request timeouts
|
|
|
|
}
|
2014-09-17 11:01:46 +00:00
|
|
|
}
|
|
|
|
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_SET_BF_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BF_CONFIG), false, save_serial_config);
|
2016-12-07 22:29:17 +00:00
|
|
|
|
2014-09-17 11:01:46 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// status data pulled via separate timer with static speed
|
2014-10-01 10:58:09 +00:00
|
|
|
GUI.interval_add('status_pull', function status_pull() {
|
2016-08-06 13:31:10 +00:00
|
|
|
MSP.send_message(MSPCodes.MSP_STATUS);
|
2014-09-17 11:01:46 +00:00
|
|
|
}, 250, true);
|
2016-01-21 17:26:45 +00:00
|
|
|
GUI.interval_add('config_load_analog', load_analog, 250, true); // 4 fps
|
2015-11-11 21:01:22 +00:00
|
|
|
GUI.content_ready(callback);
|
2014-09-17 08:31:36 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-11-10 01:28:05 +00:00
|
|
|
TABS.configuration.cleanup = function (callback) {
|
2014-09-17 08:31:36 +00:00
|
|
|
if (callback) callback();
|
2015-11-10 01:28:05 +00:00
|
|
|
};
|