max7219_common

Common library for max7219 libraries

Author Rob Hamerling, Copyright © 2014..2014, all rights reserved.
Adapted-by
Compiler 2.4q3

Description

There are several variants of this library:
 - A library for cascaded MAX7219 modules each with an 8x8 LED matrix.
   Most procedures of this library require the specification of the module
   (sequence number in the chain). Some other procedures apply to all modules
   (clear, blink, etc) and need no sequence number.
 - A subset of this library for a single MAX7219 module with an 8x8 LED matrix.
   Because there is only one module no sequence number is needed in the procedures,
   thus this library is somewhat more efficient in terms of code memory and speed.
 - A library for a single MAX7219 module with 8 7-segment displays
   with a functionality similar to the TM1638 library.
This description applies to all variants, unless otherwise indicated.
.
For multi-module variants you need to specify how many modules are cascaded:
   const MAX7219_NUM =         -- size of the chain
.
For the 8x8 matrix variants of these libraries:
When you want to control LEDs individually while retaining
the state of the other LEDs a cache must be used. This is a builtin
feature of the libraries, but you have to indicate if you need it.
By default the cache is not active and some functions will not be
available. To activate the cache declare:
   const bit MAX7219_DISPLAY_CACHE = TRUE
The cache takes 8 bytes of data memory per MAX7219 module.
.
To initialize the max7219 module(s) call procedure max7219_init().
.
These libraries use either the software SPI library (spi_master_sw, default)
or the hardware SPI library (spi_master_hw).
The advantage of using hardware SPI over software SPI (bit-banging) is
higher efficiency (less CPU cycles and possibly higher speed).
A disadvantage is that it can only be used with PICs with an MSSP module
and that 2 of the 3 leads must be connected to specific pins of the PIC.
.
With software SPI the following needs be declared in the user program before
including the max7219 library:
   const bit MAX7219_SPI_HW = FALSE                 -- (optional, FALSE is default)
   alias max7219_din   is pin_??                    -- pin for data signal (din)
   alias max7219_clk   is pin_??                    -- pin for clock signal (clk)
   alias max7219_cs    is pin_??                    -- pin for chip select signal (cs)
Any pins configurable for digital output can be used for these signals.
.
With hardware SPI the following needs be declared in the user program before
including the max7219[n] library:
   const bit MAX7219_SPI_HW = TRUE                  -- mandatory
   alias max7219_cs    is pin_??                    -- pin for chip select signal (cs)
   pin_SDO of the PIC needs be connected to the 'din' pin of the max7219
   pin_SCK of the PIC needs be connected to the 'clk' pin of the max7219
   Any pin configurable for digital output can be used for max7219_cs
   and must be connected to the 'cs' pin of the max7219.
.
Regardless the selected SPI method all 3 used pins must be configured
for output by the user program.


Notes

-


Dependencies


Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

No sample found