Skip to main content

# Use Tag Expressions

Note: Tag expressions are not supported in Samsung Gear Fit watches.

Use tag expressions in the Rotate, Placement, and Opacity properties to create a watch face that changes dynamically as the tag value changes.

You can enter a tag expression directly to Properties input fields that allow tag expression; these input fields have a triangular tag expression icon in the lower left corner . Type the tag expression formula into the input field, enclosed in square brackets [  ].

To open a larger input window to enter complex or long formulas, click the tag expression icon or double-click the input field. In the Script window, you can enter complex and lengthy tag expressions without truncation, and you can easily search for tags with the data value you want.

### Arithmetic operators

 + Addition - Subtraction * Multiplication / Quotient of division % Remainder of division

The following examples show how to use common arithmetic operations in tag expression:

• 5 * [ba] : Returns battery percentage multiplied by 5 (such as 0, 5, 10, 15...500)
• [s]%3 :  Returns the remainder of seconds in a minute divided by 3 (0, 1, 2, 0, 1, 2)

### Relational operators

 < Less than <= Less than or equal to > Greater than >= Greater than or equal to == Equal to != Not equal to

Relational operators determine the relative size between operands, comparing the operand on the left with the operand on the right to determine which is greater, less than, or equal to each other. Combined with arithmetic operators, relational operators can be used as follows:

Battery percentage

• 5 * ([ba] <= 15)
• If the battery percentage is less than 15%, this expression returns true (1). 5 times 1 equals 5. The resulting value is 5.
• If the battery percentage is more than 16, this expression returns false (0). 5 times 0 equals 0. The resulting value is 0.

Heart rate

• ([hr] <= 100)*1000 +120
• If the heart rate is less than 100 bpm, the expression returns true (1). 1 time 1000 plus 120 equals 1120. The resulting value is 1120.
• If the heart rate is more than 101 bpm, returns false (0). 0 time 1000 plus 120 equals 120. The resulting value is 120.

### Ternary operators

The ternary operator returns the A operand if the condition is true, or the B operand if the condition is false. For example:

Opacity

• [ba] <= 20? 15: 100
• If battery percentage is less than or equal to 20%, the expression is true, and the Opacity value is adjusted to 15.
• If battery percentage is greater than 20%, the expression is false, and the Opacity value is maintained at 100.

### Available tags

The following tags are available:

Data Tag ID Range
Hours in day [H] 0 - 23
Minutes in hour [m] 0 - 59
Seconds in minute [s] 0 - 59
Day of the month [d] 1 - 31
Month of the year [M] 1 - 12
Day of the week [e] 1 - 7
Day of year [D] 0.0 - 11.99

Data Tag ID  Range
Battery (%) [ba] 0 - 100
Battery charging status (0/1) [bc] 0 or 1
Battery level [bl] 0 - 4
Caffeine intake [ci] 0 - ∞
Calories burned (cal) [cal] 0 - ∞
Distance moved (Km/h) [md] 0 - ∞
Floor [fl] 0 - ∞
Heart rate (bpm) [hr] 0 - ∞
Speed (m/s) [sp] 0 - ∞
Step count [sc]

0 - ∞

Step goal [sg] 0 - ∞
Steps (%) [st] 0 - 100
Water intake  [wi] 0 - ∞

### Example: Pedometer

This example uses tag expression to create steps that use opacity and placement. Tag expression input is shown in 1, 2, and 3 in the following illustration, referring to objects a, b, and c. When a user's step percentage is 0%, object a is visible. When step percentage is 1% or more, object a disappears, and object b is visible. Object b then moves horizontally to the right by a percentage of the number of steps the user walked. When the user achieves 100% of steps walked, object b disappears, and object c is visible.

1. Object a appears when step percentage is 0%. The condition in parentheses( ) must be resolved first. The expression == returns true (1) or false (0), based on whether the value on the left [st] is equal to the value on the right.

• In step 1 in the above illustration,  step percentage [st] is equal to 0%, so it becomes true (1) and returns (1). Opacity = 100 * 1 and, finally, Opacity = 100.
• However, if the value of [st] is greater than 1%, this formula returns false (0). Because opacity = 100 * 0, opacity is 0%, so object a is invisible. As a result, when [st] is 0, the object a image appears.

The tag expression for Opacity is:  100 * ([st] == 0)

2. Object b shows 1% to 99% of steps. If [st] == 0, the object does not appear as Opacity = 0.

• When [st]> = 1 and [st] <= 99, object b is shown, and the X coordinate of object b changes according to step percentage [st].

• As step percentage [st] increases by 1%, the X value of object b increases by 1 px, causing object b to move slowly to the right. Finally, if [st] = 99%, the object appears at X + 99 px.

The tag expression for Opacity is: 100 * (([st] >= 1) * ([st] <= 99])
The tag expression for X is: 120px + ([st] <= 99) * [st]

3. Object c is visible only when step percentage is 100%, meaning the user reached the step target.

• We used > = (greater than or equal to) instead of == (equal to) to show a step target greater than 100%. In step 3 in the above illustration, the step percentage [st] is greater than or equal to 100, so it becomes true (1) and returns 1. Opacity = 100 * 1 and finally Opacity = 100.
• If the value of [st] is less than 99, this formula returns false (0), and because opacity = 100 * 0, the opacity becomes 0%, and object c is invisible.

The tag expression for Opacity is: 100 * ([st] >= 100)

### Example: Heart rate

This example describes how to create a complication with heartbeat animation that slows down or speeds up, depending on a user's heart rate.

1. In Properties > Placement, enter the heart rate [hr] tag on the X axis.
2. Create three heartbeat animations to show on the watch face:
• One in which the heart moves at slow speed when the heart rate is less than 50 bpm.

The tag expression for X is: 158px + ([hr] > 50) * 1000

• One in which the heart moves at medium speed when the heart rate is between 50 and 100 bpm.

The tag expression for X is: -22px + (([hr] <= 50) + ([hr] > 100)) * 1000 + 180

• One in which the heart moves at a high speed when the heart rate is 100 bpm or more.

The tag expression for X is: -22px + ([hr] <= 100) * 1000 + 180 • Was this article helpful?