This specification defines a concrete sensor interface to monitor
the ambient light level or illuminance of the device’s environment.
Status of this document
This section describes the status of this document at the time of
its publication. Other documents may supersede this document. A list of
current W3C publications and the latest revision of this technical report
can be found in the W3C technical reports
index at http://www.w3.org/TR/.
This document was published by the Device APIs Working Group as a Working Draft. This document is intended to become a W3C Recommendation.
If you wish to make comments regarding this document, please send them to public-device-apis@w3.org (subscribe, archives).
When sending e-mail,
please put the text “ambient-light” in the subject,
preferably like this:
“[ambient-light] …summary of comment…”.
All comments are welcome.
Publication as a Working Draft does not imply endorsement by the W3C
Membership. This is a draft document and may be updated, replaced or
obsoleted by other documents at any time. It is inappropriate to cite this
document as other than work in progress.
The Ambient Light Sensor extends the Generic Sensor API [GENERIC-SENSOR] to provide information about ambient light levels,
as detected by the device’s main light detector, in terms of lux units.
The light-level media feature [MEDIAQUERIES-4] provides
less granular information about the ambient light level.
Note: it might be worthwhile to provide a high-level Light Level Sensor
which would mirror the light-level media feature, but in JavaScript.
This sensor would _not require additional user permission to be activated_
in user agents that exposed the light-level media feature.
The Ambient Light Sensor has an associated abstract operation
to retrieve the sensor permission which
must simply return a permission whose name is "ambient-light".
Note: The precise lux value reported by
different devices in the same light can be different,
due to differences in detection method, sensor construction, etc.
Doug Turner for the initial prototype and
Marcos Caceres for the test suite.
Paul Bakaus for the LightLevelSensor idea.
Conformance
Document conventions
Conformance requirements are expressed with a combination of
descriptive assertions and RFC 2119 terminology. The key words “MUST”,
“MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”,
“RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this
document are to be interpreted as described in RFC 2119.
However, for readability, these words do not appear in all uppercase
letters in this specification.
All of the text of this specification is normative except sections
explicitly marked as non-normative, examples, and notes. [RFC2119]
Examples in this specification are introduced with the words “for example”
or are set apart from the normative text with class="example",
like this:
This is an example of an informative example.
Informative notes begin with the word “Note” and are set apart from the
normative text with class="note", like this:
Note, this is an informative note.
Conformant Algorithms
Requirements phrased in the imperative as part of algorithms (such as
"strip any leading space characters" or "return false and abort these
steps") are to be interpreted with the meaning of the key word ("must",
"should", "may", etc) used in introducing the algorithm.
Conformance requirements phrased as algorithms or specific steps can be
implemented in any manner, so long as the end result is equivalent. In
particular, the algorithms defined in this specification are intended to
be easy to understand and are not intended to be performant. Implementers
are encouraged to optimize.
Conformance Classes
A conformant user agent must implement all the requirements
listed in this specification that are applicable to user agents.
A conformant server must implement all the requirements listed
in this specification that are applicable to servers.