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

Unified Diff: content/browser/device_sensors/data_fetcher_shared_memory_mac.cc

Issue 2332903002: [sensors] [mac] Implement ambient light sensor for macOS (Closed)
Patch Set: Update commit message Created 4 years, 2 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/browser/device_sensors/DEPS ('k') | content/renderer/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/device_sensors/data_fetcher_shared_memory_mac.cc
diff --git a/content/browser/device_sensors/data_fetcher_shared_memory_mac.cc b/content/browser/device_sensors/data_fetcher_shared_memory_mac.cc
index 15bde3362a095dd3908c182220d6f2775287ea65..ab455aa6949b9185c7134899a173a8272b2f04ad 100644
--- a/content/browser/device_sensors/data_fetcher_shared_memory_mac.cc
+++ b/content/browser/device_sensors/data_fetcher_shared_memory_mac.cc
@@ -10,33 +10,13 @@
#include "base/metrics/histogram_macros.h"
#include "base/single_thread_task_runner.h"
#include "content/browser/device_sensors/ambient_light_mac.h"
+#include "device/sensors/public/cpp/device_util_mac.h"
#include "third_party/sudden_motion_sensor/sudden_motion_sensor_mac.h"
namespace {
const double kMeanGravity = 9.80665;
-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;
-}
-
void FetchLight(content::AmbientLightSensor* sensor,
content::DeviceLightHardwareBuffer* buffer) {
DCHECK(sensor);
@@ -48,7 +28,7 @@ void FetchLight(content::AmbientLightSensor* sensor,
if (!sensor->ReadSensorValue(lux_value))
return;
uint64_t mean = (lux_value[0] + lux_value[1]) / 2;
- double lux = LMUvalueToLux(mean);
+ double lux = device::LMUvalueToLux(mean);
buffer->seqlock.WriteBegin();
buffer->data.value = lux;
buffer->seqlock.WriteEnd();
« no previous file with comments | « content/browser/device_sensors/DEPS ('k') | content/renderer/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698