[JIRA #937] setChangeListener() fix
authorAdam Szczerbiak <a.szczerbiak@samsung.com>
Wed, 20 Jan 2016 10:10:40 +0000 (11:10 +0100)
committerAdam Szczerbiak <a.szczerbiak@samsung.com>
Mon, 25 Jan 2016 13:40:46 +0000 (14:40 +0100)
Documentation update to reflect a new signature of
setChangeListener() method.

Change-Id: Ia26de852b30f553101a7edab072240e9df2c61cf
Signed-off-by: Adam Szczerbiak <a.szczerbiak@samsung.com>
org.tizen.tutorials/html/web/tizen/system/sensor_tutorial_w.htm
org.tizen.web.apireference/html/device_api/mobile/tizen/sensor.html
org.tizen.web.apireference/html/device_api/wearable/tizen/sensor.html

index 37bf695..fb3ae96 100644 (file)
@@ -130,7 +130,7 @@ lightSensor.start(onsuccessCB);
 
 <li>Register a change listener to be called when the sensor data changes.
 <p>To register a  change listener, use the <span style="font-family: Courier New,Courier,monospace">setChangeListener()</span> method of the <span style="font-family: Courier New,Courier,monospace">Sensor</span> interface (in <a href="../../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/sensor.html#Sensor">mobile</a> and <a href="../../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/sensor.html#Sensor">wearable</a> applications).</p>
-<p>Whenever the sensor readout changes, the registered event handler is called and a <span style="font-family: Courier New,Courier,monospace">SensorData</span> object (in <a href="../../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/sensor.html#SensorData">mobile</a> and <a href="../../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/sensor.html#SensorData">wearable</a> applications) is passed to the listener.</p>
+<p>This command requires two parameters. The first one is a handle to the callback method, which will be invoked for every incoming event. The second argument determines the amount of time (in milliseconds) passing between two consecutive events. Valid values are integers in range &lt;10, 1000&gt; inclusively. For example, setting an <span style="font-family: Courier New,Courier,monospace">interval</span> to 100 results in approximately 10 events being send every second.</p>
 <pre class="prettyprint">var proximitySensor = tizen.sensorservice.getDefaultSensor(&quot;PROXIMITY&quot;);
 
 function onsuccessCB()
@@ -143,8 +143,26 @@ function onchangedCB(sensorData)
 &nbsp;&nbsp;&nbsp;console.log(&quot;proximity distance: &quot; + sensorData.proximityState);
 }
 
+proximitySensor.setChangeListener(onchangedCB, 500);
+proximitySensor.start(onsuccessCB);</pre>
+The default value of <span style="font-family: Courier New,Courier,monospace">interval</span> parameter is 100. If you do not pass an <span style="font-family: Courier New,Courier,monospace">interval</span> value, a default one will be used:
+<pre class="prettyprint">var lightSensor = tizen.sensorservice.getDefaultSensor(&quot;LIGHT&quot;);
+
+function onsuccessCB()
+{
+&nbsp;&nbsp;&nbsp;console.log(&quot;Light sensor service has started successfully.&quot;);
+}
+
+function onchangedCB(sensorData)
+{
+&nbsp;&nbsp;&nbsp;console.log(&quot;Light sensor data: &quot; + sensorData.lightLevel);
+}
+
+&sol;&sol; use the default interval value (100 ms):
 proximitySensor.setChangeListener(onchangedCB);
+
 proximitySensor.start(onsuccessCB);</pre>
+
 </li>
 
 <li>To stop receiving notifications on sensor data changes, use the <span style="font-family: Courier New,Courier,monospace">unsetChangeListener()</span> method of the Sensor interface.
index 96aef49..81d18ec 100644 (file)
@@ -107,7 +107,7 @@ For more information about how to use Sensor API, see <a href="../../../../../or
 <td><a href="#Sensor">Sensor</a></td>
 <td>void <a href="#Sensor::start">start</a> (<a href="tizen.html#SuccessCallback">SuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)<br>
     void <a href="#Sensor::stop">stop</a> ()<br>
