001/* Copyright (C) Cross The Road Electronics 2024 */ 002package com.ctre.phoenix.motorcontrol; 003 004/** 005 * Choose the control mode for a TalonFX / Falcon 500. 006 * 007 * @deprecated This device's Phoenix 5 API is deprecated for removal in the 008 * 2025 season. Users should update to Phoenix 6 firmware and migrate to the 009 * Phoenix 6 API. A migration guide is available at 010 * https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html. 011 * <p> 012 * If the Phoenix 5 API must be used for this device, the device must have 22.X 013 * firmware. This firmware is available in Tuner X after selecting Phoenix 5 in 014 * the firmware year dropdown. 015 */ 016@Deprecated(since = "2024", forRemoval = true) 017public enum TalonFXControlMode 018{ 019 /** 020 * Percent output [-1,1] 021 */ 022 PercentOutput(0), 023 /** 024 * Position closed loop 025 */ 026 Position(1), 027 /** 028 * Velocity closed loop 029 */ 030 Velocity(2), 031 /** 032 * Input current closed loop 033 */ 034 Current(3), 035 /** 036 * Follow other motor controller 037 */ 038 Follower(5), 039 /** 040 * Motion Profile 041 */ 042 MotionProfile(6), 043 /** 044 * Motion Magic 045 */ 046 MotionMagic(7), 047 /** 048 * Motion Profile with auxiliary output 049 */ 050 MotionProfileArc(10), 051 /** 052 * Plays a single tone. Frequency (hz) is passed into set. 053 */ 054 MusicTone(13), 055 056 /** 057 * Disable Motor Controller 058 */ 059 Disabled(15); 060 061 /** 062 * Value of control mode 063 */ 064 public final int value; 065 066 /** 067 * Create TalonFXControlMode of initValue 068 * @param initValue Value of TalonFXControlMode 069 */ 070 TalonFXControlMode(int initValue) 071 { 072 this.value = initValue; 073 } 074 075 /** 076 * Helper method to convert to generic ControlMode enum. 077 * @return value cast as ControlMode 078 */ 079 public ControlMode toControlMode(){ 080 switch(value){ 081 case 0: return ControlMode.PercentOutput; 082 case 1: return ControlMode.Position; 083 case 2: return ControlMode.Velocity; 084 case 3: return ControlMode.Current; 085 case 5: return ControlMode.Follower; 086 case 6: return ControlMode.MotionProfile; 087 case 7: return ControlMode.MotionMagic; 088 case 10: return ControlMode.MotionProfileArc; 089 case 13: return ControlMode.MusicTone; 090 case 15: return ControlMode.Disabled; 091 default: return ControlMode.PercentOutput; 092 } 093 } 094};