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

Side by Side Diff: services/device/public/cpp/sensors/device_util_mac.cc

Issue 2819273006: Move //device/sensor impl to be part of the internal implemenation of the Device Service. (Closed)
Patch Set: Move //device/sensor impl to be part of the internal implemenation of the Device Service Created 3 years, 8 months 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "device/sensors/public/cpp/device_util_mac.h" 5 #include "services/device/sensors/public/cpp/device_util_mac.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 namespace device { 9 namespace device {
10 10
11 double LMUvalueToLux(uint64_t raw_value) { 11 double LMUvalueToLux(uint64_t raw_value) {
12 // Conversion formula from regression. 12 // Conversion formula from regression.
13 // https://bugzilla.mozilla.org/show_bug.cgi?id=793728 13 // https://bugzilla.mozilla.org/show_bug.cgi?id=793728
14 // Let x = raw_value, then 14 // Let x = raw_value, then
15 // lux = -2.978303814*(10^-27)*x^4 + 2.635687683*(10^-19)*x^3 - 15 // lux = -2.978303814*(10^-27)*x^4 + 2.635687683*(10^-19)*x^3 -
16 // 3.459747434*(10^-12)*x^2 + 3.905829689*(10^-5)*x - 0.1932594532 16 // 3.459747434*(10^-12)*x^2 + 3.905829689*(10^-5)*x - 0.1932594532
17 17
18 static const long double k4 = pow(10.L, -7); 18 static const long double k4 = pow(10.L, -7);
19 static const long double k3 = pow(10.L, -4); 19 static const long double k3 = pow(10.L, -4);
20 static const long double k2 = pow(10.L, -2); 20 static const long double k2 = pow(10.L, -2);
21 static const long double k1 = pow(10.L, 5); 21 static const long double k1 = pow(10.L, 5);
22 long double scaled_value = raw_value / k1; 22 long double scaled_value = raw_value / k1;
23 23
24 long double lux_value = 24 long double lux_value =
25 (-3 * k4 * pow(scaled_value, 4)) + (2.6 * k3 * pow(scaled_value, 3)) + 25 (-3 * k4 * pow(scaled_value, 4)) + (2.6 * k3 * pow(scaled_value, 3)) +
26 (-3.4 * k2 * pow(scaled_value, 2)) + (3.9 * scaled_value) - 0.19; 26 (-3.4 * k2 * pow(scaled_value, 2)) + (3.9 * scaled_value) - 0.19;
27 27
28 double lux = ceil(static_cast<double>(lux_value)); 28 double lux = ceil(static_cast<double>(lux_value));
29 return lux > 0 ? lux : 0; 29 return lux > 0 ? lux : 0;
30 } 30 }
31 31
32 } // namespace device 32 } // namespace device
OLDNEW
« no previous file with comments | « services/device/public/cpp/sensors/device_util_mac.h ('k') | services/device/public/cpp/sensors/motion_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698