#$ TITLE:  ImpulseRC Apex 5" | mouseFPV
#$ FIRMWARE_VERSION: 4.4
#$ CATEGORY: TUNE
#$ STATUS: EXPERIMENTAL
#$ KEYWORDS: Apex, ImpulseRC, 5", 5in, 5 inch
#$ AUTHOR: mouseFPV
#$ PARSER: MARKED
#$ DESCRIPTION: <br>
#$ DESCRIPTION: <img src="https://user-images.githubusercontent.com/19867640/174462482-28bdcfec-1c3a-43db-99d7-50688b92f050.svg" width="100px" style="margin-left: auto; margin-right: auto; display: block;"/>
#$ DESCRIPTION:
#$ DESCRIPTION: # Tune for ImpulseRC Apex
#$ DESCRIPTION:
#$ DESCRIPTION: ## About:
#$ DESCRIPTION: ### **This tune is EXPERIMENTAL!** I have only tested it on a single quad, and haven't flown it on a beatup frame. Take Nnte of the following: 
#$ DESCRIPTION: * The PID gains may be a little high for a quad under 750g, or that is a little more... broken in. Try the "Less Cheese" option if you have trilling/oscillations/motor heat.
#$ DESCRIPTION: * The P:D balance should be good.
#$ DESCRIPTION: * The Filters are pretty conservative, I am erring on the side of caution until I get this on a few more builds. The filters likely have some room for improvement in a future itteration. 
#$ DESCRIPTION: * Recommended 48k PWM.
#$ DESCRIPTION:
#$ DESCRIPTION: ## Options:
#$ DESCRIPTION: ### **Filters:**
#$ DESCRIPTION: * **RPM Filters DSHOT600** Enables RPM filtering. ESCs must support bi-directional. Sets motor poles to 14, Sets Dshot600.
#$ DESCRIPTION: * **RPM Filters DSHOT300** Enables RPM filtering. ESCs must support bi-directional. Sets motor poles to 14, Sets Dshot300.
#$ DESCRIPTION:
#$ DESCRIPTION: ### **Additional Options:**
#$ DESCRIPTION: * **Dynamic Idle:** Enables Dynamic Idle for Freestyle 5"
#$ DESCRIPTION: * **93% Motor Limit:** Simulates 1800-1900kv motors down closer to 1700kv
#$ DESCRIPTION: * **Enable Battery Sag Compensation:** Self Explanatory (see tooltip). Land at 3.5v/Cell or it's a bad time.
#$ DESCRIPTION: * **Less Cheese:** Reduces the Pids/Master Slider. Helps with lighter action cams and lower AUW, or if you have flyaways.
#$ DESCRIPTION:
#$ DESCRIPTION: ## Build Specs This Was Created on:
#$ DESCRIPTION: * **Frame:** ImpulseRC Apex
#$ DESCRIPTION: * **Motors:** FPVCycle 25mm
#$ DESCRIPTION: * **FC:** Tmotor f7 (mpu6000)
#$ DESCRIPTION: * **ESC:** TMotor F55A Pro 2
#$ DESCRIPTION: * **Action Cam:** GoPro Hero 11 Mini
#$ DESCRIPTION: * **AUW:** 750g
#$ DESCRIPTION:
#$ DESCRIPTION: ## Fly Like mouseFPV | Recommendations Outside of Tune:
#$ DESCRIPTION: * Apply mouseFPV Freestyle Rates
#$ DESCRIPTION: * Use 250hz radio link if possible
#$ DESCRIPTION: * **Set Jitter Reduction (feedforward_jitter_factor) to 14**
#$ DESCRIPTION:
#$ DISCUSSION: https://github.com/betaflight/firmware-presets/pull/378
#$ WARNING: If You Choose To Include Filters, Please, See The Following:
#$ INCLUDE_WARNING: misc/warnings/en/dshot.txt
#$ FORCE_OPTIONS_REVIEW: TRUE

#$ INCLUDE: presets/4.4/tune/defaults.txt
#$ INCLUDE: presets/4.3/filters/defaults.txt

# -- End Defaults --
# -- Begin Mouse Tune --

# -- PID Sliders  --
set simplified_pids_mode = RPY
set simplified_d_gain = 125
set simplified_pi_gain = 100
set simplified_feedforward_gain = 65
set simplified_dmax_gain = 000
set simplified_i_gain = 095
set simplified_pitch_d_gain = 105
set simplified_pitch_pi_gain = 100
set simplified_master_multiplier = 150
simplified_tuning apply

