/ README.rst
README.rst
  1  
  2  Introduction
  3  ============
  4  
  5  .. image :: https://readthedocs.org/projects/adafruit-circuitpython-max7219/badge/?version=latest
  6      :target: https://circuitpython.readthedocs.io/projects/max7219/en/latest/
  7      :alt: Documentation Status
  8  
  9  .. image :: https://img.shields.io/discord/327254708534116352.svg
 10      :target: https://adafru.it/discord
 11      :alt: Discord
 12  
 13  .. image:: https://github.com/adafruit/Adafruit_CircuitPython_MAX7219/workflows/Build%20CI/badge.svg
 14      :target: https://github.com/adafruit/Adafruit_CircuitPython_MAX7219/actions/
 15      :alt: Build Status
 16  
 17  CircuitPython driver for the MAX7219 LED matrix driver chip.
 18  
 19  See `here <https://github.com/adafruit/micropython-adafruit-max7219>`_ for the equivalent MicroPython driver.
 20  
 21  Dependencies
 22  =============
 23  This driver depends on:
 24  
 25  * `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
 26  
 27  Please ensure all dependencies are available on the CircuitPython filesystem.
 28  This is easily achieved by downloading
 29  `the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
 30  
 31  Installing from PyPI
 32  ====================
 33  
 34  On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
 35  PyPI <https://pypi.org/project/adafruit-circuitpython-max7219/>`_. To install for current user:
 36  
 37  .. code-block:: shell
 38  
 39      pip3 install adafruit-circuitpython-max7219
 40  
 41  To install system-wide (this may be required in some cases):
 42  
 43  .. code-block:: shell
 44  
 45      sudo pip3 install adafruit-circuitpython-max7219
 46  
 47  To install in a virtual environment in your current project:
 48  
 49  .. code-block:: shell
 50  
 51      mkdir project-name && cd project-name
 52      python3 -m venv .env
 53      source .env/bin/activate
 54      pip3 install adafruit-circuitpython-max7219
 55  
 56  Usage Example
 57  =============
 58  
 59  adafruit_max7219.Matrix8x8 Example
 60  ----------------------------------
 61  
 62  .. code-block:: python
 63  
 64        from adafruit_max7219 import matrices
 65        from board import TX, RX, A2
 66        import busio
 67        import digitalio
 68        import time
 69  
 70        clk = RX
 71        din = TX
 72        cs = digitalio.DigitalInOut(A2)
 73  
 74        spi = busio.SPI(clk, MOSI=din)
 75        display = matrices.Matrix8x8(spi, cs)
 76        while True:
 77            display.brightness(3)
 78  
 79            display.fill(1)
 80            display.pixel(3, 3)
 81            display.pixel(3, 4)
 82            display.pixel(4, 3)
 83            display.pixel(4, 4)
 84            display.show()
 85            time.sleep(3.0)
 86  
 87            display.clear_all()
 88            s = 'Hello, World!'
 89            for c in range(len(s)*8):
 90                display.fill(0)
 91                display.text(s,-c,0)
 92                display.show()
 93                time.sleep(0.25)
 94  
 95  
 96  adafruit_max7219.BCDDigits Example
 97  ----------------------------------
 98  
 99  .. code-block:: python
100  
101        from adafruit_max7219 import bcddigits
102        from board import TX, RX, A2
103        import bitbangio
104        import digitalio
105  
106        clk = RX
107        din = TX
108        cs = digitalio.DigitalInOut(A2)
109  
110        spi = bitbangio.SPI(clk, MOSI=din)
111        display = bcddigits.BCDDigits(spi, cs, nDigits=8)
112        display.clear_all()
113        display.show_str(0,'{:9.2f}'.format(-1234.56))
114        display.show()
115  
116  Contributing
117  ============
118  
119  Contributions are welcome! Please read our `Code of Conduct
120  <https://github.com/adafruit/Adafruit_CircuitPython_max7219/blob/master/CODE_OF_CONDUCT.md>`_
121  before contributing to help this project stay welcoming.
122  
123  Documentation
124  =============
125  
126  For information on building library documentation, please check out `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.