Skip to content

Commit

Permalink
Fix comparison of rounded readings in threshold check algorithm (#85)
Browse files Browse the repository at this point in the history
The ambient light reading quantization algorithm returns an entire reading,
not an illuminance, so account for that properly in the threshold check
algorithm.

While here, remove custom anchors for some definitions that are exported by
the Generic Sensor spec.
  • Loading branch information
Raphael Kubo da Costa authored Jul 21, 2023
1 parent 5e43a98 commit adf6c8b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ urlPrefix: https://w3c.github.io/sensors/; spec: GENERIC-SENSOR
text: mock sensor type
text: MockSensorType
text: mock sensor reading values
text: threshold check algorithm
text: reading quantization algorithm
text: latest reading
urlPrefix: https://tc39.es/ecma262/; spec: ECMA-262
type: abstract-op
Expand Down Expand Up @@ -384,12 +382,12 @@ check algorithm=]:
1. Let |latestIlluminance| be |latestReading|["illuminance"].
1. If [$abs$](|latestIlluminance| - |newIlluminance|) < [=illuminance
threshold value=], return false.
1. Let |roundedNewIlluminance| be the result of invoking the [=ambient light
1. Let |roundedNewReading| be the result of invoking the [=ambient light
reading quantization algorithm=] algorithm with |newIlluminance|.
1. Let |roundedLatestIlluminance| be the result of invoking the [=ambient
1. Let |roundedLatestReading| be the result of invoking the [=ambient
light reading quantization algorithm=] algorithm with |latestIlluminance|.
1. If |roundedNewIlluminance| and |roundedLatestIlluminance| are equal,
return false.
1. If |roundedNewReading|["illuminance"] and |roundedLatestIlluminance|["illuminance"]
are equal, return false.
1. Otherwise, return true.
</div>

Expand Down

0 comments on commit adf6c8b

Please sign in to comment.