OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Device Motion/Orientation diagnostic measurements</title> | 4 <title>Device Motion/Orientation/Light diagnostic measurements</title> |
timvolodine
2014/09/04 17:16:58
could you please separate this into a separate fil
riju_
2014/09/08 09:26:18
Done. I will add similar thing for Light in the ne
| |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <table> | 7 <table> |
8 <tr> | 8 <tr> |
9 <td colspan="2"> | 9 <td colspan="2"> |
10 <hr> | 10 <hr> |
11 </td> | 11 </td> |
12 </tr> | 12 </tr> |
13 <tr> | 13 <tr> |
14 <td>Motion Supported</td> | 14 <td>Motion Supported</td> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 <td id="orientationAbsolute"></td> | 56 <td id="orientationAbsolute"></td> |
57 </tr> | 57 </tr> |
58 <tr> | 58 <tr> |
59 <td>orientation frequency (Hz)</td> | 59 <td>orientation frequency (Hz)</td> |
60 <td id="orientationFreq"></td> | 60 <td id="orientationFreq"></td> |
61 </tr> | 61 </tr> |
62 <tr> | 62 <tr> |
63 <td>orientation max frequency (Hz)</td> | 63 <td>orientation max frequency (Hz)</td> |
64 <td id="orientationMaxFreq"></td> | 64 <td id="orientationMaxFreq"></td> |
65 </tr> | 65 </tr> |
66 <tr> | |
67 <td colspan="2"> | |
68 <hr> | |
69 </td> | |
70 </tr> | |
71 <tr> | |
72 <td>DeviceLight Supported</td> | |
73 <td id="lightSupported"></td> | |
74 </tr> | |
75 <tr> | |
76 <td>Light value (Lux value)</td> | |
77 <td id="lightValue"></td> | |
78 </tr> | |
66 </table> | 79 </table> |
67 | 80 |
68 <script type="text/javascript"> | 81 <script type="text/javascript"> |
69 var numberMotionEvents = 0; | 82 var numberMotionEvents = 0; |
70 var numberOrientationEvents = 0; | 83 var numberOrientationEvents = 0; |
84 var numberLightEvents = 0; | |
71 var motionMaxFreq = 0; | 85 var motionMaxFreq = 0; |
72 var orientationMaxFreq = 0; | 86 var orientationMaxFreq = 0; |
87 var lightMaxFreq = 0; | |
73 var updateIntervalDelaySec = 2; | 88 var updateIntervalDelaySec = 2; |
74 | 89 |
75 function onMotion(event) { | 90 function onMotion(event) { |
76 document.getElementById('motionAccel').innerHTML = | 91 document.getElementById('motionAccel').innerHTML = |
77 roundToFixedArray([event.acceleration.x, | 92 roundToFixedArray([event.acceleration.x, |
78 event.acceleration.y, | 93 event.acceleration.y, |
79 event.acceleration.z]); | 94 event.acceleration.z]); |
80 | 95 |
81 document.getElementById("motionAccelG").innerHTML = | 96 document.getElementById("motionAccelG").innerHTML = |
82 roundToFixedArray([event.accelerationIncludingGravity.x, | 97 roundToFixedArray([event.accelerationIncludingGravity.x, |
(...skipping 19 matching lines...) Expand all Loading... | |
102 }).join(',') + ']'; | 117 }).join(',') + ']'; |
103 } | 118 } |
104 | 119 |
105 function onOrientation(event) { | 120 function onOrientation(event) { |
106 document.getElementById("orientationValues").innerHTML = | 121 document.getElementById("orientationValues").innerHTML = |
107 roundToFixedArray([event.alpha, event.beta, event.gamma]); | 122 roundToFixedArray([event.alpha, event.beta, event.gamma]); |
108 document.getElementById("orientationAbsolute").innerHTML = event.absolut e; | 123 document.getElementById("orientationAbsolute").innerHTML = event.absolut e; |
109 ++numberOrientationEvents; | 124 ++numberOrientationEvents; |
110 } | 125 } |
111 | 126 |
127 function onLight(event) { | |
128 document.getElementById("lightValues").innerHTML = event.value; | |
129 ++numberLightEvents; | |
130 } | |
131 | |
112 function updateMeasurements() { | 132 function updateMeasurements() { |
113 var motionFreq = numberMotionEvents/updateIntervalDelaySec; | 133 var motionFreq = numberMotionEvents/updateIntervalDelaySec; |
114 var orientationFreq = numberOrientationEvents/updateIntervalDelaySec; | 134 var orientationFreq = numberOrientationEvents/updateIntervalDelaySec; |
135 var lightFreq = numberLightEvents/updateIntervalDelaySec; | |
115 motionMaxFreq = Math.max(motionMaxFreq, motionFreq); | 136 motionMaxFreq = Math.max(motionMaxFreq, motionFreq); |
116 orientationMaxFreq = Math.max(orientationMaxFreq, orientationFreq); | 137 orientationMaxFreq = Math.max(orientationMaxFreq, orientationFreq); |
138 lightMaxFreq = Math.max(lightMaxFreq, lightFreq); | |
117 | 139 |
118 document.getElementById("motionFreq").innerHTML = motionFreq; | 140 document.getElementById("motionFreq").innerHTML = motionFreq; |
119 document.getElementById("motionMaxFreq").innerHTML = motionMaxFreq; | 141 document.getElementById("motionMaxFreq").innerHTML = motionMaxFreq; |
120 document.getElementById("orientationFreq").innerHTML = orientationFreq; | 142 document.getElementById("orientationFreq").innerHTML = orientationFreq; |
121 document.getElementById("orientationMaxFreq").innerHTML = orientationMax Freq; | 143 document.getElementById("orientationMaxFreq").innerHTML = orientationMax Freq; |
144 document.getElementById("lightFreq").innerHTML = lightFreq; | |
145 document.getElementById("lightMaxFreq").innerHTML = lightMaxFreq; | |
122 | 146 |
123 numberMotionEvents = 0; | 147 numberMotionEvents = 0; |
124 numberOrientationEvents = 0; | 148 numberOrientationEvents = 0; |
149 numberLightEvents = 0; | |
125 } | 150 } |
126 | 151 |
127 var motionSupported="not supported"; | 152 var motionSupported="not supported"; |
128 var orientationSupported="not supported"; | 153 var orientationSupported="not supported"; |
154 var lightSupported="not supported"; | |
129 | 155 |
130 if (window.DeviceMotionEvent) { | 156 if (window.DeviceMotionEvent) { |
131 window.addEventListener('devicemotion', onMotion) | 157 window.addEventListener('devicemotion', onMotion) |
132 motionSupported="supported"; | 158 motionSupported="supported"; |
133 } | 159 } |
134 document.getElementById("motionSupported").innerHTML = motionSupported; | 160 document.getElementById("motionSupported").innerHTML = motionSupported; |
135 | 161 |
136 if (window.DeviceOrientationEvent) { | 162 if (window.DeviceOrientationEvent) { |
137 window.addEventListener('deviceorientation', onOrientation); | 163 window.addEventListener('deviceorientation', onOrientation); |
138 orientationSupported = "supported"; | 164 orientationSupported = "supported"; |
139 } | 165 } |
140 document.getElementById("orientationSupported").innerHTML = orientationSup ported; | 166 document.getElementById("orientationSupported").innerHTML = orientationSup ported; |
141 | 167 |
168 if (window.DeviceLightEvent) { | |
169 window.addEventListener('devicelight', onLight); | |
170 lightSupported = "supported"; | |
171 } | |
172 document.getElementById("lightSupported").innerHTML = lightSupported; | |
173 | |
142 setInterval(function(){updateMeasurements()}, updateIntervalDelaySec*1000) ; | 174 setInterval(function(){updateMeasurements()}, updateIntervalDelaySec*1000) ; |
143 | 175 |
144 </script> | 176 </script> |
145 | 177 |
146 </body> | 178 </body> |
147 </html> | 179 </html> |
OLD | NEW |