Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

Simulating Sensors

Mobile devices contain built-in sensors, such as an accelerometer, a compass, and ambient light or proximity sensors. The availability of sensors depends on the device model.

The following types of interaction can be enabled by using the sensors on the device:

  • Changing application settings based on the ambient light conditions, such as bright sunshine or night time.
  • Changing the screen orientation on the device from portrait to landscape as the device is rotated.
  • Silencing an incoming call when the device orientation is changed (for example, on a table) from screen down to screen up and back again.
  • Allowing movement gestures, such as device rotation, to trigger an action.
  • In a map application, changing the orientation of a map based on the device compass orientation.
  • Triggering an action when the device comes in close proximity to the user's hand or head.

You can test applications that use the Qt Mobility Sensors API in the Qt Simulator. The Sensors section contains controls to set the values the sensors currently return.

"Sensors section"

Changing Light Conditions

Specify the ambient light state in the Ambient light field.

Device Movement

The accelerometer sensor channel detects movement gestures, such as moving a mobile device up or down. The three-dimensional Cartesian coordinate system is used to illustrate direction of the acceleration, as shown in the figure below. The x and y axes define a plane where z-axis direction is perpendicular to the xy plane. When a device moves along an axis in the positive direction, the acceleration is positive. When the device moves in the negative direction, the acceleration is negative. For example, when a device moves along the x-axis to the direction of -x, the acceleration is negative.

A mobile device placed screen up on a desk experiences a force of approximately 9.8 on the z axis (that is, upwards). This is the proper acceleration the device experiences relative to freefall.

To simulate movement of the device, use the sliders to specify values for the x, y, and z axis in the Accelerometer x, Accelerometer y, and Accelerometer z fields.

Device Rotation

The attitude sensor detects the rotation of the device around the x, y, or z axis:

  • Pitch of the device is the rotation around the x axis
  • Roll is the rotation around the y axis
  • Yaw is the rotation around the z axis

Pitch and roll are zero (0) when the phone lies flat, screen up. Yaw is 0 when the top of the device points towards the reference point. Yaw requires a fixed, external reference point that the device can detect. For example, devices with a compass may use magnetic north as a reference point. Devices that cannot detect a fixed, external reference point always return 0 for yaw.

Use the sliders to set the Attitude pitch, Attitude roll, and Attitude yaw values to test how the application handles the interaction related to rotating the device.

Compass Orientation

The compass returns the azimuth of the device as degrees from magnetic north in a clockwise direction based on the top of the device.

Note: The top of the device is a fixed point and may not represent the orientation that the user is holding the device in.

The calibration status of the device must be accurate for the azimuth to be accurate. It takes some time to calibrate the magnetic north sensor and, even after being calibrated, it can become uncalibrated. So, for an application to be sure the data coming from the magnetic north sensor channel is accurate, it must monitor changes in the calibration property and inform the user if something needs to be done to recalibrate the sensor.

Use sliders to set the Compass calibration level and Compass azimuth values.

Proximity

Proximity indicates how far away from the device the user is. Use the button to toggle between Near and Far distance.

Using a Fixed Timestamp

Many sensors update frequently, and therefore sensor readings done by the client application contain a fresh timestamp by default. To disable that and provide a fixed timestamp manually, select the Override radio button in the Timestamp group and specify a date and time.

[Previous: Simulating Messaging] [Next: Testing Applications Using the Qt Mobility Service Framework]

X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.

s.parentNode.insertBefore(ga, s); })(); -->
Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année

Le blog Digia au hasard

Logo

Déploiement d'applications Qt Commercial sur les tablettes Windows 8

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtsimulator-1.0
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web