HiPi
view release on metacpan or search on metacpan
lib/HiPi/Interface/Common/HD44780.pm view on Meta::CPAN
@line1 = (0..15);
@line2 = (64..79);
@line3 = (16..31);
@line4 = (80..95);
} else {
@line1 = (0..19);
@line2 = (64..83);
@line3 = (20..39);
@line4 = (84..103);
}
if( $params{lines} == 2 ) {
@pmap = ( @line1, @line2 );
} elsif( $params{lines} == 4 ) {
@pmap = ( @line1, @line2, @line3, @line4 );
}
$params{positionmap} = \@pmap;
}
my $self = $class->SUPER::new(%params);
$self->update_geometry; # will set cols / lines to controller
return $self;
}
sub enable {
my($self, $enable) = @_;
$enable = 1 unless defined($enable);
my $command = ( $enable ) ? HD44780_DISPLAY_ON : HD44780_DISPLAY_OFF;
$self->send_command( $command ) ;
}
sub set_cursor_position {
my($self, $col, $row) = @_;
my $pos = $col + ( $row * $self->width );
$self->send_command( HD44780_CURSOR_POSITION + $self->positionmap->[$pos] );
}
sub move_cursor_left {
$_[0]->send_command( HD44780_SHIFT_CURSOR_LEFT );
}
sub move_cursor_right {
$_[0]->send_command( HD44780_SHIFT_CURSOR_RIGHT );
}
sub home { $_[0]->send_command( HD44780_HOME_UNSHIFT ); }
sub clear { $_[0]->send_command( HD44780_CLEAR_DISPLAY ); $_[0]->delayMicroseconds(2000); }
sub set_cursor_mode { $_[0]->send_command( $_[1] ); }
sub backlight { croak('backlight must be overriden in derived class'); }
sub send_text { croak('send_text must be overriden in derived class'); }
sub send_command { croak('send_command must be overriden in derived class'); }
sub update_baudrate { croak('update_baudrate must be overriden in derived class'); }
sub update_geometry { croak('update_geometry must be overriden in derived class'); }
1;
__END__
( run in 0.653 second using v1.01-cache-2.11-cpan-e1769b4cff6 )