Skip to content

Commit

Permalink
Merge pull request #505 from jbeker/jb/fix_lid_closed_light_sensor_value
Browse files Browse the repository at this point in the history
When lid is closed, light sensor returns max value
  • Loading branch information
dustinrue authored Jun 13, 2019
2 parents 709ee4c + beabdd6 commit 9ae1973
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Source/LightEvidenceSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,19 @@ - (NSString *)description {
// Returns value in [0.0, 1.0]
- (double)levelFromRawLeft:(uint64_t)left andRight:(uint64_t)right {
// FIXME(rdamazio): This value is probably incorrect
// COMMENTS(dustinrue) below is the observed max value on a 13" unibody MacBook (Late 2008)
// COMMENTS(jbeker) below is the observed max value on a 15" Late 2013 Macbook Pro
// This value is ridiculous and results in a much smaller
// useful value range.
const double kMaxLightValue = 67092480.0;
const double kClosedLightValue = 4294967295.0;
const double kMaxLightValue = 67092480.0;;

const double avg = (left + right) / 2; // determine average value from the two sensors
return (avg / kMaxLightValue); // normalize

if (avg == kClosedLightValue) {
return 0; // COMMENTS(jbeker) on a 15" Late 2013 Macbook Pro it returns max value when the laptop is shut
} else {
return (avg / kMaxLightValue); // normalize
}
}

- (void)doUpdate {
Expand Down

0 comments on commit 9ae1973

Please sign in to comment.