Documentation ¶
Overview ¶
16x2 character alphanumeric display with blue backlight.
See also the documentation here: https://www.tinkerforge.com/en/doc/Software/Bricklets/LCD16x2_Bricklet_Go.html.
Index ¶
- Constants
- type Function
- type LCD16x2Bricklet
- func (device *LCD16x2Bricklet) BacklightOff() (err error)
- func (device *LCD16x2Bricklet) BacklightOn() (err error)
- func (device *LCD16x2Bricklet) ClearDisplay() (err error)
- func (device *LCD16x2Bricklet) DeregisterButtonPressedCallback(registrationId uint64)
- func (device *LCD16x2Bricklet) DeregisterButtonReleasedCallback(registrationId uint64)
- func (device *LCD16x2Bricklet) GetAPIVersion() [3]uint8
- func (device *LCD16x2Bricklet) GetConfig() (cursor bool, blinking bool, err error)
- func (device *LCD16x2Bricklet) GetCustomCharacter(index uint8) (character [8]uint8, err error)
- func (device *LCD16x2Bricklet) GetIdentity() (uid string, connectedUid string, position rune, hardwareVersion [3]uint8, ...)
- func (device *LCD16x2Bricklet) GetResponseExpected(functionID Function) (bool, error)
- func (device *LCD16x2Bricklet) IsBacklightOn() (backlight bool, err error)
- func (device *LCD16x2Bricklet) IsButtonPressed(button uint8) (pressed bool, err error)
- func (device *LCD16x2Bricklet) RegisterButtonPressedCallback(fn func(uint8)) uint64
- func (device *LCD16x2Bricklet) RegisterButtonReleasedCallback(fn func(uint8)) uint64
- func (device *LCD16x2Bricklet) SetConfig(cursor bool, blinking bool) (err error)
- func (device *LCD16x2Bricklet) SetCustomCharacter(index uint8, character [8]uint8) (err error)
- func (device *LCD16x2Bricklet) SetResponseExpected(functionID Function, responseExpected bool) error
- func (device *LCD16x2Bricklet) SetResponseExpectedAll(responseExpected bool)
- func (device *LCD16x2Bricklet) WriteLine(line uint8, position uint8, text string) (err error)
Constants ¶
const DeviceDisplayName = "LCD 16x2 Bricklet"
const DeviceIdentifier = 211
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 FunctionGetIdentity Function = 255 FunctionCallbackButtonPressed Function = 9 FunctionCallbackButtonReleased Function = 10 )
type LCD16x2Bricklet ¶
type LCD16x2Bricklet struct {
// contains filtered or unexported fields
}
func New ¶
func New(uid string, ipcon *ipconnection.IPConnection) (LCD16x2Bricklet, error)
Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ipcon` is connected.
func (*LCD16x2Bricklet) BacklightOff ¶
func (device *LCD16x2Bricklet) BacklightOff() (err error)
Turns the backlight off.
func (*LCD16x2Bricklet) BacklightOn ¶
func (device *LCD16x2Bricklet) BacklightOn() (err error)
Turns the backlight on.
func (*LCD16x2Bricklet) ClearDisplay ¶
func (device *LCD16x2Bricklet) ClearDisplay() (err error)
Deletes all characters from the display.
func (*LCD16x2Bricklet) DeregisterButtonPressedCallback ¶
func (device *LCD16x2Bricklet) DeregisterButtonPressedCallback(registrationId uint64)
Remove a registered Button Pressed callback.
func (*LCD16x2Bricklet) DeregisterButtonReleasedCallback ¶
func (device *LCD16x2Bricklet) DeregisterButtonReleasedCallback(registrationId uint64)
Remove a registered Button Released callback.
func (*LCD16x2Bricklet) GetAPIVersion ¶
func (device *LCD16x2Bricklet) 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 (*LCD16x2Bricklet) GetConfig ¶
func (device *LCD16x2Bricklet) GetConfig() (cursor bool, blinking bool, err error)
Returns the configuration as set by SetConfig.
func (*LCD16x2Bricklet) GetCustomCharacter ¶
func (device *LCD16x2Bricklet) 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 (*LCD16x2Bricklet) GetIdentity ¶
func (device *LCD16x2Bricklet) 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 (*LCD16x2Bricklet) GetResponseExpected ¶
func (device *LCD16x2Bricklet) 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 (*LCD16x2Bricklet) IsBacklightOn ¶
func (device *LCD16x2Bricklet) IsBacklightOn() (backlight bool, err error)
Returns *true* if the backlight is on and *false* otherwise.
func (*LCD16x2Bricklet) IsButtonPressed ¶
func (device *LCD16x2Bricklet) IsButtonPressed(button uint8) (pressed bool, err error)
Returns *true* if the button is pressed.
If you want to react on button presses and releases it is recommended to use the RegisterButtonPressedCallback and RegisterButtonReleasedCallback callbacks.
func (*LCD16x2Bricklet) RegisterButtonPressedCallback ¶
func (device *LCD16x2Bricklet) RegisterButtonPressedCallback(fn func(uint8)) uint64
This callback is triggered when a button is pressed. The parameter is the number of the button.
func (*LCD16x2Bricklet) RegisterButtonReleasedCallback ¶
func (device *LCD16x2Bricklet) RegisterButtonReleasedCallback(fn func(uint8)) uint64
This callback is triggered when a button is released. The parameter is the number of the button.
func (*LCD16x2Bricklet) SetConfig ¶
func (device *LCD16x2Bricklet) 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 (*LCD16x2Bricklet) SetCustomCharacter ¶
func (device *LCD16x2Bricklet) SetCustomCharacter(index uint8, character [8]uint8) (err error)
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 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 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$nbsp;(Plugin)
func (*LCD16x2Bricklet) SetResponseExpected ¶
func (device *LCD16x2Bricklet) 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 (*LCD16x2Bricklet) SetResponseExpectedAll ¶
func (device *LCD16x2Bricklet) SetResponseExpectedAll(responseExpected bool)
Changes the response expected flag for all setter and callback configuration functions of this device at once.
func (*LCD16x2Bricklet) WriteLine ¶
func (device *LCD16x2Bricklet) 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 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 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.