..
 #############################################################
 # 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       #
 #############################################################


:breadcrumbs: <a href="../../index.html">Home</a> / <a href="../../index.html#software-labview">Software</a> / LabVIEW - Barometer Bricklet

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

.. _barometer_bricklet_labview:

LabVIEW - Barometer Bricklet
============================

This is the description of the :ref:`LabVIEW API bindings <api_bindings_labview>` for the :ref:`Barometer Bricklet <barometer_bricklet>`. General information and technical
specifications for the Barometer Bricklet are summarized in its :ref:`hardware description
<barometer_bricklet_description>`.

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

.. _barometer_bricklet_labview_examples:


Examples
--------

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

Simple
^^^^^^

`Download (Example Simple.vi) <https://github.com/Tinkerforge/barometer-bricklet/raw/master/software/examples/labview/Example%20Simple.vi>`__

.. image:: /Images/Screenshots/LabVIEW/Barometer_Bricklet_LabVIEW_Example_Simple.vi.png
 :scale: 100 %
 :alt: LabVIEW Simple Example
 :align: center

Threshold
^^^^^^^^^

`Download (Example Threshold.vi) <https://github.com/Tinkerforge/barometer-bricklet/raw/master/software/examples/labview/Example%20Threshold.vi>`__, `Download (Example Threshold - AirPressureReached Callback.vi) <https://github.com/Tinkerforge/barometer-bricklet/raw/master/software/examples/labview/Example%20Threshold%20-%20AirPressureReached%20Callback.vi>`__

.. raw:: html

   <div class="horizontal-image-scroll">

.. image:: /Images/Screenshots/LabVIEW/Barometer_Bricklet_LabVIEW_Example_Threshold.vi.png
 :scale: 100 %
 :alt: LabVIEW Threshold Example
 :align: center

.. raw:: html

   </div>

Callback
^^^^^^^^

`Download (Example Callback.vi) <https://github.com/Tinkerforge/barometer-bricklet/raw/master/software/examples/labview/Example%20Callback.vi>`__, `Download (Example Callback - AirPressure Callback.vi) <https://github.com/Tinkerforge/barometer-bricklet/raw/master/software/examples/labview/Example%20Callback%20-%20AirPressure%20Callback.vi>`__, `Download (Example Callback - Altitude Callback.vi) <https://github.com/Tinkerforge/barometer-bricklet/raw/master/software/examples/labview/Example%20Callback%20-%20Altitude%20Callback.vi>`__

.. raw:: html

   <div class="horizontal-image-scroll">

.. image:: /Images/Screenshots/LabVIEW/Barometer_Bricklet_LabVIEW_Example_Callback.vi.png
 :scale: 100 %
 :alt: LabVIEW Callback Example
 :align: center

.. raw:: html

   </div>

Graph
^^^^^

`Download (Example Graph.vi) <https://github.com/Tinkerforge/barometer-bricklet/raw/master/software/examples/labview/Example%20Graph.vi>`__, `Download (Example Graph - AirPressure Callback.vi) <https://github.com/Tinkerforge/barometer-bricklet/raw/master/software/examples/labview/Example%20Graph%20-%20AirPressure%20Callback.vi>`__

.. raw:: html

   <div class="horizontal-image-scroll">

.. image:: /Images/Screenshots/LabVIEW/Barometer_Bricklet_LabVIEW_Example_Graph.vi.png
 :scale: 100 %
 :alt: LabVIEW Graph Example
 :align: center

.. raw:: html

   </div>

.. _barometer_bricklet_labview_api:

API
---

Generally, every method of the LabVIEW bindings that outputs a value can
report a ``Tinkerforge.TimeoutException``. This error gets reported if the
device did not respond. If a cable based connection is used, it is
unlikely that this exception gets thrown (assuming nobody plugs the
device out). However, if a wireless connection is used, timeouts will occur
if the distance to the device gets too big.

The namespace for all Brick/Bricklet bindings and the IPConnection is
``Tinkerforge.*``.




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


