From: Adam Szczerbiak Date: Wed, 20 Jan 2016 10:10:40 +0000 (+0100) Subject: [JIRA #937] setChangeListener() fix X-Git-Tag: tizen_3.0/TD_SYNC/20161201~184^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fe4b00f6905f2411541657fdc5daccc56e9b8375;p=sdk%2Fonline-doc.git [JIRA #937] setChangeListener() fix Documentation update to reflect a new signature of setChangeListener() method. Change-Id: Ia26de852b30f553101a7edab072240e9df2c61cf Signed-off-by: Adam Szczerbiak --- diff --git a/org.tizen.tutorials/html/web/tizen/system/sensor_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/system/sensor_tutorial_w.htm index 37bf695..fb3ae96 100644 --- a/org.tizen.tutorials/html/web/tizen/system/sensor_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/system/sensor_tutorial_w.htm @@ -130,7 +130,7 @@ lightSensor.start(onsuccessCB);
  • Register a change listener to be called when the sensor data changes.

    To register a change listener, use the setChangeListener() method of the Sensor interface (in mobile and wearable applications).

    -

    Whenever the sensor readout changes, the registered event handler is called and a SensorData object (in mobile and wearable applications) is passed to the listener.

    +

    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 <10, 1000> inclusively. For example, setting an interval to 100 results in approximately 10 events being send every second.

    var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY");
     
     function onsuccessCB()
    @@ -143,8 +143,26 @@ function onchangedCB(sensorData)
        console.log("proximity distance: " + sensorData.proximityState);
     }
     
    +proximitySensor.setChangeListener(onchangedCB, 500);
    +proximitySensor.start(onsuccessCB);
    +The default value of interval parameter is 100. If you do not pass an interval value, a default one will be used: +
    var lightSensor = tizen.sensorservice.getDefaultSensor("LIGHT");
    +
    +function onsuccessCB()
    +{
    +   console.log("Light sensor service has started successfully.");
    +}
    +
    +function onchangedCB(sensorData)
    +{
    +   console.log("Light sensor data: " + sensorData.lightLevel);
    +}
    +
    +// use the default interval value (100 ms):
     proximitySensor.setChangeListener(onchangedCB);
    +
     proximitySensor.start(onsuccessCB);
    +
  • To stop receiving notifications on sensor data changes, use the unsetChangeListener() method of the Sensor interface. diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/sensor.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/sensor.html index 96aef49..81d18ec 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/sensor.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/sensor.html @@ -107,7 +107,7 @@ For more information about how to use Sensor API, see Sensor void start (SuccessCallback successCallback, optional ErrorCallback? errorCallback)
    void stop ()
    - void setChangeListener (SensorDataSuccessCallback successCallback)
    + void setChangeListener (SensorDataSuccessCallback successCallback, optional long? interval)
    void unsetChangeListener () @@ -408,7 +408,7 @@ The supported sensor types are hardware-dependent.

    To check if the given void stop() raises(WebAPIException); - void setChangeListener(SensorDataSuccessCallback successCallback) raises(WebAPIException); + void setChangeListener(SensorDataSuccessCallback successCallback, optional long? interval) raises(WebAPIException); void unsetChangeListener() raises(WebAPIException); }; @@ -520,7 +520,7 @@ The supported sensor types are hardware-dependent.

    To check if the given
    Registers a change listener to be called when sensor data of the given type changes.
    -
    void setChangeListener(SensorDataSuccessCallback successCallback);
    +
    void setChangeListener(SensorDataSuccessCallback successCallback, optional long? interval);
                  

    Since: @@ -539,6 +539,10 @@ The start() method must be called to turn on the sensor, or the sensor data will successCallback: Callback method to be invoked when the sensor data changes

  • +
  • + interval [optional]: + The period in milliseconds at which events are invoked. Valid values are integers in range <10, 1000> inclusively. The default value is 100. +
  • @@ -554,7 +558,8 @@ The start() method must be called to turn on the sensor, or the sensor data will
    -

    Code example:

     var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY");
    +

    Code example:

    + 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);
    + 

    Code example:

    +
    + 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);
      
    @@ -1540,7 +1564,7 @@ To guarantee that the Heart Rate Monitor application runs on a device with a hea void stop() raises(WebAPIException); - void setChangeListener(SensorDataSuccessCallback successCallback) raises(WebAPIException); + void setChangeListener(SensorDataSuccessCallback successCallback, optional long? interval) raises(WebAPIException); void unsetChangeListener() raises(WebAPIException); }; diff --git a/org.tizen.web.apireference/html/device_api/wearable/tizen/sensor.html b/org.tizen.web.apireference/html/device_api/wearable/tizen/sensor.html index 2bf03ea..c0f8c60 100644 --- a/org.tizen.web.apireference/html/device_api/wearable/tizen/sensor.html +++ b/org.tizen.web.apireference/html/device_api/wearable/tizen/sensor.html @@ -107,7 +107,7 @@ For more information about how to use Sensor API, see Sensor void start (SuccessCallback successCallback, optional ErrorCallback? errorCallback)
    void stop ()
    - void setChangeListener (SensorDataSuccessCallback successCallback)
    + void setChangeListener (SensorDataSuccessCallback successCallback, optional long? interval)
    void unsetChangeListener () @@ -408,7 +408,7 @@ The supported sensor types are hardware-dependent.

    To check if the given void stop() raises(WebAPIException); - void setChangeListener(SensorDataSuccessCallback successCallback) raises(WebAPIException); + void setChangeListener(SensorDataSuccessCallback successCallback, optional long? interval) raises(WebAPIException); void unsetChangeListener() raises(WebAPIException); }; @@ -520,7 +520,7 @@ The supported sensor types are hardware-dependent.

    To check if the given
    Registers a change listener to be called when sensor data of the given type changes.
    -
    void setChangeListener(SensorDataSuccessCallback successCallback);
    +
    void setChangeListener(SensorDataSuccessCallback successCallback, optional long? interval);
                  

    Since: @@ -538,7 +538,11 @@ The start() method must be called to turn on the sensor, or the sensor data will

  • successCallback: Callback method to be invoked when the sensor data changes -
  • + +
  • +interval [optional]: +The period in milliseconds at which events are invoked. Valid values are integers in range <10, 1000> inclusively. The default value is 100. +
  • @@ -553,8 +557,10 @@ The start() method must be called to turn on the sensor, or the sensor data will
    -
    -

    Code example:

     var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY");
    +
    +
    +

    Code example:

    + 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);
    + 
    +

    Code example:

    + 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);
      
    +
    unsetChangeListener @@ -1540,7 +1566,7 @@ To guarantee that the Heart Rate Monitor application runs on a device with a hea void stop() raises(WebAPIException); - void setChangeListener(SensorDataSuccessCallback successCallback) raises(WebAPIException); + void setChangeListener(SensorDataSuccessCallback successCallback, optional long? interval) raises(WebAPIException); void unsetChangeListener() raises(WebAPIException); };