..
 #############################################################
 # This file was automatically generated on 2015-05-08.      #
 #                                                           #
 # If you have a bugfix for this file and want to commit it, #
 # please fix the bug in the generator. You can find a link  #
 # to the generators git repository on tinkerforge.com       #
 #############################################################

:orphan:
:breadcrumbs: <a href="../../index.html">Home</a> / <a href="../../index.html#software-javascript">Software</a> / JavaScript - Laser Range Finder Bricklet

.. |device_identifier_constant| replace:: There is also a :ref:`constant <laser_range_finder_bricklet_javascript_constants>` for the device identifier of this Bricklet.

.. _laser_range_finder_bricklet_javascript:

JavaScript - Laser Range Finder Bricklet
========================================

.. note::
 This Bricklet is currently in the prototype stage and the software/hardware
 as well as the documentation is in an incomplete state.


This is the description of the :ref:`JavaScript API bindings <api_bindings_javascript>` for the :ref:`Laser Range Finder Bricklet <laser_range_finder_bricklet>`. General information and technical
specifications for the Laser Range Finder Bricklet are summarized in its :ref:`hardware description
<laser_range_finder_bricklet_description>`.

An :ref:`installation guide <api_bindings_javascript_install>` for the JavaScript API
bindings is part of their general description.

.. _laser_range_finder_bricklet_javascript_examples:


Examples
--------

The example code below is `Public Domain (CC0 1.0)
<http://creativecommons.org/publicdomain/zero/1.0/>`__.

Simple (Node.js)
^^^^^^^^^^^^^^^^

`Download (ExampleSimple.js) <https://github.com/Tinkerforge/laser-range-finder-bricklet/raw/master/software/examples/javascript/ExampleSimple.js>`__

.. literalinclude:: LaserRangeFinder_Bricklet_JavaScript_ExampleSimple.js
 :language: javascript
 :linenos:
 :tab-width: 4

Callback (Node.js)
^^^^^^^^^^^^^^^^^^

`Download (ExampleCallback.js) <https://github.com/Tinkerforge/laser-range-finder-bricklet/raw/master/software/examples/javascript/ExampleCallback.js>`__

.. literalinclude:: LaserRangeFinder_Bricklet_JavaScript_ExampleCallback.js
 :language: javascript
 :linenos:
 :tab-width: 4

Threshold (Node.js)
^^^^^^^^^^^^^^^^^^^

`Download (ExampleThreshold.js) <https://github.com/Tinkerforge/laser-range-finder-bricklet/raw/master/software/examples/javascript/ExampleThreshold.js>`__

.. literalinclude:: LaserRangeFinder_Bricklet_JavaScript_ExampleThreshold.js
 :language: javascript
 :linenos:
 :tab-width: 4

Simple (HTML)
^^^^^^^^^^^^^

`Download (ExampleSimple.html) <https://github.com/Tinkerforge/laser-range-finder-bricklet/raw/master/software/examples/javascript/ExampleSimple.html>`__, `Test (ExampleSimple.html) <http://www.tinkerforge.com/en/doc/Software/Examples/JavaScript/LaserRangeFinder_Bricklet_JavaScript_ExampleSimple.html>`__

.. literalinclude:: LaserRangeFinder_Bricklet_JavaScript_ExampleSimple.html
 :language: html
 :linenos:
 :tab-width: 4

Threshold (HTML)
^^^^^^^^^^^^^^^^

`Download (ExampleThreshold.html) <https://github.com/Tinkerforge/laser-range-finder-bricklet/raw/master/software/examples/javascript/ExampleThreshold.html>`__, `Test (ExampleThreshold.html) <http://www.tinkerforge.com/en/doc/Software/Examples/JavaScript/LaserRangeFinder_Bricklet_JavaScript_ExampleThreshold.html>`__

.. literalinclude:: LaserRangeFinder_Bricklet_JavaScript_ExampleThreshold.html
 :language: html
 :linenos:
 :tab-width: 4

Callback (HTML)
^^^^^^^^^^^^^^^

`Download (ExampleCallback.html) <https://github.com/Tinkerforge/laser-range-finder-bricklet/raw/master/software/examples/javascript/ExampleCallback.html>`__, `Test (ExampleCallback.html) <http://www.tinkerforge.com/en/doc/Software/Examples/JavaScript/LaserRangeFinder_Bricklet_JavaScript_ExampleCallback.html>`__