.. labview:function:: BrickletBarometer(uid, ipcon) -> barometer

 :input uid: String
 :input ipcon: .NET Refnum (IPConnection)
 :output barometer: .NET Refnum (BrickletBarometer)

 Creates an object with the unique device ID ``uid``.
 This object can then be used after the IP Connection is connected
 (see examples :ref:`above <barometer_bricklet_labview_examples>`).


.. labview:function:: BrickletBarometer.GetAirPressure() -> airPressure


 :output airPressure: Int32

 Returns the air pressure of the air pressure sensor. The value
 has a range of 10000 to 1200000 and is given in mbar/1000, i.e. a value
 of 1001092 means that an air pressure of 1001.092 mbar is measured.
 
 If you want to get the air pressure periodically, it is recommended to use the
 callback :labview:func:`AirPressure <BrickletBarometer.AirPressure>` and set the period with
 :labview:func:`SetAirPressureCallbackPeriod() <BrickletBarometer.SetAirPressureCallbackPeriod>`.
 
.. labview:function:: BrickletBarometer.GetAltitude() -> altitude


 :output altitude: Int32

 Returns the relative altitude of the air pressure sensor. The value is given in
 cm and is calculated based on the difference between the current air pressure
 and the reference air pressure that can be set with :labview:func:`SetReferenceAirPressure() <BrickletBarometer.SetReferenceAirPressure>`.
 
 If you want to get the altitude periodically, it is recommended to use the
 callback :labview:func:`Altitude <BrickletBarometer.Altitude>` and set the period with
 :labview:func:`SetAltitudeCallbackPeriod() <BrickletBarometer.SetAltitudeCallbackPeriod>`.
 
.. labview:function:: BrickletBarometer.SetReferenceAirPressure(airPressure)

 :input airPressure: Int32

 Sets the reference air pressure in mbar/1000 for the altitude calculation.
 Setting the reference to the current air pressure results in a calculated
 altitude of 0cm. Passing 0 is a shortcut for passing the current air pressure as
 reference.
 
 Well known reference values are the Q codes
 `QNH <http://en.wikipedia.org/wiki/QNH>`__ and
 `QFE <http://en.wikipedia.org/wiki/Mean_sea_level_pressure#Mean_sea_level_pressure>`__
 used in aviation.
 
 The default value is 1013.25mbar.
 
.. labview:function:: BrickletBarometer.GetReferenceAirPressure() -> airPressure


 :output airPressure: Int32

 Returns the reference air pressure as set by :labview:func:`SetReferenceAirPressure() <BrickletBarometer.SetReferenceAirPressure>`.
 


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

.. labview:function:: BrickletBarometer.GetChipTemperature() -> temperature


 :output temperature: Int16

 Returns the temperature of the air pressure sensor. The value
 has a range of -4000 to 8500 and is given in °C/100, i.e. a value
 of 2007 means that a temperature of 20.07 °C is measured.
 
 This temperature is used internally for temperature compensation of the air
 pressure measurement. It is not as accurate as the temperature measured by the
 :ref:`temperature_bricklet` or the :ref:`temperature_ir_bricklet`.
 
.. labview:function:: BrickletBarometer.SetAveraging(movingAveragePressure, averagePressure, averageTemperature)

 :input movingAveragePressure: Byte
 :input averagePressure: Byte
 :input averageTemperature: Byte

 Sets the different averaging parameters. It is possible to set
 the length of a normal averaging for the temperature and pressure,
 as well as an additional length of a 
 `moving average <http://en.wikipedia.org/wiki/Moving_average>`__ 
 for the pressure. The moving average is calculated from the normal 
 averages.  There is no moving average for the temperature.
 
 The maximum length for the pressure average is 10, for the
 temperature average is 255 and for the moving average is 25.
 
 Setting the all three parameters to 0 will turn the averaging
 completely off. If the averaging is off, there is lots of noise
 on the data, but the data is without delay. Thus we recommend
 to turn the averaging off if the Barometer Bricklet data is
 to be used for sensor fusion with other sensors.
 
 The default values are 10 for the normal averages and 25 for the
 moving average.
 
 .. versionadded:: 2.0.1~(Plugin)
 
