Class InitMenu

java.lang.Object
com.crossbotics.ftchelper.match.InitMenu

public class InitMenu extends Object
A menu for the INIT screen: choose alliance, start delay, route and more with the gamepad, before pressing START. The robot does not move in INIT, so this is safe.

 InitMenu menu = new InitMenu(gamepad1)
         .alliance()                       // X = blue, B = red
         .delay(10)                        // 0..10 s start delay
         .choice("Route", "Near", "Far")   // any list of options
         .profile();                       // practice / competition (saved)
 while (opModeInInit()) {
     menu.update();
     menu.addTelemetry(t);
     t.update();
 }
 Alliance a = menu.getAlliance();
 if (menu.get("Route").equals("Far")) { ... }
 

Controls: D-pad up/down = choose a line, D-pad left/right = change it. Shortcuts: X = blue, B = red.

Each "add" method returns this same menu, so you can chain them as in the example. update() never waits: it reads the buttons once and returns, so the INIT loop keeps running. Docs: docs/modules/match.md (section "InitMenu"). EasyAuto builds this menu for you (Tutorial 16).

  • Constructor Details

    • InitMenu

      public InitMenu(com.qualcomm.robotcore.hardware.Gamepad gamepad)
      Parameters:
      gamepad - the gamepad used to choose (usually gamepad1)
  • Method Details

    • alliance

      public InitMenu alliance()
      Adds the alliance choice (starts at the alliance remembered from earlier, else BLUE).
    • delay

      public InitMenu delay(double maxSeconds)
      Adds a start delay choice, 0 to maxSeconds, in 1-second steps.
    • choice

      public InitMenu choice(String label, String... options)
      Adds a choice from a list. The first option is the default. (String... options means you can pass as many text options as you like.)
    • yesNo

      public InitMenu yesNo(String label, boolean startYes)
      Adds a yes/no choice.
    • profile

      public InitMenu profile()
      Adds the practice/competition profile choice (saved on the hub when changed).
    • update

      public void update()
      Reads the gamepad. Call every loop during INIT.
    • addTelemetry

      public void addTelemetry(RobotTelemetry t)
      Shows the menu.
    • getAlliance

      public Alliance getAlliance()
      The chosen alliance (BLUE if there is no alliance line).
    • getDelaySec

      public double getDelaySec()
      The chosen start delay in seconds (0 if there is no delay line).
    • get

      public String get(String label)
      The chosen option of a choice line, e.g. get("Route").
    • isYes

      public boolean isYes(String label)
      True if a yes/no line is YES.