The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Device::PaPiRus - Raspberry Pi "PaPiRus" e-paper display

SYNOPSIS

  use Device::PaPiRus;
  use GD;
  
  my $img = GD::Image->new('cvc.png');
  my $papirus = Device::PapiRus->new();

  $papirus->setThreshold(100);
  $papirus->fullUpdate($img);
  

DESCRIPTION

Device::PaPiRus is a library to use the PaPiRus e-paper display from Perl with the help of the GD image library.

The Image must match the size of the panel exactly. Also the transformation to a single-bit black&white image in this library is rather simple: take the average of R+G+B to make it greyscale, then see if it's above the given threshold.

While the implementation is simple, it still allows you a few simple "animations" with whatever framerate you can get out of your panel. For example, if you have a white-to-black gradient in the image, you can move the threshold and repaint the image to make a simple "moving" animation. Also, you can set either randomize the white or black pixels while repainting the image over and over again. Nothing fancy, for more elaborate stuff look into the GD library itself.

FUNCTIONS

new

Takes no arguments. Checks for a display panel and reads out its size.

getWidth

Returns the width of the panel in pixels.

getHeight

Returns the height of the panel in pixels.

setThreshold

Sets the threshold of where black ends and white begins. Default: 150

randomizeWhite

A true value means white pixels are randomized. Default: false

randomizeBlack

A true value means black pixels are randomized. Default: false

useGreyscale

Use a pseudo-greyscale implementation with handcoded disthering. Default: 0

The following values are supported

    0 ... disables
    1 ... 2x2 pixel grid
    2 ... 3x3 pixel grid
    3 ... 4x4 pixel grid

When greyscale is enabled, it ignores randomizeWhite, randomizeBlack and setThreshold.

useDithering

Use an experimental dithering implementation, which may or (most likely) may not work. Default: 0

The following values are supported

    0 ... disables
    1 ... 2x2 pixel grid
    2 ... 3x3 pixel grid
    3 ... 4x4 pixel grid

When dithering is enabled, it ignores randomizeWhite, randomizeBlack, setThreshold and useGreyscale.

fullUpdate

Does a "full" update of the display panel (complete clearing by inverting pixels and stuff). Slow and annoying, but guarantuees that all pixels are nice, shiny and in the correct color.

partialUpdate

Does a "partial" update of the display panel. This only overwrites pixels that have changed. A bit quicker than a full update, no annoying going-to-black-and-back flicker, but may leave artifacts. If you need "quick" screen updates for a demo, a partial update is the way to go. If you want very crisp text, you should choose a full update, at least every few screen updates.

INSTALLATION NOTES

This module uses the EPD fuse module from the rePaper project for low level device access. Something like this should get you going on Raspbian:

First, enable SPI in raspi-config (make sure it's loaded on boot).

Then:

  sudo apt-get install libfuse-dev python-imaging python-setuptools
  sudo easy_install pip

  git clone https://github.com/repaper/gratis.git
  cd gratis/PlatformWithOS
  make PANEL_VERSION=V231_G2 rpi-epd_fuse
  sudo make PANEL_VERSION=V231_G2 rpi-install

The next step is to edit /etc/default/epd-fuse. Make sure you got the correct panel size (EPD_SIZE) selected (for example 2.7).

Then reboot. If there is a problem, try

  sudo service epd-fuse start

There's also a manual from Adafruit here: https://learn.adafruit.com/repaper-eink-development-board-arm-linux-raspberry-pi-beagle-bone-black?view=all. Beware, the Adafruit manual is based on a slightly older library and uses a slightly different panel.

AUTHOR

Rene Schickbauer, <rene.schickbauer@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2008-2016 by Rene Schickbauer

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.