..
 #############################################################
 # 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-tcpip">Software</a> / TCP/IP - LCD 16x2 Bricklet

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

.. _lcd_16x2_bricklet_tcpip:

TCP/IP - LCD 16x2 Bricklet
==========================

This is the description of the :ref:`TCP/IP protocol <llproto_tcpip>` for the :ref:`LCD 16x2 Bricklet <lcd_16x2_bricklet>`. General information and technical
specifications for the LCD 16x2 Bricklet are summarized in its :ref:`hardware description
<lcd_16x2_bricklet_description>`.

.. _lcd_16x2_bricklet_tcpip_api:

API
---

A general description of the TCP/IP protocol structure can be found
:ref:`here <llproto_tcpip>`.




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



.. tcpip:function:: BrickletLCD16x2.write_line

 :functionid: 1
 :request line: uint8
 :request position: uint8
 :request text: char[16]

 :noresponse: no response

 Writes text to a specific line (0 to 1) with a specific position 
 (0 to 15). The text can have a maximum of 16 characters.
 
 For example: (0, 5, "Hello") will write *Hello* in the middle of the
 first line of the display.
 
 The display uses a special charset that includes all ASCII characters except
 backslash and tilde. The LCD charset also includes several other non-ASCII characters, see
 the `charset specification <https://github.com/Tinkerforge/lcd-16x2-bricklet/raw/master/datasheets/standard_charset.pdf>`__
 for details. The Unicode example above shows how to specify non-ASCII characters
 and how to translate from Unicode to the LCD charset.
 
.. tcpip:function:: BrickletLCD16x2.clear_display

 :functionid: 2
 :emptyrequest: empty payload

 :noresponse: no response

 Deletes all characters from the display.
 
.. tcpip:function:: BrickletLCD16x2.backlight_on

 :functionid: 3
 :emptyrequest: empty payload

 :noresponse: no response

 Turns the backlight on.
 
.. tcpip:function:: BrickletLCD16x2.backlight_off

 :functionid: 4
 :emptyrequest: empty payload

 :noresponse: no response

 Turns the backlight off.
 
.. tcpip:function:: BrickletLCD16x2.is_backlight_on

 :functionid: 5
 :emptyrequest: empty payload

 :response backlight: bool

 Returns *true* if the backlight is on and *false* otherwise.
 


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

.. tcpip:function:: BrickletLCD16x2.set_config

 :functionid: 6
 :request cursor: bool
 :request blinking: bool

 :noresponse: no response

 Configures if the cursor (shown as "_") should be visible and if it
 should be blinking (shown as a blinking block). The cursor position
 is one character behind the the last text written with 
 :tcpip:func:`write_line <BrickletLCD16x2.write_line>`.
 
 The default is (false, false).
 
.. tcpip:function:: BrickletLCD16x2.get_config

 :functionid: 7
 :emptyrequest: empty payload

 :response cursor: bool
 :response blinking: bool

 Returns the configuration as set by :tcpip:func:`set_config <BrickletLCD16x2.set_config>`.
 
.. tcpip:function:: BrickletLCD16x2.is_button_pressed

 :functionid: 8
 :request button: uint8

 :response pressed: bool

 Returns *true* if the button (0 to 2) is pressed. If you want to react
 on button presses and releases it is recommended to use the
 :tcpip:func:`CALLBACK_BUTTON_PRESSED <BrickletLCD16x2.CALLBACK_BUTTON_PRESSED>` and :tcpip:func:`CALLBACK_BUTTON_RELEASED <BrickletLCD16x2.CALLBACK_BUTTON_RELEASED>` callbacks.
 
.. tcpip:function:: BrickletLCD16x2.set_custom_character

 :functionid: 11
 :request index: uint8
 :request character: uint8[8]

 :noresponse: no response

 The LCD 16x2 Bricklet can store up to 8 custom characters. The characters
 consist of 5x8 pixels and can be addressed with the index 0-7. To describe
 the pixels, the first 5 bits of 8 bytes are used. For example, to make
 a custom character "H", you should transfer the following:
 
 * ``character[0] = 0b00010001`` (decimal value 17)
 * ``character[1] = 0b00010001`` (decimal value 17)
 * ``character[2] = 0b00010001`` (decimal value 17)
 * ``character[3] = 0b00011111`` (decimal value 31)
 * ``character[4] = 0b00010001`` (decimal value 17)
 * ``character[5] = 0b00010001`` (decimal value 17)
 * ``character[6] = 0b00010001`` (decimal value 17)
 * ``character[7] = 0b00000000`` (decimal value 0)
 
 The characters can later be written with :tcpip:func:`write_line <BrickletLCD16x2.write_line>` by using the
 characters with the byte representation 8 to 15.
 
 You can play around with the custom characters in Brick Viewer since
 version 2.0.1.
 
 Custom characters are stored by the LCD in RAM, so they have to be set
 after each startup.
 
 .. versionadded:: 2.0.1~(Plugin)
 
.. tcpip:function:: BrickletLCD16x2.get_custom_character

 :functionid: 12
 :request index: uint8

 :response character: uint8[8]

 Returns the custom character for a given index, as set with
 :tcpip:func:`set_custom_character <BrickletLCD16x2.set_custom_character>`.
 
 .. versionadded:: 2.0.1~(Plugin)
 
.. tcpip:function:: BrickletLCD16x2.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|
 


.. _lcd_16x2_bricklet_tcpip_callbacks:

Callbacks
^^^^^^^^^

.. tcpip:function:: BrickletLCD16x2.CALLBACK_BUTTON_PRESSED

 :functionid: 9

 :response button: uint8


 This callback is triggered when a button is pressed. The response value is
 the number of the button (0 to 2).
 
.. tcpip:function:: BrickletLCD16x2.CALLBACK_BUTTON_RELEASED

 :functionid: 10

 :response button: uint8


 This callback is triggered when a button is released. The response value is
 the number of the button (0 to 2).
 


