Skip to main content

Configuration API

The Configuration API is used to expose persistent module settings to the ArmorLink App.

Configuration values are stored locally on the module, persist automatically across reboots and can be changed without restarting the module.

For the conceptual overview, see Configuration.

Basic Example

int volume = 20;

module.config()
.addInt("volume", &volume, 20)
.label("Volume")
.section("Audio")
.description("DFPlayer volume")
.range(0, 30)
.step(1)
.onIntChange([](int value)
{
dfplayer.volume(value);
});

This defines a persistent integer configuration value that:

  • Is named volume
  • Is displayed as Volume in the ArmorLink App
  • Is grouped in the Audio section
  • Accepts values from 0 to 30
  • Uses a step size of 1
  • Updates the DFPlayer volume immediately when changed

Accessing the Configuration API

Configuration fields are created through the module instance.

module.config()

For more information about modules, see ArmorLinkModule.

Supported Field Types

ArmorLink currently supports the following configuration field types:

MethodTypeEditableDescription
addInt(...)IntegerYesWhole number value
addFloat(...)FloatYesFloating-point value
addBool(...)BooleanYesTrue/false value
addReadonly(...)ReadonlyNoRead-only information field

addInt(...)

Creates an integer configuration value.

int volume = 20;

module.config()
.addInt("volume", &volume, 20);

The value is stored locally on the module and automatically exposed to the ArmorLink App.

addFloat(...)

Creates a floating-point configuration value.

float speed = 1.0f;

module.config()
.addFloat("speed", &speed, 1.0f);

Float values are useful for timings, speed factors, sensor thresholds and similar settings.

addBool(...)

Creates a boolean configuration value.

bool eyesEnabled = true;

module.config()
.addBool("eyesEnabled", &eyesEnabled, true);

Boolean values are useful for feature toggles and simple on/off settings.

addReadonly(...)

Creates a read-only information field.

module.config()
.addReadonly("firmware", "1.0.0")
.label("Firmware Version");

Readonly fields are displayed in the ArmorLink App but cannot be modified by the user.

Common uses include:

  • Firmware version
  • Hardware revision
  • Module information
  • Calibration status

label(...)

Sets the user-visible label in the ArmorLink App.

.label("Volume")

Use clear labels that describe what the value controls.

description(...)

Adds a longer description for the configuration field.

.description("Controls the DFPlayer output volume")

Descriptions help users understand what a setting does.

section(...)

Groups configuration fields into sections inside the ArmorLink App.

.section("Audio")

Sections are useful when a module exposes many configuration values.

Example sections:

  • Audio
  • Servos
  • LEDs
  • Timing
  • Sensors

unit(...)

Sets the display unit for a value.

.unit("ms")

Common units include:

  • V
  • %
  • ms
  • deg
  • C

The unit is used by the ArmorLink App when presenting the value.

range(...)

Defines the allowed value range.

.range(0, 30)

The ArmorLink App uses this information to present suitable controls and prevent invalid input.

step(...)

Defines the step size used when editing a value.

.step(1)

This is useful for sliders, steppers and numeric inputs inside the ArmorLink App.

advanced(...)

Marks a configuration field as advanced.

.advanced()

Advanced fields are intended for settings that most users do not need to modify regularly.

Change Callbacks

Configuration values can execute callbacks when they are changed through the ArmorLink App.

This allows modules to react immediately without requiring a reboot.

tip

Configuration changes are applied immediately.

When the ArmorLink App changes a value, the updated value is available on the module and the matching callback is executed automatically.

onIntChange(...)

Executes a callback when an integer value changes.

module.config()
.addInt("volume", &volume, 20)
.onIntChange([](int value)
{
dfplayer.volume(value);
});

onFloatChange(...)

Executes a callback when a float value changes.

module.config()
.addFloat("speed", &speed, 1.0f)
.onFloatChange([](float value)
{
animationSpeed = value;
});

onBoolChange(...)

Executes a callback when a boolean value changes.

module.config()
.addBool("eyesEnabled", &eyesEnabled, true)
.onBoolChange([](bool value)
{
setEyesEnabled(value);
});

Persistence

Configuration values are always persistent.

No additional persistence configuration is required.

Values are stored locally on the module and restored automatically after reboot.

Configuration and the Gateway

The Gateway does not store configuration data for other modules.

Configuration belongs to the module that owns it.

When the ArmorLink App reads or updates a configuration value, the Gateway only forwards the request to the target module.

For more information, see Gateway.

Complete Example

int volume = 20;
float servoSpeed = 1.0f;
bool eyesEnabled = true;

void setupConfig()
{
module.config()
.addInt("volume", &volume, 20)
.label("Volume")
.section("Audio")
.range(0, 30)
.step(1)
.onIntChange([](int value)
{
dfplayer.volume(value);
});

module.config()
.addFloat("servoSpeed", &servoSpeed, 1.0f)
.label("Servo Speed")
.section("Servos")
.range(0.1f, 2.0f)
.step(0.1f);

module.config()
.addBool("eyesEnabled", &eyesEnabled, true)
.label("Eyes Enabled")
.section("LEDs")
.onBoolChange([](bool value)
{
setEyesEnabled(value);
});

module.config()
.addReadonly("firmware", "1.0.0")
.label("Firmware Version")
.section("System");
}

Summary

The Configuration API exposes persistent module settings to the ArmorLink App.

Common methods include:

  • addInt(...)
  • addFloat(...)
  • addBool(...)
  • addReadonly(...)
  • label(...)
  • description(...)
  • section(...)
  • unit(...)
  • range(...)
  • step(...)
  • advanced(...)
  • onIntChange(...)
  • onFloatChange(...)
  • onBoolChange(...)

Configuration values are stored locally, persist automatically and are available immediately when changed.