#$ TITLE: 4S, 3" to 5" race tune by ctzsznooze
#$ FIRMWARE_VERSION: 4.5
#$ CATEGORY: TUNE
#$ STATUS: EXPERIMENTAL
#$ KEYWORDS: 3in, 4in, 5in, twig, 4S, race, tune, ctzsnooze
#$ AUTHOR: ctzsnooze
#$ DISCUSSION: https://github.com/betaflight/firmware-presets/pull/8
#$ DESCRIPTION: Basic 3" to 5" 4S race setup by ctzsnooze.
#$ DESCRIPTION:
#$ DESCRIPTION: RPM filtering is STRONGLY Recommended!
#$ DESCRIPTION:
#$ DESCRIPTION: Choose ONE of the three FILTER options from the pop-up above!
#$ DESCRIPTION:
#$ DESCRIPTION: Choose your link speed!
#$ DESCRIPTION:
#$ FORCE_OPTIONS_REVIEW: TRUE

#$ INCLUDE: presets/4.5/tune/defaults.txt

# -- PID values --
set p_pitch = 44
set i_pitch = 79
set d_pitch = 41
set d_min_pitch = 29
set f_pitch = 132

set p_roll = 42
set i_roll = 76
set d_roll = 35
set d_min_roll = 25
set f_roll = 125

set p_yaw = 42
set i_yaw = 76
set d_yaw = 0
set d_min_yaw = 0
set f_yaw = 125

# -- Sliders --
set simplified_d_gain = 85
set simplified_pi_gain = 95
set simplified_dmax_gain = 120
set simplified_feedforward_gain = 105

# -- iTerm relax --
set iterm_relax_cutoff = 25

# -- iTerm windup (default)--
# -- iTerm rotation (off, default) --

# -- Dmax --
set d_max_advance = 0

# -- TPA --
set tpa_rate = 65
set tpa_breakpoint = 1250

# -- Feedforward --
set feedforward_max_rate_limit = 95

# -- PIDsum limits (default)--
# -- Antigravity (default) --
# -- Absolute control (off, default) --
# -- Accecleration limits (off, default) --
# -- Angle and Horizon mode tuning (default) --
# -- PIDs active below min throttle (default) --
# -- Set mixer type to default (legacy) --
# -- Set yaw spin recovery to default, which is auto --
# -- Set integrated yaw to off, so pitch and yaw are independent (default) --
# -- Gyro cal on first arm (off, default) --
# -- Transient throttle limit (off, default) --
# -- Thrust linear (off, default) --
# -- Throttle boost (default, 5)
# -- VBat warning threshold --

# -- DShot Idle --
set dshot_idle_value = 300

# -- Dynamic idle ON at 3500 rpm --
set dyn_idle_min_rpm = 35
set dyn_idle_p_gain = 40


# ------ OPIONS GO BELOW THIS LINE ------

# -- Filters --

#$ OPTION_GROUP BEGIN: (EXCLUSIVE) Choose ONE Filter option...
    #$ OPTION BEGIN (UNCHECKED): RPM enabled, normal build
    #$ INCLUDE: presets/4.3/filters/ctzsnooze_race.txt
    #$ OPTION END

    #$ OPTION BEGIN (UNCHECKED): RPM enabled, noisy build
    #$ INCLUDE: presets/4.3/filters/basic_rpm_noisy.txt
    #$ OPTION END

    #$ OPTION BEGIN (UNCHECKED): NON-RPM ESCs, normal build
    #$ INCLUDE: presets/4.3/filters/basic_no_rpm_normal.txt
    #$ OPTION END
#$ OPTION_GROUP END

# -- Fast Rx Link Options --

#$ OPTION_GROUP BEGIN: Choose your RC link speed!
    #$ OPTION BEGIN (UNCHECKED): 150Hz or less
        #$ INCLUDE: presets/4.3/rc_link/generic/150hz_race.txt
    #$ OPTION END

    #$ OPTION BEGIN (UNCHECKED): 250Hz
        #$ INCLUDE: presets/4.3/rc_link/generic/250hz_race.txt
    #$ OPTION END

    #$ OPTION BEGIN (UNCHECKED): 500Hz
        #$ INCLUDE: presets/4.3/rc_link/generic/500hz_race.txt
    #$ OPTION END
#$ OPTION_GROUP END

# -- Recommended options --

#$ OPTION_GROUP BEGIN: Check all of these (recommended)

    # -- RC_Smoothing --
    #$ OPTION BEGIN (UNCHECKED): Default RC_smoothing
        set rc_smoothing = ON
        set rc_smoothing_auto_factor = 30
        set rc_smoothing_auto_factor_throttle = 30
        set rc_smoothing_setpoint_cutoff = 0
        set rc_smoothing_feedforward_cutoff = 0
        set rc_smoothing_throttle_cutoff = 0
        set rc_smoothing_debug_axis = ROLL
    #$ OPTION END

    # -- Throttle limit --
    #$ OPTION BEGIN (UNCHECKED): Throttle limit 96%
        set throttle_limit_type = SCALE
        set throttle_limit_percent = 96
    #$ OPTION END

    # -- VBat sag compensation --
    #$ OPTION BEGIN (UNCHECKED): Full Sag compensation
        set vbat_sag_compensation = 100
        set vbat_sag_lpf_period = 2
    #$ OPTION END

    # -- Stick behaviour --
    #$ OPTION BEGIN (UNCHECKED): No deadband
        set deadband = 0
        set yaw_deadband = 0
    #$ OPTION END

    # -- Throttle curve --
    #$ OPTION BEGIN (UNCHECKED): Flat throttle curve
        set thr_mid = 50
        set thr_expo = 0
    #$ OPTION END

    # -- Startup and arming --
    #$ OPTION BEGIN (UNCHECKED): Arm at any angle
        set small_angle = 180
    #$ OPTION END

#$ OPTION_GROUP END

    # -- Rates --
#$ OPTION_GROUP BEGIN: My rates are optional:

    #$ OPTION BEGIN (UNCHECKED): Try ctzsnooze's race rates
        #$ INCLUDE: presets/4.3/rates/ctzsnooze_race.txt
    #$ OPTION END

#$ OPTION_GROUP END

simplified_tuning apply