![]() ![]() ![]() ![]() |
|
HiPi::Interface::HTBackpackV2 provides an implementation of HiPi::Interface::HD44780 for LCD devices using the HobbyTronics Backpack V2 controller.
The module inherits many of its methods from HiPi::Interface::HD44780.
This module exports the following constants on request for use with the inherited 'update_baudrate' method. use HiPi::Interface::HTBackpackV2 qw( :htv2baud ); # exports constants HTV2_BAUD_2400 HTV2_BAUD_4800 HTV2_BAUD_9600 HTV2_BAUD_14400 HTV2_BAUD_19200 HTV2_BAUD_28800 HTV2_BAUD_57600 HTV2_BAUD_115200 The following are the methods specific to this implementation. See HiPi::Interface::HD44780 for inherited methods.
%params contains a number of key value pairs Required key value pairs width => $width lines => $lines You must specify the geometry of your LCD e.g. my $lcd = HiPi::Interface::HTBackpackV2->new( width => 16, lines => 4, ); Optional params and their defaults backlightcontrol => 0 specify if methods setting the level of backlight can be used. The method $lcd->backlight will only work if you set backlightcontrol => 1 in the constructor. devicetype => 'serialrx' The Backpack supports two connection types, 'serialrx' and 'i2c' You can specify either - the default is 'serialrx' Options and their defaults when devicetype is 'serialrx' devicename => '/dev/ttyAMA0' baudrate => 9600 parity => 'none', stopbits => 1, databits => 8, If you are using a Pi 3 with default settings, the header pins on the Rpi gpio are connected to the mini uart. You will therefore need to specify the device to override the default. devicename => '/dev/ttyS0' Options and their defaults when devicetype is 'i2c' devicename => ( raspbi board version == 1 ) ? '/dev/i2c-0' : '/dev/i2c-1' address => 0x3A Example complete constructor calls: my $lcd = HiPi::Interface::HTBackpackV2->new( width => 16, lines => 4, devicetype => 'serialrx', backlightcontrol => 1, devicename => '/dev/ttyS0', ); my $lcd = HiPi::Interface::HTBackpackV2->new( width => 16, lines => 4, devicetype => 'i2c', address => 0x3A backlightcontrol => 1 );
Change the I2C address if using in i2c mode. The i2c address must be in the range 1 - 127 ( 0x01 - 0x7F )
You can use the HobbyTronics Backpack documented commands directly if you wish. The $command param is the backpack command number and you can follow this with any number of parameters required. This module exports the following constants on request for use with the the send_htv2_command '$command' parameter. use HiPi::Interface::HTBackpackV2 qw( :htv2cmd ); HTV2_CMD_PRINT HTV2_CMD_SET_CURSOR_POS HTV2_CMD_CLEAR_LINE HTV2_CMD_CLEAR_DISPLAY HTV2_CMD_LCD_TYPE HTV2_CMD_HD44780_CMD HTV2_CMD_BACKLIGHT HTV2_CMD_WRITE_CHAR HTV2_CMD_I2C_ADDRESS HTV2_CMD_BAUD_RATE HTV2_CMD_CUSTOM_CHAR