.. labview:function:: BrickletBarometer.GetAveraging() -> movingAveragePressure, averagePressure, averageTemperature


 :output movingAveragePressure: Byte
 :output averagePressure: Byte
 :output averageTemperature: Byte

 Returns the averaging configuration as set by :labview:func:`SetAveraging() <BrickletBarometer.SetAveraging>`.
 
 .. versionadded:: 2.0.1~(Plugin)
 
.. labview:function:: BrickletBarometer.GetAPIVersion() -> apiVersion


 :output apiVersion: Byte[3]

 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.
 
.. labview:function:: BrickletBarometer.GetResponseExpected(functionId) -> responseExpected

 :input functionId: Byte

 :output responseExpected: 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
 :labview:func:`SetResponseExpected() <BrickletBarometer.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 :labview:func:`SetResponseExpected() <BrickletBarometer.SetResponseExpected>`
 for the list of function ID constants available for this function.
 
.. labview:function:: BrickletBarometer.SetResponseExpected(functionId, responseExpected)

 :input functionId: Byte
 :input 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:
 
 * BrickletBarometer.FUNCTION_SET_AIR_PRESSURE_CALLBACK_PERIOD = 3
 * BrickletBarometer.FUNCTION_SET_ALTITUDE_CALLBACK_PERIOD = 5
 * BrickletBarometer.FUNCTION_SET_AIR_PRESSURE_CALLBACK_THRESHOLD = 7
 * BrickletBarometer.FUNCTION_SET_ALTITUDE_CALLBACK_THRESHOLD = 9
 * BrickletBarometer.FUNCTION_SET_DEBOUNCE_PERIOD = 11
 * BrickletBarometer.FUNCTION_SET_REFERENCE_AIR_PRESSURE = 13
 * BrickletBarometer.FUNCTION_SET_AVERAGING = 20
 
.. labview:function:: BrickletBarometer.SetResponseExpectedAll(responseExpected)

 :input responseExpected: Boolean

 Changes the response expected flag for all setter and callback configuration
 functions of this device at once.
 
.. labview:function:: BrickletBarometer.GetIdentity() -> uid, connectedUid, position, hardwareVersion, firmwareVersion, deviceIdentifier


 :output uid: String
 :output connectedUid: String
 :output position: Char
 :output hardwareVersion: Byte[3]
 :output firmwareVersion: Byte[3]
 :output deviceIdentifier: Int32

 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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



.. labview:function:: BrickletBarometer.SetAirPressureCallbackPeriod(period)

 :input period: Int64

 Sets the period in ms with which the :labview:func:`AirPressure <BrickletBarometer.AirPressure>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
 :labview:func:`AirPressure <BrickletBarometer.AirPressure>` is only triggered if the air pressure has changed since the
 last triggering.
 
 The default value is 0.
 
.. labview:function:: BrickletBarometer.GetAirPressureCallbackPeriod() -> period


 :output period: Int64

 Returns the period as set by :labview:func:`SetAirPressureCallbackPeriod() <BrickletBarometer.SetAirPressureCallbackPeriod>`.
 
