NAME

Device::PCD8544 - Driver for the PCD8544 LCD controller (aka Nokia 5110)

SYNOPSIS

my $rpi = Device::WebIO::RaspberryPi->new;
my $lcd = Device::PCD8544->new({
    dev      => 0,
    speed    => Device::PCD8544->SPEED_4MHZ,
    webio    => $rpi,
    power    => 2,
    rst      => 24,
    dc       => 23,
    contrast => 0x3C,
    bias     => Device::PCD8544->BIAS_1_40,
});

$lcd->init;
$lcd->set_image( \@PIC_OUT );
$lcd->update;

DESCRIPTION

Implements the PCD8544 LCD controller using Device::WebIO. This display is 84x48 pixels of black-and-white. It's similar to the one on the Nokia 5110 phone.

METHODS

new

 new({
    dev      => 0,
    speed    => Device::PCD8544->SPEED_4MHZ,
    webio    => $webio,
    power    => 2,
    rst      => 24,
    dc       => 23,
    contrast => 0x60,
    bias     => Device::PCD8544->BIAS_1_48,
}); 

Constructor. Params:

  • dev: SPI device number against the webio object

  • speed: SPI speed to run at. Using SPEED_4MHZ is good for most purposes. If you're running at much less than 3V, you may want to reduce this to SPEED_2MHZ.

  • webio: Device::WebIO object that does the DigitalOutput and SPI roles.

  • power: GPIO pin that's powering the device. As the display itself only draws a few milliamps, it's safe to power it from GPIO.

  • rst: GPIO pin for the reset wire.

  • dc: GPIO pin for the Data/Control wire.

  • contrast: Contrast level for the display. This should be between 0x00 and 0x7F. 0x3C is usually a nice default.

  • bias: Set bias level of the device. Default is BIAS_1_48. See the device datasheet for details.

init

Sets up the pins and brings the device up. Must be called before doing anything else.

set_image

set_image( \@IMG );

Sets an arrayref image. Each entry is an 8-bit word, with each bit representing a pixel. See Device::PCD8544::ConvertImage for converting Imager objects into this format.

Be sure to call update() to actually send the image to the display.

update

Send our image buffer to the display.

reset

Reset the device.

contrast

contrast( 0x40 )

Set the contrast on the device.

bias

$self->bias( $self->BIAS_1_80 )

Set the bias on the device. See the datasheet for details. The following constants are defined:

BIAS_1_100
BIAS_1_80
BIAS_1_65
BIAS_1_48
BIAS_1_40
BIAS_1_24
BIAS_1_18
BIAS_1_10

display_blank

Blank out all pixels on the display.

display_normal

Normal display mode of black on white background.

display_all_on

Turns on all pixels.

display_inverse

Inverse display mode of white on black background.

SEE ALSO

Datasheet: http://www.sparkfun.com/datasheets/LCD/Monochrome/Nokia5110.pdf

LICENSE

Copyright (c) 2015 Timm Murray All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of 
  conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of
  conditions and the following disclaimer in the documentation and/or other materials 
  provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.