Enum Class Profile

java.lang.Object
java.lang.Enum<Profile>
com.crossbotics.ftchelper.core.Profile
All Implemented Interfaces:
Serializable, Comparable<Profile>, Constable

public enum Profile extends Enum<Profile>
Practice or competition. Lets the same code behave safely at an event and helpfully in the shop.
PRACTICECOMPETITION
debug telemetryonoff
tuning menuallowedblocked
your own valuesProfile.pick(practiceValue, competitionValue)

The choice is saved on the Control Hub, so it stays until someone changes it (with InitMenu.profile() or set(com.crossbotics.ftchelper.core.Profile)). The default is COMPETITION, the safe one.


 double drivePower = Profile.pick(0.5, 1.0);     // gentle in the shop, full power at events
 if (Profile.current().isPractice()) { ... }
 

Java note: an "enum" is a fixed list of named choices. A Profile can only ever be PRACTICE or COMPETITION, so a typo cannot create a third, unknown profile. Docs: docs/guides/profiles.md

  • Enum Constant Details

    • PRACTICE

      public static final Profile PRACTICE
      In the shop: debug telemetry on, tuning menu allowed.
    • COMPETITION

      public static final Profile COMPETITION
      At an event: debug telemetry off, tuning menu blocked. The safe default.
  • Method Details

    • values

      public static Profile[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Profile valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • current

      public static Profile current()
      The active profile (read from the saved setting the first time).
    • set

      public static void set(Profile profile)
      Changes the profile and saves it on the Control Hub.
      Parameters:
      profile - the new profile
    • resetForTests

      public static void resetForTests()
      For tests: forget the loaded value so it is read again.
    • pick

      public static <T> T pick(T practice, T competition)
      One value for practice, another for competition.

      <T> is a "type placeholder" (a generic): it works for any kind of value (text, objects...), and you get back the same kind you gave.

      Parameters:
      practice - the value to use in PRACTICE
      competition - the value to use in COMPETITION
      Returns:
      practice in the PRACTICE profile, else competition
    • pick

      public static double pick(double practice, double competition)
      Same as pick(Object, Object) for numbers (no boxing). ("Boxing" is Java wrapping a plain number in an object; this version skips that.)
    • pick

      public static boolean pick(boolean practice, boolean competition)
      Same as pick(Object, Object) for true/false.
    • isPractice

      public boolean isPractice()
      True for PRACTICE.