githubEdit

Prompter

package com.skeletonarmy.marrow.prompts

Overview

Prompter is a pre-match configuration tool that displays a sequence of interactive prompts as telemetry. This allows you to easily set parameters such as alliance color, starting position, and strategy using the gamepad - right before a match.

This eliminates the need for multiple OpModes with hardcoded settings, reducing clutter.

A GIF showing Prompter in action

Usage

Setup

To create a Prompter, simply instantiate it with the current OpMode instance:

Enqueuing Prompts

Prompts are added to the Prompter using prompt(String, Prompt<T>).

Each prompt is tied to a key so you can retrieve the result later:

Conditional Prompts

You can conditionally add prompts using a Supplier<Prompt<T>>. This lets you decide whether to show a prompt based on earlier choices.

You can retrieve the result using getOrDefault(string, T). If there is no selection for the prompt, it will return the provided default value.

Using Results

You can run a function after all prompts are complete using onComplete(Runnable). You should retrieve prompt values inside this function, since only then are they guaranteed to be set.

Running the Prompter

To start the Prompter, simply call run() in your loop function. This will run until all prompts are completed.

Controls

Use the following gamepad controls to navigate the prompt interface:

  • D-PAD: Navigate the prompt

  • A: Confirm the current selection

  • B: Go back to the previous prompt


Example Usage

What the Driver Sees

On init, the Prompter will display the following on the Driver Hub:

Prompts will appear one at a time in this format until all selections have been made.

Last updated