.. literalinclude:: LaserRangeFinder_Bricklet_JavaScript_ExampleCallback.html
 :language: html
 :linenos:
 :tab-width: 4

.. _laser_range_finder_bricklet_javascript_api:

API
---

Generally, every method of the JavaScript bindings can take two optional
parameters, ``returnCallback`` and ``errorCallback``. These are two user
defined callback functions. The ``returnCallback`` is called with the return
values as parameters, if the method returns something. The ``errorCallback``
is called with an error code in case of an error. The error code can be one
of the following values:

* IPConnection.ERROR_ALREADY_CONNECTED = 11
* IPConnection.ERROR_NOT_CONNECTED = 12
* IPConnection.ERROR_CONNECT_FAILED = 13
* IPConnection.ERROR_INVALID_FUNCTION_ID = 21
* IPConnection.ERROR_TIMEOUT = 31
* IPConnection.ERROR_INVALID_PARAMETER = 41
* IPConnection.ERROR_FUNCTION_NOT_SUPPORTED = 42
* IPConnection.ERROR_UNKNOWN_ERROR = 43

The namespace for the JavaScript bindings is ``Tinkerforge.*``.




Basic Functions
^^^^^^^^^^^^^^^


.. javascript:function:: new BrickletLaserRangeFinder(uid, ipcon)

 :param uid: string
 :param ipcon: IPConnection

 Creates an object with the unique device ID ``uid``:

 .. code-block:: javascript

    var laserRangeFinder = new BrickletLaserRangeFinder("YOUR_DEVICE_UID", ipcon);

 This object can then be used after the IP Connection is connected
 (see examples :ref:`above <laser_range_finder_bricklet_javascript_examples>`).


.. javascript:function:: BrickletLaserRangeFinder.getDistance([returnCallback], [errorCallback])


 :return distance: int

 Returns the measured distance. The value has a range of 0 to 4000
 and is given in cm.
 
 The Laser Range Finder Bricklet knows different modes. Distances
 are only measured in the distance measurement mode,
 see :javascript:func:`setMode() <BrickletLaserRangeFinder.setMode>`. Also the laser has to be enabled, see
 :javascript:func:`enableLaser() <BrickletLaserRangeFinder.enableLaser>`.
 
 If you want to get the distance periodically, it is recommended to
 use the callback :javascript:attr:`CALLBACK_DISTANCE <BrickletLaserRangeFinder.CALLBACK_DISTANCE>` and set the period with 
 :javascript:func:`setDistanceCallbackPeriod() <BrickletLaserRangeFinder.setDistanceCallbackPeriod>`.
 
.. javascript:function:: BrickletLaserRangeFinder.getVelocity([returnCallback], [errorCallback])


 :return velocity: int

 Returns the measured velocity. The value has a range of 0 to 12700
 and is given in 1/100 m/s.
 
 The Laser Range Finder Bricklet knows different modes. Velocity 
 is only measured in the velocity measurement modes, 
 see :javascript:func:`setMode() <BrickletLaserRangeFinder.setMode>`. Also the laser has to be enabled, see
 :javascript:func:`enableLaser() <BrickletLaserRangeFinder.enableLaser>`.
 
 If you want to get the velocity periodically, it is recommended to
 use the callback :javascript:attr:`CALLBACK_VELOCITY <BrickletLaserRangeFinder.CALLBACK_VELOCITY>` and set the period with 
 :javascript:func:`setVelocityCallbackPeriod() <BrickletLaserRangeFinder.setVelocityCallbackPeriod>`.
 
.. javascript:function:: BrickletLaserRangeFinder.setMode(mode, [returnCallback], [errorCallback])

 :param mode: int

 :noreturn: undefined

 The LIDAR has five different modes. One mode is for distance
 measurements and four modes are for velocity measurements with
 different ranges.
 
 The following modes are available:
 
 * 0: Distance is measured with resolution 1.0 cm and range 0-400 cm
 * 1: Velocity is measured with resolution 0.1 m/s and range is 0-12.7 m/s
 * 2: Velocity is measured with resolution 0.25 m/s and range is 0-31.75 m/s
 * 3: Velocity is measured with resolution 0.5 m/s and range is 0-63.5 m/s
 * 4: Velocity is measured with resolution 1.0 m/s and range is 0-127 m/s
 
 The default mode is 0 (distance is measured).
 
 The following constants are available for this function:
 
 * BrickletLaserRangeFinder.MODE_DISTANCE = 0
 * BrickletLaserRangeFinder.MODE_VELOCITY_MAX_13MS = 1
 * BrickletLaserRangeFinder.MODE_VELOCITY_MAX_32MS = 2
 * BrickletLaserRangeFinder.MODE_VELOCITY_MAX_64MS = 3
 * BrickletLaserRangeFinder.MODE_VELOCITY_MAX_127MS = 4
 