-    void <a href="#Sensor::setChangeListener">setChangeListener</a> (<a href="#SensorDataSuccessCallback">SensorDataSuccessCallback</a> successCallback)<br>
+    void <a href="#Sensor::setChangeListener">setChangeListener</a> (<a href="#SensorDataSuccessCallback">SensorDataSuccessCallback</a> successCallback, optional long? interval)<br>
     void <a href="#Sensor::unsetChangeListener">unsetChangeListener</a> ()</td>
 </tr>
 <tr>
@@ -408,7 +408,7 @@ The supported sensor types are hardware-dependent. <br><br>To check if the given
 
         void stop() raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
 
-        void setChangeListener(<a href="#SensorDataSuccessCallback">SensorDataSuccessCallback</a> successCallback) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
+        void setChangeListener(<a href="#SensorDataSuccessCallback">SensorDataSuccessCallback</a> successCallback, optional long? interval) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
 
         void unsetChangeListener() raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
     };</pre>
@@ -520,7 +520,7 @@ The supported sensor types are hardware-dependent. <br><br>To check if the given
 <div class="brief">
  Registers a change listener to be called when sensor data of the given type changes.
             </div>
-<div class="synopsis"><pre class="signature prettyprint">void setChangeListener(<a href="#SensorDataSuccessCallback">SensorDataSuccessCallback</a> successCallback);
+<div class="synopsis"><pre class="signature prettyprint">void setChangeListener(<a href="#SensorDataSuccessCallback">SensorDataSuccessCallback</a> successCallback, optional long? interval);
              </pre></div>
 <p><span class="version">
             Since: </span>
@@ -539,6 +539,10 @@ The start() method must be called to turn on the sensor, or the sensor data will
 <span class="name">successCallback</span>: 
  Callback method to be invoked when the sensor data changes
                 </li>
+          <li class="param">
+            <span class="name">interval</span> <span class="optional">[optional]</span>:
+ The period in milliseconds at which events are invoked. Valid values are integers in range &lt;10, 1000&gt; inclusively. The default value is 100.
+          </li>
         </ul>
 </div>
 <div class="exceptionlist">
@@ -554,7 +558,8 @@ The start() method must be called to turn on the sensor, or the sensor data will
 </li></ul>
         </div>
 <div class="example">
-<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY");
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
+ var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY");
 
  function onsuccessCB() {
      console.log("proximity sensor start");
@@ -564,9 +569,28 @@ The start() method must be called to turn on the sensor, or the sensor data will
      console.log("proximity distance : " + sensorData.proximityState);
  }
 
+ // order to receive proximity sensor data every 100 ms (default value):
  proximitySensor.setChangeListener(onchangedCB);
 
+ // start the sensor service to begin receiving events:
  proximitySensor.start(onsuccessCB);
+ </div><div class="example"><span class="example"><p>Code example:</p></span>
+ <pre name="code" class="examplecode prettyprint">
+ var lightSensor = tizen.sensorservice.getDefaultSensor("LIGHT");
+
+ function onSuccessCB() {
+   console.log("Light sensor service has started.");
+ }
+
+ function onChangedCB(sensorData) {
+   console.log("Current light level: " + sensorData.lightLevel);
+ }
+
+ // order to receive light sensor data every 500 ms:
+ lightSensor.setChangeListener(onChangedCB, 500);
+
+ // start the sensor service to begin receiving events:
+ lightSensor.start(onSuccessCB);
  </pre>
 </div>
 </dd>
@@ -1540,7 +1564,7 @@ To guarantee that the Heart Rate Monitor application runs on a device with a hea
 
         void stop() raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
 
-        void setChangeListener(<a href="#SensorDataSuccessCallback">SensorDataSuccessCallback</a> successCallback) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
+        void setChangeListener(<a href="#SensorDataSuccessCallback">SensorDataSuccessCallback</a> successCallback, optional long? interval) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
 
         void unsetChangeListener() raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
     };
index 2bf03ea..c0f8c60 100644 (file)
@@ -107,7 +107,7 @@ For more information about how to use Sensor API, see <a href="../../../../../or
 <td><a href="#Sensor">Sensor</a></td>
 <td>void <a href="#Sensor::start">start</a> (<a href="tizen.html#SuccessCallback">SuccessCallback</a> successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback)<br>
     void <a href="#Sensor::stop">stop</a> ()<br>
