Skip to content

Commit 2c197fa

Browse files
committed
When lid is closed, light sensor returns max value
If the lid is closed (on a Macbook Pro late 2013), the light sensors both report the max value. In that case, we really want to say the value is 0, so return that.
1 parent 709ee4c commit 2c197fa

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Diff for: Source/LightEvidenceSource.m

+8-3
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,18 @@ - (NSString *)description {
8383
// Returns value in [0.0, 1.0]
8484
- (double)levelFromRawLeft:(uint64_t)left andRight:(uint64_t)right {
8585
// FIXME(rdamazio): This value is probably incorrect
86-
// COMMENTS(dustinrue) below is the observed max value on a 13" unibody MacBook (Late 2008)
86+
// COMMENTS(jbeker) below is the observed max value on a 15" Late 2013 Macbook Pro
8787
// This value is ridiculous and results in a much smaller
8888
// useful value range.
89-
const double kMaxLightValue = 67092480.0;
89+
const double kMaxLightValue = 4294967295.0;
9090

9191
const double avg = (left + right) / 2; // determine average value from the two sensors
92-
return (avg / kMaxLightValue); // normalize
92+
93+
if (avg == kMaxLightValue) {
94+
return 0; // COMMENTS(jbeker) on a 15" Late 2013 Macbook Pro it returns max value when the laptop is shut
95+
} else {
96+
return (avg / kMaxLightValue); // normalize
97+
}
9398
}
9499

95100
- (void)doUpdate {

0 commit comments

Comments
 (0)