HiPi
Perl Modules for Raspberry Pi
Version 0.74 - released 20 November 2018

HiPi::Interface::ZeroSeg

This module provides an interface to the ZeroSeg 8 digit LED Matrix display distribited by The Pi Hut.

It uses HiPi::Interface::MAX7219 as a backend.

Methods

Create a new instance of the class

use HiPi qw( :max7219 );
use HiPi::Interface::ZeroSeg;

my $dev = HiPi::Interface::ZeroSeg->new();

Write the string in $text directly to the display.
If length($text) is less than 8, the string is left padded with spaces
If length($text) is more than 8, the extra characters are truncated

The chars in text are mapped to the most appropriate LED segment configuration. The LED matrices are designed to display numbers so your mileage with none numeric characters will vary.

$dev->write_text('20 == 20');

Format the output setting decimal point where appropriate

$dev->write_decimal_number( 25 );
$dev->write_decimal_number( 25.6 );
$dev->write_decimal_number( -25.84 );

Write the $degrees with a following degree symbol and optionally followed by 'F' or 'C' if either is specified in $scale

$dev ->write_degrees( 11 );
$dev ->write_degrees( 21.01, 'C' );
$dev ->write_degrees( 69.58, 'F' );

Write time with hour, minute and second separated by the matrix decimal point. If $second is not defined, the display will only show hours and minutes.

$dev ->write_time( 12, 55, 45 );
$dev ->write_time( 12, 55 );

Write out the time as returned by Perl function localtime. If '$skipseconds' evaluates to true, only hours and minutes are written

$dev->write_localtime();
$dev->write_localtime(1);

Write out the time as returned by Perl function gmtime. If '$skipseconds' evaluates to true, only hours and minutes are written

$dev->write_gmtime();
$dev->write_gmtime(1);

Set all matrix segments off

$dev->clear_display();

Set the intensity (brightness) of the display.

$value is an integer from 1 ( low ) to 15 ( high ).

The startup default value is 2.

$dev->set_intensity(8);

By default the module will shutdown the MAX7219 LED matrix display driver on script exit. You can switch this behaviour on / off.

$dev->set_shutdown_on_exit( 1 ); # ON
$dev->set_shutdown_on_exit( 0 ); # OFF

Wake up the the MAX7219 LED matrix display driver

$dev->wake_up();

Shutdown the MAX7219 LED matrix display driver

$dev->shut_down();

You can write 8 bytes directly to the display, bypassing text conversion and decimal point handling in this module.

How each byte will set its matrix LEDs and decimal point is shown in the table below.

$dev->write_raw_bytes( @bytes );

You can write text to a buffer which then gets written to the display when you call 'write_buffer'

$dev->set_buffer_text('Some long text that will get interpreted somehow.    ');
while(1) {
    $dev->write_buffer;
    $dev->scroll_buffer_left;
    sleep(1);
}

You can write text to a buffer which then gets written to the display when you call 'write_buffer'

$dev->set_buffer_text('Some long text that will get interpreted somehow.    ');
while(1) {
    $dev->write_buffer;
    $dev->scroll_buffer_left;
    sleep(1);
}

You can write text to a buffer which then gets written to the display when you call 'write_buffer'

$dev->set_buffer_text('Some long text that will get interpreted somehow.    ');
while(1) {
    $dev->write_buffer;
    $dev->scroll_buffer_left;
    sleep(1);
}

You can write text to a buffer which then gets written to the display when you call 'write_buffer'

$dev->set_buffer_text('Some long text that will get interpreted somehow.    ');
while(1) {
    $dev->write_buffer;
    $dev->scroll_buffer_right;
    sleep(1);
}