Skip to content

AccelerometerTextIndicator JSON

roosit edited this page Nov 15, 2026 · 1 revision

AccelerometerTextIndicator JSON

Up | Code | Русский

Purpose

This page describes the persisted format of the accelerometerText indicator in a project, in a Mixel and in templates. For the user instruction on manual editing of .vttp see the page Accelerometer Text JSON.

Two save modes

  • toJSON(false) is the real state of a Mixel: it contains the selected source and sensor, the current property values, and the size and position of the layer.
  • toJSON(true) is the template state: it contains values that can be carried between projects. The sensor property (Accelerometer) is saved in a template as an empty object {}: the source and the sensor are picked when the indicator is added to a project.

Common indicator wrapper

The layer identifier is built from the plugin uid and the indicator name:

{
  "name": "com.velitask.plagin.official.accelerometerText",
  "data": {
    "properties": {}
  }
}
Part Value
plugin uid com.velitask.plagin.official
indicator name accelerometerText

Real mixel state

In a real Mixel the size and position of the layer are stored next to properties. The exact form of these State fields depends on the current runtime, so they are shown in abbreviated form. The values sourceId.value and sensorId.value are numeric identifiers of the project source and sensor, given below as an example.

{
  "name": "com.velitask.plagin.official.accelerometerText",
  "data": {
    "size": { "...": "layer size state" },
    "positionInParent": { "...": "layer position state" },
    "properties": {
      "Accelerometer": {"sourceId":{"value":1},"sensorId":{"value":3}},
      "font": {"name":"Dialog","style":0,"size":48,"color":{"r":255,"g":255,"b":255,"a":255}},
      "textAlign": {"value":4},
      "measurement": {"system":{"value":0},"format":{"value":0},"acceleration":{"value":0}},
      "textTemplate": {"template":"{total} {unit}","vars":{"total":"%.2f","x":"%.2f","y":"%.2f","z":"%.2f","unit":"%s"}}
    }
  }
}

Template state

In a template, maket (here auto) is stored instead of the size and position, and the sensor property is empty. The property values match the default values in the code.

{
  "name": "com.velitask.plagin.official.accelerometerText",
  "data": {
    "maket": { "preset": "auto" },
    "properties": {
      "Accelerometer": {},
      "font": {"name":"Dialog","style":0,"size":48,"color":{"r":255,"g":255,"b":255,"a":255}},
      "textAlign": {"value":4},
      "measurement": {"system":{"value":0},"format":{"value":0},"acceleration":{"value":0}},
      "textTemplate": {"template":"{total} {unit}","vars":{"total":"%.2f","x":"%.2f","y":"%.2f","z":"%.2f","unit":"%s"}}
    }
  }
}

Properties

JSON key Java property SDK type Meaning for the user Default
Accelerometer mAccelerometer AccelerometerAtomProperty The selected sensor: accelerometer. An empty object in a template; sourceId/sensorId in a project.
font mText FontColorProperty Font and text color. name = Dialog, style = 0, size = 48, white color 255,255,255,255.
textAlign mTextAlign TextAlignProperty Position of the text inside the layer. 4 (CENTER).
measurement mUnits MeasurementProperty Measurement system, label format and acceleration unit. system 0, format 0, acceleration 0 (g).
textTemplate mTemplate TextTemplateProperty String template with variables. {total} {unit}.

Formats of the nested values:

  • font is a flat object: name (string), style (number: 0 plain, 1 bold, 2 italic), size (integer, 1..999) and color (r, g, b, a, each 0..255).
  • textAlign is {"value": N}, N from 0 to 8 (order TOP_LEFT, TOP_CENTER, TOP_RIGHT, CENTER_LEFT, CENTER, CENTER_RIGHT, BOTTOM_LEFT, BOTTOM_CENTER, BOTTOM_RIGHT). A value out of range is treated as CENTER_LEFT.
  • measurement is a composite property without a unit key. The child keys in order: system, format, acceleration.
Key Type Values
system {"value": int} 0 from global settings, 1 metric, 2 imperial, 3 nautical, 4 mixed
format {"value": int} 0 full, 1 normal, 2 short, 3 symbol
acceleration {"value": int} ordinal of AccelerationSystem: 0 is G (g), 1 is MPS2 (m/s²)

While system is 0, acceleration is not used: the unit is taken from the application's global settings. Selecting system from 1 to 3 substitutes the default unit (G); if the saved unit differs from it, the system automatically switches to "mixed" (4).

The initial state of format is index 0 (full format), although getDefault() of the property returns "normal" (NORMAL); SpeedTextIndicator is built the same way.

  • textTemplate is {"template": string, "vars": {name: format}}; the vars keys are variable names without braces.

Template variables (order of the makeText(...) arguments: total, x, y, z, unit):

Variable Default format What it shows
{total} %.2f Magnitude of the acceleration vector in the selected unit.
{x} %.2f Acceleration along the X axis in the selected unit.
{y} %.2f Acceleration along the Y axis in the selected unit.
{z} %.2f Acceleration along the Z axis in the selected unit.
{unit} %s Acceleration unit label (g or m/s²) in the selected format.

Examples

Compact template, bold red text pressed to the right and bottom:

{
  "name": "com.velitask.plagin.official.accelerometerText",
  "data": {
    "maket": { "preset": "auto" },
    "properties": {
      "Accelerometer": {},
      "font": {"name":"Dialog","style":1,"size":64,"color":{"r":255,"g":80,"b":80,"a":255}},
      "textAlign": {"value":8},
      "measurement": {"system":{"value":0},"format":{"value":0},"acceleration":{"value":0}},
      "textTemplate": {"template":"{total}","vars":{"total":"%.2f","x":"%.2f","y":"%.2f","z":"%.2f","unit":"%s"}}
    }
  }
}

Compatibility

  • VelitaskPlagin.getUID() (com.velitask.plagin.official) must not be changed without a migration of saved projects.
  • Indicator.getName() (accelerometerText) must not be changed without a migration.
  • The names of the properties (Accelerometer, font, textAlign, measurement, textTemplate) must not be renamed without a migration: loading goes by names.
  • The names of the template variables (total, x, y, z, unit) are part of the vars format; renaming breaks the saved formats.
  • The order of properties mostly affects the UI; renaming is more dangerous than reordering.

Clone this wiki locally