..
 #############################################################
 # 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-modbus">Software</a> / Modbus - Sound Intensity Bricklet

.. |device_identifier_constant| unicode:: 0xA0
   :trim:

.. _sound_intensity_bricklet_modbus:

Modbus - Sound Intensity Bricklet
=================================

This is the description of the :ref:`Modbus protocol <llproto_modbus>` for the :ref:`Sound Intensity Bricklet <sound_intensity_bricklet>`. General information and technical
specifications for the Sound Intensity Bricklet are summarized in its :ref:`hardware description
<sound_intensity_bricklet_description>`.

.. _sound_intensity_bricklet_modbus_api:

API
---

A general description of the Modbus protocol structure can be found
:ref:`here <llproto_modbus>`.




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



.. modbus:function:: BrickletSoundIntensity.get_intensity

 :functionid: 1
 :emptyrequest: empty payload

 :response intensity: uint16

 Returns the current sound intensity. The value has a range of
 0 to 4095.
 
 The value corresponds to the `upper envelop <http://en.wikipedia.org/wiki/Envelope_(waves)>`__
 of the signal of the microphone capsule.
 
 If you want to get the intensity periodically, it is recommended to use the
 callback :modbus:func:`CALLBACK_INTENSITY <BrickletSoundIntensity.CALLBACK_INTENSITY>` and set the period with 
 :modbus:func:`set_intensity_callback_period <BrickletSoundIntensity.set_intensity_callback_period>`.
 


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

.. modbus:function:: BrickletSoundIntensity.get_identity

 :functionid: 255
 :emptyrequest: empty payload

 :response uid: char[8]
 :response connected_uid: char[8]
 :response position: char
 :response hardware_version: uint8[3]
 :response firmware_version: uint8[3]
 :response device_identifier: uint16

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



.. modbus:function:: BrickletSoundIntensity.set_intensity_callback_period

 :functionid: 2
 :request period: uint32

 :noresponse: no response

 Sets the period in ms with which the :modbus:func:`CALLBACK_INTENSITY <BrickletSoundIntensity.CALLBACK_INTENSITY>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
 :modbus:func:`CALLBACK_INTENSITY <BrickletSoundIntensity.CALLBACK_INTENSITY>` is only triggered if the intensity has changed since the
 last triggering.
 
 The default value is 0.
 
.. modbus:function:: BrickletSoundIntensity.get_intensity_callback_period

 :functionid: 3
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :modbus:func:`set_intensity_callback_period <BrickletSoundIntensity.set_intensity_callback_period>`.
 
.. modbus:function:: BrickletSoundIntensity.set_intensity_callback_threshold

 :functionid: 4
 :request option: char
 :request min: uint16
 :request max: uint16

 :noresponse: no response

 Sets the thresholds for the :modbus:func:`CALLBACK_INTENSITY_REACHED <BrickletSoundIntensity.CALLBACK_INTENSITY_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 intensity is *outside* the min and max values"
  "'i'",    "Callback is triggered when the intensity is *inside* the min and max values"
  "'<'",    "Callback is triggered when the intensity is smaller than the min value (max is ignored)"
  "'>'",    "Callback is triggered when the intensity is greater than the min value (max is ignored)"
 
 The default value is ('x', 0, 0).
 
.. modbus:function:: BrickletSoundIntensity.get_intensity_callback_threshold

 :functionid: 5
 :emptyrequest: empty payload

 :response option: char
 :response min: uint16
 :response max: uint16

 Returns the threshold as set by :modbus:func:`set_intensity_callback_threshold <BrickletSoundIntensity.set_intensity_callback_threshold>`.
 
.. modbus:function:: BrickletSoundIntensity.set_debounce_period

 :functionid: 6
 :request debounce: uint32

 :noresponse: no response

 Sets the period in ms with which the threshold callback
 
 * :modbus:func:`CALLBACK_INTENSITY_REACHED <BrickletSoundIntensity.CALLBACK_INTENSITY_REACHED>`
 
 is triggered, if the thresholds
 
 * :modbus:func:`set_intensity_callback_threshold <BrickletSoundIntensity.set_intensity_callback_threshold>`
 
 keeps being reached.
 
 The default value is 100.
 
.. modbus:function:: BrickletSoundIntensity.get_debounce_period

 :functionid: 7
 :emptyrequest: empty payload

 :response debounce: uint32

 Returns the debounce period as set by :modbus:func:`set_debounce_period <BrickletSoundIntensity.set_debounce_period>`.
 


.. _sound_intensity_bricklet_modbus_callbacks:

Callbacks
^^^^^^^^^

.. modbus:function:: BrickletSoundIntensity.CALLBACK_INTENSITY

 :functionid: 8

 :response intensity: uint16


 This callback is triggered periodically with the period that is set by
 :modbus:func:`set_intensity_callback_period <BrickletSoundIntensity.set_intensity_callback_period>`. The response value is the intensity of
 the encoder.
 
 :modbus:func:`CALLBACK_INTENSITY <BrickletSoundIntensity.CALLBACK_INTENSITY>` is only triggered if the intensity has changed since the
 last triggering.
 
.. modbus:function:: BrickletSoundIntensity.CALLBACK_INTENSITY_REACHED

 :functionid: 9

 :response intensity: uint16


 This callback is triggered when the threshold as set by
 :modbus:func:`set_intensity_callback_threshold <BrickletSoundIntensity.set_intensity_callback_threshold>` is reached.
 The response value is the intensity of the encoder.
 
 If the threshold keeps being reached, the callback is triggered periodically
 with the period as set by :modbus:func:`set_debounce_period <BrickletSoundIntensity.set_debounce_period>`.
 


