# max7219_n

Library to support cascaded 8x8 led matrices with MAX7219s

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

Description

    See the description of max7219.jal.

Notes

    - This library is designed for max7219 modules controlling an 8x8 LED matrix,
             the features of the MAX7219 chips for 7-segment displays are disabled.
           - The terms 'row' and 'column' are ambiguous: depending on the orientation
             of the module! This library calls the LEDs which can be written with a
             single write operation a column. Writing a row of a single module requires
             8 writes and the cache being active.
             See the procedures max7219_display_col() and max7219_display_row().

Dependencies

- max7219_common

## Summary

### Global variables/contants

### Procedures

- `max7219_display_blink(byte in times, byte in halfperiod)`
- `max7219_init()`
- `max7219_display_byte_bin(byte in num, byte in col, byte in data)`
- `max7219_display_row(byte in num, byte in row, bit in state)`
- `max7219_display_test(byte in period)`
- `max7219_display_col(byte in num, byte in col, bit in state)`
- `max7219_display_bit(byte in num, byte in col, byte in row, bit in state)`
- `max7219_display_clear()`
- `max7219_display_intensity(byte in intensity)`

Private

- `_max7219_write(byte in num, byte in addr, byte in data)`
- `_max7219_write_all(byte in addr, byte in data)`

### Functions

## API details

### Global variables/contants

### Procedures

- `max7219_display_blink(byte in times, byte in halfperiod)`

      Title:  Blink whole module a number of times at a given speed
      Input:  - number of times the display should blink off and on (byte)
       time in 0.1 seconds of the on and off periods (duty cycle is 50%)
      Notes:  All 'on' LEDs of all modules will blink simultaneously.

- `max7219_init()`

      Title:  Initialize all modules with max7219
      Input:  (none)
      Notes:  Must be called before any other operation involving the display

- `max7219_display_byte_bin(byte in num, byte in col, byte in data)`

      Title: Display a column (byte, 8 bits) of one module
      Input: - module number (byte, 0..7)
       column number (byte, 0..7)
       with bit pattern to be displayed (byte)

- `max7219_display_row(byte in num, byte in row, bit in state)`

      Title: Display a row of leds (all leds in a row on or off) in one module
      Input: - module number (byte, 0..7)
       row number (byte, 0..7)
       led state (bit, true or false, resp. on or off)
      Notes: - Writes 8 columns of 1 module.

- `max7219_display_test(byte in period)`

      Title:  Put all MAX7219 modules in test mode for some time.
      Input:  test period (byte, number of 0.1 seconds)
      Notes:  All leds will be in maximum intensity during the specified period

- `max7219_display_col(byte in num, byte in col, bit in state)`

      Title: Display a column of leds (all leds in a column on or off)
      Input: - module number (byte, 0..7)
       column number (byte, 0..7)
       led state (true or false, resp. on or off)

- `max7219_display_bit(byte in num, byte in col, byte in row, bit in state)`

      Title: Set or reset a single LED
      Input: - module number (byte, 0..7)
       column number (byte, 0..7)
       row number (byte, 0..7)
       led state (bit, true or false, on or off)
      Notes: - Writes 1 column of one module

- `max7219_display_clear()`

      Title:  Clear display (all LEDs off)
      Input:  (none)
      Notes:  All LEDs of all modules will be cleared
      (write 8 times the same column of every module))

- `max7219_display_intensity(byte in intensity)`

      Title:  Set LED intensity
      Input:  LED intensity (range 0..15)
      Notes:  All LEDs of all modules will have the same luminosity

Private

- `_max7219_write(byte in num, byte in addr, byte in data)`

      Title:  transfer addr + data to a specific max7219 in the chain
      Input:  - module number (0..7)
       address (command) byte
       data byte
      Notes:  Data/command is for 1 module, others in the chain receive a NOP.
      The last module in the chain is addressed first.

- `_max7219_write_all(byte in addr, byte in data)`

      Title:  transfer addr + data to all MAX7219s in the chain
      Input:  - addr
       data
      Notes:  All modules receive the same addr + data

### Functions

## Related samples

Here are the list of samples which use this library:

12f1840 | 12f1840_max7219_n_spi_sw.jal
12f1840 | 12f1840_max7219_n_spi_hw.jal
12f683 | 12f683_max7219_n_spi_sw.jal