NAME
HiPi::Control::LCD
VERSION
Version 0.01
SYNOPSYS
use HiPi::Constant qw( :raspberry :pinmode :serial
:spi :i2c :wiring :bcm2835 :mcp23017 :htv2cmd
:htv2baudrate );
use HiPi::Control::LCD qw( :cursor :hd44780 );
use HiPi::Control::LCD::SerLCD;
my $hp = HiPi::Control::LCD::SerLCD->new( { width => 16, lines => 2, backlightcontrol => 1, devicetype => 'serialrx' } );
$hp->enable(1);
$hp->backlight(25);
$hp->clear;
$hp->set_cursor_position(0,0);
$hp->send_text('Raspberry Pi');
$hp->set_cursor_position(0,1);
$hp->send_text('SerLCD Control');
DESCRIPTION
This module is a base class for a common interface to Hitachi HD44780 displays whether driven by I2C interfaces, SerialRX interfaces or direct HD44780 access.
Modules are currently provided for:
SparkFun SerLCD serialRX interface HiPi::Control::LCD::SerLCD
HobbyTronics Version 2 Backpack (serialRX and I2C ) HiPi::Control::LCD::HTBackpackV2
METHODS
Common methods used by all HiPi::Control::LCD::xx classes.
new
my $lcd = HiPi::Control::LCD::SerLCD->new(
{ width => 16,
lines => 2,
backlightcontrol => 1,
devicetype => 'serialrx' }
);
Width & lines provide the character dimensions of the display
backlightcontrol sets whether the interface should be allowed to
control the backlight levels. For some LCDs attempting to set
the backlight level via a serlRX or I2C interface can damage
the LCD. Set to 0 to disable backlight control
devicetype - can be serialrx or i2c depending on what your
hardware supports.
enable $lcd->enable($bool);
Switch the LCD on / off
set_cursor_position
$lcd->set_cursor_position($column, $row);
Set the current cursor position. $lcd->set_cursor_position(0, 0) sets the position to the leftmost column of the top row.
move_cursor_left
$lcd->move_cursor_left();
Shift the cursor position 1 to the left
move_cursor_right
$lcd->move_cursor_right();
Shift the cursor position 1 to the right
home
$lcd->home();
Move the cursor to top left
clear
$lcd->clear();
Move the cursor to top left and clear all text
set_cursor_mode
$lcd->set_cursor_mode($mode);
Set the cursor mode. Valid values for $mode are the module constants exported under tag ':cursor'
SRX_CURSOR_OFF
SRX_CURSOR_BLINK
SRX_CURSOR_UNDERLINE
backlight
$lcd->$backlight($percent);
Set the backlight light level. Valid values for $percent is a number between 0 and 100
send_text
$lcd->send_text($textstring);
Send text to be 'printed' at the current cursor position.
send_command
$lcd->send_command($command);
Send an HD44780 command. Valid values for $command are the module constants exported under tag ':hd44780'
HD44780_CLEAR_DISPLAY
HD44780_HOME_UNSHIFT
HD44780_CURSOR_MODE_LEFT
HD44780_CURSOR_MODE_LEFT_SHIFT
HD44780_CURSOR_MODE_RIGHT
HD44780_CURSOR_MODE_RIGHT_SHIFT
HD44780_DISPLAY_OFF
HD44780_DISPLAY_ON
HD44780_CURSOR_OFF
HD44780_CURSOR_UNDERLINE
HD44780_CURSOR_BLINK
HD44780_SHIFT_CURSOR_LEFT
HD44780_SHIFT_CURSOR_RIGHT
HD44780_SHIFT_DISPLAY_LEFT
HD44780_SHIFT_DISPLAY_RIGHT
update_baudrate
$lcd->update_baudrate($baudrate);
Update the interface baudrate to the new value.
update_geometry
$lcd->update_geometry();
Update the interface geometry with the 'width' and 'lines' values passed in the $lcd constructor.
LICENSE
This work is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or any later version.
License Note
I would normally release any Perl code under the Perl Artistic License but this module wraps several GPL / LGPL C libraries and I feel that the licensing of the entire distribution is simpler if the Perl code is under GPL too.
AUTHOR
Mark Dootson, <mdootson at cpan.org>
COPYRIGHT
Copyright (C) 2012-2013 Mark Dootson, all rights reserved.