|
|
|
|
- Use conditions
- Acceleration of a device: definitions
- Stop detection
SensorDetectChangeAcceleration (Function) In french: CapteurDétecteChangementAccélération Notifies when acceleration forces are applied to the device along any of the three axes.
SensorDetectChangeAcceleration("ProcDétectionAccélération", snrVertical)
PROCÉDURE ProcDétectionAccélération(AccélérationVerticale is real, ...
AccélérationHorizontale is real, AccélérationLatérale is real)
ToastDisplay(StringBuild("Accélération verticale détectée (%1 m/s²)", AccélérationVerticale))
SensorDetectChangeAcceleration("", snrVertical)
Syntax
<Result> = SensorDetectChangeAcceleration(<WLanguage procedure> [, <Movement Axis> [, <Frequency> [, <Threshold>]]])
<Result>: entier - True if the detection was triggered,
- False otherwise.
<WLanguage procedure>: Procedure name Name of the Procedure WLanguage (also called "callback") called when the acceleration of the device on one of its axes is detected.For more details on this Procedure, see Parameters of the procedure used by SensorDetectChangeAccelerationThe parameters of this procedure are optional. There is no need to pass parameters to this procedure. Indeed, these parameters are automatically filled during each call providing that the corresponding movement axis is specified in <Movement Axis>. Otherwise, these parameters are set to 0. If the name of the procedure corresponds to an empty string (""), the notifications will not be sent anymore when the acceleration changes. <Movement Axis>: Optional Integer constant Movement axes of the device for which a notification is required during the change of acceleration: | | snrLateral | Notification when the device accelerates on the horizontal axis. | snrLongitudinal | Notification when the device accelerates on the longitudinal axis. | snrVertical | Notification when the device accelerates on the vertical axis. |
By default, a notification will be sent when the acceleration changes on any one of the three axes (equivalent to snrVertical + snrLateral + snrLongitudinal). <Frequency>: Optional Integer constant Frequency according to which the notifications for changes of acceleration must be sent: | | snrFrequencyGame | Notification frequency required when using SensorDetectChangeAcceleration in a game. | snrFrequencyNormal (Default value) | Standard frequency of notification. | snrFrequencyQuick | Fast frequency of notification. |
<Threshold>: Optional real Threshold for change tolerance (in m/s²). The notifications will be sent for the changes of acceleration greater than this threshold. No threshold will be fixed if this parameter is not specified: the notifications will be sent for each change of acceleration (equivalent to a threshold set to 0). Remarks Use conditions - This function cannot be used in the emulator or in the simulator. In both cases, the result of the function will always be set to False.
- The detection of acceleration changes uses the accelerometer sensor on the device. Acceleration changes will be not be detected if this sensor is not on the device. The sensitivity of the detection depends on the quality of the sensor in the device.
Acceleration of a device: definitions The acceleration can be defined as being the measurement of the change in the device's speed in a given direction. The movement sensor considers that the device is resting when it lies down flat, the screen oriented to the sky and in portrait mode.
Coordinate system (assuming the device is flat, with the screen facing the ceiling): - The origin is found in the lower-left corner of the screen.
- The X-axis represents the horizontal axis and it points to the right of the screen.
- The Y-axis represents the longitudinal axis and it points to the top of the screen.
- The Z-axis represents the vertical axis and it points outside the front of the screen.
The change of acceleration can be specified according to the three following dimensions: - Vertical acceleration: Acceleration of the device on the vertical axis (Z). This acceleration is expressed in m/s². When the device lies down flat with the screen pointing to the sky, if the device follows an ascending movement with an acceleration set to A m/s², the total value of the vertical acceleration is equal to ~= A + 9,81, corresponding to the vertical acceleration of the device minus the gravity force on Earth.
- Longitudinal acceleration: Acceleration of the device on the longitudinal axis (Y). This acceleration is expressed in m/s². Its value is positive when the device moves backward and negative when the device moves forward.
- Lateral acceleration: Acceleration of the device on the horizontal axis (X). This acceleration is expressed in m/s². Its value is positive when the device moves to the left and negative when the device moves to the right.
Remark: The movement sensor (accelerometer) cannot differentiate between the accelerations caused by a movement and the accelerations caused by the terrestrial attraction. Therefore, the vertical acceleration measured when the device is resting will be set to -9,8m/s², corresponding to the average terrestrial gravity. Stop detection We advise you to stop the detection of acceleration changes when it is no longer required in order to reduce battery consumption. To do so, <WLanguage procedure> must correspond to an empty string (""). SensorEnd is used to stop all the current detections.
Related Examples:
|
Cross-platform examples (WINDEV Mobile): WM System
[ + ] This application is an example of some of the features of WINDEV Mobile available for Android/iOS. The following system functions are used: - NFC - Multimedia control - Brightness - Volume - Wi-Fi - Bluetooth - Toast - Compass - Accelerometer - Camera control - LED - Vibration - Notifications - Drawing functions - Internet
|
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|