| OLD | NEW |
| 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/generic_sensor/platform_sensor_ambient_light_mac.h" | 5 #include "services/device/generic_sensor/platform_sensor_ambient_light_mac.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <IOKit/IOMessage.h> | 9 #include <IOKit/IOMessage.h> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "device/base/synchronization/shared_memory_seqlock_buffer.h" | 12 #include "device/base/synchronization/shared_memory_seqlock_buffer.h" |
| 13 #include "device/generic_sensor/generic_sensor_consts.h" | 13 #include "services/device/generic_sensor/generic_sensor_consts.h" |
| 14 #include "device/generic_sensor/platform_sensor_provider_mac.h" | 14 #include "services/device/generic_sensor/platform_sensor_provider_mac.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 // Convert the value returned by the ambient light LMU sensor on Mac | 18 // Convert the value returned by the ambient light LMU sensor on Mac |
| 19 // hardware to a lux value. | 19 // hardware to a lux value. |
| 20 double LMUvalueToLux(uint64_t raw_value) { | 20 double LMUvalueToLux(uint64_t raw_value) { |
| 21 // Conversion formula from regression. | 21 // Conversion formula from regression. |
| 22 // https://bugzilla.mozilla.org/show_bug.cgi?id=793728 | 22 // https://bugzilla.mozilla.org/show_bug.cgi?id=793728 |
| 23 // Let x = raw_value, then | 23 // Let x = raw_value, then |
| 24 // lux = -2.978303814*(10^-27)*x^4 + 2.635687683*(10^-19)*x^3 - | 24 // lux = -2.978303814*(10^-27)*x^4 + 2.635687683*(10^-19)*x^3 - |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 current_lux_ = lux; | 166 current_lux_ = lux; |
| 167 | 167 |
| 168 SensorReading reading; | 168 SensorReading reading; |
| 169 reading.timestamp = (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); | 169 reading.timestamp = (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); |
| 170 reading.values[0] = current_lux_; | 170 reading.values[0] = current_lux_; |
| 171 UpdateSensorReading(reading, true); | 171 UpdateSensorReading(reading, true); |
| 172 return true; | 172 return true; |
| 173 } | 173 } |
| 174 | 174 |
| 175 } // namespace device | 175 } // namespace device |
| OLD | NEW |