Class RevUtil

java.lang.Object
org.team1126.lib.util.vendors.RevUtil

public final class RevUtil extends Object
Utilities for REVLib.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    config(com.revrobotics.spark.SparkFlex spark, com.revrobotics.spark.config.SparkBaseConfig config)
    Shorthand for configuring a Spark motor controller with error checking.
    static boolean
    config(com.revrobotics.spark.SparkMax spark, com.revrobotics.spark.config.SparkBaseConfig config)
    Shorthand for configuring a Spark motor controller with error checking.
    static boolean
    configEphemeral(com.revrobotics.spark.SparkFlex spark, com.revrobotics.spark.config.SparkBaseConfig config)
    Shorthand for configuring a Spark motor controller ephemerally with error checking.
    static boolean
    configEphemeral(com.revrobotics.spark.SparkMax spark, com.revrobotics.spark.config.SparkBaseConfig config)
    Shorthand for configuring a Spark motor controller ephemerally with error checking.
    static boolean
    configNoReset(com.revrobotics.spark.SparkFlex spark, com.revrobotics.spark.config.SparkBaseConfig config)
    Shorthand for configuring a Spark motor controller with error checking.
    static boolean
    configNoReset(com.revrobotics.spark.SparkMax spark, com.revrobotics.spark.config.SparkBaseConfig config)
    Shorthand for configuring a Spark motor controller with error checking.
    static boolean
    run(String name, com.revrobotics.spark.SparkLowLevel device, Supplier<com.revrobotics.REVLibError> target)
    Runs a REVLib API call and checks for errors.
    static boolean
    run(String name, com.revrobotics.spark.SparkLowLevel device, Supplier<com.revrobotics.REVLibError> target, int maxTries)
    Runs a REVLib API call and checks for errors.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • config

      public static boolean config(com.revrobotics.spark.SparkMax spark, com.revrobotics.spark.config.SparkBaseConfig config)
      Shorthand for configuring a Spark motor controller with error checking. Uses ResetMode.kResetSafeParameters and PersistMode.kPersistParameters.
      Parameters:
      spark - The Spark to configure.
      config - The configuration to apply.
      Returns:
      true if success (REVLibError.kOk), false otherwise.
    • config

      public static boolean config(com.revrobotics.spark.SparkFlex spark, com.revrobotics.spark.config.SparkBaseConfig config)
      Shorthand for configuring a Spark motor controller with error checking. Uses ResetMode.kResetSafeParameters and PersistMode.kPersistParameters.
      Parameters:
      spark - The Spark to configure.
      config - The configuration to apply.
      Returns:
      true if success (REVLibError.kOk), false otherwise.
    • configNoReset

      public static boolean configNoReset(com.revrobotics.spark.SparkMax spark, com.revrobotics.spark.config.SparkBaseConfig config)
      Shorthand for configuring a Spark motor controller with error checking. Uses ResetMode.kNoResetSafeParameters and PersistMode.kPersistParameters.
      Parameters:
      spark - The Spark to configure.
      config - The configuration to apply.
      Returns:
      true if success (REVLibError.kOk), false otherwise.
    • configNoReset

      public static boolean configNoReset(com.revrobotics.spark.SparkFlex spark, com.revrobotics.spark.config.SparkBaseConfig config)
      Shorthand for configuring a Spark motor controller with error checking. Uses ResetMode.kNoResetSafeParameters and PersistMode.kPersistParameters.
      Parameters:
      spark - The Spark to configure.
      config - The configuration to apply.
      Returns:
      true if success (REVLibError.kOk), false otherwise.
    • configEphemeral

      public static boolean configEphemeral(com.revrobotics.spark.SparkMax spark, com.revrobotics.spark.config.SparkBaseConfig config)
      Shorthand for configuring a Spark motor controller ephemerally with error checking. Uses ResetMode.kNoResetSafeParameters and PersistMode.kNoPersistParameters.
      Parameters:
      spark - The Spark to configure.
      config - The configuration to apply.
      Returns:
      true if success (REVLibError.kOk), false otherwise.
    • configEphemeral

      public static boolean configEphemeral(com.revrobotics.spark.SparkFlex spark, com.revrobotics.spark.config.SparkBaseConfig config)
      Shorthand for configuring a Spark motor controller ephemerally with error checking. Uses ResetMode.kNoResetSafeParameters and PersistMode.kNoPersistParameters.
      Parameters:
      spark - The Spark to configure.
      config - The configuration to apply.
      Returns:
      true if success (REVLibError.kOk), false otherwise.
    • run

      public static boolean run(String name, com.revrobotics.spark.SparkLowLevel device, Supplier<com.revrobotics.REVLibError> target)
      Runs a REVLib API call and checks for errors. Will try up to 3 times if the target API call fails.
      Parameters:
      name - The name of the API call.
      device - The device the call is relevant to.
      target - The target call to run.
      Returns:
      true if success (REVLibError.kOk), false otherwise.
    • run

      public static boolean run(String name, com.revrobotics.spark.SparkLowLevel device, Supplier<com.revrobotics.REVLibError> target, int maxTries)
      Runs a REVLib API call and checks for errors.
      Parameters:
      name - The name of the API call.
      device - The device the call is relevant to.
      target - The target call to run.
      maxTries - The number of times to try the call before failing. 1 only runs the call once.
      Returns:
      true if success (REVLibError.kOk), false otherwise.