Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 9c32bf5

Browse files
Auto-merge pull request #7174 from livecodesam/patch-110
[Bugfix-21111] Add docs note about accelerometer differences Added a note to the accelerationChanged entry explaining how and why the accelerometer outputs for Android and iOS may need to be normalised.
2 parents 086f5cd + 26d2bde commit 9c32bf5

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

docs/dictionary/message/accelerationChanged.lcdoc

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,31 @@ Handle the <accelerationChanged> message if you want to perform an
3535
action when the acceleration along any axis changes
3636

3737
The <accelerationChanged> message is sent to the current card of the
38-
defaultStack at the interval specified by the mobileEnableAccelerometer
39-
command.
38+
defaultStack at the interval specified by the
39+
<mobileEnableAccelerometer> command.
4040

4141
You can use the difference between the time values in two
4242
<accelerationChanged> events to give an indication of how much time
4343
passed between the samples.
4444

45+
>*Note:* On Android, the change in acceleration output is in meters
46+
> per second squared whereas on iOS, it is in G-forces. In order to
47+
> normalize these changes in acceleration, you must detect the
48+
> <platform> and convert appropriately. For example:
49+
50+
on accelerationChanged pXAccel, pYAccel, pZAccel
51+
if the platform is "iphone" then
52+
-- Convert from g-forces to m/s^2
53+
multiply pXAccel by 9.81
54+
multiply pYAccel by 9.81
55+
multiply pZAccel by 9.81
56+
end if
57+
-- the rest of your code
58+
end accelerationChanged
59+
4560
References: mobileStopTrackingSensor (command),
46-
mobileStartTrackingSensor (command)
61+
mobileStartTrackingSensor (command),
62+
mobileEnableAccelerometer (command), platform (function)
4763

4864
Tags: ui
4965

docs/notes/bugfix-21111.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Explained mobile accelerometer differences in the accelerationChanged entry

0 commit comments

Comments
 (0)