Built-in Functions
Pebble provides a small set of built-in functions for common operations.
Output
print text- Display a string. Use string interpolation to include variables.
print "Hello, world!"
print "Score: {score}"
Trigonometric Functions
All trigonometric functions work with float values and return float:
sin(angle: float) -> float
Sine of angle
cos(angle: float) -> float
Cosine of angle
asin(value: float) -> float
Arc sine (inverse sine)
acos(value: float) -> float
Arc cosine (inverse cosine)
atan2(y: float, x:float) -> float
Arc tangent of y/x, returns angle
Math (float)
abs(value: float) -> float
Absolute value
floor(value: float) -> int
Round down to nearest integer
round(value: float) -> int
Round to nearest integer
min(a: float, b: float) -> float
Minimum of two floats
max(a: float, b: float) -> float
Maximum of two floats
sgn(value: float) -> float
Sign of value (-1, 0, or 1)
Math (int)
iabs(value: int) -> int
Absolute value of integer
imin(a: int, b: int) -> int
Minimum of two integers
imax(a: int, b: int) -> int
Maximum of two integers
isgn(value: int) -> int
Sign of integer (-1, 0, or 1)
Pseudo Random
rnd(value: float) -> float
Returns a pseudo random float between >= 0.0 and < 1.0
Type Conversion
float(value: int) -> float
Convert int to float
byte(value: int) -> byte
Convert int to byte (0-255)
int(value: byte) -> int
Convert byte to int