Modbus - Dual Button Bricklet

This is the description of the Modbus protocol for the Dual Button Bricklet. General information and technical specifications for the Dual Button Bricklet are summarized in its hardware description.

API

A general description of the Modbus protocol structure can be found here.

Basic Functions

BrickletDualButton.set_led_state
Function ID:
  • 1
Request:
  • led_l – Type: uint8, Range: See meanings, Default: 1
  • led_r – Type: uint8, Range: See meanings, Default: 1
Response:
  • 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 get_led_state or you can use set_selected_led_state.

The following meanings are defined for the elements of this function:

For led_l:

  • 0 = Auto Toggle On
  • 1 = Auto Toggle Off
  • 2 = On
  • 3 = Off

For led_r:

  • 0 = Auto Toggle On
  • 1 = Auto Toggle Off
  • 2 = On
  • 3 = Off
BrickletDualButton.get_led_state
Function ID:
  • 2
Request:
  • empty payload
Response:
  • led_l – Type: uint8, Range: See meanings, Default: 1
  • led_r – Type: uint8, Range: See meanings, Default: 1

Returns the current state of the LEDs, as set by set_led_state.

The following meanings are defined for the elements of this function:

For led_l:

  • 0 = Auto Toggle On
  • 1 = Auto Toggle Off
  • 2 = On
  • 3 = Off

For led_r:

  • 0 = Auto Toggle On
  • 1 = Auto Toggle Off
  • 2 = On
  • 3 = Off
BrickletDualButton.get_button_state
Function ID:
  • 3
Request:
  • empty payload
Response:
  • button_l – Type: uint8, Range: See meanings
  • button_r – Type: uint8, Range: See meanings

Returns the current state for both buttons. Possible states are:

  • 0 = pressed
  • 1 = released

The following meanings are defined for the elements of this function:

For button_l:

  • 0 = Pressed
  • 1 = Released

For button_r:

  • 0 = Pressed
  • 1 = Released

Advanced Functions

BrickletDualButton.set_selected_led_state
Function ID:
  • 5
Request:
  • led – Type: uint8, Range: See meanings
  • state – Type: uint8, Range: See meanings
Response:
  • no response

Sets the state of the selected LED (0 or 1).

The other LED remains untouched.

The following meanings are defined for the elements of this function:

For led:

  • 0 = Left
  • 1 = Right

For state:

  • 0 = Auto Toggle On
  • 1 = Auto Toggle Off
  • 2 = On
  • 3 = Off
BrickletDualButton.get_identity
Function ID:
  • 255
Request:
  • empty payload
Response:
  • uid – Type: char[8]
  • connected_uid – Type: char[8]
  • position – Type: char, Range: ['a' to 'h', 'z']
  • hardware_version – Type: uint8[3]
    • 0: major – Type: uint8, Range: [0 to 255]
    • 1: minor – Type: uint8, Range: [0 to 255]
    • 2: revision – Type: uint8, Range: [0 to 255]
  • firmware_version – Type: uint8[3]
    • 0: major – Type: uint8, Range: [0 to 255]
    • 1: minor – Type: uint8, Range: [0 to 255]
    • 2: revision – Type: uint8, Range: [0 to 255]
  • device_identifier – Type: uint16, Range: [0 to 216 - 1]

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', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an Isolator Bricklet is always at position 'z'.

The device identifier numbers can be found here

Callbacks

BrickletDualButton.CALLBACK_STATE_CHANGED
Function ID:
  • 4
Response:
  • button_l – Type: uint8, Range: See meanings
  • button_r – Type: uint8, Range: See meanings
  • led_l – Type: uint8, Range: See meanings
  • led_r – Type: uint8, Range: See meanings

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

The following meanings are defined for the elements of this function:

For button_l:

  • 0 = Pressed
  • 1 = Released

For button_r:

  • 0 = Pressed
  • 1 = Released

For led_l:

  • 0 = Auto Toggle On
  • 1 = Auto Toggle Off
  • 2 = On
  • 3 = Off

For led_r:

  • 0 = Auto Toggle On
  • 1 = Auto Toggle Off
  • 2 = On
  • 3 = Off