diff --git a/index.bs b/index.bs index bc33775..0eb7c98 100644 --- a/index.bs +++ b/index.bs @@ -827,28 +827,36 @@ A {{Sensor}} object has an associated [=platform sensor=]. The [=task source=] for the [=tasks=] mentioned in this specification is the sensor task source.
- let acl = new Accelerometer({frequency: 30}); - let max_magnitude = 0; - acl.addEventListener('activate', () => console.log('Ready to measure.')); - acl.addEventListener('error', error => console.log('Error: ' + error.name)); - acl.addEventListener('reading', () => { - let magnitude = Math.hypot(acl.x, acl.y, acl.z); - if (magnitude > max_magnitude) { - max_magnitude = magnitude; - console.log(\`Max magnitude: ${max_magnitude} m/s2\`); + navigator.permissions.query({ name: 'accelerometer' }).then(result => { + if (result.state === 'denied') { + console.log('Permission to use accelerometer sensor is denied.'); + return; } + + let acl = new Accelerometer({frequency: 30}); + let max_magnitude = 0; + acl.addEventListener('activate', () => console.log('Ready to measure.')); + acl.addEventListener('error', error => console.log(\`Error: ${error.name}\`)); + acl.addEventListener('reading', () => { + let magnitude = Math.hypot(acl.x, acl.y, acl.z); + if (magnitude > max_magnitude) { + max_magnitude = magnitude; + console.log(\`Max magnitude: ${max_magnitude} m/s2\`); + } + }); + acl.start(); }); - acl.start();
A Sensor
object has an associated platform sensor.
The task source for the tasks mentioned in this specification is the sensor task source.
-The event handler event types for the corresponding Sensor Interface's event handler attributes are defined in Event handlers section.
-let acl = new Accelerometer({frequency: 30}); -let max_magnitude = 0; -acl.addEventListener('activate', () => console.log('Ready to measure.')); -acl.addEventListener('error', error => console.log('Error: ' + error.name)); -acl.addEventListener('reading', () => { - let magnitude = Math.hypot(acl.x, acl.y, acl.z); - if (magnitude > max_magnitude) { - max_magnitude = magnitude; - console.log(`Max magnitude: ${max_magnitude} m/s2`); +navigator.permissions.query({ name: 'accelerometer' }).then(result => { + if (result.state === 'denied') { + console.log('Permission to use accelerometer sensor is denied.'); + return; } + + let acl = new Accelerometer({frequency: 30}); + let max_magnitude = 0; + acl.addEventListener('activate', () => console.log('Ready to measure.')); + acl.addEventListener('error', error => console.log(`Error: ${error.name}`)); + acl.addEventListener('reading', () => { + let magnitude = Math.hypot(acl.x, acl.y, acl.z); + if (magnitude > max_magnitude) { + max_magnitude = magnitude; + console.log(`Max magnitude: ${max_magnitude} m/s2`); + } + }); + acl.start(); }); -acl.start();
[[lastEventFiredAt]]
- Sensor
object,
+ Sensor
object,
expressed in milliseconds that passed since the time origin.
It is initially null.
[[pendingReadingNotification]]
onreading
is an EventHandler
which is called
-to notify that new reading is available.
onactivate
is an EventHandler
which is called when [[state]]
transitions from "activating" to "activated".
Let type be the sensor type of sensor_instance.
If the device has a single device sensor which can provide readings for type, then
+If the device has a single device sensor which can provide readings for type, then
Associate sensor_instance with a platform sensor corresponding @@ -2434,7 +2441,7 @@
If the device has multiple device sensors which can provide readings for type, then
+If the device has multiple device sensors which can provide readings for type, then
If type has an associated default sensor, then
@@ -2549,7 +2556,7 @@Update the user-agent-specific way in which sensor readings are obtained from sensor to no longer provide readings.
+Update the user-agent-specific way in which sensor readings are obtained from sensor to no longer provide readings.
Return.
@@ -2564,7 +2571,7 @@sensor, a platform sensor.
reading, a sensor reading.
+reading, a sensor reading.
None
@@ -2760,7 +2767,7 @@A sensor reading value or null.
+A sensor reading value or null.
ProximitySensor
.
Attributes of the Sensor
subclass that
-hold sensor readings values
+hold sensor readings values
should be named after the full name of these values.
For example, the Thermometer
interface should hold
-the sensor reading's value in
+the sensor reading's value in
a temperature
attribute (and not a value
or temp
attribute).
A good starting point for naming are the
Quantities, Units, Dimensions and Data Types Ontologies [QUDT].
Extension specifications must specify the unit of sensor readings.
+Extension specifications must specify the unit of sensor readings.
As per the Technical Architecture Group’s (TAG) API Design Principles [API-DESIGN-PRINCIPLES], all time measurement should be in milliseconds. All other units should be specified using, @@ -2893,7 +2900,7 @@
SensorOptions
.
- Its attributes which expose sensor readings are read only and
+ Its attributes which expose sensor readings are read only and
their getters must return the result of invoking get value from latest reading with An implementation of the Sensor
interface for each sensor type must protect its reading by associated PermissionName
or PermissionDescriptor
.
+
An implementation of the Sensor
interface for each sensor type must protect its reading by associated PermissionName
or PermissionDescriptor
.
A Low-level sensor
may use its interface name as a PermissionName
,
for instance, "gyroscope" or "accelerometer". Fusion sensors must request permission to access each of the sensors that are
used as a source of fusion.
Even though, it might be difficult to reconstruct low-level sensor readings from +
Even though, it might be difficult to reconstruct low-level sensor readings from fused data, some of the original information might be inferred. For example, it is easy to deduce user’s orientation in space if absolute or geomagnetic orientation sensors are used, therefore, these sensors must request permission to use magnetometer as it provides information about orientation of device in relation to Earth’s @@ -3522,17 +3529,17 @@