Skip to content

Commit 9ae1973

Browse files
authored
Merge pull request #505 from jbeker/jb/fix_lid_closed_light_sensor_value
When lid is closed, light sensor returns max value
2 parents 709ee4c + beabdd6 commit 9ae1973

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Source/LightEvidenceSource.m

+9-3
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,19 @@ - (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 kClosedLightValue = 4294967295.0;
90+
const double kMaxLightValue = 67092480.0;;
9091

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

95101
- (void)doUpdate {

0 commit comments

Comments
 (0)