Utility

The RPCs listed in this section are not directly tied to any other part of PhoneIoT, but are helpers with using them.

RPCS

PhoneIoT.getColor(red: BoundedInteger<0, 255>, green: BoundedInteger<0, 255>, blue: BoundedInteger<0, 255>, alpha: BoundedInteger<0, 255>?)

Many of the Display RPCs take one or more optional parameters for controlling display color, which is specified as an integer. This RPC is a convenience function for constructing a color code from red, green, blue, and alpha values (each is 0-255).

The alpha value controls transparency, with 0 being invisible and 255 being opaque. If not specified, alpha will default to 255.

Arguments:

  • red: BoundedInteger<0, 255> info - red level (0-255)
  • green: BoundedInteger<0, 255> info - green level (0-255)
  • blue: BoundedInteger<0, 255> info - blue level (0-255)
  • alpha: BoundedInteger<0, 255>? info - alpha level (0-255)

Returns: Color info - Constructed color code (an integer)

PhoneIoT.getSensors()

This RPC returns a list containing the name of every sensor supported by PhoneIoT. Note that your specific device might not support all of these sensors, depending on the model.

See Sensors for more information.

Returns: List info - A list of sensor names

PhoneIoT.magnitude(vec: List<Number>)

Given a list of numbers representing a vector, this RPC returns the magnitude (length) of the vector. This can be used to get the total acceleration from the accelerometer (which gives a vector).

Arguments:

  • vec: List<Number> info - the vector value

Returns: Number info - magnitude of the vector (a non-negative number)

PhoneIoT.normalize(vec: List<Number>)

Given a list of numbers representing a vector, returns the normalized vector (same direction but with a magnitude of 1.0). This is identical to dividing each component by the magnitude.

Arguments:

  • vec: List<Number> info - the vector value

Returns: List<Number> info - the normalized vector