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 992ca971..a6f8b955 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 19bca033..27c465ef 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 00000000..9336e27f --- /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 27c465ef..64009317 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 9336e27f..78ae7ce4 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 71da7b46..8d7689ab 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 @@
  • - +
  • - +
  • - +