> For the complete documentation index, see [llms.txt](https://marrow.skeletonarmyftc.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://marrow.skeletonarmyftc.com/dev-tools/settings.md).

# Settings

package com.skeletonarmy.marrow\.settings

## Overview

`Settings` provide a simple way to store, change, and persist configuration values on the robot - even after the robot gets restarted. This is useful for things like enabling a debug mode, adjusting teleop or autonomous behavior, or saving preferences across sessions.

You can configure these options inside a [`SettingsOpMode`](#defining-settings), which lets you edit values directly from the Driver Hub - no code changes or redeploys required.

<figure><img src="https://4096955457-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fgfjbmar2vXl8Hq4p5TUG%2Fuploads%2FECsUfEwxRWe1ZNdrCf1I%2FMy%20Video1.gif?alt=media&amp;token=170b0f48-6b22-43b0-b344-6c020f0629d5" alt="A GIF showing Settings in action" width="563"><figcaption></figcaption></figure>

{% hint style="warning" %}
We strongly recommend disabling any settings that could interfere with TeleOp before starting autonomous to avoid issues in a match (for example, a debugging mode).
{% endhint %}

***

## Usage

### Defining Settings

To define settings, extend `SettingsOpMode` and implement `defineSettings()`:

```java
@TeleOp
public class MySettings extends SettingsOpMode {
    @Override
    public void defineSettings() {
        add("debug_mode", "Debug Mode", new BooleanPrompt("Enable debug mode?", false));
        add("tabletop_mode", "Tabletop Mode", new BooleanPrompt("Enable tabletop mode (disables movement)?", false));
        add("alliance", "Select Alliance", new OptionPrompt<>("Select alliance", Alliance.RED, Alliance.BLUE));
    }
}
```

Each setting requires:

1. **Key** - a unique, case-insensitive identifier.
2. **Display Name** - shown in the menu on the driver station.
3. **Prompt** - an instance of a [`Prompt<T>`](https://marrow.skeletonarmyftc.com/dev-tools/prompter.md) which determines how the value is entered.

### Interacting With Settings

When the OpMode runs:

* Navigate options using the <kbd>D-PAD</kbd>.
* Press <kbd>A</kbd> to modify a setting.
* Press <kbd>B</kbd> to exit a prompt without saving changes.

Settings are automatically saved to a JSON file on the Control Hub (`FIRST/marrow/settings.json`).

### Accessing Settings in Code

Use the `Settings` API to read or write settings programmatically:

```java
boolean debugMode = Settings.get("debug_mode", false); // default is false

Settings.set("alliance", Alliance.BLUE);
```

* `get(key, defaultValue)` retrieves a value, returning the default if missing.
* `set(key, value, (optional) save)` - Stores a value under the given key. If `save` is `true` (default), the settings are immediately written to file.

{% hint style="info" %}
You can use `Settings` even without any `SettingsOpMode`. It can serve simply as a central hub for saving variables between OpModes and restarts.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://marrow.skeletonarmyftc.com/dev-tools/settings.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
