NAME

    Device::Chip::MAX7219 - chip driver for a MAX7219

SYNOPSIS

       use Device::Chip::MAX7219;
       use Future::AsyncAwait;
    
       my $chip = Device::Chip::MAX7219->new;
       await $chip->mount( Device::Chip::Adapter::...->new );
    
       await $chip->power(1);
    
       await $chip->intensity( 2 );
       await $chip->limit( 8 );
    
       await $chip->displaytest( 1 );
       await $chip->shutdown( 0 );
    
       sleep 3;
    
       await $chip->displaytest( 0 );

DESCRIPTION

    This Device::Chip subclass provides specific communication to a Maxim
    Integrated MAX7219 chip attached to a computer via an SPI adapter. As
    the MAX7221 chip operates virtually identically, this chip will work
    too.

    This module drives a single MAX7219 chip. For situations involving
    multiple chips daisy-chained together (such as on popular LED matrix
    display board modules) see instead Device::Chip::MAX7219Panel.

    The reader is presumed to be familiar with the general operation of
    this chip; the documentation here will not attempt to explain or define
    chip-specific concepts or features, only the use of this module to
    access them.

METHODS

    The following methods documented in an await expression return Future
    instances.

 write_bcd

       await $chip->write_bcd( $digit, $val );

    Writes the value at the given digit, setting it to BCD mode if not
    already so. $val should be a single digit number or string, or one of
    the special recognised characters in BCD mode of -, E, H, L, P or
    space. The value may optionally be followed by a decimal point ., which
    will be set on the display.

    Switches the digit into BCD mode if not already so.

 write_raw

       await $chip->write_raw( $digit, $bits );

    Writes the value at the given digit, setting the raw column lines to
    the 8-bit value given.

    Switches the digit into undecoded raw mode if not already so.

 write_hex

       await $chip->write_hex( $digit, $val );

    Similar to write_bcd, but uses a segment decoder written in code rather
    than on the chip itself, to turn values into sets of segments to
    display. This makes it capable of displaying the letters A to F, in
    addition to numbers, - and space.

 set_decode

       await $chip->set_decode( $bits );

    Directly sets the decode mode of all the digits at once. This is more
    efficient for initialising digits into BCD or raw mode, than individual
    calls to write_bcd or write_raw for each digit individually.

 intensity

       await $chip->intensity( $value );

    Sets the intensity register. $value must be between 0 and 15, with
    higher values giving a more intense output.

 limit

       await $chip->limit( $columns );

    Sets the scan limit register. $value must be between 1 and 8, to set
    between 1 and 8 digits. This should only be used to adjust for the
    number of LED digits or columns units physically attached to the chip;
    not for normal display blanking, as it affects the overall intensity.

    Note that this is not directly the value written to the LIMIT register.

 shutdown

       await $chip->shutdown( $off );

    Sets the shutdown register, entirely blanking the display and turning
    off all output if set to a true value, or restoring the display to its
    previous content if set false.

    Note that this is not directly the value written to the SHUTDOWN
    register.

 displaytest

       await $chip->displaytest( $on );

    Sets the display test register, overriding the output control and
    turning on every LED if set to a true value, or restoring normal
    operation if set to false.

AUTHOR

    Paul Evans <leonerd@leonerd.org.uk>