-    void <a href="#Sensor::setChangeListener">setChangeListener</a> (<a href="#SensorDataSuccessCallback">SensorDataSuccessCallback</a> successCallback)<br>
+    void <a href="#Sensor::setChangeListener">setChangeListener</a> (<a href="#SensorDataSuccessCallback">SensorDataSuccessCallback</a> successCallback, optional long? interval)<br>
     void <a href="#Sensor::unsetChangeListener">unsetChangeListener</a> ()</td>
 </tr>
 <tr>
@@ -408,7 +408,7 @@ The supported sensor types are hardware-dependent. <br><br>To check if the given
 
         void stop() raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
 
-        void setChangeListener(<a href="#SensorDataSuccessCallback">SensorDataSuccessCallback</a> successCallback) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
+        void setChangeListener(<a href="#SensorDataSuccessCallback">SensorDataSuccessCallback</a> successCallback, optional long? interval) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
 
         void unsetChangeListener() raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
     };</pre>
@@ -520,7 +520,7 @@ The supported sensor types are hardware-dependent. <br><br>To check if the given
 <div class="brief">
  Registers a change listener to be called when sensor data of the given type changes.
             </div>
-<div class="synopsis"><pre class="signature prettyprint">void setChangeListener(<a href="#SensorDataSuccessCallback">SensorDataSuccessCallback</a> successCallback);
+<div class="synopsis"><pre class="signature prettyprint">void setChangeListener(<a href="#SensorDataSuccessCallback">SensorDataSuccessCallback</a> successCallback, optional long? interval);
              </pre></div>
 <p><span class="version">
             Since: </span>
@@ -538,7 +538,11 @@ The start() method must be called to turn on the sensor, or the sensor data will
           <li class="param">
 <span class="name">successCallback</span>:
  Callback method to be invoked when the sensor data changes
-                </li>
+          </li>
+          <li class="param">
+<span class="name">interval</span> <span class="optional">[optional]</span>:
+The period in milliseconds at which events are invoked. Valid values are integers in range &lt;10, 1000&gt; inclusively. The default value is 100.
+          </li>
         </ul>
 </div>
 <div class="exceptionlist">
@@ -553,8 +557,10 @@ The start() method must be called to turn on the sensor, or the sensor data will
 </ul>
 </li></ul>
         </div>
-<div class="example">
-<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY");
+
+
+<div class="example"><span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
+ var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY");
 
  function onsuccessCB() {
      console.log("proximity sensor start");
@@ -564,11 +570,31 @@ The start() method must be called to turn on the sensor, or the sensor data will
      console.log("proximity distance : " + sensorData.proximityState);
  }
 
+ // order to receive proximity sensor data every 100 ms (default value):
  proximitySensor.setChangeListener(onchangedCB);
 
+ // start the sensor service to begin receiving events:
  proximitySensor.start(onsuccessCB);
+ </div>
+ <div class="example"><span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
+ var lightSensor = tizen.sensorservice.getDefaultSensor("LIGHT");
+
+ function onSuccessCB() {
+   console.log("Light sensor service has started.");
+ }
+
+ function onChangedCB(sensorData) {
+   console.log("Current light level: " + sensorData.lightLevel);
+ }
+
+ // order to receive light sensor data every 500 ms:
+ lightSensor.setChangeListener(onChangedCB, 500);
+
+ // start the sensor service to begin receiving events:
+ lightSensor.start(onSuccessCB);
  </pre>
 </div>
+
 </dd>
 <dt class="method" id="Sensor::unsetChangeListener">
 <a class="backward-compatibility-anchor" name="::Sensor::Sensor::unsetChangeListener"></a><code><b><span class="methodName">unsetChangeListener</span></b></code>
@@ -1540,7 +1566,7 @@ To guarantee that the Heart Rate Monitor application runs on a device with a hea
 
         void stop() raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
 
-        void setChangeListener(<a href="#SensorDataSuccessCallback">SensorDataSuccessCallback</a> successCallback) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
+        void setChangeListener(<a href="#SensorDataSuccessCallback">SensorDataSuccessCallback</a> successCallback, optional long? interval) raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
 
         void unsetChangeListener() raises(<a href="tizen.html#WebAPIException">WebAPIException</a>);
     };