lcd_20x4_bricklet

package
v0.0.0-...-368b749 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2024 License: CC0-1.0 Imports: 5 Imported by: 1

Documentation

Overview

20x4 character alphanumeric display with blue backlight.

See also the documentation here: https://www.tinkerforge.com/en/doc/Software/Bricklets/LCD20x4_Bricklet_Go.html.

Index

Constants

View Source
const DeviceDisplayName = "LCD 20x4 Bricklet"
View Source
const DeviceIdentifier = 212

Variables

This section is empty.

Functions

This section is empty.

Types

type Function

type Function = uint8
const (
	FunctionWriteLine              Function = 1
	FunctionClearDisplay           Function = 2
	FunctionBacklightOn            Function = 3
	FunctionBacklightOff           Function = 4
	FunctionIsBacklightOn          Function = 5
	FunctionSetConfig              Function = 6
	FunctionGetConfig              Function = 7
	FunctionIsButtonPressed        Function = 8
	FunctionSetCustomCharacter     Function = 11
	FunctionGetCustomCharacter     Function = 12
	FunctionSetDefaultText         Function = 13
	FunctionGetDefaultText         Function = 14
	FunctionSetDefaultTextCounter  Function = 15
	FunctionGetDefaultTextCounter  Function = 16
	FunctionGetIdentity            Function = 255
	FunctionCallbackButtonPressed  Function = 9
	FunctionCallbackButtonReleased Function = 10
)

type LCD20x4Bricklet

type LCD20x4Bricklet struct {
	// contains filtered or unexported fields
}

func New

Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ipcon` is connected.

func (*LCD20x4Bricklet) BacklightOff

func (device *LCD20x4Bricklet) BacklightOff() (err error)

Turns the backlight off.

func (*LCD20x4Bricklet) BacklightOn

func (device *LCD20x4Bricklet) BacklightOn() (err error)

Turns the backlight on.

func (*LCD20x4Bricklet) ClearDisplay

func (device *LCD20x4Bricklet) ClearDisplay() (err error)

Deletes all characters from the display.

func (*LCD20x4Bricklet) DeregisterButtonPressedCallback

func (device *LCD20x4Bricklet) DeregisterButtonPressedCallback(registrationId uint64)

Remove a registered Button Pressed callback.

func (*LCD20x4Bricklet) DeregisterButtonReleasedCallback

func (device *LCD20x4Bricklet) DeregisterButtonReleasedCallback(registrationId uint64)

Remove a registered Button Released callback.

func (*LCD20x4Bricklet) GetAPIVersion

func (device *LCD20x4Bricklet) GetAPIVersion() [3]uint8

Returns the version of the API definition (major, minor, revision) implemented by this API bindings. This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.

func (*LCD20x4Bricklet) GetConfig

func (device *LCD20x4Bricklet) GetConfig() (cursor bool, blinking bool, err error)

Returns the configuration as set by SetConfig.

func (*LCD20x4Bricklet) GetCustomCharacter

func (device *LCD20x4Bricklet) GetCustomCharacter(index uint8) (character [8]uint8, err error)

Returns the custom character for a given index, as set with SetCustomCharacter.

.. versionadded:: 2.0.1$nbsp;(Plugin)

func (*LCD20x4Bricklet) GetDefaultText

func (device *LCD20x4Bricklet) GetDefaultText(line uint8) (text string, err error)

Returns the default text for a given line (0-3) as set by SetDefaultText.

.. versionadded:: 2.0.2$nbsp;(Plugin)

func (*LCD20x4Bricklet) GetDefaultTextCounter

func (device *LCD20x4Bricklet) GetDefaultTextCounter() (counter int32, err error)

Returns the current value of the default text counter.

.. versionadded:: 2.0.2$nbsp;(Plugin)

func (*LCD20x4Bricklet) GetIdentity

func (device *LCD20x4Bricklet) GetIdentity() (uid string, connectedUid string, position rune, hardwareVersion [3]uint8, firmwareVersion [3]uint8, deviceIdentifier uint16, err error)

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 <isolator_bricklet>` is always at position 'z'.

The device identifier numbers can be found `here <device_identifier>`. |device_identifier_constant|

func (*LCD20x4Bricklet) GetResponseExpected

func (device *LCD20x4Bricklet) GetResponseExpected(functionID Function) (bool, error)

Returns the response expected flag for the function specified by the function ID parameter. It is true if the function is expected to send a response, false otherwise.

For getter functions this is enabled by default and cannot be disabled, because those functions will always send a response. For callback configuration functions it is enabled by default too, but can be disabled by SetResponseExpected. For setter functions it is disabled by default and can be enabled.

Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is sent and errors are silently ignored, because they cannot be detected.

See SetResponseExpected for the list of function ID constants available for this function.

func (*LCD20x4Bricklet) IsBacklightOn

func (device *LCD20x4Bricklet) IsBacklightOn() (backlight bool, err error)

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

func (*LCD20x4Bricklet) IsButtonPressed

func (device *LCD20x4Bricklet) IsButtonPressed(button uint8) (pressed bool, err error)

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 the RegisterButtonPressedCallback and RegisterButtonReleasedCallback callbacks.

func (*LCD20x4Bricklet) RegisterButtonPressedCallback

func (device *LCD20x4Bricklet) RegisterButtonPressedCallback(fn func(uint8)) uint64

This callback is triggered when a button is pressed. The parameter is the number of the button (0 to 2 or 0 to 3 since hardware version 1.2).

func (*LCD20x4Bricklet) RegisterButtonReleasedCallback

func (device *LCD20x4Bricklet) RegisterButtonReleasedCallback(fn func(uint8)) uint64

This callback is triggered when a button is released. The parameter is the number of the button (0 to 2 or 0 to 3 since hardware version 1.2).

func (*LCD20x4Bricklet) SetConfig

func (device *LCD20x4Bricklet) SetConfig(cursor bool, blinking bool) (err error)

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

func (*LCD20x4Bricklet) SetCustomCharacter

func (device *LCD20x4Bricklet) SetCustomCharacter(index uint8, character [8]uint8) (err error)

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 with WriteLine 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)

func (*LCD20x4Bricklet) SetDefaultText

func (device *LCD20x4Bricklet) SetDefaultText(line uint8, text string) (err error)

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, see SetDefaultTextCounter.

.. versionadded:: 2.0.2$nbsp;(Plugin)

func (*LCD20x4Bricklet) SetDefaultTextCounter

func (device *LCD20x4Bricklet) SetDefaultTextCounter(counter int32) (err error)

Sets the default text counter. This counter is decremented each ms by the LCD firmware. If the counter reaches 0, the default text (see SetDefaultText) 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 call SetDefaultTextCounter 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)

func (*LCD20x4Bricklet) SetResponseExpected

func (device *LCD20x4Bricklet) SetResponseExpected(functionID Function, responseExpected bool) error

Changes the response expected flag of the function specified by the function ID parameter. This flag can only be changed for setter (default value: false) and callback configuration functions (default value: true). For getter functions it is always enabled.

Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is sent and errors are silently ignored, because they cannot be detected.

func (*LCD20x4Bricklet) SetResponseExpectedAll

func (device *LCD20x4Bricklet) SetResponseExpectedAll(responseExpected bool)

Changes the response expected flag for all setter and callback configuration functions of this device at once.

func (*LCD20x4Bricklet) WriteLine

func (device *LCD20x4Bricklet) WriteLine(line uint8, position uint8, text string) (err error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL