/ README.rst
README.rst
1 Introduction 2 ============ 3 4 .. image:: https://readthedocs.org/projects/adafruit-circuitpython-ssd1306/badge/?version=latest 5 :target: https://circuitpython.readthedocs.io/projects/ssd1306/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_SSD1306/workflows/Build%20CI/badge.svg 13 :target: https://github.com/adafruit/Adafruit_CircuitPython_SSD1306/actions/ 14 :alt: Build Status 15 16 Adafruit CircuitPython driver for SSD1306 or SSD1305 OLED displays. Note that SSD1305 displays are back compatible so they can be used in-place of SSD1306 with the same code and commands. 17 18 This driver implements the `adafruit_framebuf interface <https://circuitpython.readthedocs.io/projects/framebuf/en/latest/>`__. It is **not** the `displayio` driver for the SSD1306. See the `Adafruit CircuitPython DisplayIO SSD1306 <https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SSD1306/>`_ driver for `displayio` support. 19 20 21 Dependencies 22 ============= 23 This driver depends on: 24 25 * `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_ 26 * `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_ 27 * `Adafruit framebuf <https://github.com/adafruit/Adafruit_CircuitPython_framebuf>`_ 28 29 Please ensure all dependencies are available on the CircuitPython filesystem. 30 This is easily achieved by downloading 31 `the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_. 32 33 Installing from PyPI 34 ==================== 35 36 On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from 37 PyPI <https://pypi.org/project/adafruit-circuitpython-ssd1306/>`_. To install for current user: 38 39 .. code-block:: shell 40 41 pip3 install adafruit-circuitpython-ssd1306 42 43 To install system-wide (this may be required in some cases): 44 45 .. code-block:: shell 46 47 sudo pip3 install adafruit-circuitpython-ssd1306 48 49 To install in a virtual environment in your current project: 50 51 .. code-block:: shell 52 53 mkdir project-name && cd project-name 54 python3 -m venv .env 55 source .env/bin/activate 56 pip3 install adafruit-circuitpython-ssd1306 57 58 Usage Example 59 ============= 60 61 .. code-block:: python3 62 63 # Basic example of clearing and drawing pixels on a SSD1306 OLED display. 64 # This example and library is meant to work with Adafruit CircuitPython API. 65 # Author: Tony DiCola 66 # License: Public Domain 67 68 # Import all board pins. 69 from board import SCL, SDA 70 import busio 71 72 # Import the SSD1306 module. 73 import adafruit_ssd1306 74 75 76 # Create the I2C interface. 77 i2c = busio.I2C(SCL, SDA) 78 79 # Create the SSD1306 OLED class. 80 # The first two parameters are the pixel width and pixel height. Change these 81 # to the right size for your display! 82 display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c) 83 # Alternatively you can change the I2C address of the device with an addr parameter: 84 #display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, addr=0x31) 85 86 # Clear the display. Always call show after changing pixels to make the display 87 # update visible! 88 display.fill(0) 89 90 display.show() 91 92 93 More examples and details can be found in the `adafruit_framebuf docs <https://circuitpython.readthedocs.io/projects/framebuf/en/latest>`__. 94 95 96 Contributing 97 ============ 98 99 Contributions are welcome! Please read our `Code of Conduct 100 <https://github.com/adafruit/adafruit_CircuitPython_SSD1306/blob/master/CODE_OF_CONDUCT.md>`_ 101 before contributing to help this project stay welcoming. 102 103 Documentation 104 ============= 105 106 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>`_.