Class Lights.Rule

java.lang.Object
com.crossbotics.ftchelper.robot.Lights.Rule
Enclosing class:
Lights

public final class Lights.Rule extends Object
One rule, started with Lights.show(LightColor). Add blinking() or forSeconds(...) if you like, then finish it with when, whenStarts, whenCountGoesUp or inLastSeconds.
  • Method Details

    • blinking

      public Lights.Rule blinking()
      Blinks on and off, 2 times a second.
    • blinking

      public Lights.Rule blinking(double timesPerSecond)
      Blinks on and off this many times a second.
      Parameters:
      timesPerSecond - more than 0 (e.g. 1 = once a second, 0.5 = every 2 s), at most 5 (FTC R202 J: faster blinking can be stopped by the referees)
    • forSeconds

      public Lights.Rule forSeconds(double seconds)
      Parameters:
      seconds - more than 0
    • when

      public Lights when(BooleanSupplier condition)
      Shows the color while this is true (checked every loop, in the order the rules were written).
      Parameters:
      condition - e.g. robot.intake::isRunning or () -> robot.lift.position() > 1000
      Returns:
      the light, for the next rule
    • whenStarts

      public Lights whenStarts(BooleanSupplier condition)
      Flashes the color (0.5 s, or forSeconds(double)) each time this turns from false to true: a piece picked up, the launcher starting to shoot. Something already true at the start does not flash. For one flash per piece fired use whenCountGoesUp(java.util.function.IntSupplier) with the launcher's shot count.
      Parameters:
      condition - e.g. robot.intake::isRunning
      Returns:
      the light, for the next rule
    • whenCountGoesUp

      public Lights whenCountGoesUp(IntSupplier count)
      Flashes the color (0.5 s, or forSeconds(double)) each time this number goes up: one flash per piece really fired, even when fire(3) fires three in a row (whenStarts(java.util.function.BooleanSupplier) with isShooting flashes once for all three). The number it has at the start does not flash.
      Parameters:
      count - e.g. () -> robot.launcher.part().getShotsFired() (pieces fed into the wheel)
      Returns:
      the light, for the next rule
    • inLastSeconds

      public Lights inLastSeconds(double seconds)
      Shows the color in the last seconds of TeleOp's 2:00, counted from START (like MatchTimer: a reminder, about a second off from the field clock).
      Parameters:
      seconds - e.g. 20 for "the last 20 seconds"
      Returns:
      the light, for the next rule