diff --git a/tabs/auxiliary_configuration.js b/tabs/auxiliary_configuration.js index 983ac1971c..271bd8c4ec 100644 --- a/tabs/auxiliary_configuration.js +++ b/tabs/auxiliary_configuration.js @@ -1,11 +1,10 @@ function tab_initialize_auxiliary_configuration() { ga_tracker.sendAppView('Auxiliary Configuration'); - - $('#content').load("./tabs/auxiliary_configuration.html", function() { - GUI.active_tab = 'auxiliary_configuration'; + GUI.active_tab = 'auxiliary_configuration'; - send_message(MSP_codes.MSP_BOXNAMES, MSP_codes.MSP_BOXNAMES, false, function() { - send_message(MSP_codes.MSP_BOX, MSP_codes.MSP_BOX, false, function() { + send_message(MSP_codes.MSP_BOXNAMES, MSP_codes.MSP_BOXNAMES, false, function() { + send_message(MSP_codes.MSP_BOX, MSP_codes.MSP_BOX, false, function() { + $('#content').load("./tabs/auxiliary_configuration.html", function() { // generate table from the supplied AUX names and AUX data for (var i = 0; i < AUX_CONFIG.length; i++) { $('.boxes > tbody:last').append( @@ -77,25 +76,25 @@ function tab_initialize_auxiliary_configuration() { // enable data pulling GUI.interval_add('aux_data_poll', function() { - send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS); - send_message(MSP_codes.MSP_RC, MSP_codes.MSP_RC, false, function() { - for (var i = 0; i < AUX_CONFIG.length; i++) { - if (bit_check(CONFIG.mode, i)) { - $('td.name').eq(i).addClass('on').removeClass('off'); - } else { - $('td.name').eq(i).removeClass('on').removeClass('off'); - - if (AUX_CONFIG_values[i] > 0) { - $('td.name').eq(i).addClass('off'); + send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS); + send_message(MSP_codes.MSP_RC, MSP_codes.MSP_RC, false, function() { + for (var i = 0; i < AUX_CONFIG.length; i++) { + if (bit_check(CONFIG.mode, i)) { + $('td.name').eq(i).addClass('on').removeClass('off'); + } else { + $('td.name').eq(i).removeClass('on').removeClass('off'); + + if (AUX_CONFIG_values[i] > 0) { + $('td.name').eq(i).addClass('off'); + } } } - } - - box_highlight(RC.AUX1, 2); - box_highlight(RC.AUX2, 5); - box_highlight(RC.AUX3, 8); - box_highlight(RC.AUX4, 11); - }); + + box_highlight(RC.AUX1, 2); + box_highlight(RC.AUX2, 5); + box_highlight(RC.AUX3, 8); + box_highlight(RC.AUX4, 11); + }); }, 50, true); }); }); diff --git a/tabs/cli.js b/tabs/cli.js index 330fb825b3..e989a71395 100644 --- a/tabs/cli.js +++ b/tabs/cli.js @@ -23,13 +23,12 @@ cli_history = new CliHistory(); function tab_initialize_cli() { ga_tracker.sendAppView('CLI Page'); + GUI.active_tab = 'cli'; - $('#content').load("./tabs/cli.html", function() { - GUI.active_tab = 'cli'; - - // remove any active interval for delayed command - MSP.callbacks_cleanup(); - + // remove any active interval for delayed command + MSP.callbacks_cleanup(); + + $('#content').load("./tabs/cli.html", function() { CLI_active = true; // Enter CLI mode diff --git a/tabs/default.js b/tabs/default.js index 3452e6e363..c6f39c1542 100644 --- a/tabs/default.js +++ b/tabs/default.js @@ -1,7 +1,7 @@ function tab_initialize_default() { - $('#content').load("./tabs/default.html", function() { - GUI.active_tab = 'default'; - + GUI.active_tab = 'default'; + + $('#content').load("./tabs/default.html", function() { // load changelog content $('div.changelog.configurator .wrapper').load('./changelog.html'); diff --git a/tabs/gps.js b/tabs/gps.js index f84eff9d7c..14a8ea1a8f 100644 --- a/tabs/gps.js +++ b/tabs/gps.js @@ -1,9 +1,8 @@ function tab_initialize_gps () { ga_tracker.sendAppView('GPS Page'); + GUI.active_tab = 'gps'; $('#content').load("./tabs/gps.html", function() { - GUI.active_tab = 'gps'; - // enable data pulling GUI.interval_add('gps_pull', function() { // Update GPS data diff --git a/tabs/initial_setup.js b/tabs/initial_setup.js index fc5f4d5c8d..f90af4c25a 100644 --- a/tabs/initial_setup.js +++ b/tabs/initial_setup.js @@ -1,248 +1,245 @@ function tab_initialize_initial_setup() { ga_tracker.sendAppView('Initial Setup'); + GUI.active_tab = 'initial_setup'; - $('#content').load("./tabs/initial_setup.html", function() { - GUI.active_tab = 'initial_setup'; - - send_message(MSP_codes.MSP_IDENT, MSP_codes.MSP_IDENT, false, function() { - send_message(MSP_codes.MSP_ACC_TRIM, MSP_codes.MSP_ACC_TRIM, false, function() { - send_message(MSP_codes.MSP_MISC, MSP_codes.MSP_MISC, false, function() { - var yaw_fix = 0.0; + send_message(MSP_codes.MSP_ACC_TRIM, MSP_codes.MSP_ACC_TRIM, false, function() { + send_message(MSP_codes.MSP_MISC, MSP_codes.MSP_MISC, false, function() { + $('#content').load("./tabs/initial_setup.html", function() { + var yaw_fix = 0.0; + + // Fill in misc stuff + $('input[name="mincellvoltage"]').val(MISC.vbatmincellvoltage); + $('input[name="maxcellvoltage"]').val(MISC.vbatmaxcellvoltage); + $('input[name="voltagescale"]').val(MISC.vbatscale); + + $('input[name="minthrottle"]').val(MISC.minthrottle); + $('input[name="maxthrottle"]').val(MISC.maxthrottle); + $('input[name="failsafe_throttle"]').val(MISC.failsafe_throttle); + $('input[name="mincommand"]').val(MISC.mincommand); + + $('input[name="mag_declination"]').val(MISC.mag_declination / 10); + + // Fill in the accel trimms from CONFIG object + $('input[name="pitch"]').val(CONFIG.accelerometerTrims[0]); + $('input[name="roll"]').val(CONFIG.accelerometerTrims[1]); + + // Display multiType + var str = ''; + switch (CONFIG.multiType) { + case 1: // TRI + str = 'TRI'; + break; + case 2: // QUAD + + str = 'Quad +'; + break; + case 3: // QUAD X + str = 'Quad X'; + break; + case 4: // BI + str = 'BI'; + break; + case 5: // GIMBAL + str = 'Gimbal'; + break; + case 6: // Y6 + str = 'Y6'; + break; + case 7: // HEX 6 + str = 'HEX 6'; + break; + case 8: // FLYING_WING + str = 'Flying Wing'; + break; + case 9: // Y4 + str = 'Y4'; + break; + case 10: // HEX6 X + str = 'HEX6 X'; + break; + case 11: // OCTO X8 + case 12: + case 13: + str = 'OCTO X8'; + break; + case 14: // AIRPLANE + str = 'Airplane'; + break; + case 15: // Heli 120 + str = 'Heli 120'; + break; + case 16: // Heli 90 + str = 'Heli 90'; + break; + case 17: // Vtail + str = 'Vtail'; + break; + case 18: // HEX6 H + str = 'HEX6 H'; + break; + case 19: // PPM to SERVO + str = 'PPM to SERVO'; + break; + case 20: // Dualcopter + str = 'Dualcopter'; + break; + case 21: // + str = 'Singlecopter'; + break; + } + + $('span.model').html('Model: ' + str); + + // UI Hooks + $('a.calibrateAccel').click(function() { + var self = $(this); - // Fill in misc stuff - $('input[name="mincellvoltage"]').val(MISC.vbatmincellvoltage); - $('input[name="maxcellvoltage"]').val(MISC.vbatmaxcellvoltage); - $('input[name="voltagescale"]').val(MISC.vbatscale); - - $('input[name="minthrottle"]').val(MISC.minthrottle); - $('input[name="maxthrottle"]').val(MISC.maxthrottle); - $('input[name="failsafe_throttle"]').val(MISC.failsafe_throttle); - $('input[name="mincommand"]').val(MISC.mincommand); - - $('input[name="mag_declination"]').val(MISC.mag_declination / 10); - - // Fill in the accel trimms from CONFIG object - $('input[name="pitch"]').val(CONFIG.accelerometerTrims[0]); - $('input[name="roll"]').val(CONFIG.accelerometerTrims[1]); - - // Display multiType - var str = ''; - switch (CONFIG.multiType) { - case 1: // TRI - str = 'TRI'; - break; - case 2: // QUAD + - str = 'Quad +'; - break; - case 3: // QUAD X - str = 'Quad X'; - break; - case 4: // BI - str = 'BI'; - break; - case 5: // GIMBAL - str = 'Gimbal'; - break; - case 6: // Y6 - str = 'Y6'; - break; - case 7: // HEX 6 - str = 'HEX 6'; - break; - case 8: // FLYING_WING - str = 'Flying Wing'; - break; - case 9: // Y4 - str = 'Y4'; - break; - case 10: // HEX6 X - str = 'HEX6 X'; - break; - case 11: // OCTO X8 - case 12: - case 13: - str = 'OCTO X8'; - break; - case 14: // AIRPLANE - str = 'Airplane'; - break; - case 15: // Heli 120 - str = 'Heli 120'; - break; - case 16: // Heli 90 - str = 'Heli 90'; - break; - case 17: // Vtail - str = 'Vtail'; - break; - case 18: // HEX6 H - str = 'HEX6 H'; - break; - case 19: // PPM to SERVO - str = 'PPM to SERVO'; - break; - case 20: // Dualcopter - str = 'Dualcopter'; - break; - case 21: // - str = 'Singlecopter'; - break; + if (!self.hasClass('calibrating')) { + self.addClass('calibrating'); + + // During this period MCU won't be able to process any serial commands because its locked in a for/while loop + // until this operation finishes, sending more commands through data_poll() will result in serial buffer overflow + GUI.interval_pause('initial_setup_data_pull'); + send_message(MSP_codes.MSP_ACC_CALIBRATION, MSP_codes.MSP_ACC_CALIBRATION, false, function() { + GUI.log('Accelerometer calibration started'); + }); + + GUI.timeout_add('button_reset', function() { + GUI.interval_resume('initial_setup_data_pull'); + + GUI.log('Accelerometer calibration finished'); + + self.removeClass('calibrating'); + }, 2000); } - - $('span.model').html('Model: ' + str); - - // UI Hooks - $('a.calibrateAccel').click(function() { - var self = $(this); - - if (!self.hasClass('calibrating')) { - self.addClass('calibrating'); - - // During this period MCU won't be able to process any serial commands because its locked in a for/while loop - // until this operation finishes, sending more commands through data_poll() will result in serial buffer overflow - GUI.interval_pause('initial_setup_data_pull'); - send_message(MSP_codes.MSP_ACC_CALIBRATION, MSP_codes.MSP_ACC_CALIBRATION, false, function() { - GUI.log('Accelerometer calibration started'); - }); - - GUI.timeout_add('button_reset', function() { - GUI.interval_resume('initial_setup_data_pull'); - - GUI.log('Accelerometer calibration finished'); - - self.removeClass('calibrating'); - }, 2000); - } - }); - - $('a.calibrateMag').click(function() { - var self = $(this); - - if (!self.hasClass('calibrating')) { - self.addClass('calibrating'); - - send_message(MSP_codes.MSP_MAG_CALIBRATION, MSP_codes.MSP_MAG_CALIBRATION, false, function() { - GUI.log('Magnetometer calibration started'); - }); - - GUI.timeout_add('button_reset', function() { - GUI.log('Magnetometer calibration finished'); - self.removeClass('calibrating'); - }, 30000); - } - }); - - $('a.resetSettings').click(function() { - send_message(MSP_codes.MSP_RESET_CONF, MSP_codes.MSP_RESET_CONF, false, function() { - GUI.log('Settings restored to default'); - - GUI.tab_switch_cleanup(function() { - tab_initialize_initial_setup(); - }); - }); - }); - - - $('a.update').click(function() { - CONFIG.accelerometerTrims[0] = parseInt($('input[name="pitch"]').val()); - CONFIG.accelerometerTrims[1] = parseInt($('input[name="roll"]').val()); - - var buffer_out = new Array(); - buffer_out[0] = lowByte(CONFIG.accelerometerTrims[0]); - buffer_out[1] = highByte(CONFIG.accelerometerTrims[0]); - buffer_out[2] = lowByte(CONFIG.accelerometerTrims[1]); - buffer_out[3] = highByte(CONFIG.accelerometerTrims[1]); - - // Send over the new trims - send_message(MSP_codes.MSP_SET_ACC_TRIM, buffer_out); - - MISC.vbatmincellvoltage = parseFloat($('input[name="mincellvoltage"]').val()) * 10; - MISC.vbatmaxcellvoltage = parseFloat($('input[name="maxcellvoltage"]').val()) * 10; - MISC.vbatscale = parseInt($('input[name="voltagescale"]').val()); - - MISC.minthrottle = parseInt($('input[name="minthrottle"]').val()); - MISC.maxthrottle = parseInt($('input[name="maxthrottle"]').val()); - MISC.failsafe_throttle = parseInt($('input[name="failsafe_throttle"]').val()); - MISC.mincommand = parseInt($('input[name="mincommand"]').val()); - - MISC.mag_declination = parseFloat($('input[name="mag_declination"]').val()) * 10; - - // we also have to fill the unsupported bytes - var buffer_out = new Array(); - buffer_out[0] = 0; // powerfailmeter - buffer_out[1] = 0; - buffer_out[2] = lowByte(MISC.minthrottle); - buffer_out[3] = highByte(MISC.minthrottle); - buffer_out[4] = lowByte(MISC.maxthrottle); - buffer_out[5] = highByte(MISC.maxthrottle); - buffer_out[6] = lowByte(MISC.mincommand); - buffer_out[7] = highByte(MISC.mincommand); - buffer_out[8] = lowByte(MISC.failsafe_throttle); - buffer_out[9] = highByte(MISC.failsafe_throttle); - buffer_out[10] = 0; - buffer_out[11] = 0; - buffer_out[12] = 0; - buffer_out[13] = 0; - buffer_out[14] = 0; - buffer_out[15] = 0; - buffer_out[16] = lowByte(MISC.mag_declination); - buffer_out[17] = highByte(MISC.mag_declination); - buffer_out[18] = MISC.vbatscale; - buffer_out[19] = MISC.vbatmincellvoltage; - buffer_out[20] = MISC.vbatmaxcellvoltage; - buffer_out[21] = 0; // vbatlevel_crit (unused) - - // Send over new misc - send_message(MSP_codes.MSP_SET_MISC, buffer_out); - - // Save changes to EEPROM - send_message(MSP_codes.MSP_EEPROM_WRITE, MSP_codes.MSP_EEPROM_WRITE, false, function() { - GUI.log('EEPROM saved'); - - var element = $('a.update'); - element.addClass('success'); - - GUI.timeout_add('success_highlight', function() { - element.removeClass('success'); - }, 2000); - }); - }); - - // reset yaw button hook - $('div#interactive_block > a.reset').click(function() { - yaw_fix = SENSOR_DATA.kinematicsZ * - 1.0; - console.log("YAW reset to 0"); - }); - - $('#content .backup').click(configuration_backup); - - $('#content .restore').click(configuration_restore); - - GUI.interval_add('initial_setup_data_pull', function() { - // Update voltage indicator - $('.bat-voltage').html(ANALOG.voltage + ' V'); - - // Request new data, if transmission fails it doesn't matter as new transmission will be requested after 50ms - send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS, false, function() { // cycle time, active sensors, etc... - send_message(MSP_codes.MSP_ANALOG, MSP_codes.MSP_ANALOG, false, function() { // battery voltage - send_message(MSP_codes.MSP_ATTITUDE, MSP_codes.MSP_ATTITUDE, false, function() { // kinematics - // Update cube - var cube = $('div#cube'); - - cube.css('-webkit-transform', 'rotateY(' + ((SENSOR_DATA.kinematicsZ * -1.0) - yaw_fix) + 'deg)'); - $('#cubePITCH', cube).css('-webkit-transform', 'rotateX(' + SENSOR_DATA.kinematicsY + 'deg)'); - $('#cubeROLL', cube).css('-webkit-transform', 'rotateZ(' + SENSOR_DATA.kinematicsX + 'deg)'); - - /* - // Update Compass - $('div#compass .pointer').css('-webkit-transform', 'rotate(' + (SENSOR_DATA.kinematicsZ) + 'deg)'); - $('div#compass .value').html(SENSOR_DATA.kinematicsZ + '°'); - */ - }); - }); - }); - }, 50, true); }); + + $('a.calibrateMag').click(function() { + var self = $(this); + + if (!self.hasClass('calibrating')) { + self.addClass('calibrating'); + + send_message(MSP_codes.MSP_MAG_CALIBRATION, MSP_codes.MSP_MAG_CALIBRATION, false, function() { + GUI.log('Magnetometer calibration started'); + }); + + GUI.timeout_add('button_reset', function() { + GUI.log('Magnetometer calibration finished'); + self.removeClass('calibrating'); + }, 30000); + } + }); + + $('a.resetSettings').click(function() { + send_message(MSP_codes.MSP_RESET_CONF, MSP_codes.MSP_RESET_CONF, false, function() { + GUI.log('Settings restored to default'); + + GUI.tab_switch_cleanup(function() { + tab_initialize_initial_setup(); + }); + }); + }); + + + $('a.update').click(function() { + CONFIG.accelerometerTrims[0] = parseInt($('input[name="pitch"]').val()); + CONFIG.accelerometerTrims[1] = parseInt($('input[name="roll"]').val()); + + var buffer_out = new Array(); + buffer_out[0] = lowByte(CONFIG.accelerometerTrims[0]); + buffer_out[1] = highByte(CONFIG.accelerometerTrims[0]); + buffer_out[2] = lowByte(CONFIG.accelerometerTrims[1]); + buffer_out[3] = highByte(CONFIG.accelerometerTrims[1]); + + // Send over the new trims + send_message(MSP_codes.MSP_SET_ACC_TRIM, buffer_out); + + MISC.vbatmincellvoltage = parseFloat($('input[name="mincellvoltage"]').val()) * 10; + MISC.vbatmaxcellvoltage = parseFloat($('input[name="maxcellvoltage"]').val()) * 10; + MISC.vbatscale = parseInt($('input[name="voltagescale"]').val()); + + MISC.minthrottle = parseInt($('input[name="minthrottle"]').val()); + MISC.maxthrottle = parseInt($('input[name="maxthrottle"]').val()); + MISC.failsafe_throttle = parseInt($('input[name="failsafe_throttle"]').val()); + MISC.mincommand = parseInt($('input[name="mincommand"]').val()); + + MISC.mag_declination = parseFloat($('input[name="mag_declination"]').val()) * 10; + + // we also have to fill the unsupported bytes + var buffer_out = new Array(); + buffer_out[0] = 0; // powerfailmeter + buffer_out[1] = 0; + buffer_out[2] = lowByte(MISC.minthrottle); + buffer_out[3] = highByte(MISC.minthrottle); + buffer_out[4] = lowByte(MISC.maxthrottle); + buffer_out[5] = highByte(MISC.maxthrottle); + buffer_out[6] = lowByte(MISC.mincommand); + buffer_out[7] = highByte(MISC.mincommand); + buffer_out[8] = lowByte(MISC.failsafe_throttle); + buffer_out[9] = highByte(MISC.failsafe_throttle); + buffer_out[10] = 0; + buffer_out[11] = 0; + buffer_out[12] = 0; + buffer_out[13] = 0; + buffer_out[14] = 0; + buffer_out[15] = 0; + buffer_out[16] = lowByte(MISC.mag_declination); + buffer_out[17] = highByte(MISC.mag_declination); + buffer_out[18] = MISC.vbatscale; + buffer_out[19] = MISC.vbatmincellvoltage; + buffer_out[20] = MISC.vbatmaxcellvoltage; + buffer_out[21] = 0; // vbatlevel_crit (unused) + + // Send over new misc + send_message(MSP_codes.MSP_SET_MISC, buffer_out); + + // Save changes to EEPROM + send_message(MSP_codes.MSP_EEPROM_WRITE, MSP_codes.MSP_EEPROM_WRITE, false, function() { + GUI.log('EEPROM saved'); + + var element = $('a.update'); + element.addClass('success'); + + GUI.timeout_add('success_highlight', function() { + element.removeClass('success'); + }, 2000); + }); + }); + + // reset yaw button hook + $('div#interactive_block > a.reset').click(function() { + yaw_fix = SENSOR_DATA.kinematicsZ * - 1.0; + console.log("YAW reset to 0"); + }); + + $('#content .backup').click(configuration_backup); + + $('#content .restore').click(configuration_restore); + + GUI.interval_add('initial_setup_data_pull', function() { + // Update voltage indicator + $('.bat-voltage').html(ANALOG.voltage + ' V'); + + // Request new data, if transmission fails it doesn't matter as new transmission will be requested after 50ms + send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS, false, function() { // cycle time, active sensors, etc... + send_message(MSP_codes.MSP_ANALOG, MSP_codes.MSP_ANALOG, false, function() { // battery voltage + send_message(MSP_codes.MSP_ATTITUDE, MSP_codes.MSP_ATTITUDE, false, function() { // kinematics + // Update cube + var cube = $('div#cube'); + + cube.css('-webkit-transform', 'rotateY(' + ((SENSOR_DATA.kinematicsZ * -1.0) - yaw_fix) + 'deg)'); + $('#cubePITCH', cube).css('-webkit-transform', 'rotateX(' + SENSOR_DATA.kinematicsY + 'deg)'); + $('#cubeROLL', cube).css('-webkit-transform', 'rotateZ(' + SENSOR_DATA.kinematicsX + 'deg)'); + + /* + // Update Compass + $('div#compass .pointer').css('-webkit-transform', 'rotate(' + (SENSOR_DATA.kinematicsZ) + 'deg)'); + $('div#compass .value').html(SENSOR_DATA.kinematicsZ + '°'); + */ + }); + }); + }); + }, 50, true); }); }); }); diff --git a/tabs/motor_outputs.js b/tabs/motor_outputs.js index bf562b7973..b2909cbdf8 100644 --- a/tabs/motor_outputs.js +++ b/tabs/motor_outputs.js @@ -1,15 +1,14 @@ function tab_initialize_motor_outputs() { ga_tracker.sendAppView('Motor Outputs Page'); + GUI.active_tab = 'motor_outputs'; - $('#content').load("./tabs/motor_outputs.html", function() { - GUI.active_tab = 'motor_outputs'; - - // if CAP_DYNBALANCE is true - if (bit_check(CONFIG.capability, 2)) { - $('div.motor_testing').show(); - } - - send_message(MSP_codes.MSP_MISC, MSP_codes.MSP_MISC, false, function() { + send_message(MSP_codes.MSP_MISC, MSP_codes.MSP_MISC, false, function() { + $('#content').load("./tabs/motor_outputs.html", function() { + // if CAP_DYNBALANCE is true + if (bit_check(CONFIG.capability, 2)) { + $('div.motor_testing').show(); + } + $('input.min').val(MISC.minthrottle); $('input.max').val(MISC.maxthrottle); @@ -18,92 +17,92 @@ function tab_initialize_motor_outputs() { $('div.sliders input').prop('max', MISC.maxthrottle); $('div.sliders input').val(MISC.minthrottle); $('div.values li:not(:last)').html(MISC.minthrottle); - }); - - // UI hooks - $('div.sliders input:not(.master)').change(function() { - var index = $(this).index(); - $('div.values li').eq(index).html($(this).val()); - - // send data to mcu - var buffer_out = []; - - for (var i = 0; i < 8; i++) { - var val = parseInt($('div.sliders input').eq(i).val()); + // UI hooks + $('div.sliders input:not(.master)').change(function() { + var index = $(this).index(); - buffer_out.push(lowByte(val)); - buffer_out.push(highByte(val)); - } - - send_message(MSP_codes.MSP_SET_MOTOR, buffer_out); - }); - - $('div.sliders input.master').change(function() { - var val = $(this).val(); - - $('div.sliders input').val(val); - $('div.sliders input:not(:last):first').change(); - }); - - $('div.notice input[type="checkbox"]').change(function() { - if ($(this).is(':checked')) { - $('div.sliders input, .notice input[type="number"]').prop('disabled', false); - } else { - // disable sliders / min max - $('div.sliders input, .notice input[type="number"]').prop('disabled', true); + $('div.values li').eq(index).html($(this).val()); - // change all values to default - $('div.sliders input').val(1000); - $('div.values li:not(:last)').html(1000); + // send data to mcu + var buffer_out = []; + + for (var i = 0; i < 8; i++) { + var val = parseInt($('div.sliders input').eq(i).val()); + + buffer_out.push(lowByte(val)); + buffer_out.push(highByte(val)); + } + + send_message(MSP_codes.MSP_SET_MOTOR, buffer_out); + }); + + $('div.sliders input.master').change(function() { + var val = $(this).val(); + + $('div.sliders input').val(val); + $('div.sliders input:not(:last):first').change(); + }); + + $('div.notice input[type="checkbox"]').change(function() { + if ($(this).is(':checked')) { + $('div.sliders input, .notice input[type="number"]').prop('disabled', false); + } else { + // disable sliders / min max + $('div.sliders input, .notice input[type="number"]').prop('disabled', true); + + // change all values to default + $('div.sliders input').val(1000); + $('div.values li:not(:last)').html(1000); + + // trigger change event so values are sent to mcu + $('div.sliders input').change(); + } + }); + + $('div.notice input[type="number"]').change(function() { + var min = parseInt($('div.notice .min').val()); + var max = parseInt($('div.notice .max').val()); + + + $('div.sliders input').prop('min', min); + $('div.sliders input').prop('max', max); // trigger change event so values are sent to mcu $('div.sliders input').change(); - } - }); - - $('div.notice input[type="number"]').change(function() { - var min = parseInt($('div.notice .min').val()); - var max = parseInt($('div.notice .max').val()); + }); - - $('div.sliders input').prop('min', min); - $('div.sliders input').prop('max', max); - - // trigger change event so values are sent to mcu - $('div.sliders input').change(); - }); - - // enable Motor data pulling - GUI.interval_add('motor_poll', function() { - // Request New data - send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS, false, function() { - send_message(MSP_codes.MSP_MOTOR, MSP_codes.MSP_MOTOR, false, function() { - send_message(MSP_codes.MSP_SERVO, MSP_codes.MSP_SERVO, false, function() { - // Update UI - - var block_height = $('div.m-block:first').height(); - - for (var i = 0; i < MOTOR_DATA.length; i++) { - MOTOR_DATA[i] -= 1000; - var margin_top = block_height - (MOTOR_DATA[i] * (block_height / 1000)); - var height = (MOTOR_DATA[i] * (block_height / 1000)); - var color = parseInt(MOTOR_DATA[i] * 0.256); + // enable Motor data pulling + GUI.interval_add('motor_poll', function() { + // Request New data + send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS, false, function() { + send_message(MSP_codes.MSP_MOTOR, MSP_codes.MSP_MOTOR, false, function() { + send_message(MSP_codes.MSP_SERVO, MSP_codes.MSP_SERVO, false, function() { + // Update UI - $('.motor-' + i + ' .indicator').css({'margin-top' : margin_top + 'px', 'height' : height + 'px', 'background-color' : 'rgb(' + color + ',0,0)'}); - } - - for (var i = 0; i < SERVO_DATA.length; i++) { - SERVO_DATA[i] -= 1000; - var margin_top = block_height - (SERVO_DATA[i] * (block_height / 1000)); - var height = (SERVO_DATA[i] * (block_height / 1000)); - var color = parseInt(SERVO_DATA[i] * 0.256); + var block_height = $('div.m-block:first').height(); - $('.servo-' + i + ' .indicator').css({'margin-top' : margin_top + 'px', 'height' : height + 'px', 'background-color' : 'rgb(' + color + ',0,0)'}); - } + for (var i = 0; i < MOTOR_DATA.length; i++) { + MOTOR_DATA[i] -= 1000; + var margin_top = block_height - (MOTOR_DATA[i] * (block_height / 1000)); + var height = (MOTOR_DATA[i] * (block_height / 1000)); + var color = parseInt(MOTOR_DATA[i] * 0.256); + + $('.motor-' + i + ' .indicator').css({'margin-top' : margin_top + 'px', 'height' : height + 'px', 'background-color' : 'rgb(' + color + ',0,0)'}); + } + + for (var i = 0; i < SERVO_DATA.length; i++) { + SERVO_DATA[i] -= 1000; + var margin_top = block_height - (SERVO_DATA[i] * (block_height / 1000)); + var height = (SERVO_DATA[i] * (block_height / 1000)); + var color = parseInt(SERVO_DATA[i] * 0.256); + + $('.servo-' + i + ' .indicator').css({'margin-top' : margin_top + 'px', 'height' : height + 'px', 'background-color' : 'rgb(' + color + ',0,0)'}); + } + }); }); }); - }); - }, 50, true); + }, 50, true); + }); }); } \ No newline at end of file diff --git a/tabs/pid_tuning.js b/tabs/pid_tuning.js index 58c9ee9e28..e2676750f5 100644 --- a/tabs/pid_tuning.js +++ b/tabs/pid_tuning.js @@ -1,11 +1,10 @@ function tab_initialize_pid_tuning() { ga_tracker.sendAppView('PID Tuning'); + GUI.active_tab = 'pid_tuning'; - $('#content').load("./tabs/pid_tuning.html", function() { - GUI.active_tab = 'pid_tuning'; - - send_message(MSP_codes.MSP_PID, MSP_codes.MSP_PID, false, function() { - send_message(MSP_codes.MSP_RC_TUNING, MSP_codes.MSP_RC_TUNING, false, function() { + send_message(MSP_codes.MSP_PID, MSP_codes.MSP_PID, false, function() { + send_message(MSP_codes.MSP_RC_TUNING, MSP_codes.MSP_RC_TUNING, false, function() { + $('#content').load("./tabs/pid_tuning.html", function() { // Fill in the data from PIDs array var i = 0; $('.pid_tuning .ROLL input').each(function() { @@ -281,8 +280,8 @@ function tab_initialize_pid_tuning() { // enable data pulling GUI.interval_add('pid_data_poll', function() { send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS); - }, 50); + }, 50); }); }); - }); + }); } \ No newline at end of file diff --git a/tabs/receiver.js b/tabs/receiver.js index 25348e072a..cfc9127600 100644 --- a/tabs/receiver.js +++ b/tabs/receiver.js @@ -1,224 +1,225 @@ function tab_initialize_receiver() { ga_tracker.sendAppView('Receiver Page'); + GUI.active_tab = 'receiver'; - $('#content').load("./tabs/receiver.html", function() { - GUI.active_tab = 'receiver'; - + send_message(MSP_codes.MSP_RC, MSP_codes.MSP_RC, false, function() { send_message(MSP_codes.MSP_RC_TUNING, MSP_codes.MSP_RC_TUNING, false, function() { - // fill in data from RC_tuning - $('.tunings .throttle input[name="mid"]').val(RC_tuning.throttle_MID.toFixed(2)); - $('.tunings .throttle input[name="expo"]').val(RC_tuning.throttle_EXPO.toFixed(2)); + $('#content').load("./tabs/receiver.html", function() { + // fill in data from RC_tuning + $('.tunings .throttle input[name="mid"]').val(RC_tuning.throttle_MID.toFixed(2)); + $('.tunings .throttle input[name="expo"]').val(RC_tuning.throttle_EXPO.toFixed(2)); - $('.tunings .rate input[name="rate"]').val(RC_tuning.RC_RATE.toFixed(2)); - $('.tunings .rate input[name="expo"]').val(RC_tuning.RC_EXPO.toFixed(2)); - - // Setup plot variables and plot it self - var samples_i = 300; - - RX_plot_data = new Array(8); - for (var i = 0; i < 8; i++) { - RX_plot_data[i] = new Array(); - } + $('.tunings .rate input[name="rate"]').val(RC_tuning.RC_RATE.toFixed(2)); + $('.tunings .rate input[name="expo"]').val(RC_tuning.RC_EXPO.toFixed(2)); + + // Setup plot variables and plot it self + var samples_i = 300; + + RX_plot_data = new Array(8); + for (var i = 0; i < 8; i++) { + RX_plot_data[i] = new Array(); + } - for (var i = 0; i <= 300; i++) { - RX_plot_data[0].push([i, 0]); - RX_plot_data[1].push([i, 0]); - RX_plot_data[2].push([i, 0]); - RX_plot_data[3].push([i, 0]); - RX_plot_data[4].push([i, 0]); - RX_plot_data[5].push([i, 0]); - RX_plot_data[6].push([i, 0]); - RX_plot_data[7].push([i, 0]); - } - - e_RX_plot = document.getElementById("RX_plot"); - - RX_plot_options = { - title: "Channel width (us)", - shadowSize: 0, - yaxis : { - max: 2200, - min: 800, - noTicks: 10 - }, - xaxis : { - //noTicks = 0 - }, - grid : { - backgroundColor: "#FFFFFF" - }, - legend : { - position: "we", - backgroundOpacity: 0 - } - }; - - // UI Hooks - - // curves - $('.tunings .throttle input').change(function() { - setTimeout(function() { - var mid = parseFloat($('.tunings .throttle input[name="mid"]').val()); - var expo = parseFloat($('.tunings .throttle input[name="expo"]').val()); - - var throttle_curve = $('.throttle_curve canvas').get(0); - var context = throttle_curve.getContext("2d"); - context.clearRect(0, 0, 220, 58); - - // math magic by englishman - var midx = 220 * mid; - var midxl = midx * .5; - var midxr = (((220 - midx) * .5) + midx); - var midy = 58 - (midx * (58 / 220)); - var midyl = 58 - ((58 - midy) * .5 *(expo + 1)); - var midyr = (midy / 2) * (expo + 1); - - context.beginPath(); - context.moveTo(0, 58); - context.quadraticCurveTo(midxl, midyl, midx, midy); - context.moveTo(midx, midy); - context.quadraticCurveTo(midxr, midyr, 220, 0); - - context.lineWidth = 2; - context.stroke(); - }, 0); // race condition, that should always trigger after all events are processed - }).change(); - - $('.tunings .rate input').change(function() { - setTimeout(function() { - var rate = parseFloat($('.tunings .rate input[name="rate"]').val()); - var expo = parseFloat($('.tunings .rate input[name="expo"]').val()); - - var pitch_roll_curve = $('.pitch_roll_curve canvas').get(0); - var context = pitch_roll_curve.getContext("2d"); - context.clearRect(0, 0, 220, 58); - - // math magic by englishman - var ratey = 58 * rate; - - context.beginPath(); - context.moveTo(0, 58); - context.quadraticCurveTo(110, 58 - ((ratey / 2) * (1 - expo)), 220, 58 - ratey); - context.lineWidth = 2; - context.stroke(); - }, 0); // race condition, that should always trigger after all events are processed - }).change(); - - $('a.refresh').click(function() { - send_message(MSP_codes.MSP_RC_TUNING, MSP_codes.MSP_RC_TUNING, false, function() { - // fill in data from RC_tuning - $('.tunings .throttle input[name="mid"]').val(RC_tuning.throttle_MID.toFixed(2)); - $('.tunings .throttle input[name="expo"]').val(RC_tuning.throttle_EXPO.toFixed(2)); + for (var i = 0; i <= 300; i++) { + RX_plot_data[0].push([i, 0]); + RX_plot_data[1].push([i, 0]); + RX_plot_data[2].push([i, 0]); + RX_plot_data[3].push([i, 0]); + RX_plot_data[4].push([i, 0]); + RX_plot_data[5].push([i, 0]); + RX_plot_data[6].push([i, 0]); + RX_plot_data[7].push([i, 0]); + } + + e_RX_plot = document.getElementById("RX_plot"); + + RX_plot_options = { + title: "Channel width (us)", + shadowSize: 0, + yaxis : { + max: 2200, + min: 800, + noTicks: 10 + }, + xaxis : { + //noTicks = 0 + }, + grid : { + backgroundColor: "#FFFFFF" + }, + legend : { + position: "we", + backgroundOpacity: 0 + } + }; + + // UI Hooks + + // curves + $('.tunings .throttle input').change(function() { + setTimeout(function() { + var mid = parseFloat($('.tunings .throttle input[name="mid"]').val()); + var expo = parseFloat($('.tunings .throttle input[name="expo"]').val()); + + var throttle_curve = $('.throttle_curve canvas').get(0); + var context = throttle_curve.getContext("2d"); + context.clearRect(0, 0, 220, 58); + + // math magic by englishman + var midx = 220 * mid; + var midxl = midx * .5; + var midxr = (((220 - midx) * .5) + midx); + var midy = 58 - (midx * (58 / 220)); + var midyl = 58 - ((58 - midy) * .5 *(expo + 1)); + var midyr = (midy / 2) * (expo + 1); + + context.beginPath(); + context.moveTo(0, 58); + context.quadraticCurveTo(midxl, midyl, midx, midy); + context.moveTo(midx, midy); + context.quadraticCurveTo(midxr, midyr, 220, 0); + + context.lineWidth = 2; + context.stroke(); + }, 0); // race condition, that should always trigger after all events are processed + }).change(); + + $('.tunings .rate input').change(function() { + setTimeout(function() { + var rate = parseFloat($('.tunings .rate input[name="rate"]').val()); + var expo = parseFloat($('.tunings .rate input[name="expo"]').val()); + + var pitch_roll_curve = $('.pitch_roll_curve canvas').get(0); + var context = pitch_roll_curve.getContext("2d"); + context.clearRect(0, 0, 220, 58); + + // math magic by englishman + var ratey = 58 * rate; + + context.beginPath(); + context.moveTo(0, 58); + context.quadraticCurveTo(110, 58 - ((ratey / 2) * (1 - expo)), 220, 58 - ratey); + context.lineWidth = 2; + context.stroke(); + }, 0); // race condition, that should always trigger after all events are processed + }).change(); + + $('a.refresh').click(function() { + send_message(MSP_codes.MSP_RC_TUNING, MSP_codes.MSP_RC_TUNING, false, function() { + // fill in data from RC_tuning + $('.tunings .throttle input[name="mid"]').val(RC_tuning.throttle_MID.toFixed(2)); + $('.tunings .throttle input[name="expo"]').val(RC_tuning.throttle_EXPO.toFixed(2)); - $('.tunings .rate input[name="rate"]').val(RC_tuning.RC_RATE.toFixed(2)); - $('.tunings .rate input[name="expo"]').val(RC_tuning.RC_EXPO.toFixed(2)); - - // update visual representation - $('.tunings .throttle input').change(); - $('.tunings .rate input').change(); + $('.tunings .rate input[name="rate"]').val(RC_tuning.RC_RATE.toFixed(2)); + $('.tunings .rate input[name="expo"]').val(RC_tuning.RC_EXPO.toFixed(2)); + + // update visual representation + $('.tunings .throttle input').change(); + $('.tunings .rate input').change(); + }); }); - }); - - $('a.update').click(function() { - // catch RC_tuning changes - RC_tuning.throttle_MID = parseFloat($('.tunings .throttle input[name="mid"]').val()); - RC_tuning.throttle_EXPO = parseFloat($('.tunings .throttle input[name="expo"]').val()); - RC_tuning.RC_RATE = parseFloat($('.tunings .rate input[name="rate"]').val()); - RC_tuning.RC_EXPO = parseFloat($('.tunings .rate input[name="expo"]').val()); - - var RC_tuning_buffer_out = new Array(); - RC_tuning_buffer_out[0] = parseInt(RC_tuning.RC_RATE * 100); - RC_tuning_buffer_out[1] = parseInt(RC_tuning.RC_EXPO * 100); - RC_tuning_buffer_out[2] = parseInt(RC_tuning.roll_pitch_rate * 100); - RC_tuning_buffer_out[3] = parseInt(RC_tuning.yaw_rate * 100); - RC_tuning_buffer_out[4] = parseInt(RC_tuning.dynamic_THR_PID * 100); - RC_tuning_buffer_out[5] = parseInt(RC_tuning.throttle_MID * 100); - RC_tuning_buffer_out[6] = parseInt(RC_tuning.throttle_EXPO * 100); - - // Send over the RC_tuning changes - send_message(MSP_codes.MSP_SET_RC_TUNING, RC_tuning_buffer_out); + $('a.update').click(function() { + // catch RC_tuning changes + RC_tuning.throttle_MID = parseFloat($('.tunings .throttle input[name="mid"]').val()); + RC_tuning.throttle_EXPO = parseFloat($('.tunings .throttle input[name="expo"]').val()); + + RC_tuning.RC_RATE = parseFloat($('.tunings .rate input[name="rate"]').val()); + RC_tuning.RC_EXPO = parseFloat($('.tunings .rate input[name="expo"]').val()); + + var RC_tuning_buffer_out = new Array(); + RC_tuning_buffer_out[0] = parseInt(RC_tuning.RC_RATE * 100); + RC_tuning_buffer_out[1] = parseInt(RC_tuning.RC_EXPO * 100); + RC_tuning_buffer_out[2] = parseInt(RC_tuning.roll_pitch_rate * 100); + RC_tuning_buffer_out[3] = parseInt(RC_tuning.yaw_rate * 100); + RC_tuning_buffer_out[4] = parseInt(RC_tuning.dynamic_THR_PID * 100); + RC_tuning_buffer_out[5] = parseInt(RC_tuning.throttle_MID * 100); + RC_tuning_buffer_out[6] = parseInt(RC_tuning.throttle_EXPO * 100); + + // Send over the RC_tuning changes + send_message(MSP_codes.MSP_SET_RC_TUNING, RC_tuning_buffer_out); - // Save changes to EEPROM - send_message(MSP_codes.MSP_EEPROM_WRITE, MSP_codes.MSP_EEPROM_WRITE, false, function() { - GUI.log('EEPROM saved'); - - var element = $('a.update'); - element.addClass('success'); - - GUI.timeout_add('success_highlight', function() { - element.removeClass('success'); - }, 2000); + // Save changes to EEPROM + send_message(MSP_codes.MSP_EEPROM_WRITE, MSP_codes.MSP_EEPROM_WRITE, false, function() { + GUI.log('EEPROM saved'); + + var element = $('a.update'); + element.addClass('success'); + + GUI.timeout_add('success_highlight', function() { + element.removeClass('success'); + }, 2000); + }); }); - }); - - // enable RC data pulling - GUI.interval_add('receiver_poll', function() { - // Update UI with latest data - $('.tab-receiver meter:eq(0)').val(RC.throttle); - $('.tab-receiver .value:eq(0)').html(RC.throttle); - $('.tab-receiver meter:eq(1)').val(RC.pitch); - $('.tab-receiver .value:eq(1)').html(RC.pitch); - - $('.tab-receiver meter:eq(2)').val(RC.roll); - $('.tab-receiver .value:eq(2)').html(RC.roll); - - $('.tab-receiver meter:eq(3)').val(RC.yaw); - $('.tab-receiver .value:eq(3)').html(RC.yaw); - - - $('.tab-receiver meter:eq(4)').val(RC.AUX1); - $('.tab-receiver .value:eq(4)').html(RC.AUX1); - - $('.tab-receiver meter:eq(5)').val(RC.AUX2); - $('.tab-receiver .value:eq(5)').html(RC.AUX2); - - $('.tab-receiver meter:eq(6)').val(RC.AUX3); - $('.tab-receiver .value:eq(6)').html(RC.AUX3); - - $('.tab-receiver meter:eq(7)').val(RC.AUX4); - $('.tab-receiver .value:eq(7)').html(RC.AUX4); - - // push latest data to the main array - RX_plot_data[0].push([samples_i, RC.throttle]); - RX_plot_data[1].push([samples_i, RC.pitch]); - RX_plot_data[2].push([samples_i, RC.roll]); - RX_plot_data[3].push([samples_i, RC.yaw]); - RX_plot_data[4].push([samples_i, RC.AUX1]); - RX_plot_data[5].push([samples_i, RC.AUX2]); - RX_plot_data[6].push([samples_i, RC.AUX3]); - RX_plot_data[7].push([samples_i, RC.AUX4]); - - // Remove old data from array - while (RX_plot_data[0].length > 300) { - RX_plot_data[0].shift(); - RX_plot_data[1].shift(); - RX_plot_data[2].shift(); - RX_plot_data[3].shift(); - RX_plot_data[4].shift(); - RX_plot_data[5].shift(); - RX_plot_data[6].shift(); - RX_plot_data[7].shift(); - }; - - // redraw plot - Flotr.draw(e_RX_plot, [ - {data: RX_plot_data[0], label: "THROTTLE"}, - {data: RX_plot_data[1], label: "PITCH"}, - {data: RX_plot_data[2], label: "ROLL"}, - {data: RX_plot_data[3], label: "YAW"}, - {data: RX_plot_data[4], label: "AUX1"}, - {data: RX_plot_data[5], label: "AUX2"}, - {data: RX_plot_data[6], label: "AUX3"}, - {data: RX_plot_data[7], label: "AUX4"} ], RX_plot_options); + // enable RC data pulling + GUI.interval_add('receiver_poll', function() { + // Update UI with latest data + $('.tab-receiver meter:eq(0)').val(RC.throttle); + $('.tab-receiver .value:eq(0)').html(RC.throttle); - samples_i++; - - // Request new data - send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS); - send_message(MSP_codes.MSP_RC, MSP_codes.MSP_RC); - }, 50, true); + $('.tab-receiver meter:eq(1)').val(RC.pitch); + $('.tab-receiver .value:eq(1)').html(RC.pitch); + + $('.tab-receiver meter:eq(2)').val(RC.roll); + $('.tab-receiver .value:eq(2)').html(RC.roll); + + $('.tab-receiver meter:eq(3)').val(RC.yaw); + $('.tab-receiver .value:eq(3)').html(RC.yaw); + + + $('.tab-receiver meter:eq(4)').val(RC.AUX1); + $('.tab-receiver .value:eq(4)').html(RC.AUX1); + + $('.tab-receiver meter:eq(5)').val(RC.AUX2); + $('.tab-receiver .value:eq(5)').html(RC.AUX2); + + $('.tab-receiver meter:eq(6)').val(RC.AUX3); + $('.tab-receiver .value:eq(6)').html(RC.AUX3); + + $('.tab-receiver meter:eq(7)').val(RC.AUX4); + $('.tab-receiver .value:eq(7)').html(RC.AUX4); + + // push latest data to the main array + RX_plot_data[0].push([samples_i, RC.throttle]); + RX_plot_data[1].push([samples_i, RC.pitch]); + RX_plot_data[2].push([samples_i, RC.roll]); + RX_plot_data[3].push([samples_i, RC.yaw]); + RX_plot_data[4].push([samples_i, RC.AUX1]); + RX_plot_data[5].push([samples_i, RC.AUX2]); + RX_plot_data[6].push([samples_i, RC.AUX3]); + RX_plot_data[7].push([samples_i, RC.AUX4]); + + // Remove old data from array + while (RX_plot_data[0].length > 300) { + RX_plot_data[0].shift(); + RX_plot_data[1].shift(); + RX_plot_data[2].shift(); + RX_plot_data[3].shift(); + RX_plot_data[4].shift(); + RX_plot_data[5].shift(); + RX_plot_data[6].shift(); + RX_plot_data[7].shift(); + }; + + // redraw plot + Flotr.draw(e_RX_plot, [ + {data: RX_plot_data[0], label: "THROTTLE"}, + {data: RX_plot_data[1], label: "PITCH"}, + {data: RX_plot_data[2], label: "ROLL"}, + {data: RX_plot_data[3], label: "YAW"}, + {data: RX_plot_data[4], label: "AUX1"}, + {data: RX_plot_data[5], label: "AUX2"}, + {data: RX_plot_data[6], label: "AUX3"}, + {data: RX_plot_data[7], label: "AUX4"} ], RX_plot_options); + + samples_i++; + + // Request new data + send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS); + send_message(MSP_codes.MSP_RC, MSP_codes.MSP_RC); + }, 50, true); + }); }); }); } \ No newline at end of file diff --git a/tabs/sensors.js b/tabs/sensors.js index 0cd91f3737..765fb3c2fc 100644 --- a/tabs/sensors.js +++ b/tabs/sensors.js @@ -1,9 +1,8 @@ function tab_initialize_sensors() { ga_tracker.sendAppView('Sensor Page'); + GUI.active_tab = 'sensors'; $('#content').load("./tabs/sensors.html", function() { - GUI.active_tab = 'sensors'; - // Setup variables samples_gyro_i = 300; samples_accel_i = 300; diff --git a/tabs/servos.js b/tabs/servos.js index c148be096f..8cf8281849 100644 --- a/tabs/servos.js +++ b/tabs/servos.js @@ -7,20 +7,19 @@ function tab_initialize_servos() { ga_tracker.sendAppView('Servos'); + GUI.active_tab = 'servos'; - $('#content').load("./tabs/servos.html", function() { - GUI.active_tab = 'servos'; - - var model = $('div.tab-servos strong.model'); - var supported_models = [1, 4, 5, 8, 14, 20, 21]; - - // request current Servos Config - send_message(MSP_codes.MSP_IDENT, MSP_codes.MSP_IDENT, false, function() { - send_message(MSP_codes.MSP_SERVO_CONF, MSP_codes.MSP_SERVO_CONF, false, function() { - send_message(MSP_codes.MSP_BOXNAMES, MSP_codes.MSP_BOXNAMES, false, function() { + // request current Servos Config + send_message(MSP_codes.MSP_IDENT, MSP_codes.MSP_IDENT, false, function() { + send_message(MSP_codes.MSP_SERVO_CONF, MSP_codes.MSP_SERVO_CONF, false, function() { + send_message(MSP_codes.MSP_BOXNAMES, MSP_codes.MSP_BOXNAMES, false, function() { + $('#content').load("./tabs/servos.html", function() { // drop previous table $('div.tab-servos table.fields tr:not(:first)').remove(); + var model = $('div.tab-servos strong.model'); + var supported_models = [1, 4, 5, 8, 14, 20, 21]; + switch (CONFIG.multiType) { case 1: // TRI // looking ok so far @@ -92,7 +91,7 @@ function tab_initialize_servos() { break; default: - model.html('Doesn\'t support servos'); + model.html("This model doesn't support servos"); // implementation of feature servo_tilt if (AUX_CONFIG.indexOf('CAMSTAB') > -1 || AUX_CONFIG.indexOf('CAMTRIG') > -1) { @@ -113,21 +112,21 @@ function tab_initialize_servos() { GUI.timeout_add('servos_update', servos_update, 10); } }); + + $('a.update').click(function() { + // standard check for supported_models + custom implementation for feature servo_tilt + if (supported_models.indexOf(CONFIG.multiType) != -1 || AUX_CONFIG.indexOf('CAMSTAB') > -1 || AUX_CONFIG.indexOf('CAMTRIG') > -1) { + servos_update(true); + } + }); + + // enable data pulling + GUI.interval_add('servos_data_poll', function() { + send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS); + }, 50); }); }); }); - - $('a.update').click(function() { - // standard check for supported_models + custom implementation for feature servo_tilt - if (supported_models.indexOf(CONFIG.multiType) != -1 || AUX_CONFIG.indexOf('CAMSTAB') > -1 || AUX_CONFIG.indexOf('CAMTRIG') > -1) { - servos_update(true); - } - }); - - // enable data pulling - GUI.interval_add('servos_data_poll', function() { - send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS); - }, 50); }); }