# -- iTerm relax --
set iterm_relax = RP
set iterm_relax_type = SETPOINT
set iterm_relax_cutoff = 10

# -- TPA  --
set tpa_rate = 70

# -- Thrust linear  --
set thrust_linear = 20

# -- DShot Idle --
set dshot_idle_value = 400

# -- Filters for non bi-directional setups as a base--

# -- Gyro lowpass filters --
set gyro_lpf1_static_hz = 0
set gyro_lpf1_dyn_min_hz = 0
set gyro_lpf1_dyn_max_hz = 0
set simplified_gyro_filter = ON
set simplified_gyro_filter_multiplier = 130
simplified_tuning apply

# -- Gyro Dynamic Notches --
set dyn_notch_count = 3
set dyn_notch_q = 350
set dyn_notch_min_hz = 125
set dyn_notch_max_hz = 600

# -- Dterm sliders --
set simplified_dterm_filter = ON
set simplified_dterm_filter_multiplier = 120
simplified_tuning apply

# -- Yaw lowpass --
set yaw_lowpass_hz = 100

# ------ OPTIONS GO BELOW THIS LINE ------

#$ OPTION_GROUP BEGIN: (EXCLUSIVE) Filters (Choose One or None)

    #$ OPTION BEGIN (CHECKED): RPM Filters DShot600
        #$ INCLUDE: presets/4.3/filters/defaults.txt

        # -- End Defaults --
        # -- Begin Mouse Filters --

        # enable dshot rpm telemetry
        set motor_pwm_protocol = DSHOT600
        set dshot_bidir = ON
        set motor_poles = 14

        # -- Gyro lowpass filters --
        # -- No Gyro Lowpass
        set gyro_lpf1_static_hz = 0
        set gyro_lpf1_dyn_min_hz = 0
        set gyro_lpf1_dyn_max_hz = 0
        set simplified_gyro_filter = ON
        set simplified_gyro_filter_multiplier = 130
        simplified_tuning apply

        # -- Dterm sliders --
        set simplified_dterm_filter_multiplier = 115
        simplified_tuning apply

        # -- Gyro Dynamic Notches --
        set dyn_notch_count = 1
        set dyn_notch_q = 500
        set dyn_notch_min_hz = 150
        set dyn_notch_max_hz = 600

        # -- RPM filtering --
        set rpm_filter_min_hz = 125

        # -- Yaw lowpass --
        set yaw_lowpass_hz = 100
    #$ OPTION END


    #$ OPTION BEGIN (UNCHECKED): RPM Filters DShot300
        #$ INCLUDE: presets/4.3/filters/defaults.txt

        # -- End Defaults --
        # -- Begin Mouse Filters --

        # enable dshot rpm telemetry
        set motor_pwm_protocol = DSHOT300
        set dshot_bidir = ON
        set motor_poles = 14

          # -- Gyro lowpass filters --
        # -- No Gyro Lowpass
        set gyro_lpf1_static_hz = 0
        set gyro_lpf1_dyn_min_hz = 0
        set gyro_lpf1_dyn_max_hz = 0
        set simplified_gyro_filter = ON
        set simplified_gyro_filter_multiplier = 130
        simplified_tuning apply

        # -- Dterm sliders --
        set simplified_dterm_filter_multiplier = 115
        simplified_tuning apply

        # -- Gyro Dynamic Notches --
        set dyn_notch_count = 1
        set dyn_notch_q = 500
        set dyn_notch_min_hz = 150
        set dyn_notch_max_hz = 600

        # -- RPM filtering --
        set rpm_filter_min_hz = 125

        # -- Yaw lowpass --
        set yaw_lowpass_hz = 100

    #$ OPTION END
#$ OPTION_GROUP END

#$ OPTION_GROUP BEGIN: Additional Options (Choose Many or None)
    #$ OPTION BEGIN (CHECKED): Dynamic Idle
        set dyn_idle_min_rpm = 20
        set dyn_idle_p_gain = 45
    #$ OPTION END

    #$ OPTION BEGIN (UNCHECKED): 93% Motor Limit (Use this if its too spicy)
        set motor_output_limit = 93
    #$ OPTION END

    #$ OPTION BEGIN (UNCHECKED): Enable Battery Sag Compensation?
        set vbat_sag_compensation = 100
    #$ OPTION END

    #$ OPTION BEGIN (UNCHECKED): Less Cheese! (Reduce Master Slider)
            set simplified_master_multiplier = 130
            simplified_tuning apply
    #$ OPTION END

#$ OPTION_GROUP END