.. javascript:function:: BrickletLaserRangeFinder.getMode([returnCallback], [errorCallback])


 :return mode: int

 Returns the mode as set by :javascript:func:`setMode() <BrickletLaserRangeFinder.setMode>`.
 
 The following constants are available for this function:
 
 * BrickletLaserRangeFinder.MODE_DISTANCE = 0
 * BrickletLaserRangeFinder.MODE_VELOCITY_MAX_13MS = 1
 * BrickletLaserRangeFinder.MODE_VELOCITY_MAX_32MS = 2
 * BrickletLaserRangeFinder.MODE_VELOCITY_MAX_64MS = 3
 * BrickletLaserRangeFinder.MODE_VELOCITY_MAX_127MS = 4
 
.. javascript:function:: BrickletLaserRangeFinder.enableLaser([returnCallback], [errorCallback])


 :noreturn: undefined

 Activates the laser of the LIDAR.
 
 We recommend that you wait 250ms after enabling the laser before
 the first call of :javascript:func:`getDistance() <BrickletLaserRangeFinder.getDistance>` to ensure stable measurements.
 
.. javascript:function:: BrickletLaserRangeFinder.disableLaser([returnCallback], [errorCallback])


 :noreturn: undefined

 Deactivates the laser of the LIDAR.
 
.. javascript:function:: BrickletLaserRangeFinder.isLaserEnabled([returnCallback], [errorCallback])


 :return laserEnabled: boolean

 Returns *true* if the laser is enabled, *false* otherwise.
 


Advanced Functions
^^^^^^^^^^^^^^^^^^

.. javascript:function:: BrickletLaserRangeFinder.setMovingAverage(distanceAverageLength, velocityAverageLength, [returnCallback], [errorCallback])

 :param distanceAverageLength: int
 :param velocityAverageLength: int

 :noreturn: undefined

 Sets the length of a `moving averaging <http://en.wikipedia.org/wiki/Moving_average>`__ 
 for the distance and velocity.
 
 Setting the length to 0 will turn the averaging completely off. With less
 averaging, there is more noise on the data.
 
 The range for the averaging is 0-30.
 
 The default value is 10.
 
.. javascript:function:: BrickletLaserRangeFinder.getMovingAverage([returnCallback], [errorCallback])


 :return distanceAverageLength: int
 :return velocityAverageLength: int

 Returns the length moving average as set by :javascript:func:`setMovingAverage() <BrickletLaserRangeFinder.setMovingAverage>`.
 
.. javascript:function:: BrickletLaserRangeFinder.getAPIVersion()

 :rtype: [int, int, int]

 Returns the version of the API definition (major, minor, revision) implemented
 by this API bindings. This is neither the release version of this API bindings
 nor does it tell you anything about the represented Brick or Bricklet.
 
.. javascript:function:: BrickletLaserRangeFinder.getResponseExpected(functionId, [errorCallback])

 :param functionId: int
 :rtype: boolean

 Returns the response expected flag for the function specified by the function
 ID parameter. It is *true* if the function is expected to send a response,
 *false* otherwise.
 
 For getter functions this is enabled by default and cannot be disabled,
 because those functions will always send a response. For callback configuration
 functions it is enabled by default too, but can be disabled by
 :javascript:func:`setResponseExpected() <BrickletLaserRangeFinder.setResponseExpected>`. For setter functions it is disabled by default
 and can be enabled.
 
 Enabling the response expected flag for a setter function allows to detect
 timeouts and other error conditions calls of this setter as well. The
 device will then send a response for this purpose. If this flag is disabled for
 a setter function then no response is send and errors are silently ignored,
 because they cannot be detected.
 
 See :javascript:func:`setResponseExpected() <BrickletLaserRangeFinder.setResponseExpected>`
 for the list of function ID constants available for this function.
 
