..
 #############################################################
 # 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 - Dual Button Bricklet

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

.. _dual_button_bricklet_modbus:

Modbus - Dual Button Bricklet
=============================

This is the description of the :ref:`Modbus protocol <llproto_modbus>` for the :ref:`Dual Button Bricklet <dual_button_bricklet>`. General information and technical
specifications for the Dual Button Bricklet are summarized in its :ref:`hardware description
<dual_button_bricklet_description>`.

.. _dual_button_bricklet_modbus_api:

API
---

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




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



.. modbus:function:: BrickletDualButton.set_led_state

 :functionid: 1
 :request led_l: uint8
 :request led_r: uint8

 :noresponse: no response

 Sets the state of the LEDs. Possible states are:
 
 * 0 = AutoToggleOn: Enables auto toggle with initially enabled LED.
 * 1 = AutoToggleOff: Activates auto toggle with initially disabled LED.
 * 2 = On: Enables LED (auto toggle is disabled).
 * 3 = Off: Disables LED (auto toggle is disabled).
 
 In auto toggle mode the LED is toggled automatically at each press of a button.
 
 If you just want to set one of the LEDs and don't know the current state
 of the other LED, you can get the state with :modbus:func:`get_led_state <BrickletDualButton.get_led_state>` or you
 can use :modbus:func:`set_selected_led_state <BrickletDualButton.set_selected_led_state>`.
 
 The default value is (1, 1).
 
.. modbus:function:: BrickletDualButton.get_led_state

 :functionid: 2
 :emptyrequest: empty payload

 :response led_l: uint8
 :response led_r: uint8

 Returns the current state of the LEDs, as set by :modbus:func:`set_led_state <BrickletDualButton.set_led_state>`.
 
.. modbus:function:: BrickletDualButton.get_button_state

 :functionid: 3
 :emptyrequest: empty payload

 :response button_l: uint8
 :response button_r: uint8

 Returns the current state for both buttons. Possible states are:
 
 * 0 = pressed
 * 1 = released
 


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

.. modbus:function:: BrickletDualButton.set_selected_led_state

 :functionid: 5
 :request led: uint8
 :request state: uint8

 :noresponse: no response

 Sets the state of the selected LED (0 or 1). 
 
 The other LED remains untouched.
 
.. modbus:function:: BrickletDualButton.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|
 


.. _dual_button_bricklet_modbus_callbacks:

Callbacks
^^^^^^^^^

.. modbus:function:: BrickletDualButton.CALLBACK_STATE_CHANGED

 :functionid: 4

 :response button_l: uint8
 :response button_r: uint8
 :response led_l: uint8
 :response led_r: uint8


 This callback is called whenever a button is pressed. 
 
 Possible states for buttons are:
 
 * 0 = pressed
 * 1 = released
 
 Possible states for LEDs are:
 
 * 0 = AutoToggleOn: Auto toggle enabled and LED on.
 * 1 = AutoToggleOff: Auto toggle enabled and LED off.
 * 2 = On: LED on (auto toggle is disabled).
 * 3 = Off: LED off (auto toggle is disabled).
 


