Class TunableFloat

java.lang.Object
org.wpilib.tunable.TunableBase
org.wpilib.tunable.TunableFloat
All Implemented Interfaces:
FloatConsumer, FloatSupplier

public abstract class TunableFloat extends TunableBase implements FloatSupplier, FloatConsumer
A tunable float.
  • Constructor Details

    • TunableFloat

      protected TunableFloat(TunableConfig config)
      Constructs a tunable float.
      Parameters:
      config - tunable config
    • TunableFloat

      protected TunableFloat(TunableConfig config, boolean supportsChangeNotification)
      Constructs a tunable float.
      Parameters:
      config - tunable config
      supportsChangeNotification - whether the tunable notifies backends when it changes
  • Method Details

    • create

      public static TunableFloat create()
      Creates a tunable float with the initial value of 0.0.
      Returns:
      a tunable float
    • create

      public static TunableFloat create(float initialValue)
      Creates a tunable float with the given initial value.
      Parameters:
      initialValue - initial value
      Returns:
      a tunable float
    • create

      public static TunableFloat create(FloatSupplier getter, FloatConsumer setter)
      Creates a tunable float with the given getter and setter.

      The getter and setter must not throw.

      Parameters:
      getter - getter for the tunable value
      setter - setter for the tunable value
      Returns:
      a tunable float
    • createConfig

      public static TunableFloat createConfig(TunableConfig config)
      Creates a tunable float with the given config and an initial value of 0.0.
      Parameters:
      config - tunable config
      Returns:
      a tunable float
    • createConfig

      public static TunableFloat createConfig(float initialValue, TunableConfig config)
      Creates a tunable float with the given initial value and config.
      Parameters:
      initialValue - initial value
      config - tunable config
      Returns:
      a tunable float
    • createConfig

      public static TunableFloat createConfig(FloatSupplier getter, FloatConsumer setter, TunableConfig config)
      Creates a tunable float with the given getter, setter, and config.

      The getter and setter must not throw.

      Parameters:
      getter - getter for the tunable value
      setter - setter for the tunable value
      config - tunable config
      Returns:
      a tunable float
    • set

      public abstract void set(float value)
      Sets the value.

      Implementations must not throw.

      Parameters:
      value - value
    • get

      public abstract float get()
      Gets the value.

      Implementations must not throw.

      Returns:
      value
    • getAsFloat

      public float getAsFloat()
      Description copied from interface: FloatSupplier
      Gets a result.
      Specified by:
      getAsFloat in interface FloatSupplier
      Returns:
      a result
    • accept

      public void accept(float value)
      Description copied from interface: FloatConsumer
      Performs this operation on the given argument.
      Specified by:
      accept in interface FloatConsumer
      Parameters:
      value - the input argument