001/* Copyright (C) Cross The Road Electronics 2024 */
002package com.ctre.phoenix.motorcontrol;
003
004/**
005 * Choose the control mode for a VictorSPX.
006 */
007public enum VictorSPXControlMode
008{
009        /**
010         * Percent output [-1,1]
011         */
012        PercentOutput(0),
013        /**
014         * Position closed loop
015         */
016        Position(1),
017        /**
018         * Velocity closed loop
019         */
020        Velocity(2),
021        /**
022         * Follow other motor controller
023         */
024        Follower(5),
025        /**
026         * Motion Profile
027         */
028        MotionProfile(6),
029        /**
030         * Motion Magic
031         */
032        MotionMagic(7),
033        /**
034         * Motion Profile with auxiliary output
035         */
036        MotionProfileArc(10),
037
038        /**
039         * Disable Motor Controller
040         */
041        Disabled(15);
042
043        /**
044         * Value of control mode
045         */
046        public final int value;
047
048        /**
049         * Create VictorSPXControlMode of initValue
050         * @param initValue Value of VictorSPXControlMode
051         */
052        VictorSPXControlMode(int initValue)
053        {
054                this.value = initValue;
055        }
056
057        /**
058         * Helper method to convert to generic ControlMode enum.
059         * @return value cast as ControlMode
060         */
061        public ControlMode toControlMode(){
062                switch(value){
063                        case 0: return ControlMode.PercentOutput;
064                        case 1: return ControlMode.Position;
065                        case 2: return ControlMode.Velocity;
066                        case 5: return ControlMode.Follower;
067                        case 6: return ControlMode.MotionProfile;
068                        case 7: return ControlMode.MotionMagic;
069                        case 10: return ControlMode.MotionProfileArc;
070                        case 15: return ControlMode.Disabled;
071                        default: return ControlMode.PercentOutput;
072                }
073        }
074};