.. labview:function:: BrickletBarometer.SetAltitudeCallbackPeriod(period)

 :input period: Int64

 Sets the period in ms with which the :labview:func:`Altitude <BrickletBarometer.Altitude>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
 :labview:func:`Altitude <BrickletBarometer.Altitude>` is only triggered if the altitude has changed since the
 last triggering.
 
 The default value is 0.
 
.. labview:function:: BrickletBarometer.GetAltitudeCallbackPeriod() -> period


 :output period: Int64

 Returns the period as set by :labview:func:`SetAltitudeCallbackPeriod() <BrickletBarometer.SetAltitudeCallbackPeriod>`.
 
.. labview:function:: BrickletBarometer.SetAirPressureCallbackThreshold(option, min, max)

 :input option: Char
 :input min: Int32
 :input max: Int32

 Sets the thresholds for the :labview:func:`AirPressureReached <BrickletBarometer.AirPressureReached>` 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 air pressure is *outside* the min and max values"
  "'i'",    "Callback is triggered when the air pressure is *inside* the min and max values"
  "'<'",    "Callback is triggered when the air pressure is smaller than the min value (max is ignored)"
  "'>'",    "Callback is triggered when the air pressure is greater than the min value (max is ignored)"
 
 The default value is ('x', 0, 0).
 
 The following constants are available for this function:
 
 * BrickletBarometer.THRESHOLD_OPTION_OFF = 'x'
 * BrickletBarometer.THRESHOLD_OPTION_OUTSIDE = 'o'
 * BrickletBarometer.THRESHOLD_OPTION_INSIDE = 'i'
 * BrickletBarometer.THRESHOLD_OPTION_SMALLER = '<'
 * BrickletBarometer.THRESHOLD_OPTION_GREATER = '>'
 
.. labview:function:: BrickletBarometer.GetAirPressureCallbackThreshold() -> option, min, max


 :output option: Char
 :output min: Int32
 :output max: Int32

 Returns the threshold as set by :labview:func:`SetAirPressureCallbackThreshold() <BrickletBarometer.SetAirPressureCallbackThreshold>`.
 
 The following constants are available for this function:
 
 * BrickletBarometer.THRESHOLD_OPTION_OFF = 'x'
 * BrickletBarometer.THRESHOLD_OPTION_OUTSIDE = 'o'
 * BrickletBarometer.THRESHOLD_OPTION_INSIDE = 'i'
 * BrickletBarometer.THRESHOLD_OPTION_SMALLER = '<'
 * BrickletBarometer.THRESHOLD_OPTION_GREATER = '>'
 
.. labview:function:: BrickletBarometer.SetAltitudeCallbackThreshold(option, min, max)

 :input option: Char
 :input min: Int32
 :input max: Int32

 Sets the thresholds for the :labview:func:`AltitudeReached <BrickletBarometer.AltitudeReached>` 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 altitude is *outside* the min and max values"
  "'i'",    "Callback is triggered when the altitude is *inside* the min and max values"
  "'<'",    "Callback is triggered when the altitude is smaller than the min value (max is ignored)"
  "'>'",    "Callback is triggered when the altitude is greater than the min value (max is ignored)"
 
 The default value is ('x', 0, 0).
 
 The following constants are available for this function:
 
 * BrickletBarometer.THRESHOLD_OPTION_OFF = 'x'
 * BrickletBarometer.THRESHOLD_OPTION_OUTSIDE = 'o'
 * BrickletBarometer.THRESHOLD_OPTION_INSIDE = 'i'
 * BrickletBarometer.THRESHOLD_OPTION_SMALLER = '<'
 * BrickletBarometer.THRESHOLD_OPTION_GREATER = '>'
 
.. labview:function:: BrickletBarometer.GetAltitudeCallbackThreshold() -> option, min, max


 :output option: Char
 :output min: Int32
 :output max: Int32

 Returns the threshold as set by :labview:func:`SetAltitudeCallbackThreshold() <BrickletBarometer.SetAltitudeCallbackThreshold>`.
 
 The following constants are available for this function:
 
 * BrickletBarometer.THRESHOLD_OPTION_OFF = 'x'
 * BrickletBarometer.THRESHOLD_OPTION_OUTSIDE = 'o'
 * BrickletBarometer.THRESHOLD_OPTION_INSIDE = 'i'
 * BrickletBarometer.THRESHOLD_OPTION_SMALLER = '<'
 * BrickletBarometer.THRESHOLD_OPTION_GREATER = '>'
 
.. labview:function:: BrickletBarometer.SetDebouncePeriod(debounce)

 :input debounce: Int64

 Sets the period in ms with which the threshold callbacks
 
 * :labview:func:`AirPressureReached <BrickletBarometer.AirPressureReached>`,
 * :labview:func:`AltitudeReached <BrickletBarometer.AltitudeReached>`
 
 are triggered, if the thresholds
 
 * :labview:func:`SetAirPressureCallbackThreshold() <BrickletBarometer.SetAirPressureCallbackThreshold>`,
 * :labview:func:`SetAltitudeCallbackThreshold() <BrickletBarometer.SetAltitudeCallbackThreshold>`
 
 keep being reached.
 
 The default value is 100.
 
.. labview:function:: BrickletBarometer.GetDebouncePeriod() -> debounce


 :output debounce: Int64

 Returns the debounce period as set by :labview:func:`SetDebouncePeriod() <BrickletBarometer.SetDebouncePeriod>`.
 


.. _barometer_bricklet_labview_callbacks:

Callbacks
^^^^^^^^^

Callbacks can be registered to receive time critical or recurring data from
the device. The registration is done by assigning a function to a callback
property of the device object. The available callback property and their 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.


.. labview:function:: event BrickletBarometer.AirPressure(sender, airPressure)

 :input sender: .NET Refnum (BrickletBarometer)
 :input airPressure: Int32

 This callback is triggered periodically with the period that is set by
 :labview:func:`SetAirPressureCallbackPeriod() <BrickletBarometer.SetAirPressureCallbackPeriod>`. The parameter is the air pressure of the
 air pressure sensor.
 
 :labview:func:`AirPressure <BrickletBarometer.AirPressure>` is only triggered if the air pressure has changed since the
 last triggering.
 

.. labview:function:: event BrickletBarometer.Altitude(sender, altitude)

 :input sender: .NET Refnum (BrickletBarometer)
 :input altitude: Int32

 This callback is triggered periodically with the period that is set by
 :labview:func:`SetAltitudeCallbackPeriod() <BrickletBarometer.SetAltitudeCallbackPeriod>`. The parameter is the altitude of the
 air pressure sensor.
 
 :labview:func:`Altitude <BrickletBarometer.Altitude>` is only triggered if the altitude has changed since the
 last triggering.
 

.. labview:function:: event BrickletBarometer.AirPressureReached(sender, airPressure)

 :input sender: .NET Refnum (BrickletBarometer)
 :input airPressure: Int32

 This callback is triggered when the threshold as set by
 :labview:func:`SetAirPressureCallbackThreshold() <BrickletBarometer.SetAirPressureCallbackThreshold>` is reached.
 The parameter is the air pressure of the air pressure sensor.
 
 If the threshold keeps being reached, the callback is triggered periodically
 with the period as set by :labview:func:`SetDebouncePeriod() <BrickletBarometer.SetDebouncePeriod>`.
 

.. labview:function:: event BrickletBarometer.AltitudeReached(sender, altitude)

 :input sender: .NET Refnum (BrickletBarometer)
 :input altitude: Int32

 This callback is triggered when the threshold as set by
 :labview:func:`SetAltitudeCallbackThreshold() <BrickletBarometer.SetAltitudeCallbackThreshold>` is reached.
 The parameter is the altitude of the air pressure sensor.
 
 If the threshold keeps being reached, the callback is triggered periodically
 with the period as set by :labview:func:`SetDebouncePeriod() <BrickletBarometer.SetDebouncePeriod>`.
 


.. _barometer_bricklet_labview_constants:

Constants
^^^^^^^^^

.. labview:symbol:: BrickletBarometer.DEVICE_IDENTIFIER

 This constant is used to identify a Barometer Bricklet.

 The :labview:func:`GetIdentity() <BrickletBarometer.GetIdentity>` function and the
 :labview:func:`EnumerateCallback <IPConnection.EnumerateCallback>`
 callback of the IP Connection have a ``deviceIdentifier`` parameter to specify
 the Brick's or Bricklet's type.

