From e62ae6a48bf0e5c89febf5c24a45a647a836696f Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 30 May 2022 09:25:37 +0200 Subject: [PATCH 01/44] Move defaults to a separate file --- gulpfile.js | 1 + js/defaults_dialog.js | 727 ++-------------------------------- js/defaults_dialog_entries.js | 674 +++++++++++++++++++++++++++++++ 3 files changed, 717 insertions(+), 685 deletions(-) create mode 100644 js/defaults_dialog_entries.js diff --git a/gulpfile.js b/gulpfile.js index 992ca9713..a6f8b9556 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -127,6 +127,7 @@ sources.js = [ './js/peripherals.js', './js/appUpdater.js', './js/feature_framework.js', + './js/defaults_dialog_entries.js', './js/defaults_dialog.js', './js/safehomeCollection.js', './js/safehome.js', diff --git a/js/defaults_dialog.js b/js/defaults_dialog.js index 19bca0339..27c465ef6 100644 --- a/js/defaults_dialog.js +++ b/js/defaults_dialog.js @@ -4,685 +4,13 @@ var helper = helper || {}; var savingDefaultsModal; -helper.defaultsDialog = (function () { +helper.defaultsDialog = (function (data) { let publicScope = {}, privateScope = {}; let $container; - let data = [{ - "title": 'Mini Quad with 3"-7" propellers', - "id": 2, - "notRecommended": false, - "reboot": true, - "mixerToApply": 3, - "settings": [ - { - key: "model_preview_type", - value: 3 - }, - /* - System - */ - { - key: "gyro_hardware_lpf", - value: "256HZ" - }, - { - key: "looptime", - value: 500 - }, - { - key: "motor_pwm_protocol", - value: "DSHOT300" - }, - /* - Filtering - */ - { - key: "gyro_main_lpf_hz", - value: 110 - }, - { - key: "gyro_main_lpf_type", - value: "PT1" - }, - { - key: "dterm_lpf_hz", - value: 110 - }, - { - key: "dterm_lpf_type", - value: "PT3" - }, - { - key: "dterm_lpf2_hz", - value: 0 - }, - { - key: "dterm_lpf2_type", - value: "PT1" - }, - { - key: "dynamic_gyro_notch_enabled", - value: "ON" - }, - { - key: "dynamic_gyro_notch_q", - value: 250 - }, - { - key: "dynamic_gyro_notch_min_hz", - value: 120 - }, - { - key: "setpoint_kalman_enabled", - value: "ON" - }, - { - key: "setpoint_kalman_q", - value: 200 - }, - { - key: "smith_predictor_delay", // Enable Smith Predictor - value: 1.5 - }, - /* - Mechanics - */ - { - key: "airmode_type", - value: "THROTTLE_THRESHOLD" - }, - { - key: "airmode_throttle_threshold", - value: 1150 - }, - { - key: "mc_iterm_relax", - value: "RP" - }, - { - key: "d_boost_min", - value: 0.8 - }, - { - key: "d_boost_max", - value: 1.2 - }, - { - key: "antigravity_gain", - value: 2 - }, - { - key: "antigravity_accelerator", - value: 5 - }, - /* - Rates - */ - { - key: "rc_yaw_expo", - value: 75 - }, - { - key: "rc_expo", - value: 75 - }, - { - key: "roll_rate", - value: 70 - }, - { - key: "pitch_rate", - value: 70 - }, - { - key: "yaw_rate", - value: 60 - }, - /* - PIDs - */ - { - key: "mc_p_pitch", - value: 44 - }, - { - key: "mc_i_pitch", - value: 75 - }, - { - key: "mc_d_pitch", - value: 25 - }, - { - key: "mc_p_roll", - value: 40 - }, - { - key: "mc_i_roll", - value: 60 - }, - { - key: "mc_d_roll", - value: 23 - }, - { - key: "mc_p_yaw", - value: 35 - }, - { - key: "mc_i_yaw", - value: 80 - }, - /* - * TPA - */ - { - key: "tpa_rate", - value: 20 - }, - { - key: "tpa_breakpoint", - value: 1200 - }, - { - key: "platform_type", - value: "MULTIROTOR" - }, - { - key: "applied_defaults", - value: 2 - }, - { - key: "failsafe_procedure", - value: "DROP" - } - ] - }, - { - "title": 'Airplane with a Tail', - "notRecommended": false, - "id": 3, - "reboot": true, - "mixerToApply": 14, - "settings": [ - { - key: "model_preview_type", - value: 14 - }, - { - key: "platform_type", - value: "AIRPLANE" - }, - { - key: "applied_defaults", - value: 3 - }, - { - key: "gyro_hardware_lpf", - value: "256HZ" - }, - { - key: "gyro_main_lpf_hz", - value: 25 - }, - { - key: "dterm_lpf_hz", - value: 10 - }, - { - key: "d_boost_min", - value: 1 - }, - { - key: "d_boost_max", - value: 1 - }, - { - key: "gyro_main_lpf_type", - value: "BIQUAD" - }, - { - key: "dynamic_gyro_notch_enabled", - value: "ON" - }, - { - key: "dynamic_gyro_notch_q", - value: 250 - }, - { - key: "dynamic_gyro_notch_min_hz", - value: 30 - }, - { - key: "motor_pwm_protocol", - value: "STANDARD" - }, - { - key: "throttle_idle", - value: 5.0 - }, - { - key: "rc_yaw_expo", - value: 30 - }, - { - key: "rc_expo", - value: 30 - }, - { - key: "roll_rate", - value: 18 - }, - { - key: "pitch_rate", - value: 9 - }, - { - key: "yaw_rate", - value: 3 - }, - { - key: "nav_fw_pos_z_p", - value: 15 - }, - { - key: "nav_fw_pos_z_d", - value: 5 - }, - { - key: "nav_fw_pos_xy_p", - value: 60 - }, - { - key: "fw_turn_assist_pitch_gain", - value: 0.5 - }, - { - key: "max_angle_inclination_rll", - value: 450 - }, - { - key: "nav_fw_bank_angle", - value: 35 - }, - { - key: "fw_p_pitch", - value: 15 - }, - { - key: "fw_i_pitch", - value: 5 - }, - { - key: "fw_d_pitch", - value: 5 - }, - { - key: "fw_ff_pitch", - value: 80 - }, - { - key: "fw_p_roll", - value: 15 - }, - { - key: "fw_i_roll", - value: 3 - }, - { - key: "fw_d_roll", - value: 7 - }, - { - key: "fw_ff_roll", - value: 50 - }, - { - key: "fw_p_yaw", - value: 20 - }, - { - key: "fw_i_yaw", - value: 0 - }, - { - key: "fw_d_yaw", - value: 0 - }, - { - key: "fw_ff_yaw", - value: 100 - }, - { - key: "imu_acc_ignore_rate", - value: 9 - }, - { - key: "imu_acc_ignore_slope", - value: 5 - }, - { - key: "airmode_type", - value: "STICK_CENTER_ONCE" - }, - { - key: "small_angle", - value: 180 - }, - { - key: "nav_fw_control_smoothness", - value: 2 - }, - { - key: "nav_rth_allow_landing", - value: "FS_ONLY" - }, - { - key: "nav_rth_altitude", - value: 5000 - }, - { - key: "failsafe_mission", - value: "ON" - }, - { - key: "nav_wp_radius", - value: 5000 - }, - ], - "features": [ - { - bit: 4, // Enable MOTOR_STOP - state: true - } - ] - }, - { - "title": 'Airplane without a Tail (Wing, Delta, etc)', - "notRecommended": false, - "id": 3, - "reboot": true, - "mixerToApply": 8, - "settings": [ - { - key: "model_preview_type", - value: 8 - }, - { - key: "platform_type", - value: "AIRPLANE" - }, - { - key: "applied_defaults", - value: 3 - }, - { - key: "gyro_hardware_lpf", - value: "256HZ" - }, - { - key: "gyro_main_lpf_hz", - value: 25 - }, - { - key: "dterm_lpf_hz", - value: 10 - }, - { - key: "d_boost_min", - value: 1 - }, - { - key: "d_boost_max", - value: 1 - }, - { - key: "gyro_main_lpf_type", - value: "BIQUAD" - }, - { - key: "dynamic_gyro_notch_enabled", - value: "ON" - }, - { - key: "dynamic_gyro_notch_q", - value: 250 - }, - { - key: "dynamic_gyro_notch_min_hz", - value: 30 - }, - { - key: "motor_pwm_protocol", - value: "STANDARD" - }, - { - key: "throttle_idle", - value: 5.0 - }, - { - key: "rc_yaw_expo", - value: 30 - }, - { - key: "rc_expo", - value: 30 - }, - { - key: "roll_rate", - value: 18 - }, - { - key: "pitch_rate", - value: 9 - }, - { - key: "yaw_rate", - value: 3 - }, - { - key: "nav_fw_pos_z_p", - value: 15 - }, - { - key: "nav_fw_pos_z_d", - value: 5 - }, - { - key: "nav_fw_pos_xy_p", - value: 60 - }, - { - key: "fw_turn_assist_pitch_gain", - value: 0.2 - }, - { - key: "max_angle_inclination_rll", - value: 550 - }, - { - key: "nav_fw_bank_angle", - value: 45 - }, - { - key: "fw_p_pitch", - value: 15 - }, - { - key: "fw_i_pitch", - value: 5 - }, - { - key: "fw_d_pitch", - value: 5 - }, - { - key: "fw_ff_pitch", - value: 70 - }, - { - key: "fw_p_roll", - value: 15 - }, - { - key: "fw_i_roll", - value: 3 - }, - { - key: "fw_d_roll", - value: 7 - }, - { - key: "fw_ff_roll", - value: 50 - }, - { - key: "fw_p_yaw", - value: 20 - }, - { - key: "fw_i_yaw", - value: 0 - }, - { - key: "fw_d_yaw", - value: 0 - }, - { - key: "fw_ff_yaw", - value: 100 - }, - { - key: "imu_acc_ignore_rate", - value: 9 - }, - { - key: "imu_acc_ignore_slope", - value: 5 - }, - { - key: "airmode_type", - value: "STICK_CENTER_ONCE" - }, - { - key: "small_angle", - value: 180 - }, - { - key: "nav_fw_control_smoothness", - value: 2 - }, - { - key: "nav_rth_allow_landing", - value: "FS_ONLY" - }, - { - key: "nav_rth_altitude", - value: 5000 - }, - { - key: "failsafe_mission", - value: "ON" - }, - { - key: "nav_wp_radius", - value: 5000 - }, - ], - "features": [ - { - bit: 4, // Enable MOTOR_STOP - state: true - } - ] - }, - { - "title": 'Rovers & Boats', - "id": 1, - "notRecommended": false, - "reboot": true, - "mixerToApply": 31, - "settings": [ - { - key: "model_preview_type", - value: 31 - }, - { - key: "gyro_hardware_lpf", - value: "256HZ" - }, - { - key: "gyro_main_lpf_hz", - value: 10 - }, - { - key: "gyro_main_lpf_type", - value: "BIQUAD" - }, - { - key: "motor_pwm_protocol", - value: "STANDARD" - }, - { - key: "applied_defaults", - value: 1 - }, - { - key: "failsafe_procedure", - value: "DROP" - }, - { - key: "platform_type", - value: "ROVER" - }, - { - key: "nav_wp_safe_distance", - value: 50000 - }, - { - key: "nav_fw_loiter_radius", - value: 100 - }, - { - key: "nav_fw_yaw_deadband", - value: 5 - }, - { - key: "pidsum_limit_yaw", - value: 500 - }, - { - key: "nav_fw_pos_hdg_p", - value: 60 - }, - { - key: "nav_fw_pos_hdg_i", - value: 2 - }, - { - key: "nav_fw_pos_hdg_d", - value: 0 - } - ] - }, - { - "title": 'Keep current settings (Not recommended)', - "id": 0, - "notRecommended": true, - "reboot": false, - "settings": [ - { - key: "applied_defaults", - value: 1 - } - ] - } - ] - publicScope.init = function () { mspHelper.getSetting("applied_defaults").then(privateScope.onInitSettingReturned); $container = $("#defaults-wrapper"); @@ -709,20 +37,51 @@ helper.defaultsDialog = (function () { } }; + privateScope.wizard = function (selectedDefaultPreset, wizardStep) { + + const steps = selectedDefaultPreset.wizardPages; + const stepsCount = selectedDefaultPreset.wizardPages.length; + const stepName = steps[wizardStep]; + + console.log(steps[wizardStep], wizardStep, stepsCount); + + if (wizardStep >= stepsCount) { + //This is the last step, time to finalize + privateScope.saveAndReboot(); + } else { + + + + } + + }; + + privateScope.saveAndReboot = function () { + GUI.tab_switch_cleanup(function () { + MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () { + //noinspection JSUnresolvedVariable + savingDefaultsModal.close(); + GUI.log(chrome.i18n.getMessage('deviceRebooting')); + GUI.handleReconnect(); + }); + }); + }; + privateScope.finalize = function (selectedDefaultPreset) { + + if (selectedDefaultPreset.wizardPages) { + privateScope.wizard(selectedDefaultPreset, 0); + } + return; + //FIXME enable real flow mspHelper.saveToEeprom(function () { //noinspection JSUnresolvedVariable GUI.log(chrome.i18n.getMessage('configurationEepromSaved')); - if (selectedDefaultPreset.reboot) { - GUI.tab_switch_cleanup(function () { - MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () { - //noinspection JSUnresolvedVariable - savingDefaultsModal.close(); - GUI.log(chrome.i18n.getMessage('deviceRebooting')); - GUI.handleReconnect(); - }); - }); + if (selectedDefaultPreset.wizardPages) { + privateScope.wizard(selectedDefaultPreset, 0); + } else if (selectedDefaultPreset.reboot) { + privateScope.saveAndReboot(); } }); }; @@ -758,8 +117,6 @@ helper.defaultsDialog = (function () { privateScope.finalize(selectedDefaultPreset); } - - }) }); }; @@ -823,4 +180,4 @@ helper.defaultsDialog = (function () { } return publicScope; -})(); +})(helper.defaultsDialogData); diff --git a/js/defaults_dialog_entries.js b/js/defaults_dialog_entries.js new file mode 100644 index 000000000..9336e27f5 --- /dev/null +++ b/js/defaults_dialog_entries.js @@ -0,0 +1,674 @@ +var helper = helper || {}; + +helper.defaultsDialogData = [{ + "title": 'Mini Quad with 3"-7" propellers', + "id": 2, + "notRecommended": false, + "reboot": true, + "mixerToApply": 3, + "wizardPages": ['receiver', 'motors', 'gps', 'filter', 'pid'], + "settings": [ + { + key: "model_preview_type", + value: 3 + }, + /* + System + */ + { + key: "gyro_hardware_lpf", + value: "256HZ" + }, + { + key: "looptime", + value: 500 + }, + { + key: "motor_pwm_protocol", + value: "DSHOT300" + }, + /* + Filtering + */ + { + key: "gyro_main_lpf_hz", + value: 110 + }, + { + key: "gyro_main_lpf_type", + value: "PT1" + }, + { + key: "dterm_lpf_hz", + value: 110 + }, + { + key: "dterm_lpf_type", + value: "PT3" + }, + { + key: "dterm_lpf2_hz", + value: 0 + }, + { + key: "dterm_lpf2_type", + value: "PT1" + }, + { + key: "dynamic_gyro_notch_enabled", + value: "ON" + }, + { + key: "dynamic_gyro_notch_q", + value: 250 + }, + { + key: "dynamic_gyro_notch_min_hz", + value: 120 + }, + { + key: "setpoint_kalman_enabled", + value: "ON" + }, + { + key: "setpoint_kalman_q", + value: 200 + }, + { + key: "smith_predictor_delay", // Enable Smith Predictor + value: 1.5 + }, + /* + Mechanics + */ + { + key: "airmode_type", + value: "THROTTLE_THRESHOLD" + }, + { + key: "airmode_throttle_threshold", + value: 1150 + }, + { + key: "mc_iterm_relax", + value: "RP" + }, + { + key: "d_boost_min", + value: 0.8 + }, + { + key: "d_boost_max", + value: 1.2 + }, + { + key: "antigravity_gain", + value: 2 + }, + { + key: "antigravity_accelerator", + value: 5 + }, + /* + Rates + */ + { + key: "rc_yaw_expo", + value: 75 + }, + { + key: "rc_expo", + value: 75 + }, + { + key: "roll_rate", + value: 70 + }, + { + key: "pitch_rate", + value: 70 + }, + { + key: "yaw_rate", + value: 60 + }, + /* + PIDs + */ + { + key: "mc_p_pitch", + value: 44 + }, + { + key: "mc_i_pitch", + value: 75 + }, + { + key: "mc_d_pitch", + value: 25 + }, + { + key: "mc_p_roll", + value: 40 + }, + { + key: "mc_i_roll", + value: 60 + }, + { + key: "mc_d_roll", + value: 23 + }, + { + key: "mc_p_yaw", + value: 35 + }, + { + key: "mc_i_yaw", + value: 80 + }, + /* + * TPA + */ + { + key: "tpa_rate", + value: 20 + }, + { + key: "tpa_breakpoint", + value: 1200 + }, + { + key: "platform_type", + value: "MULTIROTOR" + }, + { + key: "applied_defaults", + value: 2 + }, + { + key: "failsafe_procedure", + value: "DROP" + } + ] +}, +{ + "title": 'Airplane with a Tail', + "notRecommended": false, + "id": 3, + "reboot": true, + "mixerToApply": 14, + "settings": [ + { + key: "model_preview_type", + value: 14 + }, + { + key: "platform_type", + value: "AIRPLANE" + }, + { + key: "applied_defaults", + value: 3 + }, + { + key: "gyro_hardware_lpf", + value: "256HZ" + }, + { + key: "gyro_main_lpf_hz", + value: 25 + }, + { + key: "dterm_lpf_hz", + value: 10 + }, + { + key: "d_boost_min", + value: 1 + }, + { + key: "d_boost_max", + value: 1 + }, + { + key: "gyro_main_lpf_type", + value: "BIQUAD" + }, + { + key: "dynamic_gyro_notch_enabled", + value: "ON" + }, + { + key: "dynamic_gyro_notch_q", + value: 250 + }, + { + key: "dynamic_gyro_notch_min_hz", + value: 30 + }, + { + key: "motor_pwm_protocol", + value: "STANDARD" + }, + { + key: "throttle_idle", + value: 5.0 + }, + { + key: "rc_yaw_expo", + value: 30 + }, + { + key: "rc_expo", + value: 30 + }, + { + key: "roll_rate", + value: 18 + }, + { + key: "pitch_rate", + value: 9 + }, + { + key: "yaw_rate", + value: 3 + }, + { + key: "nav_fw_pos_z_p", + value: 15 + }, + { + key: "nav_fw_pos_z_d", + value: 5 + }, + { + key: "nav_fw_pos_xy_p", + value: 60 + }, + { + key: "fw_turn_assist_pitch_gain", + value: 0.5 + }, + { + key: "max_angle_inclination_rll", + value: 450 + }, + { + key: "nav_fw_bank_angle", + value: 35 + }, + { + key: "fw_p_pitch", + value: 15 + }, + { + key: "fw_i_pitch", + value: 5 + }, + { + key: "fw_d_pitch", + value: 5 + }, + { + key: "fw_ff_pitch", + value: 80 + }, + { + key: "fw_p_roll", + value: 15 + }, + { + key: "fw_i_roll", + value: 3 + }, + { + key: "fw_d_roll", + value: 7 + }, + { + key: "fw_ff_roll", + value: 50 + }, + { + key: "fw_p_yaw", + value: 20 + }, + { + key: "fw_i_yaw", + value: 0 + }, + { + key: "fw_d_yaw", + value: 0 + }, + { + key: "fw_ff_yaw", + value: 100 + }, + { + key: "imu_acc_ignore_rate", + value: 9 + }, + { + key: "imu_acc_ignore_slope", + value: 5 + }, + { + key: "airmode_type", + value: "STICK_CENTER_ONCE" + }, + { + key: "small_angle", + value: 180 + }, + { + key: "nav_fw_control_smoothness", + value: 2 + }, + { + key: "nav_rth_allow_landing", + value: "FS_ONLY" + }, + { + key: "nav_rth_altitude", + value: 5000 + }, + { + key: "failsafe_mission", + value: "ON" + }, + { + key: "nav_wp_radius", + value: 5000 + }, + ], + "features": [ + { + bit: 4, // Enable MOTOR_STOP + state: true + } + ] +}, +{ + "title": 'Airplane without a Tail (Wing, Delta, etc)', + "notRecommended": false, + "id": 3, + "reboot": true, + "mixerToApply": 8, + "settings": [ + { + key: "model_preview_type", + value: 8 + }, + { + key: "platform_type", + value: "AIRPLANE" + }, + { + key: "applied_defaults", + value: 3 + }, + { + key: "gyro_hardware_lpf", + value: "256HZ" + }, + { + key: "gyro_main_lpf_hz", + value: 25 + }, + { + key: "dterm_lpf_hz", + value: 10 + }, + { + key: "d_boost_min", + value: 1 + }, + { + key: "d_boost_max", + value: 1 + }, + { + key: "gyro_main_lpf_type", + value: "BIQUAD" + }, + { + key: "dynamic_gyro_notch_enabled", + value: "ON" + }, + { + key: "dynamic_gyro_notch_q", + value: 250 + }, + { + key: "dynamic_gyro_notch_min_hz", + value: 30 + }, + { + key: "motor_pwm_protocol", + value: "STANDARD" + }, + { + key: "throttle_idle", + value: 5.0 + }, + { + key: "rc_yaw_expo", + value: 30 + }, + { + key: "rc_expo", + value: 30 + }, + { + key: "roll_rate", + value: 18 + }, + { + key: "pitch_rate", + value: 9 + }, + { + key: "yaw_rate", + value: 3 + }, + { + key: "nav_fw_pos_z_p", + value: 15 + }, + { + key: "nav_fw_pos_z_d", + value: 5 + }, + { + key: "nav_fw_pos_xy_p", + value: 60 + }, + { + key: "fw_turn_assist_pitch_gain", + value: 0.2 + }, + { + key: "max_angle_inclination_rll", + value: 550 + }, + { + key: "nav_fw_bank_angle", + value: 45 + }, + { + key: "fw_p_pitch", + value: 15 + }, + { + key: "fw_i_pitch", + value: 5 + }, + { + key: "fw_d_pitch", + value: 5 + }, + { + key: "fw_ff_pitch", + value: 70 + }, + { + key: "fw_p_roll", + value: 15 + }, + { + key: "fw_i_roll", + value: 3 + }, + { + key: "fw_d_roll", + value: 7 + }, + { + key: "fw_ff_roll", + value: 50 + }, + { + key: "fw_p_yaw", + value: 20 + }, + { + key: "fw_i_yaw", + value: 0 + }, + { + key: "fw_d_yaw", + value: 0 + }, + { + key: "fw_ff_yaw", + value: 100 + }, + { + key: "imu_acc_ignore_rate", + value: 9 + }, + { + key: "imu_acc_ignore_slope", + value: 5 + }, + { + key: "airmode_type", + value: "STICK_CENTER_ONCE" + }, + { + key: "small_angle", + value: 180 + }, + { + key: "nav_fw_control_smoothness", + value: 2 + }, + { + key: "nav_rth_allow_landing", + value: "FS_ONLY" + }, + { + key: "nav_rth_altitude", + value: 5000 + }, + { + key: "failsafe_mission", + value: "ON" + }, + { + key: "nav_wp_radius", + value: 5000 + }, + ], + "features": [ + { + bit: 4, // Enable MOTOR_STOP + state: true + } + ] +}, +{ + "title": 'Rovers & Boats', + "id": 1, + "notRecommended": false, + "reboot": true, + "mixerToApply": 31, + "settings": [ + { + key: "model_preview_type", + value: 31 + }, + { + key: "gyro_hardware_lpf", + value: "256HZ" + }, + { + key: "gyro_main_lpf_hz", + value: 10 + }, + { + key: "gyro_main_lpf_type", + value: "BIQUAD" + }, + { + key: "motor_pwm_protocol", + value: "STANDARD" + }, + { + key: "applied_defaults", + value: 1 + }, + { + key: "failsafe_procedure", + value: "DROP" + }, + { + key: "platform_type", + value: "ROVER" + }, + { + key: "nav_wp_safe_distance", + value: 50000 + }, + { + key: "nav_fw_loiter_radius", + value: 100 + }, + { + key: "nav_fw_yaw_deadband", + value: 5 + }, + { + key: "pidsum_limit_yaw", + value: 500 + }, + { + key: "nav_fw_pos_hdg_p", + value: 60 + }, + { + key: "nav_fw_pos_hdg_i", + value: 2 + }, + { + key: "nav_fw_pos_hdg_d", + value: 0 + } + ] +}, +{ + "title": 'Keep current settings (Not recommended)', + "id": 0, + "notRecommended": true, + "reboot": false, + "settings": [ + { + key: "applied_defaults", + value: 1 + } + ] +} +]; \ No newline at end of file From e0ef5b02618a4474a3cad6d55d35c1476e82c844 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 30 May 2022 11:35:19 +0200 Subject: [PATCH 02/44] Basic navigation --- js/defaults_dialog.js | 34 ++++++++++++++- js/defaults_dialog_entries.js | 2 +- main.html | 78 ++++++++++++++++++++--------------- src/css/defaults_dialog.css | 17 +++++++- wizard/buttons.html | 8 ++++ wizard/filters.html | 1 + wizard/gps.html | 1 + wizard/outputs.html | 1 + wizard/pids.html | 1 + wizard/receiver.html | 1 + 10 files changed, 107 insertions(+), 37 deletions(-) create mode 100644 wizard/buttons.html create mode 100644 wizard/filters.html create mode 100644 wizard/gps.html create mode 100644 wizard/outputs.html create mode 100644 wizard/pids.html create mode 100644 wizard/receiver.html diff --git a/js/defaults_dialog.js b/js/defaults_dialog.js index 27c465ef6..640093178 100644 --- a/js/defaults_dialog.js +++ b/js/defaults_dialog.js @@ -37,20 +37,48 @@ helper.defaultsDialog = (function (data) { } }; + privateScope.saveWizardStep = function (selectedDefaultPreset, wizardStep) { + //TODO add saving logic + + privateScope.wizard(selectedDefaultPreset, wizardStep + 1); + }; + privateScope.wizard = function (selectedDefaultPreset, wizardStep) { const steps = selectedDefaultPreset.wizardPages; const stepsCount = selectedDefaultPreset.wizardPages.length; const stepName = steps[wizardStep]; - + console.log(steps[wizardStep], wizardStep, stepsCount); - if (wizardStep >= stepsCount) { + if (wizardStep >= stepsCount - 1) { //This is the last step, time to finalize + $container.hide(); privateScope.saveAndReboot(); } else { + const $content = $container.find('.defaults-dialog__wizard'); + + $.get("./wizard/" + stepName + ".html", function(data) { + $content.html(data); + }); + $.get("./wizard/buttons.html", function(data) { + $(data).appendTo($content); + }); + + $container.on('click', '#wizard-next', function () { + privateScope.saveWizardStep(selectedDefaultPreset, wizardStep); + }); + + $container.on('click', '#wizard-skip', function () { + privateScope.wizard(selectedDefaultPreset, wizardStep + 1); + }); + $container.find('.defaults-dialog__content').hide(); + $container.find('.defaults-dialog__wizard').show(); + + savingDefaultsModal.close(); + $container.show(); } @@ -150,6 +178,8 @@ helper.defaultsDialog = (function (data) { }; privateScope.render = function () { + $container.find('.defaults-dialog__content').show(); + $container.find('.defaults-dialog__wizard').hide(); let $place = $container.find('.defaults-dialog__options'); $place.html(""); for (let i in data) { diff --git a/js/defaults_dialog_entries.js b/js/defaults_dialog_entries.js index 9336e27f5..78ae7ce4d 100644 --- a/js/defaults_dialog_entries.js +++ b/js/defaults_dialog_entries.js @@ -6,7 +6,7 @@ helper.defaultsDialogData = [{ "notRecommended": false, "reboot": true, "mixerToApply": 3, - "wizardPages": ['receiver', 'motors', 'gps', 'filter', 'pid'], + "wizardPages": ['receiver', 'outputs', 'gps', 'filters', 'pids'], "settings": [ { key: "model_preview_type", diff --git a/main.html b/main.html index 71da7b46a..8d7689ab7 100755 --- a/main.html +++ b/main.html @@ -16,8 +16,12 @@

@@ -42,38 +46,39 @@

-
+
+ +
@@ -92,10 +97,10 @@

+ + + +

@@ -104,10 +109,10 @@

+ + + +

@@ -173,13 +178,16 @@

  • - +
  • - +
  • - +
    • @@ -208,7 +216,8 @@

    • - +
    • @@ -229,7 +238,8 @@

    • - +
    • @@ -302,7 +312,9 @@

      + -
      -
      -
      - - - - - - - - - - - -
      -
      -
      -
      -
      -
      -
      +
      + +
      +

      +
      + +
      + +
      +
      +
      +
      + +
      + +
      +
      +
      From f90c0b9ebcbb9a94f4af94c4b03ea1fecbf2a7b6 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 24 Apr 2024 07:55:24 +0200 Subject: [PATCH 10/44] resolve conflicts --- tabs/pid_tuning.js | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/tabs/pid_tuning.js b/tabs/pid_tuning.js index fb66bcdd9..3303e2780 100644 --- a/tabs/pid_tuning.js +++ b/tabs/pid_tuning.js @@ -67,22 +67,8 @@ TABS.pid_tuning.initialize = function (callback) { } }); -<<<<<<< HEAD $('#tpa').val(RC_tuning.dynamic_THR_PID); $('#tpa-breakpoint').val(RC_tuning.dynamic_THR_breakpoint); -======= - // Fill in data from FC.RC_tuning object - $('#rate-roll').val(FC.RC_tuning.roll_rate); - $('#rate-pitch').val(FC.RC_tuning.pitch_rate); - $('#rate-yaw').val(FC.RC_tuning.yaw_rate); - - $('#rate-manual-roll').val(FC.RC_tuning.manual_roll_rate); - $('#rate-manual-pitch').val(FC.RC_tuning.manual_pitch_rate); - $('#rate-manual-yaw').val(FC.RC_tuning.manual_yaw_rate); - - $('#tpa').val(FC.RC_tuning.dynamic_THR_PID); - $('#tpa-breakpoint').val(FC.RC_tuning.dynamic_THR_breakpoint); ->>>>>>> master } function form_to_pid_and_rc() { @@ -103,7 +89,6 @@ TABS.pid_tuning.initialize = function (callback) { } }); -<<<<<<< HEAD // catch RC_tuning changes RC_tuning.roll_rate = parseFloat($('#rate_roll_rate').val()); RC_tuning.pitch_rate = parseFloat($('#rate_pitch_rate').val()); @@ -111,25 +96,13 @@ TABS.pid_tuning.initialize = function (callback) { RC_tuning.RC_EXPO = parseFloat($('#rate_rollpitch_expo').val()) / 100; RC_tuning.RC_YAW_EXPO = parseFloat($('#rate_yaw_expo').val()) / 100; -======= - // catch FC.RC_tuning changes - FC.RC_tuning.roll_rate = parseFloat($('#rate-roll').val()); - FC.RC_tuning.pitch_rate = parseFloat($('#rate-pitch').val()); - FC.RC_tuning.yaw_rate = parseFloat($('#rate-yaw').val()); ->>>>>>> master FC.RC_tuning.dynamic_THR_PID = parseInt($('#tpa').val()); FC.RC_tuning.dynamic_THR_breakpoint = parseInt($('#tpa-breakpoint').val()); -<<<<<<< HEAD RC_tuning.manual_roll_rate = $('#rate_manual_roll').val(); RC_tuning.manual_pitch_rate = $('#rate_manual_pitch').val(); RC_tuning.manual_yaw_rate = $('#rate_manual_yaw').val(); -======= - FC.RC_tuning.manual_roll_rate = $('#rate-manual-roll').val(); - FC.RC_tuning.manual_pitch_rate = $('#rate-manual-pitch').val(); - FC.RC_tuning.manual_yaw_rate = $('#rate-manual-yaw').val(); ->>>>>>> master // Rate Dynamics FC.RATE_DYNAMICS.sensitivityCenter = parseInt($('#rate_dynamics_center_sensitivity').val()); From 9c41a8dea318a29b3e1b7b6effd5b357f3ea89de Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sun, 28 Apr 2024 20:31:44 +0200 Subject: [PATCH 11/44] Fix RC_tuning --- tabs/pid_tuning.js | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/tabs/pid_tuning.js b/tabs/pid_tuning.js index 3303e2780..742f7d34d 100644 --- a/tabs/pid_tuning.js +++ b/tabs/pid_tuning.js @@ -9,14 +9,11 @@ const mspHelper = require('./../js/msp/MSPHelper'); const MSPCodes = require('./../js/msp/MSPCodes'); const MSP = require('./../js/msp'); const { GUI, TABS } = require('./../js/gui'); -const features = require('./../js/feature_framework'); const tabs = require('./../js/tabs'); const FC = require('./../js/fc'); const Settings = require('./../js/settings'); const i18n = require('./../js/localization'); const { scaleRangeInt } = require('./../js/helpers'); -const SerialBackend = require('./../js/serial_backend'); -const BitHelper = require('./../js/bitHelper'); TABS.pid_tuning = { @@ -67,8 +64,8 @@ TABS.pid_tuning.initialize = function (callback) { } }); - $('#tpa').val(RC_tuning.dynamic_THR_PID); - $('#tpa-breakpoint').val(RC_tuning.dynamic_THR_breakpoint); + $('#tpa').val(FC.RC_tuning.dynamic_THR_PID); + $('#tpa-breakpoint').val(FC.RC_tuning.dynamic_THR_breakpoint); } function form_to_pid_and_rc() { @@ -90,19 +87,19 @@ TABS.pid_tuning.initialize = function (callback) { }); // catch RC_tuning changes - RC_tuning.roll_rate = parseFloat($('#rate_roll_rate').val()); - RC_tuning.pitch_rate = parseFloat($('#rate_pitch_rate').val()); - RC_tuning.yaw_rate = parseFloat($('#rate_yaw_rate').val()); + FC.RC_tuning.roll_rate = parseFloat($('#rate_roll_rate').val()); + FC.RC_tuning.pitch_rate = parseFloat($('#rate_pitch_rate').val()); + FC.RC_tuning.yaw_rate = parseFloat($('#rate_yaw_rate').val()); - RC_tuning.RC_EXPO = parseFloat($('#rate_rollpitch_expo').val()) / 100; - RC_tuning.RC_YAW_EXPO = parseFloat($('#rate_yaw_expo').val()) / 100; + FC.RC_tuning.RC_EXPO = parseFloat($('#rate_rollpitch_expo').val()) / 100; + FC.RC_tuning.RC_YAW_EXPO = parseFloat($('#rate_yaw_expo').val()) / 100; FC.RC_tuning.dynamic_THR_PID = parseInt($('#tpa').val()); FC.RC_tuning.dynamic_THR_breakpoint = parseInt($('#tpa-breakpoint').val()); - RC_tuning.manual_roll_rate = $('#rate_manual_roll').val(); - RC_tuning.manual_pitch_rate = $('#rate_manual_pitch').val(); - RC_tuning.manual_yaw_rate = $('#rate_manual_yaw').val(); + FC.RC_tuning.manual_roll_rate = $('#rate_manual_roll').val(); + FC.RC_tuning.manual_pitch_rate = $('#rate_manual_pitch').val(); + FC.RC_tuning.manual_yaw_rate = $('#rate_manual_yaw').val(); // Rate Dynamics FC.RATE_DYNAMICS.sensitivityCenter = parseInt($('#rate_dynamics_center_sensitivity').val()); @@ -209,16 +206,16 @@ TABS.pid_tuning.initialize = function (callback) { }); //Slider rates - GUI.sliderize($('#rate_roll_rate'), RC_tuning.roll_rate, 40, 1000); - GUI.sliderize($('#rate_pitch_rate'), RC_tuning.pitch_rate, 40, 1000); - GUI.sliderize($('#rate_yaw_rate'), RC_tuning.yaw_rate, 40, 1000); + GUI.sliderize($('#rate_roll_rate'), FC.RC_tuning.roll_rate, 40, 1000); + GUI.sliderize($('#rate_pitch_rate'), FC.RC_tuning.pitch_rate, 40, 1000); + GUI.sliderize($('#rate_yaw_rate'), FC.RC_tuning.yaw_rate, 40, 1000); - GUI.sliderize($('#rate_rollpitch_expo'), RC_tuning.RC_EXPO * 100, 0, 100); - GUI.sliderize($('#rate_yaw_expo'), RC_tuning.RC_YAW_EXPO * 100, 0, 100); + GUI.sliderize($('#rate_rollpitch_expo'), FC.RC_tuning.RC_EXPO * 100, 0, 100); + GUI.sliderize($('#rate_yaw_expo'), FC.RC_tuning.RC_YAW_EXPO * 100, 0, 100); - GUI.sliderize($('#rate_manual_roll'), RC_tuning.manual_roll_rate, 0, 100); - GUI.sliderize($('#rate_manual_pitch'), RC_tuning.manual_pitch_rate, 0, 100); - GUI.sliderize($('#rate_manual_yaw'), RC_tuning.manual_yaw_rate, 0, 100); + GUI.sliderize($('#rate_manual_roll'), FC.RC_tuning.manual_roll_rate, 0, 100); + GUI.sliderize($('#rate_manual_pitch'), FC.RC_tuning.manual_pitch_rate, 0, 100); + GUI.sliderize($('#rate_manual_yaw'), FC.RC_tuning.manual_yaw_rate, 0, 100); updatePreview(); From 16910dd2d068cd93978c8e25f4b12cc803fbb730 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 29 Apr 2024 20:14:06 +0200 Subject: [PATCH 12/44] Basic expo graph --- src/css/tabs/pid_tuning.css | 11 +++++++++++ tabs/pid_tuning.html | 5 +++++ tabs/pid_tuning.js | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/css/tabs/pid_tuning.css b/src/css/tabs/pid_tuning.css index d241a0a56..264cfb2bc 100644 --- a/src/css/tabs/pid_tuning.css +++ b/src/css/tabs/pid_tuning.css @@ -465,4 +465,15 @@ #pid-sliders { margin-bottom: 1em; +} + +.tab-pid_tuning .expo-chart { + margin: 0 0px 0px 0; + width: 200px; + height: 117px; + border: 1px solid silver; + border-radius: 3px; + background-image: url(./../../../images/paper.jpg); + background-size: 200%; + background-position: center; } \ No newline at end of file diff --git a/tabs/pid_tuning.html b/tabs/pid_tuning.html index bf544661e..64b358079 100644 --- a/tabs/pid_tuning.html +++ b/tabs/pid_tuning.html @@ -467,6 +467,11 @@

      +
      +
      + +
      +

      diff --git a/tabs/pid_tuning.js b/tabs/pid_tuning.js index 742f7d34d..8c500f2ad 100644 --- a/tabs/pid_tuning.js +++ b/tabs/pid_tuning.js @@ -14,9 +14,10 @@ const FC = require('./../js/fc'); const Settings = require('./../js/settings'); const i18n = require('./../js/localization'); const { scaleRangeInt } = require('./../js/helpers'); +const interval = require('./../js/intervals'); TABS.pid_tuning = { - + rateChartHeight: 117 }; TABS.pid_tuning.initialize = function (callback) { @@ -46,6 +47,33 @@ TABS.pid_tuning.initialize = function (callback) { GUI.load(path.join(__dirname, "pid_tuning.html"), Settings.processHtml(process_html)); } + function drawRollPitchYawExpo() { + var pitch_roll_curve = $('.pitch_roll_curve canvas').get(0); + var context = pitch_roll_curve.getContext("2d"); + + var expoAVal = $('.tunings .rate input[name="expo"]'); + var expoA = parseFloat(expoAVal.val()); + + expoA = 0.7; + + if (expoA <= parseFloat(expoAVal.prop('min')) || expoA >= parseFloat(expoAVal.prop('max'))) { + return; + } + + var rateHeight = TABS.pid_tuning.rateChartHeight; + + // draw + context.clearRect(0, 0, 200, rateHeight); + + context.beginPath(); + context.moveTo(0, rateHeight); + context.quadraticCurveTo(110, rateHeight - ((rateHeight / 2) * (1 - expoA)), 200, 0); + context.lineWidth = 2; + // context.strokeStyle = '#f4a261'; + context.strokeStyle = '#a00000'; + context.stroke(); + } + function pid_and_rc_to_form() { // Fill in the data from FC.PIDs array @@ -311,6 +339,10 @@ TABS.pid_tuning.initialize = function (callback) { $('.rpy_d').prop('disabled', 'disabled'); } + interval.add("drawRollPitchYawExpo", function () { + drawRollPitchYawExpo(); + }, 100); + GUI.simpleBind(); // UI Hooks From e5d60775e42164d29999d68521cee785a7690746 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 29 Apr 2024 20:26:53 +0200 Subject: [PATCH 13/44] Fix tabs/cli.js and tabs/firmware_flasher.js --- tabs/cli.js | 2 +- tabs/firmware_flasher.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tabs/cli.js b/tabs/cli.js index 292b251fb..d6f9b4ff9 100644 --- a/tabs/cli.js +++ b/tabs/cli.js @@ -14,7 +14,7 @@ const { globalSettings } = require('./../js/globalSettings'); const CliAutoComplete = require('./../js/CliAutoComplete'); const { ConnectionType } = require('./../js/connection/connection'); const jBox = require('./../js/libraries/jBox/jBox.min'); -const mspDeduplicationQueue = require('./msp/mspDeduplicationQueue'); +const mspDeduplicationQueue = require('./../js/msp/mspDeduplicationQueue'); TABS.cli = { lineDelayMs: 50, diff --git a/tabs/firmware_flasher.js b/tabs/firmware_flasher.js index 231d68849..a7b7076ac 100755 --- a/tabs/firmware_flasher.js +++ b/tabs/firmware_flasher.js @@ -22,7 +22,7 @@ const mspQueue = require('./../js/serial_queue'); const mspHelper = require('./../js/msp/MSPHelper'); const STM32 = require('./../js/protocols/stm32'); const STM32DFU = require('./../js/protocols/stm32usbdfu'); -const mspDeduplicationQueue = require('./msp/mspDeduplicationQueue'); +const mspDeduplicationQueue = require('./../js/msp/mspDeduplicationQueue'); TABS.firmware_flasher = {}; TABS.firmware_flasher.initialize = function (callback) { From 7f731bb1f30b4dc96af26930c583d4eaed191807 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sat, 11 May 2024 09:05:50 +0200 Subject: [PATCH 14/44] Do not use MSP_BOXNAMES --- js/fc.js | 85 ++++++++++++++++++++++++++++++++++++++++++-- js/serial_backend.js | 29 +++++++-------- tabs/adjustments.js | 6 +--- tabs/auxiliary.js | 7 ++-- 4 files changed, 98 insertions(+), 29 deletions(-) diff --git a/js/fc.js b/js/fc.js index 6ecc9486d..a626563f8 100644 --- a/js/fc.js +++ b/js/fc.js @@ -85,6 +85,7 @@ var FC = { FEATURES: null, RATE_DYNAMICS: null, EZ_TUNE: null, + FLIGHT_MODES: null, restartRequired: false, MAX_SERVO_RATE: 125, @@ -198,8 +199,88 @@ var FC = { manual_yaw_rate: 0, }; - this.AUX_CONFIG = []; - this.AUX_CONFIG_IDS = []; + this.AUX_CONFIG = [ + "ARM", + "PREARM", + "MULTI FUNCTION", + "ANGLE", + "HORIZON", + "TURN ASSIST", + "HEADING HOLD", + "CAMSTAB", + "HEADFREE", + "HEADADJ", + "FPV ANGLE MIX", + "NAV POSHOLD", + "NAV RTH", + "NAV WP", + "NAV CRUISE", + "NAV COURSE HOLD", + "HOME RESET", + "GCS NAV", + "WP PLANNER", + "MISSION CHANGE", + "MC BRAKING", + "NAV ALTHOLD", + "BEEPER", + "BEEPER MUTE", + "OSD OFF", + "BLACKBOX", + "FAILSAFE", + "CAMERA CONTROL 1", + "CAMERA CONTROL 2", + "CAMERA CONTROL 3", + "USER1", + "USER2", + "USER3", + "USER4", + "OSD ALT 1", + "OSD ALT 2", + "OSD ALT 3", + "MIXER PROFILE 2", + "MIXER TRANSITION" + ]; + this.AUX_CONFIG_IDS = [ + 0, + 51, + 1, + 2, + 45, + 53, + 11, + 10, + 28, + 31, + 3, + 5, + 35, + 32, + 46, + 6, + 7, + 19, + 42, + 43, + 44, + 8, + 39, + 40, + 41, + 13, + 30, + 55, + 59, + 26, + 27, + 47, + 48, + 57, + 58, + 61, + 60, + 62, + 63 + ]; this.MODE_RANGES = []; this.ADJUSTMENT_RANGES = []; diff --git a/js/serial_backend.js b/js/serial_backend.js index 8f053ca90..0648c2768 100755 --- a/js/serial_backend.js +++ b/js/serial_backend.js @@ -460,27 +460,22 @@ var SerialBackend = (function () { $('#dataflash_wrapper_global').show(); /* - * Get BOXNAMES since it is used for some reason.... + * Init PIDs bank with a length that depends on the version */ - MSP.send_message(MSPCodes.MSP_BOXNAMES, false, false, function () { - /* - * Init PIDs bank with a length that depends on the version - */ - let pidCount = 11; + let pidCount = 11; - for (let i = 0; i < pidCount; i++) { - FC.PIDs.push(new Array(4)); - } + for (let i = 0; i < pidCount; i++) { + FC.PIDs.push(new Array(4)); + } - interval.add('msp-load-update', function () { - $('#msp-version').text("MSP version: " + MSP.protocolVersion.toFixed(0)); - $('#msp-load').text("MSP load: " + mspQueue.getLoad().toFixed(1)); - $('#msp-roundtrip').text("MSP round trip: " + mspQueue.getRoundtrip().toFixed(0)); - $('#hardware-roundtrip').text("HW round trip: " + mspQueue.getHardwareRoundtrip().toFixed(0)); - }, 100); + interval.add('msp-load-update', function () { + $('#msp-version').text("MSP version: " + MSP.protocolVersion.toFixed(0)); + $('#msp-load').text("MSP load: " + mspQueue.getLoad().toFixed(1)); + $('#msp-roundtrip').text("MSP round trip: " + mspQueue.getRoundtrip().toFixed(0)); + $('#hardware-roundtrip').text("HW round trip: " + mspQueue.getHardwareRoundtrip().toFixed(0)); + }, 100); - interval.add('global_data_refresh', periodicStatusUpdater.run, periodicStatusUpdater.getUpdateInterval(CONFIGURATOR.connection.bitrate), false); - }); + interval.add('global_data_refresh', periodicStatusUpdater.run, periodicStatusUpdater.getUpdateInterval(CONFIGURATOR.connection.bitrate), false); }); } diff --git a/tabs/adjustments.js b/tabs/adjustments.js index c8dcc1ce4..4cb360c53 100644 --- a/tabs/adjustments.js +++ b/tabs/adjustments.js @@ -17,9 +17,7 @@ TABS.adjustments.initialize = function (callback) { GUI.active_tab_ref = this; GUI.active_tab = 'adjustments'; - function get_adjustment_ranges() { - MSP.send_message(MSPCodes.MSP_ADJUSTMENT_RANGES, false, false, get_box_ids); - } + MSP.send_message(MSPCodes.MSP_ADJUSTMENT_RANGES, false, false, get_box_ids); function get_box_ids() { MSP.send_message(MSPCodes.MSP_BOXIDS, false, false, get_rc_data); @@ -33,8 +31,6 @@ TABS.adjustments.initialize = function (callback) { GUI.load(path.join(__dirname, "adjustments.html"), process_html); } - MSP.send_message(MSPCodes.MSP_BOXNAMES, false, false, get_adjustment_ranges); - function addAdjustment(adjustmentIndex, adjustmentRange, auxChannelCount) { var template = $('#tab-adjustments-templates').find('.adjustments .adjustment'); diff --git a/tabs/auxiliary.js b/tabs/auxiliary.js index 7d66e3897..f52b02d25 100644 --- a/tabs/auxiliary.js +++ b/tabs/auxiliary.js @@ -22,9 +22,8 @@ TABS.auxiliary = {}; TABS.auxiliary.initialize = function (callback) { GUI.active_tab_ref = this; GUI.active_tab = 'auxiliary'; - function get_mode_ranges() { - MSP.send_message(MSPCodes.MSP_MODE_RANGES, false, false, get_box_ids); - } + + MSP.send_message(MSPCodes.MSP_MODE_RANGES, false, false, get_box_ids); function get_box_ids() { MSP.send_message(MSPCodes.MSP_BOXIDS, false, false, get_rc_data); @@ -47,8 +46,6 @@ TABS.auxiliary.initialize = function (callback) { GUI.load(path.join(__dirname, "auxiliary.html"), process_html); } - MSP.send_message(MSPCodes.MSP_BOXNAMES, false, false, get_mode_ranges); - // This object separates out the dividers. This is also used to order the modes const modeSections = {}; modeSections["Arming"] = ["ARM", "PREARM"]; From fe2e6c06c46c37d5ff8143c2603c72dc145b5ea7 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sat, 11 May 2024 09:09:29 +0200 Subject: [PATCH 15/44] Do not load BOXID --- tabs/adjustments.js | 6 +----- tabs/auxiliary.js | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/tabs/adjustments.js b/tabs/adjustments.js index 4cb360c53..9b3246597 100644 --- a/tabs/adjustments.js +++ b/tabs/adjustments.js @@ -17,11 +17,7 @@ TABS.adjustments.initialize = function (callback) { GUI.active_tab_ref = this; GUI.active_tab = 'adjustments'; - MSP.send_message(MSPCodes.MSP_ADJUSTMENT_RANGES, false, false, get_box_ids); - - function get_box_ids() { - MSP.send_message(MSPCodes.MSP_BOXIDS, false, false, get_rc_data); - } + MSP.send_message(MSPCodes.MSP_ADJUSTMENT_RANGES, false, false, get_rc_data); function get_rc_data() { MSP.send_message(MSPCodes.MSP_RC, false, false, load_html); diff --git a/tabs/auxiliary.js b/tabs/auxiliary.js index f52b02d25..3436a5edb 100644 --- a/tabs/auxiliary.js +++ b/tabs/auxiliary.js @@ -23,11 +23,7 @@ TABS.auxiliary.initialize = function (callback) { GUI.active_tab_ref = this; GUI.active_tab = 'auxiliary'; - MSP.send_message(MSPCodes.MSP_MODE_RANGES, false, false, get_box_ids); - - function get_box_ids() { - MSP.send_message(MSPCodes.MSP_BOXIDS, false, false, get_rc_data); - } + MSP.send_message(MSPCodes.MSP_MODE_RANGES, false, false, get_rc_data); function get_rc_data() { if (FC.SERIAL_CONFIG.ports.length == 0) { From 87838c0127adca67b0ed9c0c88bd7080918a8afa Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sat, 11 May 2024 22:12:58 +0200 Subject: [PATCH 16/44] Extract flight modes to separate file --- js/flightModes.js | 286 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 286 insertions(+) create mode 100644 js/flightModes.js diff --git a/js/flightModes.js b/js/flightModes.js new file mode 100644 index 000000000..aab1f0cba --- /dev/null +++ b/js/flightModes.js @@ -0,0 +1,286 @@ +'use strict'; + +var FLIGHT_MODES = [ + { + boxId: 0, + boxName: "ARM", + permanentId: 0 + }, + { + boxId: 1, + boxName: "ANGLE", + permanentId: 1 + }, + { + boxId: 2, + boxName: "HORIZON", + permanentId: 2 + }, + { + boxId: 3, + boxName: "NAV ALTHOLD", + permanentId: 3 + }, + { + boxId: 4, + boxName: "HEADING HOLD", + permanentId: 5 + }, + { + boxId: 5, + boxName: "HEADFREE", + permanentId: 6 + }, + { + boxId: 6, + boxName: "HEADADJ", + permanentId: 7 + }, + { + boxId: 7, + boxName: "CAMSTAB", + permanentId: 8 + }, + { + boxId: 8, + boxName: "NAV RTH", + permanentId: 10 + }, + { + boxId: 9, + boxName: "NAV POSHOLD", + permanentId: 11 + }, + { + boxId: 10, + boxName: "MANUAL", + permanentId: 12 + }, + { + boxId: 11, + boxName: "BEEPER", + permanentId: 13 + }, + { + boxId: 12, + boxName: "LEDS OFF", + permanentId: 15 + }, + { + boxId: 13, + boxName: "LIGHTS", + permanentId: 16 + }, + { + boxId: 15, + boxName: "OSD OFF", + permanentId: 19 + }, + { + boxId: 16, + boxName: "TELEMETRY", + permanentId: 20 + }, + { + boxId: 28, + boxName: "AUTO TUNE", + permanentId: 21 + }, + { + boxId: 17, + boxName: "BLACKBOX", + permanentId: 26 + }, + { + boxId: 18, + boxName: "FAILSAFE", + permanentId: 27 + }, + { + boxId: 19, + boxName: "NAV WP", + permanentId: 28 + }, + { + boxId: 20, + boxName: "AIR MODE", + permanentId: 29 + }, + { + boxId: 21, + boxName: "HOME RESET", + permanentId: 30 + }, + { + boxId: 22, + boxName: "GCS NAV", + permanentId: 31 + }, + { + boxId: 39, + boxName: "FPV ANGLE MIX", + permanentId: 32 + }, + { + boxId: 24, + boxName: "SURFACE", + permanentId: 33 + }, + { + boxId: 25, + boxName: "FLAPERON", + permanentId: 34 + }, + { + boxId: 26, + boxName: "TURN ASSIST", + permanentId: 35 + }, + { + boxId: 14, + boxName: "NAV LAUNCH", + permanentId: 36 + }, + { + boxId: 27, + boxName: "SERVO AUTOTRIM", + permanentId: 37 + }, + { + boxId: 23, + boxName: "KILLSWITCH", + permanentId: 38 + }, + { + boxId: 29, + boxName: "CAMERA CONTROL 1", + permanentId: 39 + }, + { + boxId: 30, + boxName: "CAMERA CONTROL 2", + permanentId: 40 + }, + { + boxId: 31, + boxName: "CAMERA CONTROL 3", + permanentId: 41 + }, + { + boxId: 32, + boxName: "OSD ALT 1", + permanentId: 42 + }, + { + boxId: 33, + boxName: "OSD ALT 2", + permanentId: 43 + }, + { + boxId: 34, + boxName: "OSD ALT 3", + permanentId: 44 + }, + { + boxId: 35, + boxName: "NAV COURSE HOLD", + permanentId: 45 + }, + { + boxId: 36, + boxName: "MC BRAKING", + permanentId: 46 + }, + { + boxId: 37, + boxName: "USER1", + permanentId: 47 + }, + { + boxId: 38, + boxName: "USER2", + permanentId: 48 + }, + { + boxId: 48, + boxName: "USER3", + permanentId: 57 + }, + { + boxId: 49, + boxName: "USER4", + permanentId: 58 + }, + { + boxId: 40, + boxName: "LOITER CHANGE", + permanentId: 49 + }, + { + boxId: 41, + boxName: "MSP RC OVERRIDE", + permanentId: 50 + }, + { + boxId: 42, + boxName: "PREARM", + permanentId: 51 + }, + { + boxId: 43, + boxName: "TURTLE", + permanentId: 52 + }, + { + boxId: 44, + boxName: "NAV CRUISE", + permanentId: 53 + }, + { + boxId: 45, + boxName: "AUTO LEVEL TRIM", + permanentId: 54 + }, + { + boxId: 46, + boxName: "WP PLANNER", + permanentId: 55 + }, + { + boxId: 47, + boxName: "SOARING", + permanentId: 56 + }, + { + boxId: 50, + boxName: "MISSION CHANGE", + permanentId: 59 + }, + { + boxId: 51, + boxName: "BEEPER MUTE", + permanentId: 60 + }, + { + boxId: 52, + boxName: "MULTI FUNCTION", + permanentId: 61 + }, + { + boxId: 53, + boxName: "MIXER PROFILE 2", + permanentId: 62 + }, + { + boxId: 54, + boxName: "MIXER TRANSITION", + permanentId: 63 + }, + { + boxId: 55, + boxName: "ANGLE HOLD", + permanentId: 64 + } +]; + +module.exports = FLIGHT_MODES; \ No newline at end of file From 72eebe7d384759dda6f9ff0966c351d8d2b3da11 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sat, 11 May 2024 22:37:09 +0200 Subject: [PATCH 17/44] Generate AUX_CONFIGS from FLIGHT_MODES --- js/fc.js | 54 +++++++++++------------------------------------ js/flightModes.js | 2 +- tabs/auxiliary.js | 9 +++++++- 3 files changed, 21 insertions(+), 44 deletions(-) diff --git a/js/fc.js b/js/fc.js index a626563f8..b576d5e55 100644 --- a/js/fc.js +++ b/js/fc.js @@ -14,6 +14,7 @@ const FwApproachCollection = require('./fwApproachCollection') const { PLATFORM } = require('./model') const VTX = require('./vtx'); const BitHelper = require('./bitHelper'); +const { FLIGHT_MODES } = require('./flightModes'); var FC = { @@ -28,7 +29,7 @@ var FC = { RC_MAP: null, RC: null, RC_tuning: null, - AUX_CONFIG: null, + AUX_CONFIG: [], AUX_CONFIG_IDS: null, MODE_RANGES: null, ADJUSTMENT_RANGES: null, @@ -199,47 +200,16 @@ var FC = { manual_yaw_rate: 0, }; - this.AUX_CONFIG = [ - "ARM", - "PREARM", - "MULTI FUNCTION", - "ANGLE", - "HORIZON", - "TURN ASSIST", - "HEADING HOLD", - "CAMSTAB", - "HEADFREE", - "HEADADJ", - "FPV ANGLE MIX", - "NAV POSHOLD", - "NAV RTH", - "NAV WP", - "NAV CRUISE", - "NAV COURSE HOLD", - "HOME RESET", - "GCS NAV", - "WP PLANNER", - "MISSION CHANGE", - "MC BRAKING", - "NAV ALTHOLD", - "BEEPER", - "BEEPER MUTE", - "OSD OFF", - "BLACKBOX", - "FAILSAFE", - "CAMERA CONTROL 1", - "CAMERA CONTROL 2", - "CAMERA CONTROL 3", - "USER1", - "USER2", - "USER3", - "USER4", - "OSD ALT 1", - "OSD ALT 2", - "OSD ALT 3", - "MIXER PROFILE 2", - "MIXER TRANSITION" - ]; + this.generateAuxConfig = function () { + console.log('Generating AUX_CONFIG'); + + for ( let i = 0; i < FLIGHT_MODES.length; i++ ) { + if (this.AUX_CONFIG_IDS.indexOf(FLIGHT_MODES[i].permanentId) > -1) { + this.AUX_CONFIG.push(FLIGHT_MODES[i].boxName); + } + } + }; + this.AUX_CONFIG_IDS = [ 0, 51, diff --git a/js/flightModes.js b/js/flightModes.js index aab1f0cba..e725dda03 100644 --- a/js/flightModes.js +++ b/js/flightModes.js @@ -283,4 +283,4 @@ var FLIGHT_MODES = [ } ]; -module.exports = FLIGHT_MODES; \ No newline at end of file +module.exports = {FLIGHT_MODES}; \ No newline at end of file diff --git a/tabs/auxiliary.js b/tabs/auxiliary.js index 3436a5edb..82fdc9b70 100644 --- a/tabs/auxiliary.js +++ b/tabs/auxiliary.js @@ -23,7 +23,14 @@ TABS.auxiliary.initialize = function (callback) { GUI.active_tab_ref = this; GUI.active_tab = 'auxiliary'; - MSP.send_message(MSPCodes.MSP_MODE_RANGES, false, false, get_rc_data); + MSP.send_message(MSPCodes.MSP_MODE_RANGES, false, false, get_box_ids); + + function get_box_ids() { + MSP.send_message(MSPCodes.MSP_BOXIDS, false, false, function () { + FC.generateAuxConfig(); + get_rc_data(); + }); + } function get_rc_data() { if (FC.SERIAL_CONFIG.ports.length == 0) { From 8fca3523768091a2df558afa8cd82ce9c2eab323 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sun, 12 May 2024 13:06:43 +0200 Subject: [PATCH 18/44] No longer store local AUX IDs --- js/fc.js | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/js/fc.js b/js/fc.js index b576d5e55..b2b2e4246 100644 --- a/js/fc.js +++ b/js/fc.js @@ -210,48 +210,6 @@ var FC = { } }; - this.AUX_CONFIG_IDS = [ - 0, - 51, - 1, - 2, - 45, - 53, - 11, - 10, - 28, - 31, - 3, - 5, - 35, - 32, - 46, - 6, - 7, - 19, - 42, - 43, - 44, - 8, - 39, - 40, - 41, - 13, - 30, - 55, - 59, - 26, - 27, - 47, - 48, - 57, - 58, - 61, - 60, - 62, - 63 - ]; - this.MODE_RANGES = []; this.ADJUSTMENT_RANGES = []; From 3244df1f8b6168865c1e7a4d59b23022ed33dcd9 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sun, 12 May 2024 13:09:55 +0200 Subject: [PATCH 19/44] Correctly generate list of flight modes --- js/fc.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/js/fc.js b/js/fc.js index b2b2e4246..adecbef12 100644 --- a/js/fc.js +++ b/js/fc.js @@ -30,7 +30,7 @@ var FC = { RC: null, RC_tuning: null, AUX_CONFIG: [], - AUX_CONFIG_IDS: null, + AUX_CONFIG_IDS: [], MODE_RANGES: null, ADJUSTMENT_RANGES: null, SERVO_CONFIG: null, @@ -202,10 +202,11 @@ var FC = { this.generateAuxConfig = function () { console.log('Generating AUX_CONFIG'); - - for ( let i = 0; i < FLIGHT_MODES.length; i++ ) { - if (this.AUX_CONFIG_IDS.indexOf(FLIGHT_MODES[i].permanentId) > -1) { - this.AUX_CONFIG.push(FLIGHT_MODES[i].boxName); + this.AUX_CONFIG = []; + for ( let i = 0; i < this.AUX_CONFIG_IDS.length; i++ ) { + let found = FLIGHT_MODES.find( mode => mode.permanentId === this.AUX_CONFIG_IDS[i] ); + if (found) { + this.AUX_CONFIG.push(found.boxName); } } }; From 5c7b5f1a0ff36ce279e8514abfaaab5ff59f623e Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sun, 12 May 2024 13:13:15 +0200 Subject: [PATCH 20/44] Remove MSP_BOXNAMES from the codebase --- js/fc.js | 10 ++++++---- js/msp/MSPCodes.js | 1 - js/msp/MSPHelper.js | 15 --------------- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/js/fc.js b/js/fc.js index adecbef12..9f56d5a31 100644 --- a/js/fc.js +++ b/js/fc.js @@ -950,11 +950,13 @@ var FC = { return this.getServoMixInputNames()[input]; }, getModeId: function (name) { - for (var i = 0; i < this.AUX_CONFIG.length; i++) { - if (this.AUX_CONFIG[i] == name) - return i; + + let mode = FLIGHT_MODES.find( mode => mode.boxName === name ); + if (mode) { + return mode.permanentId; + } else { + return -1; } - return -1; }, isModeBitSet: function (i) { return BitHelper.bit_check(this.CONFIG.mode[Math.trunc(i / 32)], i % 32); diff --git a/js/msp/MSPCodes.js b/js/msp/MSPCodes.js index 66d3fd6e8..bcc49eaff 100644 --- a/js/msp/MSPCodes.js +++ b/js/msp/MSPCodes.js @@ -84,7 +84,6 @@ var MSPCodes = { MSP_PID: 112, MSP_ACTIVEBOXES: 113, MSP_MOTOR_PINS: 115, - MSP_BOXNAMES: 116, MSP_PIDNAMES: 117, MSP_WP: 118, MSP_BOXIDS: 119, diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index 4e45369b2..3e0c66067 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -386,21 +386,6 @@ var mspHelper = (function () { case MSPCodes.MSP_MOTOR_PINS: console.log(data); break; - case MSPCodes.MSP_BOXNAMES: - //noinspection JSUndeclaredVariable - FC.AUX_CONFIG = []; // empty the array as new data is coming in - buff = []; - for (let i = 0; i < data.byteLength; i++) { - if (data.getUint8(i) == 0x3B) { // ; (delimeter char) - FC.AUX_CONFIG.push(String.fromCharCode.apply(null, buff)); // convert bytes into ASCII and save as strings - - // empty buffer - buff = []; - } else { - buff.push(data.getUint8(i)); - } - } - break; case MSPCodes.MSP_PIDNAMES: //noinspection JSUndeclaredVariable FC.PID_names = []; // empty the array as new data is coming in From 24f07e23d619bdd0504c2fefaaca7824b092b1da Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sun, 12 May 2024 13:22:54 +0200 Subject: [PATCH 21/44] Do not use global AUX_CONFIG in auxiliary.js --- tabs/auxiliary.js | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/tabs/auxiliary.js b/tabs/auxiliary.js index 82fdc9b70..202f60a02 100644 --- a/tabs/auxiliary.js +++ b/tabs/auxiliary.js @@ -23,11 +23,19 @@ TABS.auxiliary.initialize = function (callback) { GUI.active_tab_ref = this; GUI.active_tab = 'auxiliary'; + let LOCAL_AUX_CONFIG = []; + let LOCAL_AUX_CONFIG_IDS = []; + MSP.send_message(MSPCodes.MSP_MODE_RANGES, false, false, get_box_ids); function get_box_ids() { MSP.send_message(MSPCodes.MSP_BOXIDS, false, false, function () { FC.generateAuxConfig(); + + //Copy global settings into local ones + LOCAL_AUX_CONFIG = Array.from(FC.AUX_CONFIG); + LOCAL_AUX_CONFIG_IDS = Array.from(FC.AUX_CONFIG_IDS); + get_rc_data(); }); } @@ -68,21 +76,21 @@ TABS.auxiliary.initialize = function (callback) { var found = false; var sortedID = 0; - for (let i=0; i FC.AUX_CONFIG.length) { + if (tmpAUX_CONFIG.length > LOCAL_AUX_CONFIG.length) { for (let i=0; i Date: Sun, 12 May 2024 13:34:16 +0200 Subject: [PATCH 22/44] God knows why Serial Config was requested to display flight modes.... --- tabs/auxiliary.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/tabs/auxiliary.js b/tabs/auxiliary.js index 202f60a02..9d4edbd33 100644 --- a/tabs/auxiliary.js +++ b/tabs/auxiliary.js @@ -35,21 +35,13 @@ TABS.auxiliary.initialize = function (callback) { //Copy global settings into local ones LOCAL_AUX_CONFIG = Array.from(FC.AUX_CONFIG); LOCAL_AUX_CONFIG_IDS = Array.from(FC.AUX_CONFIG_IDS); - + get_rc_data(); }); } function get_rc_data() { - if (FC.SERIAL_CONFIG.ports.length == 0) { - MSP.send_message(MSPCodes.MSP_RC, false, false, get_ports_data); - } else { - MSP.send_message(MSPCodes.MSP_RC, false, false, load_html); - } - } - - function get_ports_data() { - MSP.send_message(MSPCodes.MSP2_CF_SERIAL_CONFIG, false, false, load_html); + MSP.send_message(MSPCodes.MSP_RC, false, false, load_html); } function load_html() { From e1c302438b2bfe42bdf17ac42c1de4754f2e18b4 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sun, 12 May 2024 20:10:34 +0200 Subject: [PATCH 23/44] Cache settings in local storage --- js/fc.js | 3 --- js/msp/MSPHelper.js | 10 +++++++--- js/settingsCache.js | 46 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 js/settingsCache.js diff --git a/js/fc.js b/js/fc.js index 9f56d5a31..0d5d4861b 100644 --- a/js/fc.js +++ b/js/fc.js @@ -78,7 +78,6 @@ var FC = { MIXER_CONFIG: null, BATTERY_CONFIG: null, OUTPUT_MAPPING: null, - SETTINGS: null, BRAKING_CONFIG: null, SAFEHOMES: null, BOARD_ALIGNMENT: null, @@ -570,8 +569,6 @@ var FC = { this.OUTPUT_MAPPING = new OutputMappingCollection(); - this.SETTINGS = {}; - this.SAFEHOMES = new SafehomeCollection(); this.RATE_DYNAMICS = { diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index 3e0c66067..0c672b25b 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -20,6 +20,7 @@ const { FwApproach } = require('./../fwApproach'); const Waypoint = require('./../waypoint'); const mspDeduplicationQueue = require('./mspDeduplicationQueue'); const mspStatistics = require('./mspStatistics'); +const settingsCache = require('./../settingsCache'); var mspHelper = (function () { var self = {}; @@ -3060,9 +3061,12 @@ var mspHelper = (function () { }; self._getSetting = function (name) { - if (FC.SETTINGS[name]) { - return Promise.resolve(FC.SETTINGS[name]); + + const storedSetting = settingsCache.get(name); + if (typeof storedSetting !== 'undefined') { + return Promise.resolve(storedSetting); } + var data = []; self._encodeSettingReference(name, null, data); return MSP.promise(MSPCodes.MSP2_COMMON_SETTING_INFO, data).then(function (result) { @@ -3109,7 +3113,7 @@ var mspHelper = (function () { } setting.table = { values: values }; } - FC.SETTINGS[name] = setting; + settingsCache.set(name, setting); return setting; }); } diff --git a/js/settingsCache.js b/js/settingsCache.js new file mode 100644 index 000000000..fcd17957e --- /dev/null +++ b/js/settingsCache.js @@ -0,0 +1,46 @@ +'use strict'; + +const Store = require('electron-store'); +const store = new Store(); +const FC = require('./fc'); + +var settingsCache = (function() { + + let publicScope = {}; + let privateScope = {}; + + const SETTINGS_KEY = 'settings'; + + privateScope.getSetingKey = function(settingName) { + return FC.CONFIG.target + '_' + FC.CONFIG.flightControllerVersion + '_' + settingName; + } + + publicScope.flush = function() { + store.delete(SETTINGS_KEY); + }; + + publicScope.get = function(settingName) { + let settings = store.get(SETTINGS_KEY, null); + + if (settings === null) { + return undefined; + } + let setting = settings[privateScope.getSetingKey(settingName)]; + return setting; + }; + + publicScope.set = function(settingName, value) { + let settings = store.get(SETTINGS_KEY, null); + + if (settings === null) { + settings = {}; + } + + settings[privateScope.getSetingKey(settingName)] = value; + store.set(SETTINGS_KEY, settings); + }; + + return publicScope; +}()); + +module.exports = settingsCache; \ No newline at end of file From 6d25fbb8b82cb47f85b3a8fb45d4c48987016c6b Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sun, 12 May 2024 20:23:07 +0200 Subject: [PATCH 24/44] Add and option to flush settings cache --- js/configurator_main.js | 4 ++++ js/settingsCache.js | 1 + locale/en/messages.json | 6 ++++++ tabs/options.html | 10 ++++++++++ 4 files changed, 21 insertions(+) diff --git a/js/configurator_main.js b/js/configurator_main.js index ce2e56345..4ca94c2d6 100644 --- a/js/configurator_main.js +++ b/js/configurator_main.js @@ -24,6 +24,7 @@ const update = require('./globalUpdates'); const appUpdater = require('./appUpdater'); const CliAutoComplete = require('./CliAutoComplete'); const { SITLProcess } = require('./sitl'); +const settingsCache = require('./settingsCache'); process.on('uncaughtException', function (error) { if (process.env.NODE_ENV !== 'development') { @@ -385,6 +386,9 @@ $(function() { $('#demoModeReset').on('click', function () { SITLProcess.deleteEepromFile('demo.bin'); }); + $('#maintenanceFlushSettingsCache').on('click', function () { + settingsCache.flush(); + }); function close_and_cleanup(e) { if (e.type == 'click' && !$.contains($('div#options-window')[0], e.target) || e.type == 'keyup' && e.keyCode == 27) { $(document).unbind('click keyup', close_and_cleanup); diff --git a/js/settingsCache.js b/js/settingsCache.js index fcd17957e..6698cea7e 100644 --- a/js/settingsCache.js +++ b/js/settingsCache.js @@ -17,6 +17,7 @@ var settingsCache = (function() { publicScope.flush = function() { store.delete(SETTINGS_KEY); + console.log('Settings cache flushed'); }; publicScope.get = function(settingName) { diff --git a/locale/en/messages.json b/locale/en/messages.json index 3af2e7f3e..bd3ff5756 100644 --- a/locale/en/messages.json +++ b/locale/en/messages.json @@ -5812,5 +5812,11 @@ }, "gsTelemetrySpeed": { "message": "Speed" + }, + "maintenance": { + "message": "Maintenance" + }, + "maintenanceFlushSettingsCache": { + "message": "Flush settings cache" } } diff --git a/tabs/options.html b/tabs/options.html index 303aa0103..7c21b29d2 100644 --- a/tabs/options.html +++ b/tabs/options.html @@ -87,5 +87,15 @@
      +
      +
      +
      +
      +
      +
      + +
      +
      +
      \ No newline at end of file From ac87edaa793dbd7343a893b9e73445b6f8bd00be Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Tue, 14 May 2024 15:16:33 +0200 Subject: [PATCH 25/44] Update stabilized expo graph --- tabs/pid_tuning.js | 48 ++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/tabs/pid_tuning.js b/tabs/pid_tuning.js index d48c9707d..7b392fbbf 100644 --- a/tabs/pid_tuning.js +++ b/tabs/pid_tuning.js @@ -47,31 +47,45 @@ TABS.pid_tuning.initialize = function (callback) { GUI.load(path.join(__dirname, "pid_tuning.html"), Settings.processHtml(process_html)); } - function drawRollPitchYawExpo() { - var pitch_roll_curve = $('.pitch_roll_curve canvas').get(0); - var context = pitch_roll_curve.getContext("2d"); - - var expoAVal = $('.tunings .rate input[name="expo"]'); - var expoA = parseFloat(expoAVal.val()); + function drawExpoCanvas(value, $element, color, width, height, clear) { + let context = $element.getContext("2d"); - expoA = 0.7; - - if (expoA <= parseFloat(expoAVal.prop('min')) || expoA >= parseFloat(expoAVal.prop('max'))) { + if (value < 0 || value > 1) { return; } - var rateHeight = TABS.pid_tuning.rateChartHeight; - - // draw - context.clearRect(0, 0, 200, rateHeight); + if (clear === true) { + context.clearRect(0, 0, width, height); + } context.beginPath(); - context.moveTo(0, rateHeight); - context.quadraticCurveTo(110, rateHeight - ((rateHeight / 2) * (1 - expoA)), 200, 0); + context.moveTo(0, height); + context.quadraticCurveTo(110, height - ((height / 2) * (1 - value)), width, 0); context.lineWidth = 2; - // context.strokeStyle = '#f4a261'; - context.strokeStyle = '#a00000'; + context.strokeStyle = color; context.stroke(); + + }; + + function drawRollPitchYawExpo() { + let pitch_roll_curve = $('.pitch_roll_curve canvas').get(0); + + drawExpoCanvas( + parseFloat($('#rate_rollpitch_expo').val()) / 100, + pitch_roll_curve, + '#a00000', + 200, + TABS.pid_tuning.rateChartHeight, + true + ); + drawExpoCanvas( + parseFloat($('#rate_yaw_expo').val()) / 100, + pitch_roll_curve, + '#00a000', + 200, + TABS.pid_tuning.rateChartHeight, + false + ); } function pid_and_rc_to_form() { From bfd91c91f2aa2c2dec67e4f999d4559821ecb668 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Tue, 14 May 2024 18:23:50 +0200 Subject: [PATCH 26/44] Draw manual expo chart --- locale/en/messages.json | 3 +++ tabs/pid_tuning.html | 23 +++++++++++++++++++++++ tabs/pid_tuning.js | 25 +++++++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/locale/en/messages.json b/locale/en/messages.json index 6a744b9c9..c5e53172e 100644 --- a/locale/en/messages.json +++ b/locale/en/messages.json @@ -1424,6 +1424,9 @@ "pidTuning_Expo_Stabilized": { "message": "Stabilized Expo" }, + "pidTuning_Expo_Manual": { + "message": "Manual Expo" + }, "pidTuning_Expo_RollPitch": { "message": "Roll & Pitch (%)" }, diff --git a/tabs/pid_tuning.html b/tabs/pid_tuning.html index 64b358079..9e61b74c5 100644 --- a/tabs/pid_tuning.html +++ b/tabs/pid_tuning.html @@ -515,6 +515,29 @@

      +
      +
      +
      + +
      +
      +

      +
      + +
      + +
      +
      +
      +
      + +
      + +
      +
      +
      +
      +

      diff --git a/tabs/pid_tuning.js b/tabs/pid_tuning.js index 7b392fbbf..d4e84b970 100644 --- a/tabs/pid_tuning.js +++ b/tabs/pid_tuning.js @@ -69,6 +69,7 @@ TABS.pid_tuning.initialize = function (callback) { function drawRollPitchYawExpo() { let pitch_roll_curve = $('.pitch_roll_curve canvas').get(0); + let manual_expo_curve = $('.manual_expo_curve canvas').get(0); drawExpoCanvas( parseFloat($('#rate_rollpitch_expo').val()) / 100, @@ -86,6 +87,24 @@ TABS.pid_tuning.initialize = function (callback) { TABS.pid_tuning.rateChartHeight, false ); + + drawExpoCanvas( + parseFloat($('#manual_rollpitch_expo').val()) / 100, + manual_expo_curve, + '#a00000', + 200, + TABS.pid_tuning.rateChartHeight, + true + ); + + drawExpoCanvas( + parseFloat($('#manual_yaw_expo').val()) / 100, + manual_expo_curve, + '#00a000', + 200, + TABS.pid_tuning.rateChartHeight, + false + ); } function pid_and_rc_to_form() { @@ -143,6 +162,9 @@ TABS.pid_tuning.initialize = function (callback) { FC.RC_tuning.manual_pitch_rate = $('#rate_manual_pitch').val(); FC.RC_tuning.manual_yaw_rate = $('#rate_manual_yaw').val(); + FC.RC_tuning.manual_RC_EXPO = $('#manual_rollpitch_expo').val() / 100; + FC.RC_tuning.manual_RC_YAW_EXPO = $('#manual_yaw_expo').val() / 100; + // Rate Dynamics FC.RATE_DYNAMICS.sensitivityCenter = parseInt($('#rate_dynamics_center_sensitivity').val()); FC.RATE_DYNAMICS.sensitivityEnd = parseInt($('#rate_dynamics_end_sensitivity').val()); @@ -259,6 +281,9 @@ TABS.pid_tuning.initialize = function (callback) { GUI.sliderize($('#rate_manual_pitch'), FC.RC_tuning.manual_pitch_rate, 0, 100); GUI.sliderize($('#rate_manual_yaw'), FC.RC_tuning.manual_yaw_rate, 0, 100); + GUI.sliderize($('#manual_rollpitch_expo'), FC.RC_tuning.manual_RC_EXPO * 100, 0, 100); + GUI.sliderize($('#manual_yaw_expo'), FC.RC_tuning.manual_RC_YAW_EXPO * 100, 0, 100); + updatePreview(); tabs.init($('.tab-pid_tuning')); From 7432ca6872b864c01451c0004e2736f3251ffef8 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Tue, 14 May 2024 20:06:46 +0200 Subject: [PATCH 27/44] Expo preview for EzTune --- tabs/pid_tuning.html | 5 +++++ tabs/pid_tuning.js | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tabs/pid_tuning.html b/tabs/pid_tuning.html index 9e61b74c5..9da4d855a 100644 --- a/tabs/pid_tuning.html +++ b/tabs/pid_tuning.html @@ -185,6 +185,11 @@

      +
      +
      + +
      +
      diff --git a/tabs/pid_tuning.js b/tabs/pid_tuning.js index d4e84b970..06377f288 100644 --- a/tabs/pid_tuning.js +++ b/tabs/pid_tuning.js @@ -60,7 +60,7 @@ TABS.pid_tuning.initialize = function (callback) { context.beginPath(); context.moveTo(0, height); - context.quadraticCurveTo(110, height - ((height / 2) * (1 - value)), width, 0); + context.quadraticCurveTo(width / 2, height - ((height / 2) * (1 - value)), width, 0); context.lineWidth = 2; context.strokeStyle = color; context.stroke(); @@ -105,6 +105,19 @@ TABS.pid_tuning.initialize = function (callback) { TABS.pid_tuning.rateChartHeight, false ); + + drawExpoCanvas( + Math.floor(scaleRange($('#ez_tune_expo').val(), 0, 200, 40, 100)) / 100, + $('#ez_tune_expo_curve canvas').get(0), + '#a00000', + 250, + 200, + true + ); + + // console.log('orig', $('#ez_tune_expo').val()); + // console.log('scaled', Math.floor(scaleRange($('#ez_tune_expo').val(), 0, 200, 40, 100)) / 100); + } function pid_and_rc_to_form() { From d522dfd8e402d1fd46372740506c0c145a7cb13e Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Tue, 14 May 2024 20:07:09 +0200 Subject: [PATCH 28/44] Expo preview for ez tune --- tabs/pid_tuning.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tabs/pid_tuning.js b/tabs/pid_tuning.js index 06377f288..78efb95eb 100644 --- a/tabs/pid_tuning.js +++ b/tabs/pid_tuning.js @@ -114,10 +114,6 @@ TABS.pid_tuning.initialize = function (callback) { 200, true ); - - // console.log('orig', $('#ez_tune_expo').val()); - // console.log('scaled', Math.floor(scaleRange($('#ez_tune_expo').val(), 0, 200, 40, 100)) / 100); - } function pid_and_rc_to_form() { From eac50a48657630502135af50d080af933059b384 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Tue, 14 May 2024 20:13:04 +0200 Subject: [PATCH 29/44] Remove expo from the Receiver tab --- tabs/receiver.html | 38 +-------------------------------- tabs/receiver.js | 53 ---------------------------------------------- 2 files changed, 1 insertion(+), 90 deletions(-) diff --git a/tabs/receiver.html b/tabs/receiver.html index 4372788df..5609b6369 100644 --- a/tabs/receiver.html +++ b/tabs/receiver.html @@ -119,43 +119,7 @@ -
      -
      -
      - - - - -
      -
      - -
      -
      -
      -
      - - - - - - - - - -
      - - - - - - - - - -
      -
      -
      -
      +
      diff --git a/tabs/receiver.js b/tabs/receiver.js index 9b20874f0..9046d5d00 100644 --- a/tabs/receiver.js +++ b/tabs/receiver.js @@ -47,41 +47,6 @@ TABS.receiver.initialize = function (callback) { Settings.saveInputs(onComplete); } - function drawRollPitchExpo() { - var pitch_roll_curve = $('.pitch_roll_curve canvas').get(0); - var context = pitch_roll_curve.getContext("2d"); - - var expoAVal = $('.tunings .rate input[name="expo"]'); - var expoA = parseFloat(expoAVal.val()); - - var expoMVal = $('.tunings .rate input[name="manual_expo"]'); - var expoM = parseFloat(expoMVal.val()); - - if (expoA <= parseFloat(expoAVal.prop('min')) || expoA >= parseFloat(expoAVal.prop('max')) || - expoM <= parseFloat(expoMVal.prop('min')) || expoM >= parseFloat(expoMVal.prop('max'))) { - return; - } - - var rateHeight = TABS.receiver.rateChartHeight; - - // draw - context.clearRect(0, 0, 200, rateHeight); - - context.beginPath(); - context.moveTo(0, rateHeight); - context.quadraticCurveTo(110, rateHeight - ((rateHeight / 2) * (1 - expoA)), 200, 0); - context.lineWidth = 2; - context.strokeStyle = '#37a8db'; - context.stroke(); - - context.beginPath(); - context.moveTo(0, rateHeight); - context.quadraticCurveTo(110, rateHeight - ((rateHeight / 2) * (1 - expoM)), 200, 0); - context.lineWidth = 2; - context.strokeStyle = '#a837db'; - context.stroke(); - } - function process_html() { // translate to user-selected language i18n.localize();; @@ -120,12 +85,6 @@ TABS.receiver.initialize = function (callback) { $('.tunings .throttle input[name="mid"]').val(FC.RC_tuning.throttle_MID.toFixed(2)); $('.tunings .throttle input[name="expo"]').val(FC.RC_tuning.throttle_EXPO.toFixed(2)); - $('.tunings .rate input[name="expo"]').val(FC.RC_tuning.RC_EXPO.toFixed(2)); - $('.tunings .yaw_rate input[name="yaw_expo"]').val(FC.RC_tuning.RC_YAW_EXPO.toFixed(2)); - - $('.tunings .rate input[name="manual_expo"]').val(FC.RC_tuning.manual_RC_EXPO.toFixed(2)); - $('.tunings .yaw_rate input[name="manual_yaw_expo"]').val(FC.RC_tuning.manual_RC_YAW_EXPO.toFixed(2)); - $('.deadband input[name="yaw_deadband"]').val(FC.RC_deadband.yaw_deadband); $('.deadband input[name="deadband"]').val(FC.RC_deadband.deadband); @@ -284,23 +243,11 @@ TABS.receiver.initialize = function (callback) { }, 0); }).trigger('input'); - $('.tunings .rate input').on('input change', function () { - setTimeout(function () { // let global validation trigger and adjust the values first - drawRollPitchExpo(); - }, 0); - }).trigger('input'); - $('a.update').on('click', function () { // catch RC_tuning changes FC.RC_tuning.throttle_MID = parseFloat($('.tunings .throttle input[name="mid"]').val()); FC.RC_tuning.throttle_EXPO = parseFloat($('.tunings .throttle input[name="expo"]').val()); - FC.RC_tuning.RC_EXPO = parseFloat($('.tunings .rate input[name="expo"]').val()); - FC.RC_tuning.RC_YAW_EXPO = parseFloat($('.tunings .yaw_rate input[name="yaw_expo"]').val()); - - FC.RC_tuning.manual_RC_EXPO = parseFloat($('.tunings .rate input[name="manual_expo"]').val()); - FC.RC_tuning.manual_RC_YAW_EXPO = parseFloat($('.tunings .yaw_rate input[name="manual_yaw_expo"]').val()); - FC.RC_deadband.yaw_deadband = parseInt($('.deadband input[name="yaw_deadband"]').val()); FC.RC_deadband.deadband = parseInt($('.deadband input[name="deadband"]').val()); From 5d325341868e4330fe0a3d3d90150eff8a6967b2 Mon Sep 17 00:00:00 2001 From: Alden-wrk <168357057+Alden-wrk@users.noreply.github.com> Date: Wed, 15 May 2024 14:55:26 +0800 Subject: [PATCH 30/44] ADD APM32 DFU Bootloader --- manifest.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 8cee67714..1b82eb9b5 100644 --- a/manifest.json +++ b/manifest.json @@ -48,7 +48,8 @@ "alwaysOnTopWindows", {"usbDevices": [ {"vendorId": 1155, "productId": 57105}, - {"vendorId": 11836, "productId": 57105} + {"vendorId": 11836, "productId": 57105}, + {'vendorId': 12619, 'productId': 262} // APM32 DFU Bootloader ]} ], From d55595b5c1c9905d6cf572f8cb107b329408705c Mon Sep 17 00:00:00 2001 From: Alden-wrk <168357057+Alden-wrk@users.noreply.github.com> Date: Wed, 15 May 2024 15:03:43 +0800 Subject: [PATCH 31/44] Update port_handler.js --- js/port_handler.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/port_handler.js b/js/port_handler.js index 2f23678a8..182893fa8 100755 --- a/js/port_handler.js +++ b/js/port_handler.js @@ -8,7 +8,8 @@ const ConnectionSerial = require('./connection/connectionSerial'); var usbDevices = [ { 'vendorId': 1155, 'productId': 57105}, - { 'vendorId': 11836, 'productId': 57105} + { 'vendorId': 11836, 'productId': 57105}, + { 'vendorId': 12619, 'productId': 262}, // APM32 DFU Bootloader ]; @@ -297,4 +298,4 @@ PortHandler.flush_callbacks = function () { return killed; }; -module.exports = { usbDevices, PortHandler }; \ No newline at end of file +module.exports = { usbDevices, PortHandler }; From defe9442453af6ae0b4042c96edaa707a7f49c39 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Thu, 16 May 2024 10:21:10 +0200 Subject: [PATCH 32/44] Fix video type select and optimize the code --- tabs/osd.js | 434 ++++++++++++++++++++++++++-------------------------- 1 file changed, 221 insertions(+), 213 deletions(-) diff --git a/tabs/osd.js b/tabs/osd.js index 5ffca961e..03e44c54c 100644 --- a/tabs/osd.js +++ b/tabs/osd.js @@ -149,7 +149,6 @@ SYM.AH_AIRCRAFT4 = 0x1A6; SYM.AH_CROSSHAIRS = new Array(0x166, 0x1A4, new Array(0x190, 0x191, 0x192), new Array(0x193, 0x194, 0x195), new Array(0x196, 0x197, 0x198), new Array(0x199, 0x19A, 0x19B), new Array (0x19C, 0x19D, 0x19E), new Array (0x19F, 0x1A0, 0x1A1)); -var useESCTelemetry = false; var useBaro = false; var useCRSFRx = false; var usePitot = false; @@ -522,9 +521,7 @@ OSD.initData = function () { item_count: 0, items: [], groups: {}, - preview: [], - isDjiHdFpv: false, - isMspDisplay: false + preview: [] }; }; @@ -1010,7 +1007,7 @@ OSD.constants = { id: 106, min_version: '2.3.0', enabled: function() { - return useESCTelemetry; + return HARDWARE.capabilities.useESCTelemetry; }, preview: function(){ let rpmPreview = '112974'.substr((6 - parseInt(Settings.getInputValue('osd_esc_rpm_precision')))); @@ -1106,7 +1103,7 @@ OSD.constants = { id: 107, min_version: '2.5.0', enabled: function() { - return useESCTelemetry; + return HARDWARE.capabilities.useESCTelemetry; }, preview: function(osd_data) { switch (OSD.data.preferences.units) { @@ -2175,17 +2172,6 @@ OSD.reload = function(callback) { } }; - MSP.promise(MSPCodes.MSP2_CF_SERIAL_CONFIG).then(function (resp) { - $.each(FC.SERIAL_CONFIG.ports, function(index, port){ - if(port.functions.includes('DJI_FPV')) { - OSD.data.isDjiHdFpv = true; - } - if(port.functions.includes('MSP_DISPLAYPORT')) { - OSD.data.isMspDisplay = true; - } - }); - }); - MSP.promise(MSPCodes.MSP2_INAV_OSD_LAYOUTS).then(function (resp) { OSD.msp.decodeLayoutCounts(resp); @@ -2576,11 +2562,11 @@ OSD.GUI.updateVideoMode = function() { // video mode var $videoTypes = $('.video-types').empty(); - if (!OSD.data.isDjiHdFpv) { + if (!HARDWARE.capabilities.isDjiHdFpv) { $('#dji_settings').hide(); } - if (OSD.data.isMspDisplay) { + if (HARDWARE.capabilities.isMspDisplay) { if (mspVideoSystem.includes(OSD.data.preferences.video_system) == false) { OSD.data.preferences.video_system = OSD.constants.VIDEO_TYPES.indexOf('HDZERO'); OSD.updateDisplaySize(); @@ -2594,7 +2580,7 @@ OSD.GUI.updateVideoMode = function() { } } - if (OSD.data.isMspDisplay) { + if (HARDWARE.capabilities.isMspDisplay) { for (var i = 0; i < OSD.constants.VIDEO_TYPES.length; i++) { if (mspVideoSystem.includes(i)) { @@ -2805,7 +2791,7 @@ OSD.GUI.updateFields = function() { if ($('#djiUnsupportedElementsToggle').length == false) { $('#djiUnsupportedElements').prepend( $('') - .attr('checked', OSD.data.isDjiHdFpv && !OSD.data.isMspDisplay) + .attr('checked', HARDWARE.capabilities.isDjiHdFpv && !HARDWARE.capabilities.isMspDisplay) .on('change', function () { OSD.GUI.updateDjiView(this.checked); OSD.GUI.updatePreviews(); @@ -2944,7 +2930,7 @@ OSD.GUI.updateDjiView = function(on) { OSD.GUI.updateAlarms = function() { $(".osd_use_airspeed_alarm").toggle(usePitot); $(".osd_use_baro_temp_alarm").toggle(useBaro); - $(".osd_use_esc_telemetry").toggle(useESCTelemetry); + $(".osd_use_esc_telemetry").toggle(HARDWARE.capabilities.useESCTelemetry); $(".osd_use_crsf").toggle(useCRSFRx); }; @@ -3225,7 +3211,7 @@ OSD.GUI.updateAll = function() { OSD.GUI.updateFields(); OSD.GUI.updatePreviews(); OSD.GUI.updateGuidesView($('#videoGuides').find('input').is(':checked')); - OSD.GUI.updateDjiView(OSD.data.isDjiHdFpv && !OSD.data.isMspDisplay); + OSD.GUI.updateDjiView(HARDWARE.capabilities.isDjiHdFpv && !HARDWARE.capabilities.isMspDisplay); OSD.GUI.updateAlarms(); }; @@ -3247,6 +3233,38 @@ OSD.GUI.saveConfig = function() { }); }; +let HARDWARE = {}; +HARDWARE.init = function() { + HARDWARE.capabilities = { + isDjiHdFpv: false, + isMspDisplay: false, + useESCTelemetry: false + }; +}; + +HARDWARE.update = function(callback) { + + HARDWARE.init(); + + MSP.send_message(MSPCodes.MSP2_CF_SERIAL_CONFIG, false, false, function() { + $.each(FC.SERIAL_CONFIG.ports, function(index, port){ + if(port.functions.includes('DJI_FPV')) { + HARDWARE.capabilities.isDjiHdFpv = true; + } + if(port.functions.includes('MSP_DISPLAYPORT')) { + HARDWARE.capabilities.isMspDisplay = true; + } + if (port.functions.includes('ESC')) { + HARDWARE.capabilities.useESCTelemetry = true; + } + }); + + if (callback) { + callback(); + } + }); +}; + TABS.osd = {}; TABS.osd.initialize = function (callback) { @@ -3263,204 +3281,194 @@ TABS.osd.initialize = function (callback) { }); } - GUI.load(path.join(__dirname, "osd.html"), Settings.processHtml(function () { - // translate to user-selected language - i18n.localize(); - - // Open modal window - OSD.GUI.jbox = new jBox('Modal', { - width: 750, - height: 300, - position: {y:'bottom'}, - offset: {y:-50}, - closeButton: 'title', - animation: false, - attach: $('#fontmanager'), - title: 'OSD Font Manager', - content: $('#fontmanagercontent') - }); - - $('a.save').on('click', function () { - Settings.saveInputs(save_to_eeprom); - }); - - // Initialise guides checkbox - isGuidesChecked = store.get('showOSDGuides', false); - - // Setup switch indicators - $(".osdSwitchInd_channel option").each(function() { - $(this).text("Ch " + $(this).text()); - }); - - // Function when text for switch indicators change - $('.osdSwitchIndName').on('keyup', function() { - // Make sure that the switch hint only contains A to Z - let testExp = new RegExp('^[A-Za-z0-9]'); - let testText = $(this).val(); - if (testExp.test(testText.slice(-1))) { - $(this).val(testText.toUpperCase()); - } else { - $(this).val(testText.slice(0, -1)); - } - - // Update the OSD preview - refreshOSDSwitchIndicators(); - }); - - // Function to update the OSD layout when the switch text alignment changes - $("#switchIndicators_alignLeft").on('change', function() { - refreshOSDSwitchIndicators(); - }); - - // Functions for when pan servo settings change - $('#osdPanServoIndicatorShowDegrees').on('change', function() { - // Update the OSD preview - updatePanServoPreview(); - }); - - $('#panServoOutput').on('change', function() { - // Update the OSD preview - updatePanServoPreview(); - }); - - // Function for when text for craft name changes - $('#craft_name').on('keyup', function() { - // Make sure that the craft name only contains A to Z, 0-9, spaces, and basic ASCII symbols - let testExp = new RegExp('^[A-Za-z0-9 !_,:;=@#\\%\\&\\-\\*\\^\\(\\)\\.\\+\\<\\>\\[\\]]'); - let testText = $(this).val(); - if (testExp.test(testText.slice(-1))) { - $(this).val(testText.toUpperCase()); - } else { - $(this).val(testText.slice(0, -1)); + HARDWARE.update(function () { + GUI.load(path.join(__dirname, "osd.html"), Settings.processHtml(function () { + // translate to user-selected language + i18n.localize(); + + // Open modal window + OSD.GUI.jbox = new jBox('Modal', { + width: 750, + height: 300, + position: {y:'bottom'}, + offset: {y:-50}, + closeButton: 'title', + animation: false, + attach: $('#fontmanager'), + title: 'OSD Font Manager', + content: $('#fontmanagercontent') + }); + + $('a.save').on('click', function () { + Settings.saveInputs(save_to_eeprom); + }); + + // Initialise guides checkbox + isGuidesChecked = store.get('showOSDGuides', false); + + // Setup switch indicators + $(".osdSwitchInd_channel option").each(function() { + $(this).text("Ch " + $(this).text()); + }); + + // Function when text for switch indicators change + $('.osdSwitchIndName').on('keyup', function() { + // Make sure that the switch hint only contains A to Z + let testExp = new RegExp('^[A-Za-z0-9]'); + let testText = $(this).val(); + if (testExp.test(testText.slice(-1))) { + $(this).val(testText.toUpperCase()); + } else { + $(this).val(testText.slice(0, -1)); + } + + // Update the OSD preview + refreshOSDSwitchIndicators(); + }); + + // Function to update the OSD layout when the switch text alignment changes + $("#switchIndicators_alignLeft").on('change', function() { + refreshOSDSwitchIndicators(); + }); + + // Functions for when pan servo settings change + $('#osdPanServoIndicatorShowDegrees').on('change', function() { + // Update the OSD preview + updatePanServoPreview(); + }); + + $('#panServoOutput').on('change', function() { + // Update the OSD preview + updatePanServoPreview(); + }); + + // Function for when text for craft name changes + $('#craft_name').on('keyup', function() { + // Make sure that the craft name only contains A to Z, 0-9, spaces, and basic ASCII symbols + let testExp = new RegExp('^[A-Za-z0-9 !_,:;=@#\\%\\&\\-\\*\\^\\(\\)\\.\\+\\<\\>\\[\\]]'); + let testText = $(this).val(); + if (testExp.test(testText.slice(-1))) { + $(this).val(testText.toUpperCase()); + } else { + $(this).val(testText.slice(0, -1)); + } + + // Update the OSD preview + updatePilotAndCraftNames(); + }); + + $('#pilot_name').on('keyup', function() { + // Make sure that the pilot name only contains A to Z, 0-9, spaces, and basic ASCII symbols + let testExp = new RegExp('^[A-Za-z0-9 !_,:;=@#\\%\\&\\-\\*\\^\\(\\)\\.\\+\\<\\>\\[\\]]'); + let testText = $(this).val(); + if (testExp.test(testText.slice(-1))) { + $(this).val(testText.toUpperCase()); + } else { + $(this).val(testText.slice(0, -1)); + } + + // Update the OSD preview + updatePilotAndCraftNames(); + }); + + // font preview window + var $preview = $('.font-preview'); + + // init structs once, also clears current font + FONT.initData(); + + var $fontPicker = $('.fontbuttons button'); + $fontPicker.on('click', function () { + if (!$(this).data('font-file')) { + return; + } + $fontPicker.removeClass('active'); + $(this).addClass('active'); + $.get('./resources/osd/analogue/' + $(this).data('font-file') + '.mcm', function (data) { + FONT.parseMCMFontFile(data); + FONT.preview($preview); + OSD.GUI.update(); + }); + store.set('osd_font', $(this).data('font-file')); + }); + + // load the last selected font when we change tabs + var osd_font = store.get('osd_font', false); + var previous_font_button; + if (osd_font) { + previous_font_button = $('.fontbuttons button[data-font-file="' + osd_font + '"]'); + if (previous_font_button.attr('data-font-file') == undefined) previous_font_button = undefined; } - - // Update the OSD preview - updatePilotAndCraftNames(); - }); - - $('#pilot_name').on('keyup', function() { - // Make sure that the pilot name only contains A to Z, 0-9, spaces, and basic ASCII symbols - let testExp = new RegExp('^[A-Za-z0-9 !_,:;=@#\\%\\&\\-\\*\\^\\(\\)\\.\\+\\<\\>\\[\\]]'); - let testText = $(this).val(); - if (testExp.test(testText.slice(-1))) { - $(this).val(testText.toUpperCase()); + + if (typeof previous_font_button == "undefined") { + $fontPicker.first().trigger( "click" ); } else { - $(this).val(testText.slice(0, -1)); - } - - // Update the OSD preview - updatePilotAndCraftNames(); - }); - - // font preview window - var $preview = $('.font-preview'); - - // init structs once, also clears current font - FONT.initData(); - - var $fontPicker = $('.fontbuttons button'); - $fontPicker.on('click', function () { - if (!$(this).data('font-file')) { - return; + previous_font_button.trigger( "click" ); } - $fontPicker.removeClass('active'); - $(this).addClass('active'); - $.get('./resources/osd/analogue/' + $(this).data('font-file') + '.mcm', function (data) { - FONT.parseMCMFontFile(data); - FONT.preview($preview); - OSD.GUI.update(); - }); - store.set('osd_font', $(this).data('font-file')); - }); - - // load the last selected font when we change tabs - var osd_font = store.get('osd_font', false); - var previous_font_button; - if (osd_font) { - previous_font_button = $('.fontbuttons button[data-font-file="' + osd_font + '"]'); - if (previous_font_button.attr('data-font-file') == undefined) previous_font_button = undefined; - } - - if (typeof previous_font_button == "undefined") { - $fontPicker.first().trigger( "click" ); - } else { - previous_font_button.trigger( "click" ); - } - - - $('button.load_font_file').on('click', function () { - $fontPicker.removeClass('active'); - FONT.openFontFile().then(function () { - FONT.preview($preview); - OSD.GUI.update(); + + + $('button.load_font_file').on('click', function () { + $fontPicker.removeClass('active'); + FONT.openFontFile().then(function () { + FONT.preview($preview); + OSD.GUI.update(); + }); }); - }); - - // font upload - $('a.flash_font').on('click', function () { - if (!GUI.connect_lock) { // button disabled while flashing is in progress - var progressLabel = $('.progressLabel'); - var progressBar = $('.progress'); - var uploading = i18n.getMessage('uploadingCharacters'); - progressLabel.text(uploading); - var progressCallback = function(done, total, percentage) { - progressBar.val(percentage); - if (done == total) { - progressLabel.text(i18n.getMessage('uploadedCharacters'), [total]); - } else { - progressLabel.text(uploading + ' (' + done + '/' + total + ')'); + + // font upload + $('a.flash_font').on('click', function () { + if (!GUI.connect_lock) { // button disabled while flashing is in progress + var progressLabel = $('.progressLabel'); + var progressBar = $('.progress'); + var uploading = i18n.getMessage('uploadingCharacters'); + progressLabel.text(uploading); + var progressCallback = function(done, total, percentage) { + progressBar.val(percentage); + if (done == total) { + progressLabel.text(i18n.getMessage('uploadedCharacters'), [total]); + } else { + progressLabel.text(uploading + ' (' + done + '/' + total + ')'); + } } + FONT.upload(progressCallback); } - FONT.upload(progressCallback); - } - }); - - $('.update_preview').on('change', function () { - if (OSD.data) { - // Force an OSD redraw by saving any element - // with a small delay, to make sure the setting - // change is performance before the OSD starts - // the full redraw. - // This will also update all previews - setTimeout(function() { - OSD.GUI.saveItem({id: 0}); - }, 100); - } - }); - - $('#useCraftnameForMessages').on('change', function() { - OSD.GUI.updateDjiMessageElements(this.checked); - }); - - // Update RX data for Crossfire detection - mspHelper.loadRxConfig(function() { - useCRSFRx = (FC.RX_CONFIG.serialrx_provider == 6); - }); - - // Get status of ESC Telemetry - useESCTelemetry = false; - MSP.send_message(MSPCodes.MSP2_CF_SERIAL_CONFIG, false, false, function() { - for (var portIndex = 0; portIndex < FC.SERIAL_CONFIG.ports.length; portIndex++) { - var serialPort = FC.SERIAL_CONFIG.ports[portIndex]; - if (serialPort.functions.indexOf("ESC") >= 0) { - useESCTelemetry = true; - break; + }); + + $('.update_preview').on('change', function () { + if (OSD.data) { + // Force an OSD redraw by saving any element + // with a small delay, to make sure the setting + // change is performance before the OSD starts + // the full redraw. + // This will also update all previews + setTimeout(function() { + OSD.GUI.saveItem({id: 0}); + }, 100); } + }); + + $('#useCraftnameForMessages').on('change', function() { + OSD.GUI.updateDjiMessageElements(this.checked); + }); + + // Update RX data for Crossfire detection + mspHelper.loadRxConfig(function() { + useCRSFRx = (FC.RX_CONFIG.serialrx_provider == 6); + }); + + // Update SENSOR_CONFIG, used to detect + // OSD_AIR_SPEED + mspHelper.loadSensorConfig(function () { + useBaro = (FC.SENSOR_CONFIG.barometer != 0); + usePitot = (FC.SENSOR_CONFIG.pitot != 0); + GUI.content_ready(callback); + }); + + if(semver.gte(FC.CONFIG.flightControllerVersion, '7.1.0')) { + mspHelper.loadOsdCustomElements(createCustomElements); } - }); - - // Update SENSOR_CONFIG, used to detect - // OSD_AIR_SPEED - mspHelper.loadSensorConfig(function () { - useBaro = (FC.SENSOR_CONFIG.barometer != 0); - usePitot = (FC.SENSOR_CONFIG.pitot != 0); - GUI.content_ready(callback); - }); - - if(semver.gte(FC.CONFIG.flightControllerVersion, '7.1.0')) { - mspHelper.loadOsdCustomElements(createCustomElements); - } - })); + })); + }); }; function createCustomElements(){ From 977af87a50665bbbb7b3a62079a3493496b040ba Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Thu, 16 May 2024 12:59:20 +0200 Subject: [PATCH 33/44] Fix other calls as well --- tabs/osd.js | 54 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/tabs/osd.js b/tabs/osd.js index 03e44c54c..e80df966c 100644 --- a/tabs/osd.js +++ b/tabs/osd.js @@ -149,10 +149,6 @@ SYM.AH_AIRCRAFT4 = 0x1A6; SYM.AH_CROSSHAIRS = new Array(0x166, 0x1A4, new Array(0x190, 0x191, 0x192), new Array(0x193, 0x194, 0x195), new Array(0x196, 0x197, 0x198), new Array(0x199, 0x19A, 0x19B), new Array (0x19C, 0x19D, 0x19E), new Array (0x19F, 0x1A0, 0x1A1)); -var useBaro = false; -var useCRSFRx = false; -var usePitot = false; - var video_type = null; var isGuidesChecked = false; var FONT = FONT || {}; @@ -951,7 +947,7 @@ OSD.constants = { name: 'AIR_SPEED', id: 27, enabled: function() { - return usePitot; + return HARDWARE.capabilities.usePitot; }, preview: function(osd_data) { var speed; @@ -976,7 +972,7 @@ OSD.constants = { name: 'AIR_MAX_SPEED', id: 127, enabled: function() { - return usePitot; + return HARDWARE.capabilities.usePitot; }, preview: function(osd_data) { // 3 chars @@ -1087,7 +1083,7 @@ OSD.constants = { name: 'BARO_TEMPERATURE', id: 87, enabled: function() { - return useBaro; + return HARDWARE.capabilities.useBaro; }, preview: function(osd_data) { switch (OSD.data.preferences.units) { @@ -1801,7 +1797,7 @@ OSD.constants = { { name: 'osdGroupCRSF', enabled: function() { - return useCRSFRx; + return HARDWARE.capabilities.useCRSFRx; }, items: [ { @@ -2928,10 +2924,10 @@ OSD.GUI.updateDjiView = function(on) { }; OSD.GUI.updateAlarms = function() { - $(".osd_use_airspeed_alarm").toggle(usePitot); - $(".osd_use_baro_temp_alarm").toggle(useBaro); + $(".osd_use_airspeed_alarm").toggle(HARDWARE.capabilities.usePitot); + $(".osd_use_baro_temp_alarm").toggle(HARDWARE.capabilities.useBaro); $(".osd_use_esc_telemetry").toggle(HARDWARE.capabilities.useESCTelemetry); - $(".osd_use_crsf").toggle(useCRSFRx); + $(".osd_use_crsf").toggle(HARDWARE.capabilities.useCRSFRx); }; OSD.GUI.updateMapPreview = function(mapCenter, name, directionSymbol, centerSymbol) { @@ -3238,7 +3234,10 @@ HARDWARE.init = function() { HARDWARE.capabilities = { isDjiHdFpv: false, isMspDisplay: false, - useESCTelemetry: false + useESCTelemetry: false, + useCRSFRx: false, + useBaro: false, + usePitot: false }; }; @@ -3259,9 +3258,19 @@ HARDWARE.update = function(callback) { } }); - if (callback) { - callback(); - } + // Update RX data for Crossfire detection + mspHelper.loadRxConfig(function() { + HARDWARE.capabilities.useCRSFRx = (FC.RX_CONFIG.serialrx_provider == 6); + + mspHelper.loadSensorConfig(function () { + HARDWARE.capabilities.useBaro = (FC.SENSOR_CONFIG.barometer != 0); + HARDWARE.capabilities.usePitot = (FC.SENSOR_CONFIG.pitot != 0); + + if (callback) { + callback(); + } + }); + }); }); }; @@ -3451,22 +3460,11 @@ TABS.osd.initialize = function (callback) { OSD.GUI.updateDjiMessageElements(this.checked); }); - // Update RX data for Crossfire detection - mspHelper.loadRxConfig(function() { - useCRSFRx = (FC.RX_CONFIG.serialrx_provider == 6); - }); - - // Update SENSOR_CONFIG, used to detect - // OSD_AIR_SPEED - mspHelper.loadSensorConfig(function () { - useBaro = (FC.SENSOR_CONFIG.barometer != 0); - usePitot = (FC.SENSOR_CONFIG.pitot != 0); - GUI.content_ready(callback); - }); - if(semver.gte(FC.CONFIG.flightControllerVersion, '7.1.0')) { mspHelper.loadOsdCustomElements(createCustomElements); } + + GUI.content_ready(callback); })); }); }; From 35c32374a90ab74cb9458e3391885f275f4e1ed0 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Thu, 16 May 2024 15:07:08 +0200 Subject: [PATCH 34/44] Fix crosshair --- tabs/osd.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tabs/osd.js b/tabs/osd.js index e80df966c..4b1c989dd 100644 --- a/tabs/osd.js +++ b/tabs/osd.js @@ -3028,8 +3028,8 @@ OSD.GUI.updatePreviews = function() { // crosshairs if ($('input[name="CROSSHAIRS"]').prop('checked')) { - crsHNumber = Settings.getInputValue('osd_crosshairs_style'); - if (crsHNumber == 1) { + let crsHNumber = Settings.getInputValue('osd_crosshairs_style'); + if (crsHNumber == 1) { // AIRCRAFT style OSD.GUI.checkAndProcessSymbolPosition(hudCenterPosition - 2, SYM.AH_AIRCRAFT0); OSD.GUI.checkAndProcessSymbolPosition(hudCenterPosition - 1, SYM.AH_AIRCRAFT1); From d46b797830e20ba2d33a9ef183fdb482661fa78c Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 17 May 2024 08:12:02 +0200 Subject: [PATCH 35/44] Update layout of the defaults dialog --- js/defaults_dialog_entries.js | 13 +++++++++++++ src/css/defaults_dialog.css | 13 +++++++++++++ wizard/receiver.html | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/js/defaults_dialog_entries.js b/js/defaults_dialog_entries.js index 44fc7d80c..c8998740e 100644 --- a/js/defaults_dialog_entries.js +++ b/js/defaults_dialog_entries.js @@ -1,6 +1,19 @@ 'use strict'; var defaultsDialogData = [ + { + "title": 'Wizard', + "id": 76, + "notRecommended": false, + "reboot": true, + "wizardPages": ['receiver', 'outputs', 'gps', 'filters', 'pids'], + "settings": [ + { + key: "applied_defaults", + value: 1 + } + ] + }, { "title": 'Mini Quad with 3" propellers', "id": 6, diff --git a/src/css/defaults_dialog.css b/src/css/defaults_dialog.css index 7cd771f9b..2b32baa88 100644 --- a/src/css/defaults_dialog.css +++ b/src/css/defaults_dialog.css @@ -40,6 +40,19 @@ padding: 1em; } +.defaults-dialog__wizard { + font-size: 1.2em; +} + +.defaults-dialog__wizard > div { + margin-top: 1em; +} + +.defaults-dialog__wizard label { + min-width: 30%; + display: inline-block; +} + .defaults-dialog__content--wrapper { overflow-y: auto; } diff --git a/wizard/receiver.html b/wizard/receiver.html index 67c519359..5cd304f7d 100644 --- a/wizard/receiver.html +++ b/wizard/receiver.html @@ -1,6 +1,6 @@

      Receiver wizard

      -
      From a45d85c0b0ef0b49ac8a67f37a9074d401a08114 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 17 May 2024 08:50:20 +0200 Subject: [PATCH 36/44] Move UI bindings to separate module --- js/defaults_dialog.js | 27 +++++++++++++++++------ js/defaults_dialog_entries.js | 2 +- js/wizard_ui_bindings.js | 41 +++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 js/wizard_ui_bindings.js diff --git a/js/defaults_dialog.js b/js/defaults_dialog.js index 98a3a63b9..aee4317d5 100644 --- a/js/defaults_dialog.js +++ b/js/defaults_dialog.js @@ -13,6 +13,8 @@ const jBox = require('./libraries/jBox/jBox.min'); const i18n = require('./localization'); const defaultsDialogData = require('./defaults_dialog_entries.js'); const Settings = require('./settings.js'); +const serialPortHelper = require('./serialPortHelper'); +const wizardUiBindings = require('./wizard_ui_bindings'); var savingDefaultsModal; @@ -23,6 +25,8 @@ var defaultsDialog = (function () { let $container; + privateScope.wizardSettings = {}; + publicScope.init = function () { mspHelper.getSetting("applied_defaults").then(privateScope.onInitSettingReturned); $container = $("#defaults-wrapper"); @@ -50,16 +54,22 @@ var defaultsDialog = (function () { }; privateScope.saveWizardStep = function (selectedDefaultPreset, wizardStep) { - //TODO add saving logic + const steps = selectedDefaultPreset.wizardPages; + const stepName = steps[wizardStep]; - privateScope.wizard(selectedDefaultPreset, wizardStep + 1); - }; + if (stepName == "receiver") { + let $receiverPort = $container.find('#wizard-receiver-port'); + let receiverPort = $receiverPort.val(); - privateScope.handleTabLoadReceiver = function ($content) { - console.log('ready to handle receiver'); + if (receiverPort != "-1") { + privateScope.wizardSettings['receiverPort'] = receiverPort; + } + privateScope.wizardSettings['receiverProcol'] = $container.find('#wizard-receiver-protocol').val(); + } - }, + privateScope.wizard(selectedDefaultPreset, wizardStep + 1); + }; privateScope.wizard = function (selectedDefaultPreset, wizardStep) { @@ -94,7 +104,10 @@ var defaultsDialog = (function () { }); if (stepName == "receiver") { - privateScope.handleTabLoadReceiver($content); + /** + * Bindings executed when the receiver wizard tab is loaded + */ + wizardUiBindings.receiver($content); } Settings.configureInputs().then( diff --git a/js/defaults_dialog_entries.js b/js/defaults_dialog_entries.js index c8998740e..eb5e28fd6 100644 --- a/js/defaults_dialog_entries.js +++ b/js/defaults_dialog_entries.js @@ -6,7 +6,7 @@ var defaultsDialogData = [ "id": 76, "notRecommended": false, "reboot": true, - "wizardPages": ['receiver', 'outputs', 'gps', 'filters', 'pids'], + "wizardPages": ['receiver'], "settings": [ { key: "applied_defaults", diff --git a/js/wizard_ui_bindings.js b/js/wizard_ui_bindings.js new file mode 100644 index 000000000..8125ba3d8 --- /dev/null +++ b/js/wizard_ui_bindings.js @@ -0,0 +1,41 @@ +'use strict'; + +const mspHelper = require('./msp/MSPHelper'); +const serialPortHelper = require('./serialPortHelper'); + +const wizardUiBindings = (function () { + + let self = {}; + + self.receiver = function ($content) { + + mspHelper.loadSerialPorts(function () { + let $receiverPort = $content.find('#wizard-receiver-port'); + let ports = serialPortHelper.getPortIdentifiersForFunction('RX_SERIAL'); + let currentPort = null; + + if (ports.length > 0) { + currentPort = ports[0]; + } + + let availablePorts = serialPortHelper.getPortList(); + + $receiverPort.append(''); + for (let i = 0; i < availablePorts.length; i++) { + let port = availablePorts[i]; + $receiverPort.append(''); + } + + if (currentPort !== null) { + $receiverPort.val(currentPort); + } else { + $receiverPort.val(-1); + } + }); + + } + + return self; +})(); + +module.exports = wizardUiBindings; \ No newline at end of file From 4fe7728d466fdd9420eb381df6a00c8edccacbdc Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 17 May 2024 08:55:50 +0200 Subject: [PATCH 37/44] Add a page descritpion to the wizard receiver page --- src/css/defaults_dialog.css | 6 ++++++ wizard/receiver.html | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/css/defaults_dialog.css b/src/css/defaults_dialog.css index 2b32baa88..945a30158 100644 --- a/src/css/defaults_dialog.css +++ b/src/css/defaults_dialog.css @@ -53,6 +53,12 @@ display: inline-block; } +.defaults-dialog__wizard p { + margin-top: 1em; + font-size: 0.9em; + color:#444; +} + .defaults-dialog__content--wrapper { overflow-y: auto; } diff --git a/wizard/receiver.html b/wizard/receiver.html index 5cd304f7d..3c2b2ee6e 100644 --- a/wizard/receiver.html +++ b/wizard/receiver.html @@ -1,4 +1,8 @@

      Receiver wizard

      +

      + Configure receiver serial port and protocol. If you unsure about serial port or protocol, click `Skip` to go to the next page. + You can change those settings later with the configurator UI. +

      From 6a514920fa0c39e8599b5d1f776cc1db5d675f5f Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 17 May 2024 10:18:35 +0200 Subject: [PATCH 38/44] Store receiver port in wizard --- js/defaults_dialog.js | 31 +++++++++++++++------- js/msp/MSPHelper.js | 1 + js/serialPortHelper.js | 5 ++++ js/wizard_save_framework.js | 51 +++++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 9 deletions(-) create mode 100644 js/wizard_save_framework.js diff --git a/js/defaults_dialog.js b/js/defaults_dialog.js index aee4317d5..52b841e8c 100644 --- a/js/defaults_dialog.js +++ b/js/defaults_dialog.js @@ -13,8 +13,8 @@ const jBox = require('./libraries/jBox/jBox.min'); const i18n = require('./localization'); const defaultsDialogData = require('./defaults_dialog_entries.js'); const Settings = require('./settings.js'); -const serialPortHelper = require('./serialPortHelper'); const wizardUiBindings = require('./wizard_ui_bindings'); +const wizardSaveFramework = require('./wizard_save_framework'); var savingDefaultsModal; @@ -25,7 +25,7 @@ var defaultsDialog = (function () { let $container; - privateScope.wizardSettings = {}; + privateScope.wizardSettings = []; publicScope.init = function () { mspHelper.getSetting("applied_defaults").then(privateScope.onInitSettingReturned); @@ -62,10 +62,16 @@ var defaultsDialog = (function () { let receiverPort = $receiverPort.val(); if (receiverPort != "-1") { - privateScope.wizardSettings['receiverPort'] = receiverPort; + privateScope.wizardSettings.push({ + name: "receiverPort", + value: receiverPort + }); } - privateScope.wizardSettings['receiverProcol'] = $container.find('#wizard-receiver-protocol').val(); + privateScope.wizardSettings.push({ + name: "receiverProtocol", + value: $container.find('#wizard-receiver-protocol').val() + }); } privateScope.wizard(selectedDefaultPreset, wizardStep + 1); @@ -77,12 +83,19 @@ var defaultsDialog = (function () { const stepsCount = selectedDefaultPreset.wizardPages.length; const stepName = steps[wizardStep]; - console.log(steps[wizardStep], wizardStep, stepsCount); - if (wizardStep >= stepsCount) { //This is the last step, time to finalize $container.hide(); - privateScope.saveAndReboot(); + + wizardSaveFramework.persist(privateScope.wizardSettings, function () { + mspHelper.saveToEeprom(function () { + //noinspection JSUnresolvedVariable + GUI.log(i18n.getMessage('configurationEepromSaved')); + if (selectedDefaultPreset.reboot) { + privateScope.reboot(); + } + }); + }); } else { const $content = $container.find('.defaults-dialog__wizard'); @@ -126,7 +139,7 @@ var defaultsDialog = (function () { }; - privateScope.saveAndReboot = function () { + privateScope.reboot = function () { GUI.tab_switch_cleanup(function () { MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () { @@ -149,7 +162,7 @@ var defaultsDialog = (function () { //noinspection JSUnresolvedVariable GUI.log(i18n.getMessage('configurationEepromSaved')); if (selectedDefaultPreset.reboot) { - privateScope.saveAndReboot(); + privateScope.reboot(); } }); } diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index 0c672b25b..9bb29ced5 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -1847,6 +1847,7 @@ var mspHelper = (function () { break; case MSPCodes.MSP2_SET_CF_SERIAL_CONFIG: + console.log('will crunch', FC.SERIAL_CONFIG); for (let i = 0; i < FC.SERIAL_CONFIG.ports.length; i++) { var serialPort = FC.SERIAL_CONFIG.ports[i]; diff --git a/js/serialPortHelper.js b/js/serialPortHelper.js index d6bdbf184..20df6e75f 100644 --- a/js/serialPortHelper.js +++ b/js/serialPortHelper.js @@ -332,9 +332,14 @@ const serialPortHelper = (function () { publicScope.set = function(port, functionName, baudrate) { + console.log('Start', FC.SERIAL_CONFIG); + publicScope.clearByFunction(functionName); let config = publicScope.getPortByIdentifier(port); + + console.log('Config to change', config); + if (config) { config.functions = [functionName]; diff --git a/js/wizard_save_framework.js b/js/wizard_save_framework.js new file mode 100644 index 000000000..d529a67fe --- /dev/null +++ b/js/wizard_save_framework.js @@ -0,0 +1,51 @@ +'use strict'; + +const mspHelper = require('./msp/MSPHelper'); +const serialPortHelper = require('./serialPortHelper'); +const FC = require('./fc'); + +var wizardSaveFramework = (function () { + + let self = {}; + + self.saveSetting = function (config, callback) { + + switch (config.name) { + case 'receiverPort': + serialPortHelper.set(config.value, 'RX_SERIAL', null); + mspHelper.saveSerialPorts(callback); + break; + default: + callback(); + break; + } + }; + + self.handleSetting = function (configs, finalCallback) { + + if (configs.length > 0) { + let setting = configs.shift(); + self.saveSetting(setting, function () { + self.handleSetting(configs, finalCallback); + }); + } else { + console.log('Nothing to save'); + finalCallback(); + } + }; + + self.persist = function (config, finalCallback) { + if (config === null || config === undefined || config.length === 0) { + finalCallback(); + return; + } + + let configCopy = Array.from(config); + + self.handleSetting(configCopy, finalCallback); + } + + return self; +})(); + +module.exports = wizardSaveFramework; \ No newline at end of file From 7e66940d02d695550c7cdcd1f97cb8fe6a03a56a Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 17 May 2024 11:04:18 +0200 Subject: [PATCH 39/44] Finish receiver wizard page --- js/defaults_dialog.js | 2 +- js/msp/MSPHelper.js | 2 +- js/wizard_save_framework.js | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/js/defaults_dialog.js b/js/defaults_dialog.js index 52b841e8c..6bb62f138 100644 --- a/js/defaults_dialog.js +++ b/js/defaults_dialog.js @@ -70,7 +70,7 @@ var defaultsDialog = (function () { privateScope.wizardSettings.push({ name: "receiverProtocol", - value: $container.find('#wizard-receiver-protocol').val() + value: $container.find('#wizard-receiver-protocol option:selected').text() }); } diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index 9bb29ced5..95ce5cbd9 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -3231,7 +3231,7 @@ var mspHelper = (function () { this.encodeSetting(name, value).then(function (data) { return MSP.promise(MSPCodes.MSPV2_SET_SETTING, data).then(callback); }).catch(error => { - console.log("Invalid setting: " + name); + console.log("Invalid setting: " + name, error); return Promise.resolve().then(callback); }); }; diff --git a/js/wizard_save_framework.js b/js/wizard_save_framework.js index d529a67fe..04dd8f59e 100644 --- a/js/wizard_save_framework.js +++ b/js/wizard_save_framework.js @@ -9,12 +9,19 @@ var wizardSaveFramework = (function () { let self = {}; self.saveSetting = function (config, callback) { - + /* + serialrx_provider to 2 + serialrx_provider to 6 + */ + switch (config.name) { case 'receiverPort': serialPortHelper.set(config.value, 'RX_SERIAL', null); mspHelper.saveSerialPorts(callback); break; + case 'receiverProtocol': + mspHelper.setSetting('serialrx_provider', config.value, callback); + break; default: callback(); break; From 23f16b4edeefcb9ecc197115c60d448d0ad88a29 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 17 May 2024 11:16:37 +0200 Subject: [PATCH 40/44] Enable wizard pages --- js/defaults_dialog_entries.js | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/js/defaults_dialog_entries.js b/js/defaults_dialog_entries.js index eb5e28fd6..7bc3d0eea 100644 --- a/js/defaults_dialog_entries.js +++ b/js/defaults_dialog_entries.js @@ -1,26 +1,13 @@ 'use strict'; var defaultsDialogData = [ - { - "title": 'Wizard', - "id": 76, - "notRecommended": false, - "reboot": true, - "wizardPages": ['receiver'], - "settings": [ - { - key: "applied_defaults", - value: 1 - } - ] - }, { "title": 'Mini Quad with 3" propellers', "id": 6, "notRecommended": false, "reboot": true, "mixerToApply": 3, - "wizardPages": ['receiver', 'outputs', 'gps', 'filters', 'pids'], + "wizardPages": ['receiver'], "settings": [ { key: "model_preview_type", @@ -142,6 +129,7 @@ var defaultsDialogData = [ "notRecommended": false, "reboot": true, "mixerToApply": 3, + "wizardPages": ['receiver'], "settings": [ { key: "model_preview_type", @@ -282,6 +270,7 @@ var defaultsDialogData = [ "notRecommended": false, "reboot": true, "mixerToApply": 3, + "wizardPages": ['receiver'], "settings": [ { key: "model_preview_type", @@ -403,6 +392,7 @@ var defaultsDialogData = [ "id": 3, "reboot": true, "mixerToApply": 14, + "wizardPages": ['receiver'], "settings": [ { key: "model_preview_type", @@ -608,6 +598,7 @@ var defaultsDialogData = [ "id": 4, "reboot": true, "mixerToApply": 8, + "wizardPages": ['receiver'], "settings": [ { key: "model_preview_type", @@ -813,6 +804,7 @@ var defaultsDialogData = [ "notRecommended": false, "reboot": true, "mixerToApply": 31, + "wizardPages": ['receiver'], "settings": [ { key: "model_preview_type", From 6bc214dad250cdeb7f71c4a091771ebe85d6e146 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 17 May 2024 11:23:23 +0200 Subject: [PATCH 41/44] remove not needed debug --- js/defaults_dialog.js | 7 +++---- js/serialPortHelper.js | 4 ---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/js/defaults_dialog.js b/js/defaults_dialog.js index 6bb62f138..06557eb70 100644 --- a/js/defaults_dialog.js +++ b/js/defaults_dialog.js @@ -346,10 +346,9 @@ var defaultsDialog = (function () { privateScope.onInitSettingReturned = function (promise) { - //FIXME for now we trigger wizard always - // if (promise.value > 0) { - // return; //Defaults were applied, we can just ignore - // } + if (promise.value > 0) { + return; //Defaults were applied, we can just ignore + } privateScope.render(); $container.show(); diff --git a/js/serialPortHelper.js b/js/serialPortHelper.js index 20df6e75f..f2c7d186c 100644 --- a/js/serialPortHelper.js +++ b/js/serialPortHelper.js @@ -332,14 +332,10 @@ const serialPortHelper = (function () { publicScope.set = function(port, functionName, baudrate) { - console.log('Start', FC.SERIAL_CONFIG); - publicScope.clearByFunction(functionName); let config = publicScope.getPortByIdentifier(port); - console.log('Config to change', config); - if (config) { config.functions = [functionName]; From e909eec5c32faced25f685d1bca9236b6d05118a Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Fri, 17 May 2024 11:06:14 +0100 Subject: [PATCH 42/44] Update auxiliary.js --- tabs/auxiliary.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tabs/auxiliary.js b/tabs/auxiliary.js index 9d4edbd33..8ac2342b7 100644 --- a/tabs/auxiliary.js +++ b/tabs/auxiliary.js @@ -52,7 +52,7 @@ TABS.auxiliary.initialize = function (callback) { // This object separates out the dividers. This is also used to order the modes const modeSections = {}; modeSections["Arming"] = ["ARM", "PREARM"]; - modeSections["Flight Modes"] = ["ANGLE", "HORIZON", "MANUAL"]; + modeSections["Flight Modes"] = ["ANGLE", "HORIZON", "MANUAL", "ANGLE HOLD"]; modeSections["Navigation Modes"] = ["NAV COURSE HOLD", "NAV CRUISE", "NAV POSHOLD", "NAV RTH", "NAV WP", "GCS NAV"]; modeSections["Flight Mode Modifiers"] = ["NAV ALTHOLD", "HEADING HOLD", "AIR MODE", "SOARING", "SURFACE", "TURN ASSIST"]; modeSections["Fixed Wing"] = ["AUTO TUNE", "SERVO AUTOTRIM", "AUTO LEVEL TRIM", "NAV LAUNCH", "LOITER CHANGE", "FLAPERON"]; @@ -504,7 +504,7 @@ TABS.auxiliary.initialize = function (callback) { }) .prop("checked", !!hideUnusedModesStore) .trigger('change'); - + // update ui instantly on first load update_ui(); From 2be9e53e97b268fb0f7153dc670a690ab981a7bf Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 17 May 2024 15:25:22 +0200 Subject: [PATCH 43/44] Fix tab switching --- js/gui.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/gui.js b/js/gui.js index 0dc3b6cc2..175916485 100644 --- a/js/gui.js +++ b/js/gui.js @@ -9,6 +9,7 @@ const FC = require('./fc'); const interval = require('./intervals'); const { scaleRangeInt } = require('./helpers'); const i18n = require('./localization'); +const mspDeduplicationQueue = require("./msp/mspDeduplicationQueue"); var TABS = {}; // filled by individual tab js file @@ -90,6 +91,7 @@ GUI_control.prototype.log = function (message) { // default switch doesn't require callback to be set GUI_control.prototype.tab_switch_cleanup = function (callback) { MSP.callbacks_cleanup(); // we don't care about any old data that might or might not arrive + mspDeduplicationQueue.flush(); interval.killAll(['global_data_refresh', 'msp-load-update', 'ltm-connection-check']); From afc097f8960e7fea28a0fc4bf7bfe1c963edf516 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sat, 18 May 2024 18:29:53 +0200 Subject: [PATCH 44/44] Hopefully this fixes crash on GPS tab --- tabs/gps.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tabs/gps.js b/tabs/gps.js index 5a72d1f2e..07c4f95ff 100644 --- a/tabs/gps.js +++ b/tabs/gps.js @@ -229,8 +229,8 @@ TABS.gps.initialize = function (callback) { var feature = mapHandler.forEachFeatureAtPixel(mapHandler.getEventPixel(evt.originalEvent), function(feature, layer) { return feature; }); - - if (feature) { + + if (feature && feature.get('data') && feature.get('name')) { TABS.gps.toolboxAdsbVehicle.setContent( `icao: ` + feature.get('name') + `
      ` + `lat: `+ (feature.get('data').lat / 10000000) + `
      `