Class SparkUtils

java.lang.Object
com.revrobotics.spark.SparkUtils

public class SparkUtils extends Object
A static class to allow for for direct JNI SparkMax and SparkFlex interactions.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    getInverted(com.revrobotics.spark.SparkFlex spark)
    Returns whether the SparkFlex is inverted or not.
    static boolean
    getInverted(com.revrobotics.spark.SparkMax spark)
    Returns whether the SparkMax is inverted or not.
    static boolean
    retryUntilOk(Supplier<com.revrobotics.REVLibError> applierFunction, int numMaxTries, String desc)
    Tries to apply the given function until a valid Ok status code is reached, or until the maximum number of tries is exceeded.
    static com.revrobotics.REVLibError
    setInverted(com.revrobotics.spark.SparkFlex spark, boolean inverted)
    Sets whether the SparkFlex is inverted or not.
    static com.revrobotics.REVLibError
    setInverted(com.revrobotics.spark.SparkMax spark, boolean inverted)
    Sets whether the SparkMax is inverted or not.

    Methods inherited from class java.lang.Object

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

    • setInverted

      public static com.revrobotics.REVLibError setInverted(com.revrobotics.spark.SparkMax spark, boolean inverted)
      Sets whether the SparkMax is inverted or not.
      Parameters:
      spark - The SparkMax.
      inverted - True if inverted.
      Returns:
      The REVLibError code.
    • setInverted

      public static com.revrobotics.REVLibError setInverted(com.revrobotics.spark.SparkFlex spark, boolean inverted)
      Sets whether the SparkFlex is inverted or not.
      Parameters:
      spark - The SparkFlex to use.
      inverted - True if inverted.
      Returns:
      The REVLibError code.
    • getInverted

      public static boolean getInverted(com.revrobotics.spark.SparkMax spark)
      Returns whether the SparkMax is inverted or not.
      Parameters:
      spark - The SparkMax.
      Returns:
      True if inverted.
    • getInverted

      public static boolean getInverted(com.revrobotics.spark.SparkFlex spark)
      Returns whether the SparkFlex is inverted or not.
      Parameters:
      spark - The SparkFlex.
      Returns:
      True if inverted.
    • retryUntilOk

      public static boolean retryUntilOk(Supplier<com.revrobotics.REVLibError> applierFunction, int numMaxTries, String desc)
      Tries to apply the given function until a valid Ok status code is reached, or until the maximum number of tries is exceeded. The logged values can be checked from the REVLibError enum.
      Parameters:
      applierFunction - The function interacts with hardware and returns the status code.
      numMaxTries - The maximmum number of tries before canceling.
      desc - The description of the hardware interaction. For example: "Applying the configuration to elevator motor #1"
      Returns:
      True if an Ok status code was reached within the given attempts, false otherwise.