# max7219_7

Library to support an 8-character 7-segment display with MAX7219

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

Description

    See the description of max7219_common.jal.
    The functionality is similar to the TM1638 library.
    This library supports a single MAX7219 module with an 8 character
    7-segment display.
    This library supports binary, signed and unsigned decimal and unsigned
    hexadecimal representations. It does not support display of strings.
    Individual digits or segment patterns are addressed from left to right
    (offset 0 addresses the leftmost digit). However with the procedures to
    display formatted numbers an offset from the right must be specified.

Notes

    - The feature to decode digits to segment patterns (builtin font) is
             not used, for the following reasons:
             * The builtin font does not support hexadecimal digits (A..F), so
               an external font is required anyway, thus the 'no-decode' mode.
             * Switching between decode and no-decode mode proved to give
               sometimes undesired effects, especially with screen 'blanking'.

Dependencies

- max7219_font
- max7219_common

## Summary

### Global variables/contants

- `const byte MAX7219_WIDTH = 8`

### Procedures

- `max7219_display_blink(byte in times, byte in halfperiod)`
- `max7219_display_dword_hex(dword in number, byte in offset)`
- `max7219_init()`
- `max7219_display_byte_bin(byte in number)`
- `max7219_display_clear_all()`
- `max7219_display_word_hex(word in number, byte in offset)`
- `max7219_display_test(byte in period)`
- `max7219_display_clear(byte in offset)`
- `max7219_display_pattern(byte in pattern, byte in offset)`
- `max7219_display_byte_hex(byte in number, byte in offset)`
- `max7219_display_digit(byte in digit, byte in offset, bit in dp)`
- `max7219_display_intensity(byte in intensity)`

Private

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

### Functions

## API details

### Global variables/contants

- `const byte MAX7219_WIDTH = 8`

      number of 7-segment displays

### 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
       Time in 0.1 seconds of the on and off periods (duty cycle is 50%)
      Notes:  All 'on' segments will blink simultaneously.

- `max7219_display_dword_hex(dword in number, byte in offset)`

      Title:  Display doubleword as 8 hexadecimal digits
      Input:  - Dword value to be displayed
       Offset of the rightmost digit from the rightmost position
      Notes:  - No decimal points

- `max7219_init()`

      Title:  Initialize 8 digits 7-segment module with MAX7219
      Input:  (none)
      Notes:  Must be called before any other operation involving the display

- `max7219_display_byte_bin(byte in number)`

      Title:  Display binary number
      Input:  - Byte value to be displayed
      Notes:  - No decimal points

- `max7219_display_clear_all()`

      Title: Clear all display digits (all segments off)
      Input: (none)

- `max7219_display_word_hex(word in number, byte in offset)`

      Title:  Display word as 4 hexadecimal digits
      Input:  - Word value to be displayed
       Offset of the rightmost digit from the rightmost position
      Notes:  - No decimal points

- `max7219_display_test(byte in period)`

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

- `max7219_display_clear(byte in offset)`

      Title: Clear a single display digit (all segments off)
      Input: Offset of digit from the left (0..7)

- `max7219_display_pattern(byte in pattern, byte in offset)`

      Title: Display segment pattern of a digit.
      Input: - Segment pattern to be displayed (byte)
       Offset of the digit from the left (byte, 0..7)

- `max7219_display_byte_hex(byte in number, byte in offset)`

      Title:  Display byte as 2 hexadecimal digits
      Input:  - Byte value to be displayed
       Offset of the rightmost digit from the rightmost position
      Notes:  - No decimal points

- `max7219_display_digit(byte in digit, byte in offset, bit in dp)`

      Title: Display a byte with decimal point
      Input: - Byte with (hexa)decimal digit to be displayed (0..15)
       Offset of digit from the left (byte, 0..7)
       Flag for decimal point (bit, 0 = no DP, 1 = DP)

- `max7219_display_intensity(byte in intensity)`

      Title:  Set LED intensity
      Input:  LED intensity (supported range 0..15)

Private

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

      Title:  Transfer addr + data to the max7219
      Input:  - address (command) byte
       data byte

### Functions

## Related samples

Here are the list of samples which use this library:

12f1840 | 12f1840_max7219_7_spi_hw.jal