.. javascript:function:: BrickletLaserRangeFinder.setResponseExpected(functionId, responseExpected, [errorCallback])

 :param functionId: int
 :param responseExpected: boolean

 Changes the response expected flag of the function specified by the
 function ID parameter. This flag can only be changed for setter (default value:
 *false*) and callback configuration functions (default value: *true*). For
 getter functions it is always enabled and callbacks it is always disabled.
 
 Enabling the response expected flag for a setter function allows to detect
 timeouts and other error conditions calls of this setter as well. The
 device will then send a response for this purpose. If this flag is disabled for
 a setter function then no response is send and errors are silently ignored,
 because they cannot be detected.
 
 The following function ID constants are available for this function:
 
 * BrickletLaserRangeFinder.FUNCTION_SET_DISTANCE_CALLBACK_PERIOD = 3
 * BrickletLaserRangeFinder.FUNCTION_SET_VELOCITY_CALLBACK_PERIOD = 5
 * BrickletLaserRangeFinder.FUNCTION_SET_DISTANCE_CALLBACK_THRESHOLD = 7
 * BrickletLaserRangeFinder.FUNCTION_SET_VELOCITY_CALLBACK_THRESHOLD = 9
 * BrickletLaserRangeFinder.FUNCTION_SET_DEBOUNCE_PERIOD = 11
 * BrickletLaserRangeFinder.FUNCTION_SET_MOVING_AVERAGE = 13
 * BrickletLaserRangeFinder.FUNCTION_SET_MODE = 15
 * BrickletLaserRangeFinder.FUNCTION_ENABLE_LASER = 17
 * BrickletLaserRangeFinder.FUNCTION_DISABLE_LASER = 18
 
.. javascript:function:: BrickletLaserRangeFinder.setResponseExpectedAll(responseExpected)

 :param responseExpected: boolean

 Changes the response expected flag for all setter and callback configuration
 functions of this device at once.
 
.. javascript:function:: BrickletLaserRangeFinder.getIdentity([returnCallback], [errorCallback])


 :return uid: string
 :return connectedUid: string
 :return position: char
 :return hardwareVersion: [int, int, int]
 :return firmwareVersion: [int, int, int]
 :return deviceIdentifier: int

 Returns the UID, the UID where the Bricklet is connected to, 
 the position, the hardware and firmware version as well as the
 device identifier.
 
 The position can be 'a', 'b', 'c' or 'd'.
 
 The device identifier numbers can be found :ref:`here <device_identifier>`.
 |device_identifier_constant|
 


Callback Configuration Functions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


.. javascript:function:: BrickletLaserRangeFinder.on(id, callback)

 :param id: int
 :param callback: function

 Registers a callback with ID *id* to the function *callback*. The available
 IDs with corresponding function signatures are listed
 :ref:`below <laser_range_finder_bricklet_javascript_callbacks>`.


.. javascript:function:: BrickletLaserRangeFinder.setDistanceCallbackPeriod(period, [returnCallback], [errorCallback])

 :param period: int

 :noreturn: undefined

 Sets the period in ms with which the :javascript:attr:`CALLBACK_DISTANCE <BrickletLaserRangeFinder.CALLBACK_DISTANCE>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
 :javascript:attr:`CALLBACK_DISTANCE <BrickletLaserRangeFinder.CALLBACK_DISTANCE>` is only triggered if the distance value has changed since the
 last triggering.
 
 The default value is 0.
 
.. javascript:function:: BrickletLaserRangeFinder.getDistanceCallbackPeriod([returnCallback], [errorCallback])


 :return period: int

 Returns the period as set by :javascript:func:`setDistanceCallbackPeriod() <BrickletLaserRangeFinder.setDistanceCallbackPeriod>`.
 
.. javascript:function:: BrickletLaserRangeFinder.setVelocityCallbackPeriod(period, [returnCallback], [errorCallback])

 :param period: int

 :noreturn: undefined

 Sets the period in ms with which the :javascript:attr:`CALLBACK_VELOCITY <BrickletLaserRangeFinder.CALLBACK_VELOCITY>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
 :javascript:attr:`CALLBACK_VELOCITY <BrickletLaserRangeFinder.CALLBACK_VELOCITY>` is only triggered if the velocity value has changed since the
 last triggering.
 
 The default value is 0.
 
