PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Use conditions
  • Acceleration of a device: definitions
  • Stopping the detection
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
SensorDetectChangeAcceleration (Function)
In French: CapteurDétecteChangementAccélération
Allows you to be notified when accelerations occur on the device on any one of its 3 axes.
Versions 17 and later
Universal Windows 10 App This function is now available for the Windows Phone applications.
New in version 17
Universal Windows 10 App This function is now available for the Windows Phone applications.
Universal Windows 10 App This function is now available for the Windows Phone applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
New in version 18
Android Widget This function is now available in Android Widget mode.
Android Widget This function is now available in Android Widget mode.
Versions 19 and later
WEBDEV - Browser code This function is now available in Browser code.
iPhone/iPad This function is now available for the iPhone/iPad applications.
New in version 19
WEBDEV - Browser code This function is now available in Browser code.
iPhone/iPad This function is now available for the iPhone/iPad applications.
WEBDEV - Browser code This function is now available in Browser code.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Example
// Detect the changes of acceleration
SensorDetectChangeAcceleration("ProcDetectAcceleration", snrVertical)
// Procedure called by the SensorDetectChangeAcceleration function
PROCÉDURE ProcDetectAcceleration(VerticalAcceleration is real, ...
HorizontalAcceleration is real, LateralAcceleration is real)
ToastDisplay(StringBuild("Vertical acceleration detected (%1 m/s²)", VerticalAcceleration))


// Stop detecting the changes of acceleration
SensorDetectChangeAcceleration("", snrVertical)
Syntax
<Result> = SensorDetectChangeAcceleration(<Procedure Name> [, <Movement Axis> [, <Frequency> [, <Threshold>]]])
<Result>: Integer
  • True if the detection was triggered,
  • False otherwise.
<Procedure Name>: Character string (with or without quotes)
Name of the WLanguage procedure ("callback" procedure) that will be called when detecting the acceleration of the device on one of its axes. This procedure has the following format :
PROCEDURE <Procedure Name> (<Vertical>, <Longitudinal>, <Lateral>)
where
  • <Vertical> is a real corresponding to the measurement of the device acceleration on the vertical axis (Z) in m/s²,
  • <Longitudinal> is a real corresponding to the measurement of the device acceleration on the longitudinal axis (Y) in m/s²,
  • <Lateral> is a real corresponding to the measurement of the device acceleration on the horizontal axis (X) in m/s².
The 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:
snrLateralNotification when the device accelerates on the horizontal axis.
snrLongitudinalNotification when the device accelerates on the longitudinal axis.
snrVerticalNotification 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:
snrFrequencyGameFrequency of notification required when using SensorDetectChangeAcceleration in a game.
snrFrequencyNormal
(Default value)
Standard frequency of notification.
snrFrequencyQuickFast frequency of notification.
iPhone/iPad This parameter is ignored. The frequency is the same, regardless of the specified constant.
<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 found on the device. No detection of acceleration changes will be performed if this sensor is not found on the device. The sensitivity of detection depends on the quality of the sensor found 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.
Origin of the acceleration
System of coordinates (considering that the device lies down flat, the screen directed to the ceiling):
  • The origin is found in the bottom 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.
Note: 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.

Stopping the detection

We advise you to stop detecting the changes of acceleration when no longer required in order to save the battery of the device. To do so, <Procedure Name> must correspond to an empty string ("").
SensorEnd is used to stop all the current detections.
Related Examples:
iOS System iPhone/iPad (WINDEV Mobile): iOS System
[ + ] This application is an example presenting the use of various features.
The features are as follows:
- Playing videos
- Trace in the logs
- Slider
- Popup control
- Hourglass
...
Components
WEBDEV - Browser code WDJS.DLL
Android wd230android.jar
See also
Minimum required version
  • Version 16
This page is also available for…
Comments
Click [Add] to post a comment