Sensors (sensor.h)

Functions to read various input sensors on the device.

This file defines the sensor service, which provides functions for reading the various input sensors that are available on the device, including the accelerometer, magnetometer, temperature, illuminance, and so on.

The sensors are listed by the enumeration sensor_type_t. To see if a sensor is supported on the device call sensor_is_supported(). To start receiving sensor events, call sensor_request_events() and pass in the sensor type. To set the refresh rate of the sensor, call the sensor_set_rate() function. To specify whether duplicate sensor events should be skipped, call the sensor_set_skip_duplicates() function.

Once a BPS event is received, you can call the sensor_get_domain() function to determine whether it was a sensor event and the bps_event_get_code() to determine the type of sensor event.

The sensors return a variety of different data, so depending on which sensor you want to use, you need to call a different sensor_event_get_* function to retrieve the readings. See the individual functions to determine which sensors they work with.

To stop receiving sensor events, call the sensor_stop_events() function.

Since:
BlackBerry 10.0.0

Last modified: 2014-05-14



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus