/ README.rst
README.rst
1 Introduction 2 ============= 3 4 .. image:: https://readthedocs.org/projects/adafruit-circuitpython-ht16k33/badge/?version=latest 5 :target: https://circuitpython.readthedocs.io/projects/ht16k33/en/latest/ 6 :alt: Documentation Status 7 8 .. image :: https://img.shields.io/discord/327254708534116352.svg 9 :target: https://adafru.it/discord 10 :alt: Discord 11 12 .. image:: https://github.com/adafruit/Adafruit_CircuitPython_HT16K33/workflows/Build%20CI/badge.svg 13 :target: https://github.com/adafruit/Adafruit_CircuitPython_HT16K33/actions/ 14 :alt: Build Status 15 16 This is a library for using the I²C-based LED matrices with the HT16K33 chip. 17 It supports both 16x8 and 8x8 matrices, as well as 7- and 14-segment displays. 18 19 * **Notes** 20 21 #. This library is intended for Adafruit CircuitPython's API. For a library compatible with MicroPython machine API see this `library <https://github.com/adafruit/micropython-adafruit-ht16k33>`_. 22 23 #. This library does not work with the Trellis 4x4 LED+Keypad board. For that product use: `CircuitPython Trellis Library <https://github.com/adafruit/Adafruit_CircuitPython_Trellis/releases/latest>`_ 24 25 Dependencies 26 ============= 27 This driver depends on: 28 29 * `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_ 30 * `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_ 31 32 Please ensure all dependencies are available on the CircuitPython filesystem. 33 This is easily achieved by downloading 34 `the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_. 35 36 Installing from PyPI 37 ==================== 38 39 On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from 40 PyPI <https://pypi.org/project/adafruit-circuitpython-ht16k33/>`_. To install for current user: 41 42 .. code-block:: shell 43 44 pip3 install adafruit-circuitpython-ht16k33 45 46 To install system-wide (this may be required in some cases): 47 48 .. code-block:: shell 49 50 sudo pip3 install adafruit-circuitpython-ht16k33 51 52 To install in a virtual environment in your current project: 53 54 .. code-block:: shell 55 56 mkdir project-name && cd project-name 57 python3 -m venv .env 58 source .env/bin/activate 59 pip3 install adafruit-circuitpython-ht16k33 60 61 Usage Example 62 ============= 63 64 .. code-block :: python 65 66 # Import all board pins and bus interface. 67 import board 68 import busio 69 70 # Import the HT16K33 LED matrix module. 71 from adafruit_ht16k33 import matrix 72 73 # Create the I2C interface. 74 i2c = busio.I2C(board.SCL, board.SDA) 75 76 # Create the matrix class. 77 # This creates a 16x8 matrix: 78 matrix = matrix.Matrix16x8(i2c) 79 # Or this creates a 8x8 matrix: 80 #matrix = matrix.Matrix8x8(i2c) 81 # Or this creates a 8x8 bicolor matrix: 82 #matrix = matrix.Matrix8x8x2 83 # Finally you can optionally specify a custom I2C address of the HT16k33 like: 84 #matrix = matrix.Matrix16x8(i2c, address=0x70) 85 86 # Clear the matrix. 87 matrix.fill(0) 88 89 # Set a pixel in the origin 0,0 position. 90 matrix[0, 0] = 1 91 # Set a pixel in the middle 8, 4 position. 92 matrix[8, 4] = 1 93 # Set a pixel in the opposite 15, 7 position. 94 matrix[15, 7] = 1 95 matrix.show() 96 97 # Change the brightness 98 matrix.brightness = 8 99 100 # Set the blink rate 101 matrix.blink_rate = 2 102 103 104 Contributing 105 ============ 106 107 Contributions are welcome! Please read our `Code of Conduct 108 <https://github.com/adafruit/Adafruit_CircuitPython_HT16K33/blob/master/CODE_OF_CONDUCT.md>`_ 109 before contributing to help this project stay welcoming. 110 111 Documentation 112 ============= 113 114 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>`_.