Subject: | Several bugs found and fixed |
Date: | Wed, 14 Jan 2015 10:12:21 -0000 |
To: | bug-Device-BCM2835-LCD [...] rt.cpan.org |
From: | "Tomas Christian Jensen" <tcj [...] tomas.dk> |
Hi,
First of all, thanks a lot for a great tool. Works fine.
But when I first tried it there where some major bugs when running on
Raspberry pi B+
The wiring has to be this way:
my %RPI_PIN = qw(
RPI_GPIO_P1_03 0
RPI_GPIO_P1_05 1
RPI_GPIO_P1_07 4
RPI_GPIO_P1_08 14
RPI_GPIO_P1_10 15
RPI_GPIO_P1_11 17
RPI_GPIO_P1_12 18
RPI_GPIO_P1_13 27
RPI_GPIO_P1_15 22
RPI_GPIO_P1_16 23
RPI_GPIO_P1_18 24
RPI_GPIO_P1_19 10
RPI_GPIO_P1_21 9
RPI_GPIO_P1_22 25
RPI_GPIO_P1_23 11
RPI_GPIO_P1_24 8
RPI_GPIO_P1_26 7
);
Init had a bug with passing arguments. Fixed:
sub init {
my $self = shift;
my %defaults = qw(
Display 2004
pin_rs RPI_GPIO_P1_24
pin_e RPI_GPIO_P1_23
pin_d4 RPI_GPIO_P1_07
pin_d5 RPI_GPIO_P1_11
pin_d6 RPI_GPIO_P1_13
pin_d7 RPI_GPIO_P1_15
);
my %args = (%defaults, %_);
The init sequense was missing a delay:
# initialise the device in 4 bit mode
# During this phase of display init there's
# some specific timing requirements,
# so can't use generic cmd()s...
$self->delay(40); # wait 40ms for screen to power-up
# I really don't think this is necessary
# considering how long it takes to boot
# the R-Pi...
Device::BCM2835::gpio_write($rs,0); # cmd mode
Device::BCM2835::gpio_write($e,0); # start with EN low
nibbleToLines(3); # high nibble 0x03
&strobe_E; # strobe EN
usleep(5000); # allow display to finish last cmd
nibbleToLines(3); # low nibble 0x03
&strobe_E; # strobe EN
usleep(200);
nibbleToLines(3); # high nibble 0x03
&strobe_E; # strobe EN
usleep(200);
nibbleToLines(2); # low nibble 0x02, 4 bit mode
&strobe_E; # strobe EN
$self->delay(5);
Clear display does also miss a delay:
sub ClearDisplay {
my $self = shift;
$self->cmd(0x01);
usleep 5000; # mandatory delay
}
--
Regards
Tomas Jensen
http://vejr.tomas.dk/ps/