From 272d99be508c75d806efdd648d39db65db6fa7bf Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Thu, 26 Jan 2017 12:39:03 +0200 Subject: [PATCH] Adapt Gyroscope to the latest changes in the Generic Sensor API This patch gets rids of 'Reading' class and re-defines reading attributes using "latest reading" terminology from Generic Sensor API (https://w3c.github.io/sensors/#latest-reading). --- index.bs | 90 +++++++--------------- index.html | 214 +++++++++++++++++++++-------------------------------- 2 files changed, 111 insertions(+), 193 deletions(-) diff --git a/index.bs b/index.bs index 7ad1f6f..e367109 100644 --- a/index.bs +++ b/index.bs @@ -16,24 +16,18 @@ Version History: https://github.com/w3c/gyroscope/commits/gh-pages/index.bs Indent: 2 Repository: w3c/gyroscope Markup Shorthands: markdown on -Inline Github Issues: true +Inline Github Issues: title !Test Suite: web-platform-tests on GitHub Boilerplate: omit issues-index, omit conformance Default Biblio Status: current
-urlPrefix: https://w3c.github.io/permissions/; spec: PERMISSIONS
-  type: dfn
-    text: permission; url: idl-def-Permission
-    text: associated PermissionDescriptor;  url: dfn-associated-permissiondescriptor
 urlPrefix: https://w3c.github.io/sensors; spec: GENERIC-SENSOR
   type: dfn
     text: high-level
-    text: sensor subclass
-    text: sensorreading subclass
+    text: sensor
+    text: latest reading
     text: default sensor
-    text: supported reporting mode; url: supported-reporting-modes
-    text: auto 
     text: construct a sensor object; url: construct-sensor-object
 
@@ -53,10 +47,10 @@ Examples {#examples} let sensor = new Gyroscope(); sensor.start(); - sensor.onchange = event => { - console.log("Rotation rate around the X-axis " + event.reading.x); - console.log("Rotation rate around the Y-axis " + event.reading.y); - console.log("Rotation rate around the Z-axis " + event.reading.z); + sensor.onchange = () => { + console.log("Angular velocity around the X-axis " + sensor.x); + console.log("Angular velocity around the Y-axis " + sensor.y); + console.log("Angular velocity around the Z-axis " + sensor.z); }; sensor.onerror = event => console.log(event.error.name, event.error.message); @@ -72,32 +66,13 @@ beyond those described in the Generic Sensor API [[!GENERIC-SENSOR]]. Model {#model} ===== -The Gyroscope's associated Sensor subclass -is the {{Gyroscope}} class. - -The Gyroscope's associated SensorReading subclass -is the {{GyroscopeReading}} class. - -The Gyroscope has a default sensor, -which is the device's main gyroscope sensor. - -The Gyroscope has a single supported reporting mode -which is "periodic". +The gyroscope's associated {{Sensor}} subclass is the {{Gyroscope}} class. -The Gyroscope Sensor's permission name is `"gyroscope"`. -It has no associated PermissionDescriptor. +Gyroscope has a default sensor, which is the device's main gyroscope sensor. -The Gyroscope has an associated abstract operation -to retrieve the sensor permission which -must simply return a permission whose name is "gyroscope". - -The Gyroscope has an associated abstract operation -to construct a SensorReading object -which creates a new {{GyroscopeReading}} object and sets each of its -x -y and -z attributes to -the current angular velocity about the corresponding axis. +A [=latest reading=] per [=sensor=] of gyroscope type includes three [=map/entries=] +whose [=map/keys=] are "x", "y", "z" and whose [=map/values=] contain current angular +velocity about the corresponding axes. The current angular velocity is the rate at which the device rotates about a specified axis. Its unit is the radian per second (rad/s) [[SI]]. @@ -118,43 +93,32 @@ The Gyroscope Interface {#gyroscope-interface}
   [Constructor(optional SensorOptions sensorOptions)]
   interface Gyroscope : Sensor {
-    readonly attribute GyroscopeReading? reading;
+    readonly attribute unrestricted double? x;
+    readonly attribute unrestricted double? y;
+    readonly attribute unrestricted double? z;
   };
 
-To Construct an Gyroscope Object the user agent must invoke the +To Construct a Gyroscope Object the user agent must invoke the construct a Sensor object abstract operation. -The GyroscopeReading Interface {#gyroscope-reading-interface} ---------------------------------------- - -
-  [Constructor(GyroscopeReadingInit GyroscopeReadingInit)]
-  interface GyroscopeReading : SensorReading {
-      readonly attribute unrestricted double x;
-      readonly attribute unrestricted double y;
-      readonly attribute unrestricted double z;
-  };
-  
-  dictionary GyroscopeReadingInit {
-      unrestricted double x = 0;
-      unrestricted double y = 0;
-      unrestricted double z = 0;
-  };
-
- -### The GyroscopeReading constructor ### {#gyroscope-reading-constructor} +### Gyroscope.x ### {#gyroscope-x} -### The attribute ### {#gyroscope-reading-attribute} - -The x attribute of the {{GyroscopeReading}} +The {{Gyroscope/x!!attribute}} attribute of the {{Gyroscope}} interface represents the current angular velocity around X-axis. +In other words, this attribute returns [=latest reading=]["x"]. + +### Gyroscope.y ### {#gyroscope-y} -The y attribute of the {{GyroscopeReading}} +The {{Gyroscope/y!!attribute}} attribute of the {{Gyroscope}} interface represents the current angular velocity around Y-axis. +In other words, this attribute returns [=latest reading=]["y"]. + +### Gyroscope.z ### {#gyroscope-z} -The x attribute of the {{GyroscopeReading}} +The {{Gyroscope/z!!attribute}} attribute of the {{Gyroscope}} interface represents the current angular velocity around Z-axis. +In other words, this attribute returns [=latest reading=]["z"]. Acknowledgements {#acknowledgements} ================ diff --git a/index.html b/index.html index eb262fa..73cd4af 100644 --- a/index.html +++ b/index.html @@ -415,6 +415,19 @@ border-left: 0.5em solid #DEF; } + /* Put nice boxes around each algorithm. */ + [data-algorithm]:not(.heading) { + padding: .5em; + border: thin solid #ddd; border-radius: .5em; + margin: .5em 0; + } + [data-algorithm]:not(.heading) > :first-child { + margin-top: 0; + } + [data-algorithm]:not(.heading) > :last-child { + margin-bottom: 0; + } + /* Style for switch/case
s */ dl.switch > dd > ol.only, dl.switch > dd > .only > ol { @@ -956,6 +969,8 @@ /* Reverse color scheme */ color: black; border-color: #3980B5; + border-bottom-width: 3px !important; + margin-bottom: 0px !important; } .toc a:visited { border-color: #054572; @@ -1168,7 +1183,7 @@ background-attachment: fixed; } - +