001/* Copyright (C) Cross The Road Electronics 2024 */
002package com.ctre.phoenix.motorcontrol.can;
003import com.ctre.phoenix.motorcontrol.MotorCommutation;
004
005import com.ctre.phoenix.motorcontrol.StatorCurrentLimitConfiguration;
006import com.ctre.phoenix.motorcontrol.SupplyCurrentLimitConfiguration;
007import com.ctre.phoenix.motorcontrol.FeedbackDevice;
008import com.ctre.phoenix.sensors.AbsoluteSensorRange;
009import com.ctre.phoenix.sensors.SensorInitializationStrategy;
010
011/**
012 * Configurables available to TalonFX
013 *
014 * @deprecated This device's Phoenix 5 API is deprecated for removal in the
015 * 2025 season. Users should update to Phoenix 6 firmware and migrate to the
016 * Phoenix 6 API. A migration guide is available at
017 * https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html.
018 * <p>
019 * If the Phoenix 5 API must be used for this device, the device must have 22.X
020 * firmware. This firmware is available in Tuner X after selecting Phoenix 5 in
021 * the firmware year dropdown.
022 */
023@Deprecated(since = "2024", forRemoval = true)
024public class TalonFXConfiguration extends com.ctre.phoenix.motorcontrol.can.BaseTalonConfiguration {
025
026    /**
027     * Supply-side current limiting.  This is typically used to prevent breakers from tripping.
028     */
029    public SupplyCurrentLimitConfiguration supplyCurrLimit = new SupplyCurrentLimitConfiguration();
030    /**
031     * Stator-side current limiting.  This is typically used to limit acceleration/torque and heat generation.
032     */
033    public StatorCurrentLimitConfiguration statorCurrLimit = new StatorCurrentLimitConfiguration();
034
035    /**
036     * Choose the type of motor commutation.
037     */
038    public MotorCommutation motorCommutation = MotorCommutation.Trapezoidal;
039
040    /**
041     * Desired Sign / Range for the absolute position register.
042     * Choose unsigned for an absolute range of[0, +1) rotations, [0, 360) deg, etc.
043     * Choose signed for an absolute range of[-0.5, +0.5) rotations, [-180, +180) deg, etc.
044     */
045    public AbsoluteSensorRange absoluteSensorRange = AbsoluteSensorRange.Unsigned_0_to_360;
046    /**
047     * Adjusts the zero point for the absolute position register.
048     * The absolute position of the sensor will always have a discontinuity (360 -> 0 deg) or (+180 -> -180)
049     * and a hard-limited mechanism may have such a discontinuity in its functional range.
050     * In which case use this config to move the discontinuity outside of the function range.
051     */
052    public double integratedSensorOffsetDegrees = 0;
053    /**
054     * The sensor initialization strategy to use.This will impact the behavior the next time device boots up.
055     *
056     * Pick the strategy on how to initialize the "Position" register.  Depending on the mechanism,
057     * it may be desirable to auto set the Position register to match the Absolute Position(swerve for example).
058     * Or it may be desired to zero the sensor on boot(drivetrain translation sensor or a relative servo).
059     *
060     * TIP: Tuner's self-test feature will report what the boot sensor value will be in the event the device is reset.
061     */
062    public SensorInitializationStrategy initializationStrategy = SensorInitializationStrategy.BootToZero;
063
064        public TalonFXConfiguration() {
065        super(FeedbackDevice.IntegratedSensor);
066        }
067
068    /**
069     * @return String representation of all the configs
070     */
071        public String toString() {
072                return toString("");
073        }
074
075    /**
076     * @param prependString
077     *              String to prepend to all the configs
078     * @return String representation of all the configs
079     */
080    public String toString(String prependString) {
081        String retstr = prependString + ".supplyCurrLimit = " + supplyCurrLimit.toString() + ";\n";
082        retstr += prependString + ".statorCurrLimit = " + statorCurrLimit.toString() + ";\n";
083        retstr += prependString + ".motorCommutation = " + motorCommutation.toString() + ";\n";
084        retstr += prependString + ".absoluteSensorRange = " + absoluteSensorRange.toString() + ";\n";
085        retstr += prependString + ".integratedSensorOffsetDegrees = " + integratedSensorOffsetDegrees + ";\n";
086        retstr += prependString + ".initializationStrategy = " + initializationStrategy.toString() + ";\n";
087        retstr += super.toString(prependString);
088
089        return retstr;
090    }
091
092}
093