SensorsThis covers both high-level sensors such as screen orientation (portrait, landscape) and low-level, real-time sensors such as accelerometer data. NamespaceThe QtMobility APIs are placed into the QtMobility namespace. This is done to facilitate the future migration of Mobility APIs into Qt. See the Quickstart guide for an example on how the namespace impacts on application development. Sensor TypesOn a device there can be many types of sensors. Not all of the types that the Sensors API supports may be available. There may also be types available that are not defined in the Sensors API. You can find the sensor types available on a device using the QSensor::sensorTypes() function. For a list of built-in sensor types, see the Sensor Classes section below. Common ConventionsUnless otherwise specified, sensors shall use the Right Hand Cartesian coordinate system. To allow for measurements in all 6 directions, negative values are used. Where rotation around an axis is used, the rotation shall be expressed as a Right Hand rotation. In general, sensor data is oriented to the top of the device. If values are to be displayed on the screen the values may need to be transformed so that they match the user interface orientation. A sensor may define its data as being oriented to the UI. This will be noted in the documentation for the sensor. The life cycle of a sensor is typically: Here is an example of creating a sensor on the heap and on the stack. The preferred way to deal with sensor data is via the Reading Classes. However, sometimes this may not be possible. For example, you may be deploying an application to a device that has a new sensor type but no C++ header describing the reading class is available. Thanks to Qt's property system you can still access the sensor data. You need to know 3 pieces of information in order to do this: For example, here is an example of how you can access a property of the accelerometer. This code does not require any compile-time links to QAccelerometer or QAccelerometerReading. You can discover all of this information at runtime too. The sensor_explorer example shows you information about available sensors. The Sensors API has a front end, for application developers to use and a back end, where device implementors write code to access their hardware. As an application developer you do not need to access the back end though it may be useful to understand how it works. Commands from the application are delivered through QSensor and then down to the device plugin. Data comes back through the QSensorReading class. More information about the back end can be found in Sensors Backend. The primary classes that make up the Sensors API. Represents a single hardware sensor Efficient callback facility for asynchronous notifications of sensor changes Holds the readings from the sensor The best way to access sensor data is via one of these classes. Reports on linear acceleration along the X, Y and Z axes Represents one reading from the ambient light sensor Represents one reading from a compass Represents one reading from the magnetometer Represents one reading from the orientation sensor Represents one reading from the proximity sensor Represents one reading from the rotation sensor Represents one reading from the tap sensor These classes provide convenience wrappers that reduce the need for casting. Each of these classes represents a sensor type that the Sensors API knows about. Note that additional types may be made available at run-time. See Sensor Types for more information. Convenience wrapper around QSensor Convenience wrapper around QSensor Convenience wrapper around QSensor Convenience wrapper around QSensor Convenience wrapper around QSensor Convenience wrapper around QSensor Convenience wrapper around QSensor Convenience wrapper around QSensor As with the sensor classes, these provide convenience wrappers that reduce the need for casting. Convenience wrapper around QSensorFilter Convenience wrapper around QSensorFilter Convenience wrapper around QSensorFilter Convenience wrapper around QSensorFilter Convenience wrapper around QSensorFilter Convenience wrapper around QSensorFilter Convenience wrapper around QSensorFilter Convenience wrapper around QSensorFilter X
|