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

Unified Diff: device/generic_sensor/platform_sensor_ambient_light_mac.cc

Issue 2845763002: Remove DeviceLightEvent implementation (Closed)
Patch Set: same as previous patch 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/test/layouttest_support.cc ('k') | device/sensors/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/generic_sensor/platform_sensor_ambient_light_mac.cc
diff --git a/device/generic_sensor/platform_sensor_ambient_light_mac.cc b/device/generic_sensor/platform_sensor_ambient_light_mac.cc
index e96299e4db013927a9c1121e1aaf261c6e8aa5d9..363b97e443c01f2f4ee4551d33a79b5685c3b54c 100644
--- a/device/generic_sensor/platform_sensor_ambient_light_mac.cc
+++ b/device/generic_sensor/platform_sensor_ambient_light_mac.cc
@@ -4,13 +4,41 @@
#include "device/generic_sensor/platform_sensor_ambient_light_mac.h"
+#include <stdint.h>
+
#include <IOKit/IOMessage.h>
#include "base/bind.h"
#include "device/base/synchronization/shared_memory_seqlock_buffer.h"
+#include "device/generic_sensor/generic_sensor_consts.h"
#include "device/generic_sensor/platform_sensor_provider_mac.h"
-#include "device/sensors/public/cpp/device_sensors_consts.h"
-#include "device/sensors/public/cpp/device_util_mac.h"
+
+namespace {
+
+// Convert the value returned by the ambient light LMU sensor on Mac
+// hardware to a lux value.
+double LMUvalueToLux(uint64_t raw_value) {
+ // Conversion formula from regression.
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=793728
+ // Let x = raw_value, then
+ // lux = -2.978303814*(10^-27)*x^4 + 2.635687683*(10^-19)*x^3 -
+ // 3.459747434*(10^-12)*x^2 + 3.905829689*(10^-5)*x - 0.1932594532
+
+ static const long double k4 = pow(10.L, -7);
+ static const long double k3 = pow(10.L, -4);
+ static const long double k2 = pow(10.L, -2);
+ static const long double k1 = pow(10.L, 5);
+ long double scaled_value = raw_value / k1;
+
+ long double lux_value =
+ (-3 * k4 * pow(scaled_value, 4)) + (2.6 * k3 * pow(scaled_value, 3)) +
+ (-3.4 * k2 * pow(scaled_value, 2)) + (3.9 * scaled_value) - 0.19;
+
+ double lux = ceil(static_cast<double>(lux_value));
+ return lux > 0 ? lux : 0;
+}
+
+} // namespace
namespace device {
« no previous file with comments | « content/test/layouttest_support.cc ('k') | device/sensors/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698