> 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/html-telemetry.md).

# HTML Telemetry

package com.skeletonarmy.marrow\.telemetry

## Overview

`MarrowTelemetry` is an implementation of the `Telemetry` interface which enables developers to easily format and style text using a subset of HTML.

Formatting can be done using pre-made or custom `TelemetryModifier`s, and is fully compatible with FTC Dashboard's `MultipleTelemery` (or others like it)

{% hint style="warning" %}
HTML formatting is only known to work on the Driver Station's telemetry. Other `Telemetry` implementations, like FTC Dashboard's, aren't known to support it and might display the raw HTML tags instead.
{% endhint %}

***

## Usage

### Setup

To use `MarrowTelemetry` simply redefine the OpMode telemetry with `MarrowTelemetry` and pass it the current `telemetry` object.

```java
telemetry = new MarrowTelemetry(telemetry);
```

### Printing Data

To add data to your Telemetry simply call the `addData` method, it will format and print the text to your Telemetry.

&#x20;For example the following line will print the runtime in bold:

```java
telemetry.addData("Runtime", String.valueOf(getRuntime()), new BoldModifier());
```

<figure><img src="https://4096955457-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fgfjbmar2vXl8Hq4p5TUG%2Fuploads%2FNPguYYyxFxhKRYOmAbqo%2Fbold_runtime.gif?alt=media&amp;token=a5cd616a-79ec-4f01-9fea-9a584d782e33" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
The second parameter **must** be a `String`. Passing an object directly won't compile.

```java
// ❌ Won't compile - expects a String
telemetry.addData("Battery", voltage, modifiers...);

// ✅ Compiles - works as intended
telemetry.addData("Battery", String.valueOf(voltage), modifiers...);
```

Most IDEs will flag this and offer to wrap the value in `String.valueOf(...)` .&#x20;
{% endhint %}

Passing an empty string or `null` caption adds the second parameter as a standalone telemetry line instead of a caption/value pair. This is handy for formatted text that shouldn't be tied to a caption.

So this line

```java
telemetry.addData(null, "── Status ──", new BoldModifier());
```

Is the same as

```java
telemetry.addLine("<b>── Status ──</b>");
```

{% hint style="info" %}
This is only the most basic usage, for more details see [MarrowTelemetry](/dev-tools/html-telemetry/marrowtelemetry.md)
{% endhint %}

### Builder

A formatted string can also be created using the `FormatBuilder` , then be stored as a string or directly sent to telemetry. Useful when when you need to chain more then 1 or 2 modifiers.

The builder can be created like this:&#x20;

```java
FormatBuilder builder = new FormatBuilder("── Ready ──")
                .italic()
                .setColor(HtmlColor.LIME_GREEN);
```

Then printed like this:

```java
telemetry.addLine(builder.format());
```

So the driver can see this:

<figure><img src="https://4096955457-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fgfjbmar2vXl8Hq4p5TUG%2Fuploads%2FPEkObZdVceTj19c057iM%2Fready.gif?alt=media&amp;token=1e39f836-9a82-4491-87d0-3b9152fc9052" alt=""><figcaption></figcaption></figure>

Instead of formatting a string then printing it, you can directly print the formatted string to a telemetry channel.

You can directly print data:

```java
new FormatBuilder("── Ready ──")
         .italic()
         .setColor(HtmlColor.LIME_GREEN)
         .printData(telemetry, "Status");
```

Or print a regular line:

```java
new FormatBuilder("── Ready ──")
         .italic()
         .setColor(HtmlColor.LIME_GREEN)
         .printLine(telemetry);
```

{% hint style="info" %}
For more details see [FormatBuilder](/dev-tools/html-telemetry/formatbuilder.md)
{% endhint %}

## Example Usage

```java
telemetry.addData(null, "-- Shooting --", new BoldModifier());
new FormatBuilder(isInsideLaunchZone())
        .addConditional(this::isInsideLaunchZone, new ColorModifier(HtmlColor.LIME_GREEN), new ColorModifier(HtmlColor.RED))
        .italic()
        .printData(telemetry, "Is inside LaunchZone");
        
new FormatBuilder(canShoot())
          .addConditional(this::canShoot, new ColorModifier(HtmlColor.LIME_GREEN), new ColorModifier(HtmlColor.RED))
          .italic()
          .printData(telemetry, "Can Shoot");

telemetry.addData(null, "-- Misc --", new BoldModifier());
telemetry.addData("Loop Time ms", String.valueOf(loopTimeMs), new ItalicModifier());

telemetry.update();
```

### What the Driver Sees

<figure><img src="https://4096955457-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fgfjbmar2vXl8Hq4p5TUG%2Fuploads%2F2WnH28nCjgy0g6iKzu5x%2Fmany.gif?alt=media&amp;token=d20a6ac1-f115-4e1b-a0e0-f042df6212a4" alt=""><figcaption></figcaption></figure>


---

# 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 dynamically 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/html-telemetry.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 `build a script that syncs our docs to a CMS` 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.
