2014-09-17 08:31:36 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
TABS.configuration = {};
|
|
|
|
|
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';
|
|
|
|
googleAnalytics.sendAppView('Configuration');
|
|
|
|
}
|
2014-09-17 08:31:36 +00:00
|
|
|
|
|
|
|
function load_config() {
|
2015-01-04 10:28:32 +00:00
|
|
|
MSP.send_message(MSP_codes.MSP_BF_CONFIG, false, false, load_serial_config);
|
|
|
|
}
|
|
|
|
|
|
|
|
function load_serial_config() {
|
2015-05-07 21:10:26 +00:00
|
|
|
if (semver.lt(CONFIG.apiVersion, "1.6.0")) {
|
2015-02-27 01:15:37 +00:00
|
|
|
MSP.send_message(MSP_codes.MSP_CF_SERIAL_CONFIG, false, false, load_rc_map);
|
|
|
|
} else {
|
|
|
|
load_rc_map();
|
|
|
|
}
|
2014-09-17 08:31:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function load_rc_map() {
|
2015-03-29 13:51:28 +00:00
|
|
|
MSP.send_message(MSP_codes.MSP_RX_MAP, false, false, load_misc);
|
2014-09-17 08:31:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function load_misc() {
|
|
|
|
MSP.send_message(MSP_codes.MSP_MISC, false, false, load_acc_trim);
|
|
|
|
}
|
|
|
|
|
|
|
|
function load_acc_trim() {
|
2015-03-18 03:17:20 +00:00
|
|
|
MSP.send_message(MSP_codes.MSP_ACC_TRIM, false, false
|
2015-05-07 21:10:26 +00:00
|
|
|
, semver.gte(CONFIG.apiVersion, "1.8.0") ? load_arming_config : load_html);
|
2015-03-18 03:17:20 +00:00
|
|
|
}
|
|
|
|
|
2015-03-28 21:42:30 +00:00
|
|
|
function load_arming_config() {
|
2015-05-26 06:28:58 +00:00
|
|
|
MSP.send_message(MSP_codes.MSP_ARMING_CONFIG, false, false, load_loop_time);
|
|
|
|
}
|
|
|
|
|
|
|
|
function load_loop_time() {
|
|
|
|
MSP.send_message(MSP_codes.MSP_LOOP_TIME, false, false, load_html);
|
2014-09-17 08:31:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function load_html() {
|
|
|
|
$('#content').load("./tabs/configuration.html", process_html);
|
|
|
|
}
|
|
|
|
|
2014-10-12 16:38:04 +00:00
|
|
|
MSP.send_message(MSP_codes.MSP_IDENT, false, false, load_config);
|
2014-09-17 08:31:36 +00:00
|
|
|
|
2015-07-13 18:07:39 +00:00
|
|
|
function recalculate_cycles_sec() {
|
|
|
|
var looptime = $('input[name="looptime"]').val();
|
|
|
|
|
|
|
|
var message = 'Max';
|
|
|
|
if (looptime > 0) {
|
|
|
|
message = parseFloat((1 / looptime) * 1000 * 1000).toFixed(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
$('input[name="looptimehz"]').val(message);
|
|
|
|
}
|
|
|
|
|
2014-09-17 08:31:36 +00:00
|
|
|
function process_html() {
|
|
|
|
// translate to user-selected language
|
|
|
|
localize();
|
|
|
|
|
2014-09-17 12:22:16 +00:00
|
|
|
var mixer_list_e = $('select.mixerList');
|
|
|
|
for (var i = 0; i < mixerList.length; i++) {
|
|
|
|
mixer_list_e.append('<option value="' + (i + 1) + '">' + mixerList[i].name + '</option>');
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
// generate features
|
2015-01-04 08:09:10 +00:00
|
|
|
var features = [
|
|
|
|
{bit: 0, group: 'rxMode', mode: 'group', name: 'RX_PPM', description: 'PPM RX input'},
|
|
|
|
{bit: 1, group: 'batteryVoltage', name: 'VBAT', description: 'Battery voltage monitoring'},
|
|
|
|
{bit: 2, group: 'other', name: 'INFLIGHT_ACC_CAL', description: 'In-flight level calibration'},
|
|
|
|
{bit: 3, group: 'rxMode', mode: 'group', name: 'RX_SERIAL', description: 'Serial-based receiver (SPEKSAT, SBUS, SUMD)'},
|
|
|
|
{bit: 4, group: 'esc', name: 'MOTOR_STOP', description: 'Don\'t spin the motors when armed'},
|
|
|
|
{bit: 5, group: 'other', name: 'SERVO_TILT', description: 'Servo gimbal'},
|
2015-07-12 19:44:43 +00:00
|
|
|
{bit: 6, group: 'other', name: 'SOFTSERIAL', description: 'Enable CPU based serial ports'},
|
2015-01-04 08:09:10 +00:00
|
|
|
{bit: 7, group: 'gps', name: 'GPS', description: 'GPS (configure port scenario first)'},
|
|
|
|
{bit: 8, group: 'rxFailsafe', name: 'FAILSAFE', description: 'Failsafe settings on RX signal loss'},
|
|
|
|
{bit: 9, group: 'other', name: 'SONAR', description: 'Sonar'},
|
|
|
|
{bit: 10, group: 'other', name: 'TELEMETRY', description: 'Telemetry output'},
|
|
|
|
{bit: 11, group: 'batteryCurrent', name: 'CURRENT_METER', description: 'Battery current monitoring'},
|
|
|
|
{bit: 12, group: 'other', name: '3D', description: '3D mode (for use with reversible ESCs)'},
|
|
|
|
{bit: 13, group: 'rxMode', mode: 'group', name: 'RX_PARALLEL_PWM', description: 'PWM RX input'},
|
|
|
|
{bit: 14, group: 'rxMode', mode: 'group', name: 'RX_MSP', description: 'MSP RX input'},
|
|
|
|
{bit: 15, group: 'rssi', name: 'RSSI_ADC', description: 'Analog RSSI input'},
|
|
|
|
{bit: 16, group: 'other', name: 'LED_STRIP', description: 'Addressable RGB LED strip support'},
|
|
|
|
{bit: 17, group: 'other', name: 'DISPLAY', description: 'OLED Screen Display'},
|
2015-01-06 23:40:21 +00:00
|
|
|
{bit: 18, group: 'esc', name: 'ONESHOT125', description: 'ONESHOT ESC support (disconnect ESCs, remove props)'},
|
|
|
|
{bit: 19, group: 'other', name: 'BLACKBOX', description: 'Blackbox flight data recorder'}
|
2014-09-17 09:23:31 +00:00
|
|
|
];
|
2015-07-12 19:44:43 +00:00
|
|
|
|
|
|
|
if (semver.gte(CONFIG.apiVersion, "1.12.0")) {
|
|
|
|
features.push(
|
|
|
|
{bit: 20, group: 'other', name: 'CHANNEL_FORWARDING', description: 'Forward aux channels to remaining servo outputs'}
|
|
|
|
);
|
|
|
|
}
|
2014-09-17 09:23:31 +00:00
|
|
|
|
2015-01-04 08:09:10 +00:00
|
|
|
var radioGroups = [];
|
|
|
|
|
2014-09-17 11:01:46 +00:00
|
|
|
var features_e = $('.features');
|
2015-01-04 08:09:10 +00:00
|
|
|
for (var i = 0; i < features.length; i++) {
|
|
|
|
var row_e;
|
|
|
|
|
2015-03-14 02:21:41 +00:00
|
|
|
if (features[i].mode === 'group') {
|
|
|
|
row_e = $('<tr><td><input class="feature" id="feature-'
|
|
|
|
+ i
|
|
|
|
+ '" value="'
|
|
|
|
+ features[i].bit
|
|
|
|
+ '" title="'
|
|
|
|
+ features[i].name
|
|
|
|
+ '" type="radio" name="'
|
|
|
|
+ features[i].group
|
|
|
|
+ '" /></td><td><label for="feature-'
|
|
|
|
+ i
|
|
|
|
+ '">'
|
|
|
|
+ features[i].name
|
|
|
|
+ '</label></td><td>'
|
|
|
|
+ features[i].description
|
|
|
|
+ '</td>');
|
2015-01-04 08:09:10 +00:00
|
|
|
radioGroups.push(features[i].group);
|
|
|
|
} else {
|
2015-03-14 02:21:41 +00:00
|
|
|
row_e = $('<tr><td><input class="feature" id="feature-'
|
|
|
|
+ i
|
|
|
|
+ '" name="'
|
|
|
|
+ features[i].name
|
|
|
|
+ '" title="'
|
|
|
|
+ features[i].name
|
|
|
|
+ '" type="checkbox" /></td><td><label for="feature-'
|
|
|
|
+ i
|
|
|
|
+ '">'
|
|
|
|
+ features[i].name
|
|
|
|
+ '</label></td><td>'
|
|
|
|
+ features[i].description
|
|
|
|
+ '</td>');
|
|
|
|
|
2015-03-29 18:05:59 +00:00
|
|
|
var feature_e = row_e.find('input.feature');
|
|
|
|
|
2015-01-04 08:09:10 +00:00
|
|
|
feature_e.prop('checked', bit_check(BF_CONFIG.features, features[i].bit));
|
2015-03-14 02:21:41 +00:00
|
|
|
feature_e.data('bit', features[i].bit);
|
2015-01-04 08:09:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
features_e.each(function () {
|
|
|
|
if ($(this).hasClass(features[i].group)) {
|
|
|
|
$(this).append(row_e);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-09-17 11:01:46 +00:00
|
|
|
|
2015-01-04 08:09:10 +00:00
|
|
|
for (var i = 0; i < radioGroups.length; i++) {
|
|
|
|
var group = radioGroups[i];
|
|
|
|
var controls_e = $('input[name="' + group + '"].feature');
|
|
|
|
|
|
|
|
|
|
|
|
controls_e.each(function() {
|
|
|
|
var bit = parseInt($(this).attr('value'));
|
|
|
|
var state = bit_check(BF_CONFIG.features, bit);
|
|
|
|
|
|
|
|
$(this).prop('checked', state);
|
|
|
|
});
|
2014-09-17 11:01:46 +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 = [
|
2014-11-23 09:41:24 +00:00
|
|
|
'Disabled',
|
2014-09-17 15:46:21 +00:00
|
|
|
'Auto-detect',
|
|
|
|
'European EGNOS',
|
|
|
|
'North American WAAS',
|
|
|
|
'Japanese MSAS',
|
|
|
|
'Indian GAGAN'
|
|
|
|
];
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
2015-02-27 01:15:37 +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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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++) {
|
2014-11-29 09:16:53 +00:00
|
|
|
gps_ubx_sbas_e.append('<option value="' + (i - 1) + '">' + 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
|
|
|
];
|
|
|
|
|
|
|
|
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
|
2014-11-03 17:36:29 +00:00
|
|
|
$('input[name="mag_declination"]').val(MISC.mag_declination);
|
2014-09-17 13:44:28 +00:00
|
|
|
|
2015-05-26 06:28:58 +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);
|
|
|
|
$('input[name="disarmkillswitch"]').prop('checked', ARMING_CONFIG.disarm_kill_switch);
|
2015-03-30 01:48:02 +00:00
|
|
|
$('div.disarm').show();
|
|
|
|
if(bit_check(BF_CONFIG.features, 4))//MOTOR_STOP
|
2015-03-29 13:51:28 +00:00
|
|
|
$('div.disarmdelay').show();
|
2015-03-30 01:48:02 +00:00
|
|
|
else
|
|
|
|
$('div.disarmdelay').hide();
|
2015-05-26 06:28:58 +00:00
|
|
|
|
|
|
|
// fill FC loop time
|
|
|
|
$('input[name="looptime"]').val(FC_CONFIG.loopTime);
|
2015-07-13 18:07:39 +00:00
|
|
|
|
|
|
|
recalculate_cycles_sec();
|
2015-05-26 06:28:58 +00:00
|
|
|
|
|
|
|
$('div.cycles').show();
|
2015-03-18 03:17:20 +00:00
|
|
|
}
|
|
|
|
|
2014-09-17 13:44:28 +00:00
|
|
|
// fill throttle
|
2014-09-17 13:20:21 +00:00
|
|
|
$('input[name="minthrottle"]').val(MISC.minthrottle);
|
2014-09-17 18:13:13 +00:00
|
|
|
$('input[name="midthrottle"]').val(MISC.midrc);
|
2014-09-17 13:20:21 +00:00
|
|
|
$('input[name="maxthrottle"]').val(MISC.maxthrottle);
|
|
|
|
$('input[name="failsafe_throttle"]').val(MISC.failsafe_throttle);
|
|
|
|
$('input[name="mincommand"]').val(MISC.mincommand);
|
|
|
|
|
2014-09-17 13:44:28 +00:00
|
|
|
// fill battery
|
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
|
|
|
|
$('input[name="currentscale"]').val(BF_CONFIG.currentscale);
|
|
|
|
$('input[name="currentoffset"]').val(BF_CONFIG.currentoffset);
|
2014-09-18 10:24:38 +00:00
|
|
|
$('input[name="multiwiicurrentoutput"]').prop('checked', MISC.multiwiicurrentoutput);
|
2014-09-17 13:20:21 +00:00
|
|
|
|
2014-09-17 11:01:46 +00:00
|
|
|
|
|
|
|
// UI hooks
|
2015-05-26 06:28:58 +00:00
|
|
|
$('input[name="looptime"]').change(function() {
|
2015-07-13 18:07:39 +00:00
|
|
|
recalculate_cycles_sec();
|
2015-05-26 06:28:58 +00:00
|
|
|
});
|
|
|
|
|
2015-01-04 08:09:10 +00:00
|
|
|
$('input[type="checkbox"].feature', features_e).change(function () {
|
2014-09-17 11:01:46 +00:00
|
|
|
var element = $(this),
|
2015-01-04 08:09:10 +00:00
|
|
|
index = element.data('bit'),
|
2014-09-17 11:01:46 +00:00
|
|
|
state = element.is(':checked');
|
|
|
|
|
|
|
|
if (state) {
|
|
|
|
BF_CONFIG.features = bit_set(BF_CONFIG.features, index);
|
2015-03-14 00:02:05 +00:00
|
|
|
if(element.attr('name') === 'MOTOR_STOP')
|
2015-03-29 13:51:28 +00:00
|
|
|
$('div.disarmdelay').show();
|
2014-09-17 11:01:46 +00:00
|
|
|
} else {
|
|
|
|
BF_CONFIG.features = bit_clear(BF_CONFIG.features, index);
|
2015-03-14 00:02:05 +00:00
|
|
|
if(element.attr('name') === 'MOTOR_STOP')
|
2015-03-29 13:51:28 +00:00
|
|
|
$('div.disarmdelay').hide();
|
2014-09-17 11:01:46 +00:00
|
|
|
}
|
|
|
|
});
|
2014-09-17 09:23:31 +00:00
|
|
|
|
2015-01-04 08:09:10 +00:00
|
|
|
// UI hooks
|
|
|
|
$('input[type="radio"].feature', features_e).change(function () {
|
|
|
|
var element = $(this),
|
|
|
|
group = element.attr('name');
|
|
|
|
|
|
|
|
var controls_e = $('input[name="' + group + '"]');
|
|
|
|
var selected_bit = controls_e.filter(':checked').val();
|
|
|
|
|
|
|
|
controls_e.each(function() {
|
|
|
|
var bit = $(this).attr('value');
|
|
|
|
|
|
|
|
var selected = (selected_bit == bit);
|
|
|
|
if (selected) {
|
|
|
|
BF_CONFIG.features = bit_set(BF_CONFIG.features, bit);
|
|
|
|
} else {
|
|
|
|
BF_CONFIG.features = bit_clear(BF_CONFIG.features, bit);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
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());
|
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());
|
|
|
|
ARMING_CONFIG.disarm_kill_switch = ~~$('input[name="disarmkillswitch"]').is(':checked'); // ~~ boolean to decimal conversion
|
2015-05-26 06:28:58 +00:00
|
|
|
FC_CONFIG.loopTime = parseInt($('input[name="looptime"]').val());
|
2015-03-29 00:24:32 +00:00
|
|
|
}
|
|
|
|
|
2014-09-17 13:20:21 +00:00
|
|
|
MISC.minthrottle = parseInt($('input[name="minthrottle"]').val());
|
2014-09-17 18:13:13 +00:00
|
|
|
MISC.midrc = parseInt($('input[name="midthrottle"]').val());
|
2014-09-17 13:20:21 +00:00
|
|
|
MISC.maxthrottle = parseInt($('input[name="maxthrottle"]').val());
|
|
|
|
MISC.failsafe_throttle = parseInt($('input[name="failsafe_throttle"]').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());
|
2014-09-18 10:24:38 +00:00
|
|
|
MISC.multiwiicurrentoutput = ~~$('input[name="multiwiicurrentoutput"]').is(':checked'); // ~~ boolean to decimal conversion
|
2014-09-17 13:44:28 +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")) {
|
2015-02-27 01:15:37 +00:00
|
|
|
MSP.send_message(MSP_codes.MSP_SET_CF_SERIAL_CONFIG, MSP.crunch(MSP_codes.MSP_SET_CF_SERIAL_CONFIG), false, save_misc);
|
|
|
|
} else {
|
|
|
|
save_misc();
|
|
|
|
}
|
2015-01-04 10:28:32 +00:00
|
|
|
}
|
|
|
|
|
2014-09-17 13:20:21 +00:00
|
|
|
function save_misc() {
|
|
|
|
MSP.send_message(MSP_codes.MSP_SET_MISC, MSP.crunch(MSP_codes.MSP_SET_MISC), false, save_acc_trim);
|
|
|
|
}
|
|
|
|
|
|
|
|
function save_acc_trim() {
|
2015-03-18 03:17:20 +00:00
|
|
|
MSP.send_message(MSP_codes.MSP_SET_ACC_TRIM, MSP.crunch(MSP_codes.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() {
|
2015-05-26 06:28:58 +00:00
|
|
|
MSP.send_message(MSP_codes.MSP_SET_ARMING_CONFIG, MSP.crunch(MSP_codes.MSP_SET_ARMING_CONFIG), false, save_looptime_config);
|
|
|
|
}
|
|
|
|
|
|
|
|
function save_looptime_config() {
|
|
|
|
MSP.send_message(MSP_codes.MSP_SET_LOOP_TIME, MSP.crunch(MSP_codes.MSP_SET_LOOP_TIME), false, save_to_eeprom);
|
2014-09-17 13:20:21 +00:00
|
|
|
}
|
|
|
|
|
2014-09-17 11:01:46 +00:00
|
|
|
function save_to_eeprom() {
|
|
|
|
MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, reboot);
|
|
|
|
}
|
|
|
|
|
|
|
|
function reboot() {
|
|
|
|
GUI.log(chrome.i18n.getMessage('configurationEepromSaved'));
|
|
|
|
|
|
|
|
GUI.tab_switch_cleanup(function() {
|
|
|
|
MSP.send_message(MSP_codes.MSP_SET_REBOOT, false, false, reinitialize);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function reinitialize() {
|
|
|
|
GUI.log(chrome.i18n.getMessage('deviceRebooting'));
|
|
|
|
|
2014-10-01 11:16:22 +00:00
|
|
|
GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() {
|
|
|
|
MSP.send_message(MSP_codes.MSP_IDENT, false, false, function () {
|
|
|
|
GUI.log(chrome.i18n.getMessage('deviceReady'));
|
2014-10-07 22:30:54 +00:00
|
|
|
TABS.configuration.initialize(false, $('#content').scrollTop());
|
2014-10-01 11:16:22 +00:00
|
|
|
});
|
2014-12-20 00:29:49 +00:00
|
|
|
},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
|
|
|
}
|
|
|
|
|
2015-01-04 10:28:32 +00:00
|
|
|
MSP.send_message(MSP_codes.MSP_SET_BF_CONFIG, MSP.crunch(MSP_codes.MSP_SET_BF_CONFIG), false, save_serial_config);
|
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() {
|
2014-09-17 11:01:46 +00:00
|
|
|
MSP.send_message(MSP_codes.MSP_STATUS);
|
|
|
|
}, 250, true);
|
2014-09-17 08:31:36 +00:00
|
|
|
|
|
|
|
if (callback) callback();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TABS.configuration.cleanup = function (callback) {
|
|
|
|
if (callback) callback();
|
2014-12-25 11:25:23 +00:00
|
|
|
};
|