Skip to main content

LedModule API Reference

The LedModule class provides comprehensive LED control functionality for MentraOS Apps, including RGB LED control and pattern methods. It automatically handles request tracking and provides fire-and-forget LED control with immediate resolution.

Import

Class: LedModule

The LedModule is automatically instantiated by the AppSession. You should not create instances directly.

Low-level LED Control Methods

turnOn

Turn on an LED with specified timing parameters.
Parameters:
  • options: LED control configuration
Returns: Promise that resolves immediately after sending the command (fire-and-forget) Example:

turnOff

Turn off all LEDs on the connected glasses.
Returns: Promise that resolves immediately after sending the command Example:

Pattern Methods

Blink an LED with specified timing.
Parameters:
  • color: LED color to use
  • ontime: How long LED stays on (ms)
  • offtime: How long LED stays off (ms)
  • count: Number of blink cycles
Returns: Promise that resolves immediately after sending the command Example:

solid

LED stays on continuously for specified duration.
Parameters:
  • color: LED color to use
  • duration: How long LED stays on (ms)
Returns: Promise that resolves immediately after sending the command Example:

Capability Methods

getCapabilities

Get available LED capabilities for the current device.
Returns: Array of available LED configurations Example:

Interfaces

LedControlOptions

Options for LED control.

LedColor

Available LED colors.

Device Compatibility

Different smart glasses models have different LED capabilities:

Best Practices

1. Always Check Device Capabilities

2. Use Semantic Colors

3. Handle Errors Gracefully

4. Provide Graceful Fallbacks

5. Don’t Overuse LEDs

6. Combine with Other Feedback Methods

Common Use Cases

Notification System

Recording Indicator