diff options
author | Fawzi Mohamed <fawzi.mohamed@digia.com> | 2014-04-11 12:08:08 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-17 13:44:44 +0200 |
commit | 75487a011fb8b8de1e22c25425f024dfb97dc192 (patch) | |
tree | 815dc724b478da8597c177513622e267ea3eec58 /examples | |
parent | e60743e095b8bb7fcc3f0de823d2a46aa68343d3 (diff) | |
download | qtsensors-75487a011fb8b8de1e22c25425f024dfb97dc192.tar.gz |
accelbubble: avoid updating position if NaN.
Invalid sensor data is NaN, and should be ignored.
Change-Id: I6436bdd494b3d167121bd8ee80f81c031e60743e
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/sensors/accelbubble/accelbubble.qml | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/examples/sensors/accelbubble/accelbubble.qml b/examples/sensors/accelbubble/accelbubble.qml index 8f676dc..033e66a 100644 --- a/examples/sensors/accelbubble/accelbubble.qml +++ b/examples/sensors/accelbubble/accelbubble.qml @@ -69,6 +69,9 @@ ApplicationWindow { var newX = (bubble.x + calcRoll(accel.reading.x, accel.reading.y, accel.reading.z) * .1) var newY = (bubble.y - calcPitch(accel.reading.x, accel.reading.y, accel.reading.z) * .1) + if (isNaN(newX) || isNaN(newY)) + return; + if (newX < 0) newX = 0 |