Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: ui/accelerometer/accelerometer_types.cc

Issue 759063002: Move Screen Rotation from MaximizeModeController to ScreenOrientationController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change similarity to account for moved files Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/accelerometer/accelerometer_types.h" 5 #include "ui/accelerometer/accelerometer_types.h"
6 6
7 #include <cmath>
8
7 namespace ui { 9 namespace ui {
8 10
11 namespace {
12
13 // The mean acceleration due to gravity on Earth in m/s^2.
14 const float kMeanGravity = 9.80665f;
15
16 // The maximum deviation from the acceleration expected due to gravity under
17 // which to detect hinge angle and screen rotation in m/s^2
18 const float kDeviationFromGravityThreshold = 1.0f;
19 }
20
9 AccelerometerReading::AccelerometerReading() : present(false) { 21 AccelerometerReading::AccelerometerReading() : present(false) {
10 } 22 }
11 23
12 AccelerometerReading::~AccelerometerReading() { 24 AccelerometerReading::~AccelerometerReading() {
13 } 25 }
14 26
15 AccelerometerUpdate::AccelerometerUpdate() { 27 AccelerometerUpdate::AccelerometerUpdate() {
16 } 28 }
17 29
18 AccelerometerUpdate::~AccelerometerUpdate() { 30 AccelerometerUpdate::~AccelerometerUpdate() {
19 } 31 }
20 32
33 bool AccelerometerUpdate::IsReadingStable(AccelerometerSource source) const {
34 return has(source) &&
35 std::abs(get(source).Length() - kMeanGravity) <=
36 kDeviationFromGravityThreshold;
37 }
38
21 } // namespace ui 39 } // namespace ui
OLDNEW
« ui/accelerometer/accelerometer_types.h ('K') | « ui/accelerometer/accelerometer_types.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698