Package com.tinkerforge
Class BrickletLCD20x4
- java.lang.Object
-
- com.tinkerforge.DeviceBase
-
- com.tinkerforge.Device
-
- com.tinkerforge.BrickletLCD20x4
-
public class BrickletLCD20x4 extends Device
20x4 character alphanumeric display with blue backlight
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
BrickletLCD20x4.ButtonPressedListener
This listener is triggered when a button is pressed.static interface
BrickletLCD20x4.ButtonReleasedListener
This listener is triggered when a button is released.class
BrickletLCD20x4.Config
-
Nested classes/interfaces inherited from class com.tinkerforge.Device
Device.Identity
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEVICE_DISPLAY_NAME
static int
DEVICE_IDENTIFIER
static byte
FUNCTION_BACKLIGHT_OFF
static byte
FUNCTION_BACKLIGHT_ON
static byte
FUNCTION_CLEAR_DISPLAY
static byte
FUNCTION_GET_CONFIG
static byte
FUNCTION_GET_CUSTOM_CHARACTER
static byte
FUNCTION_GET_DEFAULT_TEXT
static byte
FUNCTION_GET_DEFAULT_TEXT_COUNTER
static byte
FUNCTION_GET_IDENTITY
static byte
FUNCTION_IS_BACKLIGHT_ON
static byte
FUNCTION_IS_BUTTON_PRESSED
static byte
FUNCTION_SET_CONFIG
static byte
FUNCTION_SET_CUSTOM_CHARACTER
static byte
FUNCTION_SET_DEFAULT_TEXT
static byte
FUNCTION_SET_DEFAULT_TEXT_COUNTER
static byte
FUNCTION_WRITE_LINE
-
Constructor Summary
Constructors Constructor Description BrickletLCD20x4(java.lang.String uid, IPConnection ipcon)
Creates an object with the unique device ID \c uid.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addButtonPressedListener(BrickletLCD20x4.ButtonPressedListener listener)
Adds a ButtonPressed listener.void
addButtonReleasedListener(BrickletLCD20x4.ButtonReleasedListener listener)
Adds a ButtonReleased listener.void
backlightOff()
Turns the backlight off.void
backlightOn()
Turns the backlight on.void
clearDisplay()
Deletes all characters from the display.BrickletLCD20x4.Config
getConfig()
Returns the configuration as set bysetConfig(boolean, boolean)
.short[]
getCustomCharacter(short index)
Returns the custom character for a given index, as set withsetCustomCharacter(short, short[])
.java.lang.String
getDefaultText(short line)
Returns the default text for a given line (0-3) as set bysetDefaultText(short, String)
.int
getDefaultTextCounter()
Returns the current value of the default text counter.Device.Identity
getIdentity()
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.boolean
isBacklightOn()
Returns *true* if the backlight is on and *false* otherwise.boolean
isButtonPressed(short button)
Returns *true* if the button (0 to 2 or 0 to 3 since hardware version 1.2) is pressed.void
removeButtonPressedListener(BrickletLCD20x4.ButtonPressedListener listener)
Removes a ButtonPressed listener.void
removeButtonReleasedListener(BrickletLCD20x4.ButtonReleasedListener listener)
Removes a ButtonReleased listener.void
setConfig(boolean cursor, boolean blinking)
Configures if the cursor (shown as "_") should be visible and if it should be blinking (shown as a blinking block).void
setCustomCharacter(short index, short[] character)
The LCD 20x4 Bricklet can store up to 8 custom characters.void
setDefaultText(short line, java.lang.String text)
Sets the default text for lines 0-3.void
setDefaultTextCounter(int counter)
Sets the default text counter.void
writeLine(short line, short position, java.lang.String text)
Writes text to a specific line with a specific position.-
Methods inherited from class com.tinkerforge.DeviceBase
getAPIVersion, getResponseExpected, setResponseExpected, setResponseExpectedAll
-
-
-
-
Field Detail
-
DEVICE_IDENTIFIER
public static final int DEVICE_IDENTIFIER
- See Also:
- Constant Field Values
-
DEVICE_DISPLAY_NAME
public static final java.lang.String DEVICE_DISPLAY_NAME
- See Also:
- Constant Field Values
-
FUNCTION_WRITE_LINE
public static final byte FUNCTION_WRITE_LINE
- See Also:
- Constant Field Values
-
FUNCTION_CLEAR_DISPLAY
public static final byte FUNCTION_CLEAR_DISPLAY
- See Also:
- Constant Field Values
-
FUNCTION_BACKLIGHT_ON
public static final byte FUNCTION_BACKLIGHT_ON
- See Also:
- Constant Field Values
-
FUNCTION_BACKLIGHT_OFF
public static final byte FUNCTION_BACKLIGHT_OFF
- See Also:
- Constant Field Values
-
FUNCTION_IS_BACKLIGHT_ON
public static final byte FUNCTION_IS_BACKLIGHT_ON
- See Also:
- Constant Field Values
-
FUNCTION_SET_CONFIG
public static final byte FUNCTION_SET_CONFIG
- See Also:
- Constant Field Values
-
FUNCTION_GET_CONFIG
public static final byte FUNCTION_GET_CONFIG
- See Also:
- Constant Field Values
-
FUNCTION_IS_BUTTON_PRESSED
public static final byte FUNCTION_IS_BUTTON_PRESSED
- See Also:
- Constant Field Values
-
FUNCTION_SET_CUSTOM_CHARACTER
public static final byte FUNCTION_SET_CUSTOM_CHARACTER
- See Also:
- Constant Field Values
-
FUNCTION_GET_CUSTOM_CHARACTER
public static final byte FUNCTION_GET_CUSTOM_CHARACTER
- See Also:
- Constant Field Values
-
FUNCTION_SET_DEFAULT_TEXT
public static final byte FUNCTION_SET_DEFAULT_TEXT
- See Also:
- Constant Field Values
-
FUNCTION_GET_DEFAULT_TEXT
public static final byte FUNCTION_GET_DEFAULT_TEXT
- See Also:
- Constant Field Values
-
FUNCTION_SET_DEFAULT_TEXT_COUNTER
public static final byte FUNCTION_SET_DEFAULT_TEXT_COUNTER
- See Also:
- Constant Field Values
-
FUNCTION_GET_DEFAULT_TEXT_COUNTER
public static final byte FUNCTION_GET_DEFAULT_TEXT_COUNTER
- See Also:
- Constant Field Values
-
FUNCTION_GET_IDENTITY
public static final byte FUNCTION_GET_IDENTITY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BrickletLCD20x4
public BrickletLCD20x4(java.lang.String uid, IPConnection ipcon)
Creates an object with the unique device ID \c uid. and adds it to the IP Connection \c ipcon.
-
-
Method Detail
-
writeLine
public void writeLine(short line, short position, java.lang.String text) throws TinkerforgeException
Writes text to a specific line with a specific position. The text can have a maximum of 20 characters. For example: (0, 7, "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-20x4-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.- Throws:
TinkerforgeException
-
clearDisplay
public void clearDisplay() throws TinkerforgeException
Deletes all characters from the display.- Throws:
TinkerforgeException
-
backlightOn
public void backlightOn() throws TinkerforgeException
Turns the backlight on.- Throws:
TinkerforgeException
-
backlightOff
public void backlightOff() throws TinkerforgeException
Turns the backlight off.- Throws:
TinkerforgeException
-
isBacklightOn
public boolean isBacklightOn() throws TinkerforgeException
Returns *true* if the backlight is on and *false* otherwise.- Throws:
TinkerforgeException
-
setConfig
public void setConfig(boolean cursor, boolean blinking) throws TinkerforgeException
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 withwriteLine(short, short, String)
.- Throws:
TinkerforgeException
-
getConfig
public BrickletLCD20x4.Config getConfig() throws TinkerforgeException
Returns the configuration as set bysetConfig(boolean, boolean)
.- Throws:
TinkerforgeException
-
isButtonPressed
public boolean isButtonPressed(short button) throws TinkerforgeException
Returns *true* if the button (0 to 2 or 0 to 3 since hardware version 1.2) is pressed. If you want to react on button presses and releases it is recommended to use theBrickletLCD20x4.ButtonPressedListener
andBrickletLCD20x4.ButtonReleasedListener
listeners.- Throws:
TinkerforgeException
-
setCustomCharacter
public void setCustomCharacter(short index, short[] character) throws TinkerforgeException
The LCD 20x4 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 withwriteLine(short, short, String)
by using the characters with the byte representation 8 ("\\x08" or "\\u0008") to 15 ("\\x0F" or "\\u000F"). You can play around with the custom characters in Brick Viewer version since 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$nbsp;(Plugin)- Throws:
TinkerforgeException
-
getCustomCharacter
public short[] getCustomCharacter(short index) throws TinkerforgeException
Returns the custom character for a given index, as set withsetCustomCharacter(short, short[])
. .. versionadded:: 2.0.1$nbsp;(Plugin)- Throws:
TinkerforgeException
-
setDefaultText
public void setDefaultText(short line, java.lang.String text) throws TinkerforgeException
Sets the default text for lines 0-3. The max number of characters per line is 20. The default text is shown on the LCD, if the default text counter expires, seesetDefaultTextCounter(int)
. .. versionadded:: 2.0.2$nbsp;(Plugin)- Throws:
TinkerforgeException
-
getDefaultText
public java.lang.String getDefaultText(short line) throws TinkerforgeException
Returns the default text for a given line (0-3) as set bysetDefaultText(short, String)
. .. versionadded:: 2.0.2$nbsp;(Plugin)- Throws:
TinkerforgeException
-
setDefaultTextCounter
public void setDefaultTextCounter(int counter) throws TinkerforgeException
Sets the default text counter. This counter is decremented each ms by the LCD firmware. If the counter reaches 0, the default text (seesetDefaultText(short, String)
) is shown on the LCD. This functionality can be used to show a default text if the controlling program crashes or the connection is interrupted. A possible approach is to callsetDefaultTextCounter(int)
every minute with the parameter 1000*60*2 (2 minutes). In this case the default text will be shown no later than 2 minutes after the controlling program crashes. A negative counter turns the default text functionality off. .. versionadded:: 2.0.2$nbsp;(Plugin)- Throws:
TinkerforgeException
-
getDefaultTextCounter
public int getDefaultTextCounter() throws TinkerforgeException
Returns the current value of the default text counter. .. versionadded:: 2.0.2$nbsp;(Plugin)- Throws:
TinkerforgeException
-
getIdentity
public Device.Identity getIdentity() throws TinkerforgeException
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 :ref:`Isolator Bricklet <isolator_bricklet>` is always at position 'z'. The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|- Specified by:
getIdentity
in classDevice
- Throws:
TinkerforgeException
-
addButtonPressedListener
public void addButtonPressedListener(BrickletLCD20x4.ButtonPressedListener listener)
Adds a ButtonPressed listener.
-
removeButtonPressedListener
public void removeButtonPressedListener(BrickletLCD20x4.ButtonPressedListener listener)
Removes a ButtonPressed listener.
-
addButtonReleasedListener
public void addButtonReleasedListener(BrickletLCD20x4.ButtonReleasedListener listener)
Adds a ButtonReleased listener.
-
removeButtonReleasedListener
public void removeButtonReleasedListener(BrickletLCD20x4.ButtonReleasedListener listener)
Removes a ButtonReleased listener.
-
-