.. javascript:function:: BrickletLaserRangeFinder.getVelocityCallbackPeriod([returnCallback], [errorCallback])


 :return period: int

 Returns the period as set by :javascript:func:`setVelocityCallbackPeriod() <BrickletLaserRangeFinder.setVelocityCallbackPeriod>`.
 
.. javascript:function:: BrickletLaserRangeFinder.setDistanceCallbackThreshold(option, min, max, [returnCallback], [errorCallback])

 :param option: char
 :param min: int
 :param max: int

 :noreturn: undefined

 Sets the thresholds for the :javascript:attr:`CALLBACK_DISTANCE_REACHED <BrickletLaserRangeFinder.CALLBACK_DISTANCE_REACHED>` callback. 
 
 The following options are possible:
 
 .. csv-table::
  :header: "Option", "Description"
  :widths: 10, 100
 
  "'x'",    "Callback is turned off"
  "'o'",    "Callback is triggered when the distance value is *outside* the min and max values"
  "'i'",    "Callback is triggered when the distance value is *inside* the min and max values"
  "'<'",    "Callback is triggered when the distance value is smaller than the min value (max is ignored)"
  "'>'",    "Callback is triggered when the distance value is greater than the min value (max is ignored)"
 
 The default value is ('x', 0, 0).
 
 The following constants are available for this function:
 
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_OFF = 'x'
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_OUTSIDE = 'o'
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_INSIDE = 'i'
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_SMALLER = '<'
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_GREATER = '>'
 
.. javascript:function:: BrickletLaserRangeFinder.getDistanceCallbackThreshold([returnCallback], [errorCallback])


 :return option: char
 :return min: int
 :return max: int

 Returns the threshold as set by :javascript:func:`setDistanceCallbackThreshold() <BrickletLaserRangeFinder.setDistanceCallbackThreshold>`.
 
 The following constants are available for this function:
 
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_OFF = 'x'
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_OUTSIDE = 'o'
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_INSIDE = 'i'
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_SMALLER = '<'
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_GREATER = '>'
 
.. javascript:function:: BrickletLaserRangeFinder.setVelocityCallbackThreshold(option, min, max, [returnCallback], [errorCallback])

 :param option: char
 :param min: int
 :param max: int

 :noreturn: undefined

 Sets the thresholds for the :javascript:attr:`CALLBACK_VELOCITY_REACHED <BrickletLaserRangeFinder.CALLBACK_VELOCITY_REACHED>` callback. 
 
 The following options are possible:
 
 .. csv-table::
  :header: "Option", "Description"
  :widths: 10, 100
 
  "'x'",    "Callback is turned off"
  "'o'",    "Callback is triggered when the velocity is *outside* the min and max values"
  "'i'",    "Callback is triggered when the velocity is *inside* the min and max values"
  "'<'",    "Callback is triggered when the velocity is smaller than the min value (max is ignored)"
  "'>'",    "Callback is triggered when the velocity is greater than the min value (max is ignored)"
 
 The default value is ('x', 0, 0).
 
 The following constants are available for this function:
 
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_OFF = 'x'
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_OUTSIDE = 'o'
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_INSIDE = 'i'
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_SMALLER = '<'
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_GREATER = '>'
 
.. javascript:function:: BrickletLaserRangeFinder.getVelocityCallbackThreshold([returnCallback], [errorCallback])


 :return option: char
 :return min: int
 :return max: int

 Returns the threshold as set by :javascript:func:`setVelocityCallbackThreshold() <BrickletLaserRangeFinder.setVelocityCallbackThreshold>`.
 
 The following constants are available for this function:
 
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_OFF = 'x'
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_OUTSIDE = 'o'
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_INSIDE = 'i'
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_SMALLER = '<'
 * BrickletLaserRangeFinder.THRESHOLD_OPTION_GREATER = '>'
 
.. javascript:function:: BrickletLaserRangeFinder.setDebouncePeriod(debounce, [returnCallback], [errorCallback])

 :param debounce: int

 :noreturn: undefined

 Sets the period in ms with which the threshold callbacks
 
 * :javascript:attr:`CALLBACK_DISTANCE_REACHED <BrickletLaserRangeFinder.CALLBACK_DISTANCE_REACHED>`,
 * :javascript:attr:`CALLBACK_VELOCITY_REACHED <BrickletLaserRangeFinder.CALLBACK_VELOCITY_REACHED>`,
 
 are triggered, if the thresholds
 
 * :javascript:func:`setDistanceCallbackThreshold() <BrickletLaserRangeFinder.setDistanceCallbackThreshold>`,
 * :javascript:func:`setVelocityCallbackThreshold() <BrickletLaserRangeFinder.setVelocityCallbackThreshold>`,
 
 keep being reached.
 
 The default value is 100.
 
.. javascript:function:: BrickletLaserRangeFinder.getDebouncePeriod([returnCallback], [errorCallback])


 :return debounce: int

 Returns the debounce period as set by :javascript:func:`setDebouncePeriod() <BrickletLaserRangeFinder.setDebouncePeriod>`.
 


.. _laser_range_finder_bricklet_javascript_callbacks:

Callbacks
^^^^^^^^^

Callbacks can be registered to receive
time critical or recurring data from the device. The registration is done
with the :javascript:func:`on() <BrickletLaserRangeFinder.on>` function of
the device object. The first parameter is the callback ID and the second
parameter the callback function:

.. code-block:: javascript

    laserRangeFinder.on(BrickletLaserRangeFinder.CALLBACK_EXAMPLE,
        function (param) {
            console.log(param);
        }
    );

The available constants with inherent number and type of parameters are
described below.

.. note::
 Using callbacks for recurring events is *always* preferred
 compared to using getters. It will use less USB bandwidth and the latency
 will be a lot better, since there is no round trip time.

.. javascript:attribute:: BrickletLaserRangeFinder.CALLBACK_DISTANCE

 :param distance: int


 This callback is triggered periodically with the period that is set by
 :javascript:func:`setDistanceCallbackPeriod() <BrickletLaserRangeFinder.setDistanceCallbackPeriod>`. The parameter is the distance value
 of the sensor.
 
 :javascript:attr:`CALLBACK_DISTANCE <BrickletLaserRangeFinder.CALLBACK_DISTANCE>` is only triggered if the distance value has changed since the
 last triggering.
 
.. javascript:attribute:: BrickletLaserRangeFinder.CALLBACK_VELOCITY

 :param velocity: int


 This callback is triggered periodically with the period that is set by
 :javascript:func:`setVelocityCallbackPeriod() <BrickletLaserRangeFinder.setVelocityCallbackPeriod>`. The parameter is the velocity value
 of the sensor.
 
 :javascript:attr:`CALLBACK_VELOCITY <BrickletLaserRangeFinder.CALLBACK_VELOCITY>` is only triggered if the velocity has changed since the
 last triggering.
 
.. javascript:attribute:: BrickletLaserRangeFinder.CALLBACK_DISTANCE_REACHED

 :param distance: int


 This callback is triggered when the threshold as set by
 :javascript:func:`setDistanceCallbackThreshold() <BrickletLaserRangeFinder.setDistanceCallbackThreshold>` is reached.
 The parameter is the distance value of the sensor.
 
 If the threshold keeps being reached, the callback is triggered periodically
 with the period as set by :javascript:func:`setDebouncePeriod() <BrickletLaserRangeFinder.setDebouncePeriod>`.
 
.. javascript:attribute:: BrickletLaserRangeFinder.CALLBACK_VELOCITY_REACHED

 :param velocity: int


 This callback is triggered when the threshold as set by
 :javascript:func:`setVelocityCallbackThreshold() <BrickletLaserRangeFinder.setVelocityCallbackThreshold>` is reached.
 The parameter is the velocity value of the sensor.
 
 If the threshold keeps being reached, the callback is triggered periodically
 with the period as set by :javascript:func:`setDebouncePeriod() <BrickletLaserRangeFinder.setDebouncePeriod>`.
 


.. _laser_range_finder_bricklet_javascript_constants:

Constants
^^^^^^^^^

.. javascript:attribute:: BrickletLaserRangeFinder.DEVICE_IDENTIFIER

 This constant is used to identify a Laser Range Finder Bricklet.

 The :javascript:func:`getIdentity() <BrickletLaserRangeFinder.getIdentity>` function and the
 :javascript:attr:`CALLBACK_ENUMERATE <IPConnection.CALLBACK_ENUMERATE>`
 callback of the IP Connection have a ``device_identifier`` parameter to specify
 the Brick's or Bricklet's type.

