├── .gitattributes ├── .github ├── PULL_REQUEST_TEMPLATE │ └── adafruit_circuitpython_pr.md └── workflows │ ├── build.yml │ ├── failure-help-text.yml │ ├── release_gh.yml │ └── release_pypi.yml ├── .gitignore ├── .pre-commit-config.yaml ├── .readthedocs.yaml ├── CODE_OF_CONDUCT.md ├── LICENSE ├── LICENSES ├── CC-BY-4.0.txt ├── CC-BY-SA-4.0.txt ├── CC0-1.0.txt ├── MIT.txt └── Unlicense.txt ├── README.rst ├── README.rst.license ├── adafruit_ssd1306.py ├── docs ├── _static │ ├── favicon.ico │ └── favicon.ico.license ├── api.rst ├── api.rst.license ├── conf.py ├── examples.rst ├── examples.rst.license ├── index.rst ├── index.rst.license └── requirements.txt ├── examples ├── happycat_oled_32.ppm ├── happycat_oled_32.ppm.license ├── happycat_oled_64.ppm ├── happycat_oled_64.ppm.license ├── ssd1306_bonnet_buttons.py ├── ssd1306_bouncing_ball.py ├── ssd1306_clear.py ├── ssd1306_framebuftest.py ├── ssd1306_pillow_animate.py ├── ssd1306_pillow_clock.py ├── ssd1306_pillow_demo.py ├── ssd1306_pillow_image_display.py ├── ssd1306_pillow_images.py ├── ssd1306_pillow_ip.py ├── ssd1306_pillow_shapes.py ├── ssd1306_pillow_text.py ├── ssd1306_simpletest.py └── ssd1306_stats.py ├── optional_requirements.txt ├── pyproject.toml ├── requirements.txt └── ruff.toml /.gitattributes: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | .py text eol=lf 6 | .rst text eol=lf 7 | .txt text eol=lf 8 | .yaml text eol=lf 9 | .toml text eol=lf 10 | .license text eol=lf 11 | .md text eol=lf 12 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | Thank you for contributing! Before you submit a pull request, please read the following. 6 | 7 | Make sure any changes you're submitting are in line with the CircuitPython Design Guide, available here: https://docs.circuitpython.org/en/latest/docs/design_guide.html 8 | 9 | If your changes are to documentation, please verify that the documentation builds locally by following the steps found here: https://adafru.it/build-docs 10 | 11 | Before submitting the pull request, make sure you've run Pylint and Black locally on your code. You can do this manually or using pre-commit. Instructions are available here: https://adafru.it/check-your-code 12 | 13 | Please remove all of this text before submitting. Include an explanation or list of changes included in your PR, as well as, if applicable, a link to any related issues. 14 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | name: Build CI 6 | 7 | on: [pull_request, push] 8 | 9 | jobs: 10 | test: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Run Build CI workflow 14 | uses: adafruit/workflows-circuitpython-libs/build@main 15 | -------------------------------------------------------------------------------- /.github/workflows/failure-help-text.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Scott Shawcroft for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | name: Failure help text 6 | 7 | on: 8 | workflow_run: 9 | workflows: ["Build CI"] 10 | types: 11 | - completed 12 | 13 | jobs: 14 | post-help: 15 | runs-on: ubuntu-latest 16 | if: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.event == 'pull_request' }} 17 | steps: 18 | - name: Post comment to help 19 | uses: adafruit/circuitpython-action-library-ci-failed@v1 20 | -------------------------------------------------------------------------------- /.github/workflows/release_gh.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | name: GitHub Release Actions 6 | 7 | on: 8 | release: 9 | types: [published] 10 | 11 | jobs: 12 | upload-release-assets: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Run GitHub Release CI workflow 16 | uses: adafruit/workflows-circuitpython-libs/release-gh@main 17 | with: 18 | github-token: ${{ secrets.GITHUB_TOKEN }} 19 | upload-url: ${{ github.event.release.upload_url }} 20 | -------------------------------------------------------------------------------- /.github/workflows/release_pypi.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | name: PyPI Release Actions 6 | 7 | on: 8 | release: 9 | types: [published] 10 | 11 | jobs: 12 | upload-release-assets: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Run PyPI Release CI workflow 16 | uses: adafruit/workflows-circuitpython-libs/release-pypi@main 17 | with: 18 | pypi-username: ${{ secrets.pypi_username }} 19 | pypi-password: ${{ secrets.pypi_password }} 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Kattni Rembor, written for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | # Do not include files and directories created by your personal work environment, such as the IDE 6 | # you use, except for those already listed here. Pull requests including changes to this file will 7 | # not be accepted. 8 | 9 | # This .gitignore file contains rules for files generated by working with CircuitPython libraries, 10 | # including building Sphinx, testing with pip, and creating a virual environment, as well as the 11 | # MacOS and IDE-specific files generated by using MacOS in general, or the PyCharm or VSCode IDEs. 12 | 13 | # If you find that there are files being generated on your machine that should not be included in 14 | # your git commit, you should create a .gitignore_global file on your computer to include the 15 | # files created by your personal setup. To do so, follow the two steps below. 16 | 17 | # First, create a file called .gitignore_global somewhere convenient for you, and add rules for 18 | # the files you want to exclude from git commits. 19 | 20 | # Second, configure Git to use the exclude file for all Git repositories by running the 21 | # following via commandline, replacing "path/to/your/" with the actual path to your newly created 22 | # .gitignore_global file: 23 | # git config --global core.excludesfile path/to/your/.gitignore_global 24 | 25 | # CircuitPython-specific files 26 | *.mpy 27 | 28 | # Python-specific files 29 | __pycache__ 30 | *.pyc 31 | 32 | # Sphinx build-specific files 33 | _build 34 | 35 | # This file results from running `pip -e install .` in a local repository 36 | *.egg-info 37 | 38 | # Virtual environment-specific files 39 | .env 40 | .venv 41 | 42 | # MacOS-specific files 43 | *.DS_Store 44 | 45 | # IDE-specific files 46 | .idea 47 | .vscode 48 | *~ 49 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | repos: 6 | - repo: https://github.com/pre-commit/pre-commit-hooks 7 | rev: v4.5.0 8 | hooks: 9 | - id: check-yaml 10 | - id: end-of-file-fixer 11 | - id: trailing-whitespace 12 | - repo: https://github.com/astral-sh/ruff-pre-commit 13 | rev: v0.3.4 14 | hooks: 15 | - id: ruff-format 16 | - id: ruff 17 | args: ["--fix"] 18 | - repo: https://github.com/fsfe/reuse-tool 19 | rev: v3.0.1 20 | hooks: 21 | - id: reuse 22 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | # Read the Docs configuration file 6 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 7 | 8 | # Required 9 | version: 2 10 | 11 | sphinx: 12 | configuration: docs/conf.py 13 | 14 | build: 15 | os: ubuntu-20.04 16 | tools: 17 | python: "3" 18 | 19 | python: 20 | install: 21 | - requirements: docs/requirements.txt 22 | - requirements: requirements.txt 23 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # Adafruit Community Code of Conduct 8 | 9 | ## Our Pledge 10 | 11 | In the interest of fostering an open and welcoming environment, we as 12 | contributors and leaders pledge to making participation in our project and 13 | our community a harassment-free experience for everyone, regardless of age, body 14 | size, disability, ethnicity, gender identity and expression, level or type of 15 | experience, education, socio-economic status, nationality, personal appearance, 16 | race, religion, or sexual identity and orientation. 17 | 18 | ## Our Standards 19 | 20 | We are committed to providing a friendly, safe and welcoming environment for 21 | all. 22 | 23 | Examples of behavior that contributes to creating a positive environment 24 | include: 25 | 26 | * Be kind and courteous to others 27 | * Using welcoming and inclusive language 28 | * Being respectful of differing viewpoints and experiences 29 | * Collaborating with other community members 30 | * Gracefully accepting constructive criticism 31 | * Focusing on what is best for the community 32 | * Showing empathy towards other community members 33 | 34 | Examples of unacceptable behavior by participants include: 35 | 36 | * The use of sexualized language or imagery and sexual attention or advances 37 | * The use of inappropriate images, including in a community member's avatar 38 | * The use of inappropriate language, including in a community member's nickname 39 | * Any spamming, flaming, baiting or other attention-stealing behavior 40 | * Excessive or unwelcome helping; answering outside the scope of the question 41 | asked 42 | * Trolling, insulting/derogatory comments, and personal or political attacks 43 | * Promoting or spreading disinformation, lies, or conspiracy theories against 44 | a person, group, organisation, project, or community 45 | * Public or private harassment 46 | * Publishing others' private information, such as a physical or electronic 47 | address, without explicit permission 48 | * Other conduct which could reasonably be considered inappropriate 49 | 50 | The goal of the standards and moderation guidelines outlined here is to build 51 | and maintain a respectful community. We ask that you don’t just aim to be 52 | "technically unimpeachable", but rather try to be your best self. 53 | 54 | We value many things beyond technical expertise, including collaboration and 55 | supporting others within our community. Providing a positive experience for 56 | other community members can have a much more significant impact than simply 57 | providing the correct answer. 58 | 59 | ## Our Responsibilities 60 | 61 | Project leaders are responsible for clarifying the standards of acceptable 62 | behavior and are expected to take appropriate and fair corrective action in 63 | response to any instances of unacceptable behavior. 64 | 65 | Project leaders have the right and responsibility to remove, edit, or 66 | reject messages, comments, commits, code, issues, and other contributions 67 | that are not aligned to this Code of Conduct, or to ban temporarily or 68 | permanently any community member for other behaviors that they deem 69 | inappropriate, threatening, offensive, or harmful. 70 | 71 | ## Moderation 72 | 73 | Instances of behaviors that violate the Adafruit Community Code of Conduct 74 | may be reported by any member of the community. Community members are 75 | encouraged to report these situations, including situations they witness 76 | involving other community members. 77 | 78 | You may report in the following ways: 79 | 80 | In any situation, you may send an email to . 81 | 82 | On the Adafruit Discord, you may send an open message from any channel 83 | to all Community Moderators by tagging @community moderators. You may 84 | also send an open message from any channel, or a direct message to 85 | @kattni#1507, @tannewt#4653, @Dan Halbert#1614, @cater#2442, 86 | @sommersoft#0222, @Mr. Certainly#0472 or @Andon#8175. 87 | 88 | Email and direct message reports will be kept confidential. 89 | 90 | In situations on Discord where the issue is particularly egregious, possibly 91 | illegal, requires immediate action, or violates the Discord terms of service, 92 | you should also report the message directly to Discord. 93 | 94 | These are the steps for upholding our community’s standards of conduct. 95 | 96 | 1. Any member of the community may report any situation that violates the 97 | Adafruit Community Code of Conduct. All reports will be reviewed and 98 | investigated. 99 | 2. If the behavior is an egregious violation, the community member who 100 | committed the violation may be banned immediately, without warning. 101 | 3. Otherwise, moderators will first respond to such behavior with a warning. 102 | 4. Moderators follow a soft "three strikes" policy - the community member may 103 | be given another chance, if they are receptive to the warning and change their 104 | behavior. 105 | 5. If the community member is unreceptive or unreasonable when warned by a 106 | moderator, or the warning goes unheeded, they may be banned for a first or 107 | second offense. Repeated offenses will result in the community member being 108 | banned. 109 | 110 | ## Scope 111 | 112 | This Code of Conduct and the enforcement policies listed above apply to all 113 | Adafruit Community venues. This includes but is not limited to any community 114 | spaces (both public and private), the entire Adafruit Discord server, and 115 | Adafruit GitHub repositories. Examples of Adafruit Community spaces include 116 | but are not limited to meet-ups, audio chats on the Adafruit Discord, or 117 | interaction at a conference. 118 | 119 | This Code of Conduct applies both within project spaces and in public spaces 120 | when an individual is representing the project or its community. As a community 121 | member, you are representing our community, and are expected to behave 122 | accordingly. 123 | 124 | ## Attribution 125 | 126 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 127 | version 1.4, available at 128 | , 129 | and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html). 130 | 131 | For other projects adopting the Adafruit Community Code of 132 | Conduct, please contact the maintainers of those projects for enforcement. 133 | If you wish to use this code of conduct for your own project, consider 134 | explicitly mentioning your moderation policy or making a copy with your 135 | own moderation policy so as to avoid confusion. 136 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016, 2017 Adafruit Industries 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSES/CC-BY-4.0.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Attribution 4.0 International Creative Commons Corporation 2 | ("Creative Commons") is not a law firm and does not provide legal services 3 | or legal advice. Distribution of Creative Commons public licenses does not 4 | create a lawyer-client or other relationship. Creative Commons makes its licenses 5 | and related information available on an "as-is" basis. Creative Commons gives 6 | no warranties regarding its licenses, any material licensed under their terms 7 | and conditions, or any related information. Creative Commons disclaims all 8 | liability for damages resulting from their use to the fullest extent possible. 9 | 10 | Using Creative Commons Public Licenses 11 | 12 | Creative Commons public licenses provide a standard set of terms and conditions 13 | that creators and other rights holders may use to share original works of 14 | authorship and other material subject to copyright and certain other rights 15 | specified in the public license below. The following considerations are for 16 | informational purposes only, are not exhaustive, and do not form part of our 17 | licenses. 18 | 19 | Considerations for licensors: Our public licenses are intended for use by 20 | those authorized to give the public permission to use material in ways otherwise 21 | restricted by copyright and certain other rights. Our licenses are irrevocable. 22 | Licensors should read and understand the terms and conditions of the license 23 | they choose before applying it. Licensors should also secure all rights necessary 24 | before applying our licenses so that the public can reuse the material as 25 | expected. Licensors should clearly mark any material not subject to the license. 26 | This includes other CC-licensed material, or material used under an exception 27 | or limitation to copyright. More considerations for licensors : wiki.creativecommons.org/Considerations_for_licensors 28 | 29 | Considerations for the public: By using one of our public licenses, a licensor 30 | grants the public permission to use the licensed material under specified 31 | terms and conditions. If the licensor's permission is not necessary for any 32 | reason–for example, because of any applicable exception or limitation to copyright–then 33 | that use is not regulated by the license. Our licenses grant only permissions 34 | under copyright and certain other rights that a licensor has authority to 35 | grant. Use of the licensed material may still be restricted for other reasons, 36 | including because others have copyright or other rights in the material. A 37 | licensor may make special requests, such as asking that all changes be marked 38 | or described. Although not required by our licenses, you are encouraged to 39 | respect those requests where reasonable. More considerations for the public 40 | : wiki.creativecommons.org/Considerations_for_licensees Creative Commons Attribution 41 | 4.0 International Public License 42 | 43 | By exercising the Licensed Rights (defined below), You accept and agree to 44 | be bound by the terms and conditions of this Creative Commons Attribution 45 | 4.0 International Public License ("Public License"). To the extent this Public 46 | License may be interpreted as a contract, You are granted the Licensed Rights 47 | in consideration of Your acceptance of these terms and conditions, and the 48 | Licensor grants You such rights in consideration of benefits the Licensor 49 | receives from making the Licensed Material available under these terms and 50 | conditions. 51 | 52 | Section 1 – Definitions. 53 | 54 | a. Adapted Material means material subject to Copyright and Similar Rights 55 | that is derived from or based upon the Licensed Material and in which the 56 | Licensed Material is translated, altered, arranged, transformed, or otherwise 57 | modified in a manner requiring permission under the Copyright and Similar 58 | Rights held by the Licensor. For purposes of this Public License, where the 59 | Licensed Material is a musical work, performance, or sound recording, Adapted 60 | Material is always produced where the Licensed Material is synched in timed 61 | relation with a moving image. 62 | 63 | b. Adapter's License means the license You apply to Your Copyright and Similar 64 | Rights in Your contributions to Adapted Material in accordance with the terms 65 | and conditions of this Public License. 66 | 67 | c. Copyright and Similar Rights means copyright and/or similar rights closely 68 | related to copyright including, without limitation, performance, broadcast, 69 | sound recording, and Sui Generis Database Rights, without regard to how the 70 | rights are labeled or categorized. For purposes of this Public License, the 71 | rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. 72 | 73 | d. Effective Technological Measures means those measures that, in the absence 74 | of proper authority, may not be circumvented under laws fulfilling obligations 75 | under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, 76 | and/or similar international agreements. 77 | 78 | e. Exceptions and Limitations means fair use, fair dealing, and/or any other 79 | exception or limitation to Copyright and Similar Rights that applies to Your 80 | use of the Licensed Material. 81 | 82 | f. Licensed Material means the artistic or literary work, database, or other 83 | material to which the Licensor applied this Public License. 84 | 85 | g. Licensed Rights means the rights granted to You subject to the terms and 86 | conditions of this Public License, which are limited to all Copyright and 87 | Similar Rights that apply to Your use of the Licensed Material and that the 88 | Licensor has authority to license. 89 | 90 | h. Licensor means the individual(s) or entity(ies) granting rights under this 91 | Public License. 92 | 93 | i. Share means to provide material to the public by any means or process that 94 | requires permission under the Licensed Rights, such as reproduction, public 95 | display, public performance, distribution, dissemination, communication, or 96 | importation, and to make material available to the public including in ways 97 | that members of the public may access the material from a place and at a time 98 | individually chosen by them. 99 | 100 | j. Sui Generis Database Rights means rights other than copyright resulting 101 | from Directive 96/9/EC of the European Parliament and of the Council of 11 102 | March 1996 on the legal protection of databases, as amended and/or succeeded, 103 | as well as other essentially equivalent rights anywhere in the world. 104 | 105 | k. You means the individual or entity exercising the Licensed Rights under 106 | this Public License. Your has a corresponding meaning. 107 | 108 | Section 2 – Scope. 109 | 110 | a. License grant. 111 | 112 | 1. Subject to the terms and conditions of this Public License, the Licensor 113 | hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, 114 | irrevocable license to exercise the Licensed Rights in the Licensed Material 115 | to: 116 | 117 | A. reproduce and Share the Licensed Material, in whole or in part; and 118 | 119 | B. produce, reproduce, and Share Adapted Material. 120 | 121 | 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions 122 | and Limitations apply to Your use, this Public License does not apply, and 123 | You do not need to comply with its terms and conditions. 124 | 125 | 3. Term. The term of this Public License is specified in Section 6(a). 126 | 127 | 4. Media and formats; technical modifications allowed. The Licensor authorizes 128 | You to exercise the Licensed Rights in all media and formats whether now known 129 | or hereafter created, and to make technical modifications necessary to do 130 | so. The Licensor waives and/or agrees not to assert any right or authority 131 | to forbid You from making technical modifications necessary to exercise the 132 | Licensed Rights, including technical modifications necessary to circumvent 133 | Effective Technological Measures. For purposes of this Public License, simply 134 | making modifications authorized by this Section 2(a)(4) never produces Adapted 135 | Material. 136 | 137 | 5. Downstream recipients. 138 | 139 | A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed 140 | Material automatically receives an offer from the Licensor to exercise the 141 | Licensed Rights under the terms and conditions of this Public License. 142 | 143 | B. No downstream restrictions. You may not offer or impose any additional 144 | or different terms or conditions on, or apply any Effective Technological 145 | Measures to, the Licensed Material if doing so restricts exercise of the Licensed 146 | Rights by any recipient of the Licensed Material. 147 | 148 | 6. No endorsement. Nothing in this Public License constitutes or may be construed 149 | as permission to assert or imply that You are, or that Your use of the Licensed 150 | Material is, connected with, or sponsored, endorsed, or granted official status 151 | by, the Licensor or others designated to receive attribution as provided in 152 | Section 3(a)(1)(A)(i). 153 | 154 | b. Other rights. 155 | 156 | 1. Moral rights, such as the right of integrity, are not licensed under this 157 | Public License, nor are publicity, privacy, and/or other similar personality 158 | rights; however, to the extent possible, the Licensor waives and/or agrees 159 | not to assert any such rights held by the Licensor to the limited extent necessary 160 | to allow You to exercise the Licensed Rights, but not otherwise. 161 | 162 | 2. Patent and trademark rights are not licensed under this Public License. 163 | 164 | 3. To the extent possible, the Licensor waives any right to collect royalties 165 | from You for the exercise of the Licensed Rights, whether directly or through 166 | a collecting society under any voluntary or waivable statutory or compulsory 167 | licensing scheme. In all other cases the Licensor expressly reserves any right 168 | to collect such royalties. 169 | 170 | Section 3 – License Conditions. 171 | 172 | Your exercise of the Licensed Rights is expressly made subject to the following 173 | conditions. 174 | 175 | a. Attribution. 176 | 177 | 1. If You Share the Licensed Material (including in modified form), You must: 178 | 179 | A. retain the following if it is supplied by the Licensor with the Licensed 180 | Material: 181 | 182 | i. identification of the creator(s) of the Licensed Material and any others 183 | designated to receive attribution, in any reasonable manner requested by the 184 | Licensor (including by pseudonym if designated); 185 | 186 | ii. a copyright notice; 187 | 188 | iii. a notice that refers to this Public License; 189 | 190 | iv. a notice that refers to the disclaimer of warranties; 191 | 192 | v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; 193 | 194 | B. indicate if You modified the Licensed Material and retain an indication 195 | of any previous modifications; and 196 | 197 | C. indicate the Licensed Material is licensed under this Public License, and 198 | include the text of, or the URI or hyperlink to, this Public License. 199 | 200 | 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner 201 | based on the medium, means, and context in which You Share the Licensed Material. 202 | For example, it may be reasonable to satisfy the conditions by providing a 203 | URI or hyperlink to a resource that includes the required information. 204 | 205 | 3. If requested by the Licensor, You must remove any of the information required 206 | by Section 3(a)(1)(A) to the extent reasonably practicable. 207 | 208 | 4. If You Share Adapted Material You produce, the Adapter's License You apply 209 | must not prevent recipients of the Adapted Material from complying with this 210 | Public License. 211 | 212 | Section 4 – Sui Generis Database Rights. 213 | 214 | Where the Licensed Rights include Sui Generis Database Rights that apply to 215 | Your use of the Licensed Material: 216 | 217 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, 218 | reuse, reproduce, and Share all or a substantial portion of the contents of 219 | the database; 220 | 221 | b. if You include all or a substantial portion of the database contents in 222 | a database in which You have Sui Generis Database Rights, then the database 223 | in which You have Sui Generis Database Rights (but not its individual contents) 224 | is Adapted Material; and 225 | 226 | c. You must comply with the conditions in Section 3(a) if You Share all or 227 | a substantial portion of the contents of the database. 228 | 229 | For the avoidance of doubt, this Section 4 supplements and does not replace 230 | Your obligations under this Public License where the Licensed Rights include 231 | other Copyright and Similar Rights. 232 | 233 | Section 5 – Disclaimer of Warranties and Limitation of Liability. 234 | 235 | a. Unless otherwise separately undertaken by the Licensor, to the extent possible, 236 | the Licensor offers the Licensed Material as-is and as-available, and makes 237 | no representations or warranties of any kind concerning the Licensed Material, 238 | whether express, implied, statutory, or other. This includes, without limitation, 239 | warranties of title, merchantability, fitness for a particular purpose, non-infringement, 240 | absence of latent or other defects, accuracy, or the presence or absence of 241 | errors, whether or not known or discoverable. Where disclaimers of warranties 242 | are not allowed in full or in part, this disclaimer may not apply to You. 243 | 244 | b. To the extent possible, in no event will the Licensor be liable to You 245 | on any legal theory (including, without limitation, negligence) or otherwise 246 | for any direct, special, indirect, incidental, consequential, punitive, exemplary, 247 | or other losses, costs, expenses, or damages arising out of this Public License 248 | or use of the Licensed Material, even if the Licensor has been advised of 249 | the possibility of such losses, costs, expenses, or damages. Where a limitation 250 | of liability is not allowed in full or in part, this limitation may not apply 251 | to You. 252 | 253 | c. The disclaimer of warranties and limitation of liability provided above 254 | shall be interpreted in a manner that, to the extent possible, most closely 255 | approximates an absolute disclaimer and waiver of all liability. 256 | 257 | Section 6 – Term and Termination. 258 | 259 | a. This Public License applies for the term of the Copyright and Similar Rights 260 | licensed here. However, if You fail to comply with this Public License, then 261 | Your rights under this Public License terminate automatically. 262 | 263 | b. Where Your right to use the Licensed Material has terminated under Section 264 | 6(a), it reinstates: 265 | 266 | 1. automatically as of the date the violation is cured, provided it is cured 267 | within 30 days of Your discovery of the violation; or 268 | 269 | 2. upon express reinstatement by the Licensor. 270 | 271 | c. For the avoidance of doubt, this Section 6(b) does not affect any right 272 | the Licensor may have to seek remedies for Your violations of this Public 273 | License. 274 | 275 | d. For the avoidance of doubt, the Licensor may also offer the Licensed Material 276 | under separate terms or conditions or stop distributing the Licensed Material 277 | at any time; however, doing so will not terminate this Public License. 278 | 279 | e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. 280 | 281 | Section 7 – Other Terms and Conditions. 282 | 283 | a. The Licensor shall not be bound by any additional or different terms or 284 | conditions communicated by You unless expressly agreed. 285 | 286 | b. Any arrangements, understandings, or agreements regarding the Licensed 287 | Material not stated herein are separate from and independent of the terms 288 | and conditions of this Public License. 289 | 290 | Section 8 – Interpretation. 291 | 292 | a. For the avoidance of doubt, this Public License does not, and shall not 293 | be interpreted to, reduce, limit, restrict, or impose conditions on any use 294 | of the Licensed Material that could lawfully be made without permission under 295 | this Public License. 296 | 297 | b. To the extent possible, if any provision of this Public License is deemed 298 | unenforceable, it shall be automatically reformed to the minimum extent necessary 299 | to make it enforceable. If the provision cannot be reformed, it shall be severed 300 | from this Public License without affecting the enforceability of the remaining 301 | terms and conditions. 302 | 303 | c. No term or condition of this Public License will be waived and no failure 304 | to comply consented to unless expressly agreed to by the Licensor. 305 | 306 | d. Nothing in this Public License constitutes or may be interpreted as a limitation 307 | upon, or waiver of, any privileges and immunities that apply to the Licensor 308 | or You, including from the legal processes of any jurisdiction or authority. 309 | 310 | Creative Commons is not a party to its public licenses. Notwithstanding, Creative 311 | Commons may elect to apply one of its public licenses to material it publishes 312 | and in those instances will be considered the "Licensor." The text of the 313 | Creative Commons public licenses is dedicated to the public domain under the 314 | CC0 Public Domain Dedication. Except for the limited purpose of indicating 315 | that material is shared under a Creative Commons public license or as otherwise 316 | permitted by the Creative Commons policies published at creativecommons.org/policies, 317 | Creative Commons does not authorize the use of the trademark "Creative Commons" 318 | or any other trademark or logo of Creative Commons without its prior written 319 | consent including, without limitation, in connection with any unauthorized 320 | modifications to any of its public licenses or any other arrangements, understandings, 321 | or agreements concerning use of licensed material. For the avoidance of doubt, 322 | this paragraph does not form part of the public licenses. 323 | 324 | Creative Commons may be contacted at creativecommons.org. 325 | -------------------------------------------------------------------------------- /LICENSES/CC-BY-SA-4.0.txt: -------------------------------------------------------------------------------- 1 | Text 2 | Creative Commons Attribution-ShareAlike 4.0 International 3 | 4 | Creative Commons Corporation ("Creative Commons") is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an "as-is" basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. 5 | 6 | Using Creative Commons Public Licenses 7 | 8 | Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. 9 | 10 | Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors : wiki.creativecommons.org/Considerations_for_licensors 11 | 12 | Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor's permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. 13 | 14 | Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public : wiki.creativecommons.org/Considerations_for_licensees 15 | 16 | Creative Commons Attribution-ShareAlike 4.0 International Public License 17 | 18 | By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. 19 | 20 | Section 1 – Definitions. 21 | 22 | a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. 23 | b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. 24 | c. BY-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License. 25 | d. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. 26 | e. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. 27 | f. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. 28 | g. License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution and ShareAlike. 29 | h. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. 30 | i. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. 31 | j. Licensor means the individual(s) or entity(ies) granting rights under this Public License. 32 | k. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. 33 | l. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. 34 | m. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. 35 | Section 2 – Scope. 36 | 37 | a. License grant. 38 | 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: 39 | A. reproduce and Share the Licensed Material, in whole or in part; and 40 | B. produce, reproduce, and Share Adapted Material. 41 | 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. 42 | 3. Term. The term of this Public License is specified in Section 6(a). 43 | 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. 44 | 5. Downstream recipients. 45 | A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. 46 | B. Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter's License You apply. 47 | C. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. 48 | 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). 49 | b. Other rights. 50 | 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. 51 | 2. Patent and trademark rights are not licensed under this Public License. 52 | 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties. 53 | Section 3 – License Conditions. 54 | 55 | Your exercise of the Licensed Rights is expressly made subject to the following conditions. 56 | 57 | a. Attribution. 58 | 1. If You Share the Licensed Material (including in modified form), You must: 59 | A. retain the following if it is supplied by the Licensor with the Licensed Material: 60 | i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); 61 | ii. a copyright notice; 62 | iii. a notice that refers to this Public License; 63 | iv. a notice that refers to the disclaimer of warranties; 64 | v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; 65 | 66 | B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and 67 | C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. 68 | 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. 69 | 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. 70 | b. ShareAlike.In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply. 71 | 1. The Adapter's License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License. 72 | 2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material. 73 | 3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply. 74 | Section 4 – Sui Generis Database Rights. 75 | 76 | Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: 77 | 78 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database; 79 | b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and 80 | c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. 81 | For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. 82 | Section 5 – Disclaimer of Warranties and Limitation of Liability. 83 | 84 | a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You. 85 | b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You. 86 | c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. 87 | Section 6 – Term and Termination. 88 | 89 | a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. 90 | b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: 91 | 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or 92 | 2. upon express reinstatement by the Licensor. 93 | c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. 94 | d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. 95 | e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. 96 | Section 7 – Other Terms and Conditions. 97 | 98 | a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. 99 | b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. 100 | Section 8 – Interpretation. 101 | 102 | a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. 103 | b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. 104 | c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. 105 | d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. 106 | Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the "Licensor." The text of the Creative Commons public licenses is dedicated to the public domain under the CC0 Public Domain Dedication. Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark "Creative Commons" or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. 107 | 108 | Creative Commons may be contacted at creativecommons.org. 109 | -------------------------------------------------------------------------------- /LICENSES/CC0-1.0.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER. 6 | 7 | Statement of Purpose 8 | 9 | The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work"). 10 | 11 | Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others. 12 | 13 | For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights. 14 | 15 | 1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following: 16 | i. the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work; 17 | ii. moral rights retained by the original author(s) and/or performer(s); 18 | iii. publicity and privacy rights pertaining to a person's image or likeness depicted in a Work; 19 | iv. rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below; 20 | v. rights protecting the extraction, dissemination, use and reuse of data in a Work; 21 | vi. database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and 22 | vii. other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof. 23 | 2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose. 24 | 3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose. 25 | 4. Limitations and Disclaimers. 26 | a. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document. 27 | b. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law. 28 | c. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work. 29 | d. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work. 30 | -------------------------------------------------------------------------------- /LICENSES/MIT.txt: -------------------------------------------------------------------------------- 1 | MIT License Copyright (c) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice (including the next 11 | paragraph) shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 17 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 19 | OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /LICENSES/Unlicense.txt: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or distribute 4 | this software, either in source code form or as a compiled binary, for any 5 | purpose, commercial or non-commercial, and by any means. 6 | 7 | In jurisdictions that recognize copyright laws, the author or authors of this 8 | software dedicate any and all copyright interest in the software to the public 9 | domain. We make this dedication for the benefit of the public at large and 10 | to the detriment of our heirs and successors. We intend this dedication to 11 | be an overt act of relinquishment in perpetuity of all present and future 12 | rights to this software under copyright law. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 17 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 18 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH 19 | THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, 20 | please refer to 21 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | .. image:: https://readthedocs.org/projects/adafruit-circuitpython-ssd1306/badge/?version=latest 5 | :target: https://docs.circuitpython.org/projects/ssd1306/en/latest/ 6 | :alt: Documentation Status 7 | 8 | .. image:: https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_Bundle/main/badges/adafruit_discord.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 | .. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json 17 | :target: https://github.com/astral-sh/ruff 18 | :alt: Code Style: Ruff 19 | 20 | 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. 21 | 22 | This driver implements the `adafruit_framebuf interface `__. It is **not** the `displayio` driver for the SSD1306. See the `Adafruit CircuitPython DisplayIO SSD1306 `_ driver for `displayio` support. 23 | 24 | 25 | Dependencies 26 | ============= 27 | This driver depends on: 28 | 29 | * `Adafruit CircuitPython `_ 30 | * `Bus Device `_ 31 | * `Adafruit framebuf `_ 32 | 33 | Please ensure all dependencies are available on the CircuitPython filesystem. 34 | This is easily achieved by downloading 35 | `the Adafruit library and driver bundle `_. 36 | 37 | Installing from PyPI 38 | ==================== 39 | 40 | On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from 41 | PyPI `_. To install for current user: 42 | 43 | .. code-block:: shell 44 | 45 | pip3 install adafruit-circuitpython-ssd1306 46 | 47 | To install system-wide (this may be required in some cases): 48 | 49 | .. code-block:: shell 50 | 51 | sudo pip3 install adafruit-circuitpython-ssd1306 52 | 53 | To install in a virtual environment in your current project: 54 | 55 | .. code-block:: shell 56 | 57 | mkdir project-name && cd project-name 58 | python3 -m venv .venv 59 | source .venv/bin/activate 60 | pip3 install adafruit-circuitpython-ssd1306 61 | 62 | Usage Example 63 | ============= 64 | 65 | .. code-block:: python3 66 | 67 | # Basic example of clearing and drawing pixels on a SSD1306 OLED display. 68 | # This example and library is meant to work with Adafruit CircuitPython API. 69 | # Author: Tony DiCola 70 | # License: Public Domain 71 | 72 | # Import all board pins. 73 | from board import SCL, SDA 74 | import busio 75 | 76 | # Import the SSD1306 module. 77 | import adafruit_ssd1306 78 | 79 | 80 | # Create the I2C interface. 81 | i2c = busio.I2C(SCL, SDA) 82 | 83 | # Create the SSD1306 OLED class. 84 | # The first two parameters are the pixel width and pixel height. Change these 85 | # to the right size for your display! 86 | display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c) 87 | # Alternatively you can change the I2C address of the device with an addr parameter: 88 | #display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, addr=0x31) 89 | 90 | # Clear the display. Always call show after changing pixels to make the display 91 | # update visible! 92 | display.fill(0) 93 | 94 | display.show() 95 | 96 | # Set a pixel in the origin 0,0 position. 97 | display.pixel(0, 0, 1) 98 | # Set a pixel in the middle 64, 16 position. 99 | display.pixel(64, 16, 1) 100 | # Set a pixel in the opposite 127, 31 position. 101 | display.pixel(127, 31, 1) 102 | display.show() 103 | 104 | More examples and details can be found in the `adafruit_framebuf docs `__. 105 | 106 | 107 | Documentation 108 | ============= 109 | 110 | API documentation for this library can be found on `Read the Docs `_. 111 | 112 | For information on building library documentation, please check out `this guide `_. 113 | 114 | Contributing 115 | ============ 116 | 117 | Contributions are welcome! Please read our `Code of Conduct 118 | `_ 119 | before contributing to help this project stay welcoming. 120 | -------------------------------------------------------------------------------- /README.rst.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | 3 | SPDX-License-Identifier: MIT 4 | -------------------------------------------------------------------------------- /adafruit_ssd1306.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Michael McWethy for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | """ 6 | `adafruit_ssd1306` 7 | ==================================================== 8 | 9 | MicroPython SSD1306 OLED driver, I2C and SPI interfaces 10 | 11 | * Author(s): Tony DiCola, Michael McWethy 12 | """ 13 | 14 | import time 15 | 16 | from adafruit_bus_device import i2c_device, spi_device 17 | from micropython import const 18 | 19 | try: 20 | # MicroPython framebuf import 21 | import framebuf 22 | 23 | _FRAMEBUF_FORMAT = framebuf.MONO_VLSB 24 | except ImportError: 25 | # CircuitPython framebuf import 26 | import adafruit_framebuf as framebuf 27 | 28 | _FRAMEBUF_FORMAT = framebuf.MVLSB 29 | 30 | try: 31 | # Used only for typing 32 | from typing import Optional 33 | 34 | import busio 35 | import digitalio 36 | except ImportError: 37 | pass 38 | 39 | __version__ = "0.0.0+auto.0" 40 | __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_SSD1306.git" 41 | 42 | # register definitions 43 | SET_CONTRAST = const(0x81) 44 | SET_ENTIRE_ON = const(0xA4) 45 | SET_NORM_INV = const(0xA6) 46 | SET_DISP = const(0xAE) 47 | SET_MEM_ADDR = const(0x20) 48 | SET_COL_ADDR = const(0x21) 49 | SET_PAGE_ADDR = const(0x22) 50 | SET_DISP_START_LINE = const(0x40) 51 | SET_SEG_REMAP = const(0xA0) 52 | SET_MUX_RATIO = const(0xA8) 53 | SET_IREF_SELECT = const(0xAD) 54 | SET_COM_OUT_DIR = const(0xC0) 55 | SET_DISP_OFFSET = const(0xD3) 56 | SET_COM_PIN_CFG = const(0xDA) 57 | SET_DISP_CLK_DIV = const(0xD5) 58 | SET_PRECHARGE = const(0xD9) 59 | SET_VCOM_DESEL = const(0xDB) 60 | SET_CHARGE_PUMP = const(0x8D) 61 | 62 | 63 | class _SSD1306(framebuf.FrameBuffer): 64 | """Base class for SSD1306 display driver""" 65 | 66 | def __init__( 67 | self, 68 | buffer: memoryview, 69 | width: int, 70 | height: int, 71 | *, 72 | external_vcc: bool, 73 | reset: Optional[digitalio.DigitalInOut], 74 | page_addressing: bool, 75 | ): 76 | super().__init__(buffer, width, height, _FRAMEBUF_FORMAT) 77 | self.width = width 78 | self.height = height 79 | self.external_vcc = external_vcc 80 | # reset may be None if not needed 81 | self.reset_pin = reset 82 | self.page_addressing = page_addressing 83 | if self.reset_pin: 84 | self.reset_pin.switch_to_output(value=0) 85 | self.pages = self.height // 8 86 | # Note the subclass must initialize self.framebuf to a framebuffer. 87 | # This is necessary because the underlying data buffer is different 88 | # between I2C and SPI implementations (I2C needs an extra byte). 89 | self._power = False 90 | # Parameters for efficient Page Addressing Mode (typical of U8Glib libraries) 91 | # Important as not all screens appear to support Horizontal Addressing Mode 92 | if self.page_addressing: 93 | self.pagebuffer = bytearray(width + 1) # type: Optional[bytearray] 94 | self.pagebuffer[0] = 0x40 # Set first byte of data buffer to Co=0, D/C=1 95 | self.page_column_start = bytearray(2) # type: Optional[bytearray] 96 | self.page_column_start[0] = self.width % 32 97 | self.page_column_start[1] = 0x10 + self.width // 32 98 | else: 99 | self.pagebuffer = None 100 | self.page_column_start = None 101 | # Let's get moving! 102 | self.poweron() 103 | self.init_display() 104 | 105 | @property 106 | def power(self) -> bool: 107 | """True if the display is currently powered on, otherwise False""" 108 | return self._power 109 | 110 | def init_display(self) -> None: 111 | """Base class to initialize display""" 112 | # The various screen sizes available with the ssd1306 OLED driver 113 | # chip require differing configuration values for the display clock 114 | # div and com pin, which are listed below for reference and future 115 | # compatibility: 116 | # w, h: DISP_CLK_DIV COM_PIN_CFG 117 | # 128, 64: 0x80 0x12 118 | # 128, 32: 0x80 0x02 119 | # 96, 16: 0x60 0x02 120 | # 64, 48: 0x80 0x12 121 | # 64, 32: 0x80 0x12 122 | for cmd in ( 123 | SET_DISP, # off 124 | # address setting 125 | SET_MEM_ADDR, 126 | 0x10 # Page Addressing Mode 127 | if self.page_addressing 128 | else 0x00, # Horizontal Addressing Mode 129 | # resolution and layout 130 | SET_DISP_START_LINE, 131 | SET_SEG_REMAP | 0x01, # column addr 127 mapped to SEG0 132 | SET_MUX_RATIO, 133 | self.height - 1, 134 | SET_COM_OUT_DIR | 0x08, # scan from COM[N] to COM0 135 | SET_DISP_OFFSET, 136 | 0x00, 137 | SET_COM_PIN_CFG, 138 | 0x02 if self.width > 2 * self.height else 0x12, 139 | # timing and driving scheme 140 | SET_DISP_CLK_DIV, 141 | 0x80, 142 | SET_PRECHARGE, 143 | 0x22 if self.external_vcc else 0xF1, 144 | SET_VCOM_DESEL, 145 | 0x30, # 0.83*Vcc # n.b. specs for ssd1306 64x32 oled screens imply this should be 0x40 146 | # display 147 | SET_CONTRAST, 148 | 0xFF, # maximum 149 | SET_ENTIRE_ON, # output follows RAM contents 150 | SET_NORM_INV, # not inverted 151 | SET_IREF_SELECT, 152 | 0x30, # enable internal IREF during display on 153 | # charge pump 154 | SET_CHARGE_PUMP, 155 | 0x10 if self.external_vcc else 0x14, 156 | SET_DISP | 0x01, # display on 157 | ): 158 | self.write_cmd(cmd) 159 | self.fill(0) 160 | self.show() 161 | 162 | def poweroff(self) -> None: 163 | """Turn off the display (nothing visible)""" 164 | self.write_cmd(SET_DISP) 165 | self._power = False 166 | 167 | def contrast(self, contrast: int) -> None: 168 | """Adjust the contrast""" 169 | self.write_cmd(SET_CONTRAST) 170 | self.write_cmd(contrast) 171 | 172 | def invert(self, invert: bool) -> None: 173 | """Invert all pixels on the display""" 174 | self.write_cmd(SET_NORM_INV | (invert & 1)) 175 | 176 | def rotate(self, rotate: bool) -> None: 177 | """Rotate the display 0 or 180 degrees""" 178 | self.write_cmd(SET_COM_OUT_DIR | ((rotate & 1) << 3)) 179 | self.write_cmd(SET_SEG_REMAP | (rotate & 1)) 180 | # com output (vertical mirror) is changed immediately 181 | # you need to call show() for the seg remap to be visible 182 | 183 | def write_framebuf(self) -> None: 184 | """Derived class must implement this""" 185 | raise NotImplementedError 186 | 187 | def write_cmd(self, cmd: int) -> None: 188 | """Derived class must implement this""" 189 | raise NotImplementedError 190 | 191 | def poweron(self) -> None: 192 | "Reset device and turn on the display." 193 | if self.reset_pin: 194 | self.reset_pin.value = 1 195 | time.sleep(0.001) 196 | self.reset_pin.value = 0 197 | time.sleep(0.010) 198 | self.reset_pin.value = 1 199 | time.sleep(0.010) 200 | self.write_cmd(SET_DISP | 0x01) 201 | self._power = True 202 | 203 | def show(self) -> None: 204 | """Update the display""" 205 | if not self.page_addressing: 206 | xpos0 = 0 207 | xpos1 = self.width - 1 208 | if self.width != 128: 209 | # narrow displays use centered columns 210 | col_offset = (128 - self.width) // 2 211 | xpos0 += col_offset 212 | xpos1 += col_offset 213 | self.write_cmd(SET_COL_ADDR) 214 | self.write_cmd(xpos0) 215 | self.write_cmd(xpos1) 216 | self.write_cmd(SET_PAGE_ADDR) 217 | self.write_cmd(0) 218 | self.write_cmd(self.pages - 1) 219 | self.write_framebuf() 220 | 221 | 222 | class SSD1306_I2C(_SSD1306): 223 | """ 224 | I2C class for SSD1306 225 | 226 | :param width: the width of the physical screen in pixels, 227 | :param height: the height of the physical screen in pixels, 228 | :param i2c: the I2C peripheral to use, 229 | :param addr: the 8-bit bus address of the device, 230 | :param external_vcc: whether external high-voltage source is connected. 231 | :param reset: if needed, DigitalInOut designating reset pin 232 | """ 233 | 234 | def __init__( 235 | self, 236 | width: int, 237 | height: int, 238 | i2c: busio.I2C, 239 | *, 240 | addr: int = 0x3C, 241 | external_vcc: bool = False, 242 | reset: Optional[digitalio.DigitalInOut] = None, 243 | page_addressing: bool = False, 244 | ): 245 | self.i2c_device = i2c_device.I2CDevice(i2c, addr) 246 | self.addr = addr 247 | self.page_addressing = page_addressing 248 | self.temp = bytearray(2) 249 | # Add an extra byte to the data buffer to hold an I2C data/command byte 250 | # to use hardware-compatible I2C transactions. A memoryview of the 251 | # buffer is used to mask this byte from the framebuffer operations 252 | # (without a major memory hit as memoryview doesn't copy to a separate 253 | # buffer). 254 | self.buffer = bytearray(((height // 8) * width) + 1) 255 | self.buffer[0] = 0x40 # Set first byte of data buffer to Co=0, D/C=1 256 | super().__init__( 257 | memoryview(self.buffer)[1:], 258 | width, 259 | height, 260 | external_vcc=external_vcc, 261 | reset=reset, 262 | page_addressing=self.page_addressing, 263 | ) 264 | 265 | def write_cmd(self, cmd: int) -> None: 266 | """Send a command to the I2C device""" 267 | self.temp[0] = 0x80 # Co=1, D/C#=0 268 | self.temp[1] = cmd 269 | with self.i2c_device: 270 | self.i2c_device.write(self.temp) 271 | 272 | def write_framebuf(self) -> None: 273 | """Blast out the frame buffer using a single I2C transaction to support 274 | hardware I2C interfaces.""" 275 | if self.page_addressing: 276 | for page in range(self.pages): 277 | self.write_cmd(0xB0 + page) 278 | self.write_cmd(self.page_column_start[0]) 279 | self.write_cmd(self.page_column_start[1]) 280 | self.pagebuffer[1:] = self.buffer[ 281 | 1 + self.width * page : 1 + self.width * (page + 1) 282 | ] 283 | with self.i2c_device: 284 | self.i2c_device.write(self.pagebuffer) 285 | else: 286 | with self.i2c_device: 287 | self.i2c_device.write(self.buffer) 288 | 289 | 290 | class SSD1306_SPI(_SSD1306): 291 | """ 292 | SPI class for SSD1306 293 | 294 | :param width: the width of the physical screen in pixels, 295 | :param height: the height of the physical screen in pixels, 296 | :param spi: the SPI peripheral to use, 297 | :param dc: the data/command pin to use (often labeled "D/C"), 298 | :param reset: the reset pin to use, 299 | :param cs: the chip-select pin to use (sometimes labeled "SS"). 300 | """ 301 | 302 | # Disable should be reconsidered when refactor can be tested. 303 | def __init__( 304 | self, 305 | width: int, 306 | height: int, 307 | spi: busio.SPI, 308 | dc: digitalio.DigitalInOut, 309 | reset: Optional[digitalio.DigitalInOut], 310 | cs: digitalio.DigitalInOut, 311 | *, 312 | external_vcc: bool = False, 313 | baudrate: int = 8000000, 314 | polarity: int = 0, 315 | phase: int = 0, 316 | page_addressing: bool = False, 317 | ): 318 | self.page_addressing = page_addressing 319 | if self.page_addressing: 320 | raise NotImplementedError("Page addressing mode with SPI has not yet been implemented.") 321 | 322 | self.rate = 10 * 1024 * 1024 323 | dc.switch_to_output(value=0) 324 | self.spi_device = spi_device.SPIDevice( 325 | spi, cs, baudrate=baudrate, polarity=polarity, phase=phase 326 | ) 327 | self.dc_pin = dc 328 | self.buffer = bytearray((height // 8) * width) 329 | super().__init__( 330 | memoryview(self.buffer), 331 | width, 332 | height, 333 | external_vcc=external_vcc, 334 | reset=reset, 335 | page_addressing=self.page_addressing, 336 | ) 337 | 338 | def write_cmd(self, cmd: int) -> None: 339 | """Send a command to the SPI device""" 340 | self.dc_pin.value = 0 341 | with self.spi_device as spi: 342 | spi.write(bytearray([cmd])) 343 | 344 | def write_framebuf(self) -> None: 345 | """write to the frame buffer via SPI""" 346 | self.dc_pin.value = 1 347 | with self.spi_device as spi: 348 | spi.write(self.buffer) 349 | -------------------------------------------------------------------------------- /docs/_static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_SSD1306/e010231c5fe36cbd984f907c929a5ae6d2ce87b2/docs/_static/favicon.ico -------------------------------------------------------------------------------- /docs/_static/favicon.ico.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries 2 | 3 | SPDX-License-Identifier: CC-BY-4.0 4 | -------------------------------------------------------------------------------- /docs/api.rst: -------------------------------------------------------------------------------- 1 | 2 | .. If you created a package, create one automodule per module in the package. 3 | 4 | .. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py) 5 | .. use this format as the module name: "adafruit_foo.foo" 6 | 7 | API Reference 8 | ############# 9 | 10 | .. automodule:: adafruit_ssd1306 11 | :members: 12 | -------------------------------------------------------------------------------- /docs/api.rst.license: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2020 ladyada for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | import datetime 6 | import os 7 | import sys 8 | 9 | sys.path.insert(0, os.path.abspath("..")) 10 | 11 | # -- General configuration ------------------------------------------------ 12 | 13 | # Add any Sphinx extension module names here, as strings. They can be 14 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 15 | # ones. 16 | extensions = [ 17 | "sphinx.ext.autodoc", 18 | "sphinxcontrib.jquery", 19 | "sphinx.ext.intersphinx", 20 | "sphinx.ext.napoleon", 21 | "sphinx.ext.todo", 22 | ] 23 | 24 | # Uncomment the below if you use native CircuitPython modules such as 25 | # digitalio, micropython and busio. List the modules you use. Without it, the 26 | # autodoc module docs will fail to generate with a warning. 27 | autodoc_mock_imports = ["framebuf"] 28 | 29 | intersphinx_mapping = { 30 | "python": ("https://docs.python.org/3", None), 31 | "BusDevice": ( 32 | "https://docs.circuitpython.org/projects/busdevice/en/latest/", 33 | None, 34 | ), 35 | "CircuitPython": ("https://docs.circuitpython.org/en/latest/", None), 36 | } 37 | 38 | # Add any paths that contain templates here, relative to this directory. 39 | templates_path = ["_templates"] 40 | 41 | source_suffix = ".rst" 42 | 43 | # The master toctree document. 44 | master_doc = "index" 45 | 46 | # General information about the project. 47 | project = "Adafruit SSD1306 Library" 48 | creation_year = "2017" 49 | current_year = str(datetime.datetime.now().year) 50 | year_duration = ( 51 | current_year if current_year == creation_year else creation_year + " - " + current_year 52 | ) 53 | copyright = year_duration + " Michael McWethy" 54 | author = "Michael McWethy" 55 | 56 | # The version info for the project you're documenting, acts as replacement for 57 | # |version| and |release|, also used in various other places throughout the 58 | # built documents. 59 | # 60 | # The short X.Y version. 61 | version = "1.0" 62 | # The full version, including alpha/beta/rc tags. 63 | release = "1.0" 64 | 65 | # The language for content autogenerated by Sphinx. Refer to documentation 66 | # for a list of supported languages. 67 | # 68 | # This is also used if you do content translation via gettext catalogs. 69 | # Usually you set "language" from the command line for these cases. 70 | language = "en" 71 | 72 | # List of patterns, relative to source directory, that match files and 73 | # directories to ignore when looking for source files. 74 | # This patterns also effect to html_static_path and html_extra_path 75 | exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"] 76 | 77 | # The reST default role (used for this markup: `text`) to use for all 78 | # documents. 79 | # 80 | default_role = "any" 81 | 82 | # If true, '()' will be appended to :func: etc. cross-reference text. 83 | # 84 | add_function_parentheses = True 85 | 86 | # The name of the Pygments (syntax highlighting) style to use. 87 | pygments_style = "sphinx" 88 | 89 | # If true, `todo` and `todoList` produce output, else they produce nothing. 90 | todo_include_todos = False 91 | 92 | # If this is True, todo emits a warning for each TODO entries. The default is False. 93 | todo_emit_warnings = True 94 | 95 | napoleon_numpy_docstring = False 96 | 97 | # -- Options for HTML output ---------------------------------------------- 98 | 99 | # The theme to use for HTML and HTML Help pages. See the documentation for 100 | # a list of builtin themes. 101 | # 102 | import sphinx_rtd_theme 103 | 104 | html_theme = "sphinx_rtd_theme" 105 | 106 | # Add any paths that contain custom static files (such as style sheets) here, 107 | # relative to this directory. They are copied after the builtin static files, 108 | # so a file named "default.css" will overwrite the builtin "default.css". 109 | html_static_path = ["_static"] 110 | 111 | # Output file base name for HTML help builder. 112 | htmlhelp_basename = "AdafruitSsd1306Librarydoc" 113 | 114 | # -- Options for LaTeX output --------------------------------------------- 115 | 116 | latex_elements = { 117 | # The paper size ('letterpaper' or 'a4paper'). 118 | # 119 | # 'papersize': 'letterpaper', 120 | # The font size ('10pt', '11pt' or '12pt'). 121 | # 122 | # 'pointsize': '10pt', 123 | # Additional stuff for the LaTeX preamble. 124 | # 125 | # 'preamble': '', 126 | # Latex figure (float) alignment 127 | # 128 | # 'figure_align': 'htbp', 129 | } 130 | 131 | # Grouping the document tree into LaTeX files. List of tuples 132 | # (source start file, target name, title, 133 | # author, documentclass [howto, manual, or own class]). 134 | latex_documents = [ 135 | ( 136 | master_doc, 137 | "AdafruitSSD1306Library.tex", 138 | "AdafruitSSD1306 Library Documentation", 139 | author, 140 | "manual", 141 | ), 142 | ] 143 | 144 | # -- Options for manual page output --------------------------------------- 145 | 146 | # One entry per manual page. List of tuples 147 | # (source start file, name, description, authors, manual section). 148 | man_pages = [ 149 | ( 150 | master_doc, 151 | "AdafruitSSD1306library", 152 | "Adafruit SSD1306 Library Documentation", 153 | [author], 154 | 1, 155 | ) 156 | ] 157 | 158 | # -- Options for Texinfo output ------------------------------------------- 159 | 160 | # Grouping the document tree into Texinfo files. List of tuples 161 | # (source start file, target name, title, author, 162 | # dir menu entry, description, category) 163 | texinfo_documents = [ 164 | ( 165 | master_doc, 166 | "AdafruitSSD1306Library", 167 | "Adafruit SSD1306 Library Documentation", 168 | author, 169 | "AdafruitSSD1306Library", 170 | "One line description of project.", 171 | "Miscellaneous", 172 | ), 173 | ] 174 | -------------------------------------------------------------------------------- /docs/examples.rst: -------------------------------------------------------------------------------- 1 | Simple test 2 | ------------ 3 | 4 | Ensure your device works with this simple test. 5 | 6 | .. literalinclude:: ../examples/ssd1306_simpletest.py 7 | :caption: examples/ssd1306_simpletest.py 8 | :linenos: 9 | -------------------------------------------------------------------------------- /docs/examples.rst.license: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2020 ladyada for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../README.rst 2 | 3 | Table of Contents 4 | ================= 5 | 6 | .. toctree:: 7 | :maxdepth: 4 8 | :hidden: 9 | 10 | self 11 | 12 | .. toctree:: 13 | :caption: Examples 14 | 15 | examples 16 | 17 | .. toctree:: 18 | :caption: API Reference 19 | :maxdepth: 3 20 | 21 | api 22 | 23 | .. toctree:: 24 | :caption: Tutorials 25 | 26 | CircuitPython Hardware: SSD1306 OLED Display 27 | 28 | .. toctree:: 29 | :caption: Related Products 30 | 31 | Several SSD1306-based products 32 | 33 | .. toctree:: 34 | :caption: Other Links 35 | 36 | Download from GitHub 37 | Download Library Bundle 38 | CircuitPython Reference Documentation 39 | CircuitPython Support Forum 40 | Discord Chat 41 | Adafruit Learning System 42 | Adafruit Blog 43 | Adafruit Store 44 | 45 | Indices and tables 46 | ================== 47 | 48 | * :ref:`genindex` 49 | * :ref:`modindex` 50 | * :ref:`search` 51 | -------------------------------------------------------------------------------- /docs/index.rst.license: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2020 ladyada for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | sphinx 6 | sphinxcontrib-jquery 7 | sphinx-rtd-theme 8 | -------------------------------------------------------------------------------- /examples/happycat_oled_32.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_SSD1306/e010231c5fe36cbd984f907c929a5ae6d2ce87b2/examples/happycat_oled_32.ppm -------------------------------------------------------------------------------- /examples/happycat_oled_32.ppm.license: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: CC-BY-SA-4.0 4 | -------------------------------------------------------------------------------- /examples/happycat_oled_64.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_SSD1306/e010231c5fe36cbd984f907c929a5ae6d2ce87b2/examples/happycat_oled_64.ppm -------------------------------------------------------------------------------- /examples/happycat_oled_64.ppm.license: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: CC-BY-SA-4.0 4 | -------------------------------------------------------------------------------- /examples/ssd1306_bonnet_buttons.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 James DeVito for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | # This example is for use on (Linux) computers that are using CPython with 5 | # Adafruit Blinka to support CircuitPython libraries. CircuitPython does 6 | # not support PIL/pillow (python imaging library)! 7 | 8 | import board 9 | import busio 10 | from digitalio import DigitalInOut, Direction, Pull 11 | from PIL import Image, ImageDraw 12 | 13 | import adafruit_ssd1306 14 | 15 | # Create the I2C interface. 16 | i2c = busio.I2C(board.SCL, board.SDA) 17 | # Create the SSD1306 OLED class. 18 | disp = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c) 19 | 20 | 21 | # Input pins: 22 | button_A = DigitalInOut(board.D5) 23 | button_A.direction = Direction.INPUT 24 | button_A.pull = Pull.UP 25 | 26 | button_B = DigitalInOut(board.D6) 27 | button_B.direction = Direction.INPUT 28 | button_B.pull = Pull.UP 29 | 30 | button_L = DigitalInOut(board.D27) 31 | button_L.direction = Direction.INPUT 32 | button_L.pull = Pull.UP 33 | 34 | button_R = DigitalInOut(board.D23) 35 | button_R.direction = Direction.INPUT 36 | button_R.pull = Pull.UP 37 | 38 | button_U = DigitalInOut(board.D17) 39 | button_U.direction = Direction.INPUT 40 | button_U.pull = Pull.UP 41 | 42 | button_D = DigitalInOut(board.D22) 43 | button_D.direction = Direction.INPUT 44 | button_D.pull = Pull.UP 45 | 46 | button_C = DigitalInOut(board.D4) 47 | button_C.direction = Direction.INPUT 48 | button_C.pull = Pull.UP 49 | 50 | 51 | # Clear display. 52 | disp.fill(0) 53 | disp.show() 54 | 55 | # Create blank image for drawing. 56 | # Make sure to create image with mode '1' for 1-bit color. 57 | width = disp.width 58 | height = disp.height 59 | image = Image.new("1", (width, height)) 60 | 61 | # Get drawing object to draw on image. 62 | draw = ImageDraw.Draw(image) 63 | 64 | # Draw a black filled box to clear the image. 65 | draw.rectangle((0, 0, width, height), outline=0, fill=0) 66 | 67 | 68 | while True: 69 | if button_U.value: # button is released 70 | draw.polygon([(20, 20), (30, 2), (40, 20)], outline=255, fill=0) # Up 71 | else: # button is pressed: 72 | draw.polygon([(20, 20), (30, 2), (40, 20)], outline=255, fill=1) # Up filled 73 | 74 | if button_L.value: # button is released 75 | draw.polygon([(0, 30), (18, 21), (18, 41)], outline=255, fill=0) # left 76 | else: # button is pressed: 77 | draw.polygon([(0, 30), (18, 21), (18, 41)], outline=255, fill=1) # left filled 78 | 79 | if button_R.value: # button is released 80 | draw.polygon([(60, 30), (42, 21), (42, 41)], outline=255, fill=0) # right 81 | else: # button is pressed: 82 | draw.polygon([(60, 30), (42, 21), (42, 41)], outline=255, fill=1) # right filled 83 | 84 | if button_D.value: # button is released 85 | draw.polygon([(30, 60), (40, 42), (20, 42)], outline=255, fill=0) # down 86 | else: # button is pressed: 87 | draw.polygon([(30, 60), (40, 42), (20, 42)], outline=255, fill=1) # down filled 88 | 89 | if button_C.value: # button is released 90 | draw.rectangle((20, 22, 40, 40), outline=255, fill=0) # center 91 | else: # button is pressed: 92 | draw.rectangle((20, 22, 40, 40), outline=255, fill=1) # center filled 93 | 94 | if button_A.value: # button is released 95 | draw.ellipse((70, 40, 90, 60), outline=255, fill=0) # A button 96 | else: # button is pressed: 97 | draw.ellipse((70, 40, 90, 60), outline=255, fill=1) # A button filled 98 | 99 | if button_B.value: # button is released 100 | draw.ellipse((100, 20, 120, 40), outline=255, fill=0) # B button 101 | else: # button is pressed: 102 | draw.ellipse((100, 20, 120, 40), outline=255, fill=1) # B button filled 103 | 104 | if not button_A.value and not button_B.value and not button_C.value: 105 | catImage = Image.open("happycat_oled_64.ppm").convert("1") 106 | disp.image(catImage) 107 | else: 108 | # Display image. 109 | disp.image(image) 110 | 111 | disp.show() 112 | -------------------------------------------------------------------------------- /examples/ssd1306_bouncing_ball.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | import board 5 | import busio 6 | 7 | import adafruit_ssd1306 8 | 9 | # Create the I2C interface. 10 | i2c = busio.I2C(board.SCL, board.SDA) 11 | 12 | # Create the SSD1306 OLED class. 13 | # The first two parameters are the pixel width and pixel height. Change these 14 | # to the right size for your display! 15 | oled = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c) 16 | 17 | 18 | # Helper function to draw a circle from a given position with a given radius 19 | # This is an implementation of the midpoint circle algorithm, 20 | # see https://en.wikipedia.org/wiki/Midpoint_circle_algorithm#C_example for details 21 | def draw_circle(xpos0, ypos0, rad, col=1): 22 | x = rad - 1 23 | y = 0 24 | dx = 1 25 | dy = 1 26 | err = dx - (rad << 1) 27 | while x >= y: 28 | oled.pixel(xpos0 + x, ypos0 + y, col) 29 | oled.pixel(xpos0 + y, ypos0 + x, col) 30 | oled.pixel(xpos0 - y, ypos0 + x, col) 31 | oled.pixel(xpos0 - x, ypos0 + y, col) 32 | oled.pixel(xpos0 - x, ypos0 - y, col) 33 | oled.pixel(xpos0 - y, ypos0 - x, col) 34 | oled.pixel(xpos0 + y, ypos0 - x, col) 35 | oled.pixel(xpos0 + x, ypos0 - y, col) 36 | if err <= 0: 37 | y += 1 38 | err += dy 39 | dy += 2 40 | if err > 0: 41 | x -= 1 42 | dx += 2 43 | err += dx - (rad << 1) 44 | 45 | 46 | # initial center of the circle 47 | center_x = 63 48 | center_y = 15 49 | # how fast does it move in each direction 50 | x_inc = 1 51 | y_inc = 1 52 | # what is the starting radius of the circle 53 | radius = 8 54 | 55 | # start with a blank screen 56 | oled.fill(0) 57 | # we just blanked the framebuffer. to push the framebuffer onto the display, we call show() 58 | oled.show() 59 | while True: 60 | # undraw the previous circle 61 | draw_circle(center_x, center_y, radius, col=0) 62 | 63 | # if bouncing off right 64 | if center_x + radius >= oled.width: 65 | # start moving to the left 66 | x_inc = -1 67 | # if bouncing off left 68 | elif center_x - radius < 0: 69 | # start moving to the right 70 | x_inc = 1 71 | 72 | # if bouncing off top 73 | if center_y + radius >= oled.height: 74 | # start moving down 75 | y_inc = -1 76 | # if bouncing off bottom 77 | elif center_y - radius < 0: 78 | # start moving up 79 | y_inc = 1 80 | 81 | # go more in the current direction 82 | center_x += x_inc 83 | center_y += y_inc 84 | 85 | # draw the new circle 86 | draw_circle(center_x, center_y, radius) 87 | # show all the changes we just made 88 | oled.show() 89 | -------------------------------------------------------------------------------- /examples/ssd1306_clear.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Tony DiCola 2 | # SPDX-License-Identifier: CC0-1.0 3 | 4 | # Basic example of clearing and drawing pixels on a SSD1306 OLED display. 5 | # This example and library is meant to work with Adafruit CircuitPython API. 6 | 7 | # Import all board pins. 8 | import busio 9 | from board import SCL, SDA 10 | 11 | # Import the SSD1306 module. 12 | import adafruit_ssd1306 13 | 14 | # Create the I2C interface. 15 | i2c = busio.I2C(SCL, SDA) 16 | 17 | # Create the SSD1306 OLED class. 18 | # The first two parameters are the pixel width and pixel height. Change these 19 | # to the right size for your display! 20 | display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c) 21 | # Alternatively you can change the I2C address of the device with an addr parameter: 22 | # display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, addr=0x31) 23 | 24 | # Clear the display. Always call show after changing pixels to make the display 25 | # update visible! 26 | display.fill(0) 27 | display.show() 28 | -------------------------------------------------------------------------------- /examples/ssd1306_framebuftest.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Tony DiCola 2 | # SPDX-License-Identifier: CC0-1.0 3 | 4 | # Basic example of using framebuf capabilities on a SSD1306 OLED display. 5 | # This example and library is meant to work with Adafruit CircuitPython API. 6 | 7 | # Import all board pins. 8 | import time 9 | 10 | import board 11 | import busio 12 | from digitalio import DigitalInOut 13 | 14 | # Import the SSD1306 module. 15 | import adafruit_ssd1306 16 | 17 | # Create the I2C interface. 18 | i2c = busio.I2C(board.SCL, board.SDA) 19 | # A reset line may be required if there is no auto-reset circuitry 20 | reset_pin = DigitalInOut(board.D5) 21 | 22 | # Create the SSD1306 OLED class. 23 | # The first two parameters are the pixel width and pixel height. Change these 24 | # to the right size for your display! 25 | # The I2C address for these displays is 0x3d or 0x3c, change to match 26 | # A reset line may be required if there is no auto-reset circuitry 27 | display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, addr=0x3C, reset=reset_pin) 28 | 29 | print( 30 | "Framebuf capability test - these are slow and minimal but don't require" 31 | "a special graphics management library, only `adafruit_framebuf`" 32 | ) 33 | 34 | print("Pixel test") 35 | # Clear the display. Always call show after changing pixels to make the display 36 | # update visible! 37 | display.fill(0) 38 | display.show() 39 | 40 | # Set a pixel in the origin 0,0 position. 41 | display.pixel(0, 0, 1) 42 | # Set a pixel in the middle position. 43 | display.pixel(display.width // 2, display.height // 2, 1) 44 | # Set a pixel in the opposite corner position. 45 | display.pixel(display.width - 1, display.height - 1, 1) 46 | display.show() 47 | time.sleep(0.1) 48 | 49 | print("Lines test") 50 | # we'll draw from corner to corner, lets define all the pair coordinates here 51 | corners = ( 52 | (0, 0), 53 | (0, display.height - 1), 54 | (display.width - 1, 0), 55 | (display.width - 1, display.height - 1), 56 | ) 57 | 58 | display.fill(0) 59 | for corner_from in corners: 60 | for corner_to in corners: 61 | display.line(corner_from[0], corner_from[1], corner_to[0], corner_to[1], 1) 62 | display.show() 63 | time.sleep(0.1) 64 | 65 | print("Rectangle test") 66 | display.fill(0) 67 | w_delta = display.width / 10 68 | h_delta = display.height / 10 69 | for i in range(11): 70 | display.rect(0, 0, int(w_delta * i), int(h_delta * i), 1) 71 | display.show() 72 | time.sleep(0.1) 73 | 74 | print("Text test") 75 | display.fill(0) 76 | try: 77 | display.text("hello world", 0, 0, 1) 78 | display.show() 79 | time.sleep(1) 80 | display.fill(0) 81 | char_width = 6 82 | char_height = 8 83 | chars_per_line = display.width // 6 84 | for i in range(255): 85 | x = char_width * (i % chars_per_line) 86 | y = char_height * (i // chars_per_line) 87 | display.text(chr(i), x, y, 1) 88 | display.show() 89 | except FileNotFoundError: 90 | print( 91 | "To test the framebuf font setup, you'll need the font5x8.bin file from " 92 | + "https://github.com/adafruit/Adafruit_CircuitPython_framebuf/blob/main/examples/" 93 | + " in the same directory as this script" 94 | ) 95 | -------------------------------------------------------------------------------- /examples/ssd1306_pillow_animate.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2014 Tony DiCola for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | # This example is for use on (Linux) computers that are using CPython with 5 | # Adafruit Blinka to support CircuitPython libraries. CircuitPython does 6 | # not support PIL/pillow (python imaging library)! 7 | 8 | import math 9 | import time 10 | 11 | import busio 12 | from board import SCL, SDA 13 | from PIL import Image, ImageDraw, ImageFont 14 | 15 | import adafruit_ssd1306 16 | 17 | # Create the I2C interface. 18 | i2c = busio.I2C(SCL, SDA) 19 | 20 | # Create the SSD1306 OLED class. 21 | # The first two parameters are the pixel width and pixel height. 22 | # Change these to the right size for your display! 23 | disp = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c) 24 | 25 | # Note you can change the I2C address, or add a reset pin: 26 | # disp = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, addr=0x3c, reset=reset_pin) 27 | 28 | # Get display width and height. 29 | width = disp.width 30 | height = disp.height 31 | 32 | # Clear display. 33 | disp.fill(0) 34 | disp.show() 35 | 36 | # Create image buffer. 37 | # Make sure to create image with mode '1' for 1-bit color. 38 | image = Image.new("1", (width, height)) 39 | 40 | # Load default font. 41 | font = ImageFont.load_default() 42 | 43 | # Alternatively load a TTF font. Make sure the .ttf font file is in the 44 | # same directory as this python script! 45 | # Some nice fonts to try: http://www.dafont.com/bitmap.php 46 | # font = ImageFont.truetype('Minecraftia.ttf', 8) 47 | 48 | # Create drawing object. 49 | draw = ImageDraw.Draw(image) 50 | 51 | # Define text and get total width. 52 | text = ( 53 | "SSD1306 ORGANIC LED DISPLAY. THIS IS AN OLD SCHOOL DEMO SCROLLER!!" 54 | + "GREETZ TO: LADYADA & THE ADAFRUIT CREW, TRIXTER, FUTURE CREW, AND FARBRAUSCH" 55 | ) 56 | bbox = draw.textbbox((0, 0), text, font=font) 57 | maxwidth = bbox[2] - bbox[0] 58 | 59 | # Set animation and sine wave parameters. 60 | amplitude = height / 4 61 | offset = height / 2 - 4 62 | velocity = -2 63 | startpos = width 64 | 65 | # Animate text moving in sine wave. 66 | print("Press Ctrl-C to quit.") 67 | pos = startpos 68 | while True: 69 | # Clear image buffer by drawing a black filled box. 70 | draw.rectangle((0, 0, width, height), outline=0, fill=0) 71 | # Enumerate characters and draw them offset vertically based on a sine wave. 72 | x = pos 73 | for i, c in enumerate(text): 74 | # Stop drawing if off the right side of screen. 75 | if x > width: 76 | break 77 | # Calculate width but skip drawing if off the left side of screen. 78 | if x < -10: 79 | bbox = draw.textbbox((0, 0), c, font=font) 80 | char_width, char_height = bbox[2] - bbox[0], bbox[3] - bbox[1] 81 | x += char_width 82 | continue 83 | # Calculate offset from sine wave. 84 | y = offset + math.floor(amplitude * math.sin(x / float(width) * 2.0 * math.pi)) 85 | # Draw text. 86 | draw.text((x, y), c, font=font, fill=255) 87 | # Increment x position based on chacacter width. 88 | bbox = draw.textbbox((0, 0), c, font=font) 89 | char_width, char_height = bbox[2] - bbox[0], bbox[3] - bbox[1] 90 | x += char_width 91 | 92 | # Draw the image buffer. 93 | disp.image(image) 94 | disp.show() 95 | 96 | # Move position for next frame. 97 | pos += velocity 98 | # Start over if text has scrolled completely off left side of screen. 99 | if pos < -maxwidth: 100 | pos = startpos 101 | 102 | # Pause briefly before drawing next frame. 103 | time.sleep(0.05) 104 | -------------------------------------------------------------------------------- /examples/ssd1306_pillow_clock.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Melissa LeBlanc-Williams for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | # This example is for use on (Linux) computers that are using CPython with 5 | # Adafruit Blinka to support CircuitPython libraries. CircuitPython does 6 | # not support PIL/pillow (python imaging library)! 7 | # 8 | # Ported to Pillow by Melissa LeBlanc-Williams for Adafruit Industries from Code available at: 9 | # https://learn.adafruit.com/adafruit-oled-displays-for-raspberry-pi/programming-your-display 10 | 11 | # Imports the necessary libraries... 12 | import time 13 | 14 | import board 15 | import digitalio 16 | from PIL import Image, ImageDraw, ImageFont 17 | 18 | import adafruit_ssd1306 19 | 20 | # Setting some variables for our reset pin etc. 21 | RESET_PIN = digitalio.DigitalInOut(board.D4) 22 | 23 | i2c = board.I2C() # uses board.SCL and board.SDA 24 | # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller 25 | 26 | # Create the SSD1306 OLED class. 27 | # The first two parameters are the pixel width and pixel height. 28 | # Change these to the right size for your display! 29 | oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c) 30 | 31 | # Note you can change the I2C address, or add a reset pin: 32 | # oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c, addr=0x3D, reset=RESET_PIN) 33 | 34 | # Clear display. 35 | oled.fill(0) 36 | oled.show() 37 | 38 | # Create blank image for drawing. 39 | image = Image.new("1", (oled.width, oled.height)) 40 | draw = ImageDraw.Draw(image) 41 | 42 | # Load a font in 2 different sizes. 43 | font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 16) 44 | font2 = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 24) 45 | 46 | offset = 0 # flips between 0 and 32 for double buffering 47 | 48 | while True: 49 | # write the current time to the display after each scroll 50 | draw.rectangle((0, 0, oled.width, oled.height * 2), outline=0, fill=0) 51 | text = time.strftime("%A") 52 | draw.text((0, 0), text, font=font, fill=255) 53 | text = time.strftime("%e %b %Y") 54 | draw.text((0, 14), text, font=font, fill=255) 55 | text = time.strftime("%X") 56 | draw.text((0, 36), text, font=font2, fill=255) 57 | oled.image(image) 58 | oled.show() 59 | 60 | time.sleep(1) 61 | 62 | for i in range(0, oled.height // 2): 63 | offset = (offset + 1) % oled.height 64 | oled.write_cmd(adafruit_ssd1306.SET_DISP_START_LINE | offset) 65 | oled.show() 66 | time.sleep(0.001) 67 | -------------------------------------------------------------------------------- /examples/ssd1306_pillow_demo.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | """ 5 | This demo will fill the screen with white, draw a black box on top 6 | and then print Hello World! in the center of the display 7 | 8 | This example is for use on (Linux) computers that are using CPython with 9 | Adafruit Blinka to support CircuitPython libraries. CircuitPython does 10 | not support PIL/pillow (python imaging library)! 11 | """ 12 | 13 | import board 14 | import digitalio 15 | from PIL import Image, ImageDraw, ImageFont 16 | 17 | import adafruit_ssd1306 18 | 19 | # Define the Reset Pin 20 | oled_reset = digitalio.DigitalInOut(board.D4) 21 | 22 | # Change these 23 | # to the right size for your display! 24 | WIDTH = 128 25 | HEIGHT = 32 # Change to 64 if needed 26 | BORDER = 5 27 | 28 | # Use for I2C. 29 | i2c = board.I2C() # uses board.SCL and board.SDA 30 | # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller 31 | oled = adafruit_ssd1306.SSD1306_I2C(WIDTH, HEIGHT, i2c, addr=0x3C, reset=oled_reset) 32 | 33 | # Use for SPI 34 | # spi = board.SPI() 35 | # oled_cs = digitalio.DigitalInOut(board.D5) 36 | # oled_dc = digitalio.DigitalInOut(board.D6) 37 | # oled = adafruit_ssd1306.SSD1306_SPI(WIDTH, HEIGHT, spi, oled_dc, oled_reset, oled_cs) 38 | 39 | # Clear display. 40 | oled.fill(0) 41 | oled.show() 42 | 43 | # Create blank image for drawing. 44 | # Make sure to create image with mode '1' for 1-bit color. 45 | image = Image.new("1", (oled.width, oled.height)) 46 | 47 | # Get drawing object to draw on image. 48 | draw = ImageDraw.Draw(image) 49 | 50 | # Draw a white background 51 | draw.rectangle((0, 0, oled.width, oled.height), outline=255, fill=255) 52 | 53 | # Draw a smaller inner rectangle 54 | draw.rectangle( 55 | (BORDER, BORDER, oled.width - BORDER - 1, oled.height - BORDER - 1), 56 | outline=0, 57 | fill=0, 58 | ) 59 | 60 | # Load default font. 61 | font = ImageFont.load_default() 62 | 63 | # Draw Some Text 64 | text = "Hello World!" 65 | bbox = font.getbbox(text) 66 | (font_width, font_height) = bbox[2] - bbox[0], bbox[3] - bbox[1] 67 | draw.text( 68 | (oled.width // 2 - font_width // 2, oled.height // 2 - font_height // 2), 69 | text, 70 | font=font, 71 | fill=255, 72 | ) 73 | 74 | # Display image 75 | oled.image(image) 76 | oled.show() 77 | -------------------------------------------------------------------------------- /examples/ssd1306_pillow_image_display.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Melissa LeBlanc-Williams for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | # This example is for use on (Linux) computers that are using CPython with 5 | # Adafruit Blinka to support CircuitPython libraries. CircuitPython does 6 | # not support PIL/pillow (python imaging library)! 7 | # 8 | # Ported to Pillow by Melissa LeBlanc-Williams for Adafruit Industries from Code available at: 9 | # https://learn.adafruit.com/adafruit-oled-displays-for-raspberry-pi/programming-your-display 10 | 11 | # Imports the necessary libraries... 12 | import sys 13 | 14 | import board 15 | import digitalio 16 | from PIL import Image 17 | 18 | import adafruit_ssd1306 19 | 20 | # Setting some variables for our reset pin etc. 21 | RESET_PIN = digitalio.DigitalInOut(board.D4) 22 | 23 | i2c = board.I2C() # uses board.SCL and board.SDA 24 | # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller 25 | 26 | # Create the SSD1306 OLED class. 27 | # The first two parameters are the pixel width and pixel height. 28 | # Change these to the right size for your display! 29 | oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c) 30 | 31 | # Note you can change the I2C address, or add a reset pin: 32 | # oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c, addr=0x3D, reset=RESET_PIN) 33 | 34 | # Clear display. 35 | oled.fill(0) 36 | oled.show() 37 | 38 | # Open, resize, and convert image to Black and White 39 | image = Image.open(sys.argv[1]).resize((oled.width, oled.height), Image.BICUBIC).convert("1") 40 | 41 | # Display the converted image 42 | oled.image(image) 43 | oled.show() 44 | -------------------------------------------------------------------------------- /examples/ssd1306_pillow_images.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2014 Tony DiCola for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | # This example is for use on (Linux) computers that are using CPython with 5 | # Adafruit Blinka to support CircuitPython libraries. CircuitPython does 6 | # not support PIL/pillow (python imaging library)! 7 | 8 | import busio 9 | from board import SCL, SDA 10 | from PIL import Image 11 | 12 | import adafruit_ssd1306 13 | 14 | # Create the I2C interface. 15 | i2c = busio.I2C(SCL, SDA) 16 | 17 | # Create the SSD1306 OLED class. 18 | # The first two parameters are the pixel width and pixel height. Change these 19 | # to the right size for your display! 20 | disp = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c) 21 | 22 | # Note you can change the I2C address, or add a reset pin: 23 | # disp = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, addr=0x3c, reset=reset_pin) 24 | 25 | # Clear display. 26 | disp.fill(0) 27 | disp.show() 28 | 29 | 30 | # Load image based on OLED display height. Note that image is converted to 1 bit color. 31 | if disp.height == 64: 32 | image = Image.open("happycat_oled_64.ppm").convert("1") 33 | else: 34 | image = Image.open("happycat_oled_32.ppm").convert("1") 35 | 36 | # Alternatively load a different format image, resize it, and convert to 1 bit color. 37 | # image = Image.open('happycat.png').resize((disp.width, disp.height), Image.ANTIALIAS).convert('1') 38 | 39 | # Display image. 40 | disp.image(image) 41 | disp.show() 42 | -------------------------------------------------------------------------------- /examples/ssd1306_pillow_ip.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Melissa LeBlanc-Williams for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | # This example is for use on (Linux) computers that are using CPython with 5 | # Adafruit Blinka to support CircuitPython libraries. CircuitPython does 6 | # not support PIL/pillow (python imaging library)! 7 | # 8 | # Ported to Pillow by Melissa LeBlanc-Williams for Adafruit Industries from Code available at: 9 | # https://learn.adafruit.com/adafruit-oled-displays-for-raspberry-pi/programming-your-display 10 | 11 | # Imports the necessary libraries... 12 | import fcntl 13 | import socket 14 | import struct 15 | 16 | import board 17 | import digitalio 18 | from PIL import Image, ImageDraw, ImageFont 19 | 20 | import adafruit_ssd1306 21 | 22 | 23 | # This function allows us to grab any of our IP addresses 24 | def get_ip_address(ifname): 25 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 26 | return socket.inet_ntoa( 27 | fcntl.ioctl( 28 | s.fileno(), 29 | 0x8915, # SIOCGIFADDR 30 | struct.pack("256s", str.encode(ifname[:15])), 31 | )[20:24] 32 | ) 33 | 34 | 35 | # Setting some variables for our reset pin etc. 36 | RESET_PIN = digitalio.DigitalInOut(board.D4) 37 | TEXT = "" 38 | 39 | # Very important... This lets py-gaugette 'know' what pins to use in order to reset the display 40 | i2c = board.I2C() # uses board.SCL and board.SDA 41 | # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller 42 | 43 | # Create the SSD1306 OLED class. 44 | # The first two parameters are the pixel width and pixel height. 45 | # Change these to the right size for your display! 46 | oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c) 47 | 48 | # Note you can change the I2C address, or add a reset pin: 49 | # oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c, addr=0x3D, reset=RESET_PIN) 50 | 51 | # This sets TEXT equal to whatever your IP address is, or isn't 52 | try: 53 | TEXT = get_ip_address("wlan0") # WiFi address of WiFi adapter. NOT ETHERNET 54 | except OSError: 55 | try: 56 | TEXT = get_ip_address("eth0") # WiFi address of Ethernet cable. NOT ADAPTER 57 | except OSError: 58 | TEXT = "NO INTERNET!" 59 | 60 | # Clear display. 61 | oled.fill(0) 62 | oled.show() 63 | 64 | # Create blank image for drawing. 65 | image = Image.new("1", (oled.width, oled.height)) 66 | draw = ImageDraw.Draw(image) 67 | 68 | # Load a font in 2 different sizes. 69 | font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 28) 70 | font2 = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 14) 71 | 72 | # Draw the text 73 | intro = "Hello!" 74 | ip = "Your IP Address is:" 75 | draw.text((0, 46), TEXT, font=font2, fill=255) 76 | draw.text((0, 0), intro, font=font, fill=255) 77 | draw.text((0, 30), ip, font=font2, fill=255) 78 | 79 | # Display image 80 | oled.image(image) 81 | oled.show() 82 | -------------------------------------------------------------------------------- /examples/ssd1306_pillow_shapes.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2014 Tony DiCola for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | # This example is for use on (Linux) computers that are using CPython with 5 | # Adafruit Blinka to support CircuitPython libraries. CircuitPython does 6 | # not support PIL/pillow (python imaging library)! 7 | 8 | import busio 9 | from board import SCL, SDA 10 | from PIL import Image, ImageDraw, ImageFont 11 | 12 | import adafruit_ssd1306 13 | 14 | # Create the I2C interface. 15 | i2c = busio.I2C(SCL, SDA) 16 | 17 | # Create the SSD1306 OLED class. 18 | # The first two parameters are the pixel width and pixel height. Change these 19 | # to the right size for your display! 20 | disp = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c) 21 | 22 | # Note you can change the I2C address, or add a reset pin: 23 | # disp = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, addr=0x3c, reset=reset_pin) 24 | 25 | # Clear display. 26 | disp.fill(0) 27 | disp.show() 28 | 29 | # Create blank image for drawing. 30 | # Make sure to create image with mode '1' for 1-bit color. 31 | width = disp.width 32 | height = disp.height 33 | image = Image.new("1", (width, height)) 34 | 35 | # Get drawing object to draw on image. 36 | draw = ImageDraw.Draw(image) 37 | 38 | # Draw a black filled box to clear the image. 39 | draw.rectangle((0, 0, width, height), outline=0, fill=0) 40 | 41 | # Draw some shapes. 42 | # First define some constants to allow easy resizing of shapes. 43 | padding = 2 44 | shape_width = 20 45 | top = padding 46 | bottom = height - padding 47 | # Move left to right keeping track of the current x position for drawing shapes. 48 | x = padding 49 | # Draw an ellipse. 50 | draw.ellipse((x, top, x + shape_width, bottom), outline=255, fill=0) 51 | x += shape_width + padding 52 | # Draw a rectangle. 53 | draw.rectangle((x, top, x + shape_width, bottom), outline=255, fill=0) 54 | x += shape_width + padding 55 | # Draw a triangle. 56 | draw.polygon( 57 | [(x, bottom), (x + shape_width / 2, top), (x + shape_width, bottom)], 58 | outline=255, 59 | fill=0, 60 | ) 61 | x += shape_width + padding 62 | # Draw an X. 63 | draw.line((x, bottom, x + shape_width, top), fill=255) 64 | draw.line((x, top, x + shape_width, bottom), fill=255) 65 | x += shape_width + padding 66 | 67 | # Load default font. 68 | font = ImageFont.load_default() 69 | 70 | # Alternatively load a TTF font. Make sure the .ttf font file is in the 71 | # same directory as the python script! 72 | # Some other nice fonts to try: http://www.dafont.com/bitmap.php 73 | # font = ImageFont.truetype('Minecraftia.ttf', 8) 74 | 75 | # Write two lines of text. 76 | draw.text((x, top), "Hello", font=font, fill=255) 77 | draw.text((x, top + 20), "World!", font=font, fill=255) 78 | 79 | # Display image. 80 | disp.image(image) 81 | disp.show() 82 | -------------------------------------------------------------------------------- /examples/ssd1306_pillow_text.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | # This example is for use on (Linux) computers that are using CPython with 5 | # Adafruit Blinka to support CircuitPython libraries. CircuitPython does 6 | # not support PIL/pillow (python imaging library)! 7 | # 8 | # Ported to Pillow by Melissa LeBlanc-Williams for Adafruit Industries from Code available at: 9 | # https://learn.adafruit.com/adafruit-oled-displays-for-raspberry-pi/programming-your-display 10 | 11 | # Imports the necessary libraries... 12 | import board 13 | import digitalio 14 | from PIL import Image, ImageDraw, ImageFont 15 | 16 | import adafruit_ssd1306 17 | 18 | # Setting some variables for our reset pin etc. 19 | RESET_PIN = digitalio.DigitalInOut(board.D4) 20 | 21 | # Very important... This lets py-gaugette 'know' what pins to use in order to reset the display 22 | i2c = board.I2C() # uses board.SCL and board.SDA 23 | # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller 24 | 25 | # Create the SSD1306 OLED class. 26 | # The first two parameters are the pixel width and pixel height. 27 | # Change these to the right size for your display! 28 | oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c) 29 | 30 | # Note you can change the I2C address, or add a reset pin: 31 | # oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c, addr=0x3D, reset=RESET_PIN) 32 | 33 | # Clear display. 34 | oled.fill(0) 35 | oled.show() 36 | 37 | # Create blank image for drawing. 38 | image = Image.new("1", (oled.width, oled.height)) 39 | draw = ImageDraw.Draw(image) 40 | 41 | # Load a font in 2 different sizes. 42 | font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 28) 43 | font2 = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 14) 44 | 45 | # Draw the text 46 | draw.text((0, 0), "Hello!", font=font, fill=255) 47 | draw.text((0, 30), "Hello!", font=font2, fill=255) 48 | draw.text((34, 46), "Hello!", font=font2, fill=255) 49 | 50 | # Display image 51 | oled.image(image) 52 | oled.show() 53 | -------------------------------------------------------------------------------- /examples/ssd1306_simpletest.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Tony DiCola 2 | # SPDX-License-Identifier: CC0-1.0 3 | 4 | # Basic example of clearing and drawing pixels on a SSD1306 OLED display. 5 | # This example and library is meant to work with Adafruit CircuitPython API. 6 | 7 | import board 8 | 9 | import adafruit_ssd1306 10 | 11 | # Create the I2C bus interface. 12 | i2c = board.I2C() # uses board.SCL and board.SDA 13 | # i2c = busio.I2C(board.GP1, board.GP0) # Pi Pico RP2040 14 | 15 | # Create the SSD1306 OLED class. 16 | display_width = 128 17 | display_height = 32 18 | display = adafruit_ssd1306.SSD1306_I2C(display_width, display_height, i2c) 19 | # You can change the I2C address with an addr parameter: 20 | # display = adafruit_ssd1306.SSD1306_I2C(display_width, display_height, i2c, addr=0x31) 21 | 22 | # fills display with black pixels clearing it 23 | display.fill(0) 24 | display.show() 25 | 26 | # Set a pixel in the origin 0,0 position. 27 | display.pixel(0, 0, 1) 28 | # Set a pixel in the middle 64, 16 position. 29 | display.pixel(64, 16, 1) 30 | # Set a pixel in the opposite 127, 31 position. 31 | display.pixel(127, 31, 1) 32 | display.show() 33 | -------------------------------------------------------------------------------- /examples/ssd1306_stats.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Tony DiCola for Adafruit Industries 2 | # SPDX-FileCopyrightText: 2017 James DeVito for Adafruit Industries 3 | # SPDX-License-Identifier: MIT 4 | 5 | # This example is for use on (Linux) computers that are using CPython with 6 | # Adafruit Blinka to support CircuitPython libraries. CircuitPython does 7 | # not support PIL/pillow (python imaging library)! 8 | 9 | import subprocess 10 | import time 11 | 12 | import busio 13 | from board import SCL, SDA 14 | from PIL import Image, ImageDraw, ImageFont 15 | 16 | import adafruit_ssd1306 17 | 18 | # Create the I2C interface. 19 | i2c = busio.I2C(SCL, SDA) 20 | 21 | # Create the SSD1306 OLED class. 22 | # The first two parameters are the pixel width and pixel height. Change these 23 | # to the right size for your display! 24 | disp = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c) 25 | 26 | # Clear display. 27 | disp.fill(0) 28 | disp.show() 29 | 30 | # Create blank image for drawing. 31 | # Make sure to create image with mode '1' for 1-bit color. 32 | width = disp.width 33 | height = disp.height 34 | image = Image.new("1", (width, height)) 35 | 36 | # Get drawing object to draw on image. 37 | draw = ImageDraw.Draw(image) 38 | 39 | # Draw a black filled box to clear the image. 40 | draw.rectangle((0, 0, width, height), outline=0, fill=0) 41 | 42 | # Draw some shapes. 43 | # First define some constants to allow easy resizing of shapes. 44 | padding = -2 45 | top = padding 46 | bottom = height - padding 47 | # Move left to right keeping track of the current x position for drawing shapes. 48 | x = 0 49 | 50 | 51 | # Load default font. 52 | font = ImageFont.load_default() 53 | 54 | # Alternatively load a TTF font. Make sure the .ttf font file is in the 55 | # same directory as the python script! 56 | # Some other nice fonts to try: http://www.dafont.com/bitmap.php 57 | # font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 9) 58 | 59 | while True: 60 | # Draw a black filled box to clear the image. 61 | draw.rectangle((0, 0, width, height), outline=0, fill=0) 62 | 63 | # Shell scripts for system monitoring from here: 64 | # https://unix.stackexchange.com/questions/119126/command-to-display-memory-usage-disk-usage-and-cpu-load 65 | cmd = "hostname -I | cut -d' ' -f1" 66 | IP = subprocess.check_output(cmd, shell=True).decode("utf-8") 67 | cmd = 'cut -f 1 -d " " /proc/loadavg' 68 | CPU = subprocess.check_output(cmd, shell=True).decode("utf-8") 69 | cmd = "free -m | awk 'NR==2{printf \"Mem: %s/%s MB %.2f%%\", $3,$2,$3*100/$2 }'" 70 | MemUsage = subprocess.check_output(cmd, shell=True).decode("utf-8") 71 | cmd = 'df -h | awk \'$NF=="/"{printf "Disk: %d/%d GB %s", $3,$2,$5}\'' 72 | Disk = subprocess.check_output(cmd, shell=True).decode("utf-8") 73 | 74 | # Write four lines of text. 75 | 76 | draw.text((x, top + 0), "IP: " + IP, font=font, fill=255) 77 | draw.text((x, top + 8), "CPU load: " + CPU, font=font, fill=255) 78 | draw.text((x, top + 16), MemUsage, font=font, fill=255) 79 | draw.text((x, top + 25), Disk, font=font, fill=255) 80 | 81 | # Display image. 82 | disp.image(image) 83 | disp.show() 84 | time.sleep(0.1) 85 | -------------------------------------------------------------------------------- /optional_requirements.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Alec Delaney for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | [build-system] 6 | requires = [ 7 | "setuptools", 8 | "wheel", 9 | "setuptools-scm", 10 | ] 11 | 12 | [project] 13 | name = "adafruit-circuitpython-ssd1306" 14 | description = "CircuitPython library for SSD1306 OLED displays." 15 | version = "0.0.0+auto.0" 16 | readme = "README.rst" 17 | authors = [ 18 | {name = "Adafruit Industries", email = "circuitpython@adafruit.com"} 19 | ] 20 | urls = {Homepage = "https://github.com/adafruit/Adafruit_CircuitPython_SSD1306"} 21 | keywords = [ 22 | "adafruit", 23 | "ssd1306", 24 | "oled", 25 | "displays", 26 | "hardware", 27 | "micropython", 28 | "circuitpython", 29 | ] 30 | license = {text = "MIT"} 31 | classifiers = [ 32 | "Intended Audience :: Developers", 33 | "Topic :: Software Development :: Libraries", 34 | "Topic :: Software Development :: Embedded Systems", 35 | "Topic :: System :: Hardware", 36 | "License :: OSI Approved :: MIT License", 37 | "Programming Language :: Python :: 3", 38 | ] 39 | dynamic = ["dependencies", "optional-dependencies"] 40 | 41 | [tool.setuptools] 42 | py-modules = ["adafruit_ssd1306"] 43 | 44 | [tool.setuptools.dynamic] 45 | dependencies = {file = ["requirements.txt"]} 46 | optional-dependencies = {optional = {file = ["optional_requirements.txt"]}} 47 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | Adafruit-Blinka 6 | adafruit-circuitpython-busdevice 7 | adafruit-circuitpython-framebuf 8 | -------------------------------------------------------------------------------- /ruff.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | target-version = "py38" 6 | line-length = 100 7 | 8 | [lint] 9 | preview = true 10 | select = ["I", "PL", "UP"] 11 | 12 | extend-select = [ 13 | "D419", # empty-docstring 14 | "E501", # line-too-long 15 | "W291", # trailing-whitespace 16 | "PLC0414", # useless-import-alias 17 | "PLC2401", # non-ascii-name 18 | "PLC2801", # unnecessary-dunder-call 19 | "PLC3002", # unnecessary-direct-lambda-call 20 | "E999", # syntax-error 21 | "PLE0101", # return-in-init 22 | "F706", # return-outside-function 23 | "F704", # yield-outside-function 24 | "PLE0116", # continue-in-finally 25 | "PLE0117", # nonlocal-without-binding 26 | "PLE0241", # duplicate-bases 27 | "PLE0302", # unexpected-special-method-signature 28 | "PLE0604", # invalid-all-object 29 | "PLE0605", # invalid-all-format 30 | "PLE0643", # potential-index-error 31 | "PLE0704", # misplaced-bare-raise 32 | "PLE1141", # dict-iter-missing-items 33 | "PLE1142", # await-outside-async 34 | "PLE1205", # logging-too-many-args 35 | "PLE1206", # logging-too-few-args 36 | "PLE1307", # bad-string-format-type 37 | "PLE1310", # bad-str-strip-call 38 | "PLE1507", # invalid-envvar-value 39 | "PLE2502", # bidirectional-unicode 40 | "PLE2510", # invalid-character-backspace 41 | "PLE2512", # invalid-character-sub 42 | "PLE2513", # invalid-character-esc 43 | "PLE2514", # invalid-character-nul 44 | "PLE2515", # invalid-character-zero-width-space 45 | "PLR0124", # comparison-with-itself 46 | "PLR0202", # no-classmethod-decorator 47 | "PLR0203", # no-staticmethod-decorator 48 | "UP004", # useless-object-inheritance 49 | "PLR0206", # property-with-parameters 50 | "PLR0904", # too-many-public-methods 51 | "PLR0911", # too-many-return-statements 52 | "PLR0912", # too-many-branches 53 | "PLR0913", # too-many-arguments 54 | "PLR0914", # too-many-locals 55 | "PLR0915", # too-many-statements 56 | "PLR0916", # too-many-boolean-expressions 57 | "PLR1702", # too-many-nested-blocks 58 | "PLR1704", # redefined-argument-from-local 59 | "PLR1711", # useless-return 60 | "C416", # unnecessary-comprehension 61 | "PLR1733", # unnecessary-dict-index-lookup 62 | "PLR1736", # unnecessary-list-index-lookup 63 | 64 | # ruff reports this rule is unstable 65 | #"PLR6301", # no-self-use 66 | 67 | "PLW0108", # unnecessary-lambda 68 | "PLW0120", # useless-else-on-loop 69 | "PLW0127", # self-assigning-variable 70 | "PLW0129", # assert-on-string-literal 71 | "B033", # duplicate-value 72 | "PLW0131", # named-expr-without-context 73 | "PLW0245", # super-without-brackets 74 | "PLW0406", # import-self 75 | "PLW0602", # global-variable-not-assigned 76 | "PLW0603", # global-statement 77 | "PLW0604", # global-at-module-level 78 | 79 | # fails on the try: import typing used by libraries 80 | #"F401", # unused-import 81 | 82 | "F841", # unused-variable 83 | "E722", # bare-except 84 | "PLW0711", # binary-op-exception 85 | "PLW1501", # bad-open-mode 86 | "PLW1508", # invalid-envvar-default 87 | "PLW1509", # subprocess-popen-preexec-fn 88 | "PLW2101", # useless-with-lock 89 | "PLW3301", # nested-min-max 90 | ] 91 | 92 | ignore = [ 93 | "PLR2004", # magic-value-comparison 94 | "UP030", # format literals 95 | "PLW1514", # unspecified-encoding 96 | "PLR0913", # too-many-arguments 97 | "PLR0915", # too-many-statements 98 | "PLR0917", # too-many-positional-arguments 99 | "PLR0904", # too-many-public-methods 100 | "PLR0912", # too-many-branches 101 | "PLR0916", # too-many-boolean-expressions 102 | "PLR6301", # could-be-static no-self-use 103 | ] 104 | 105 | [format] 106 | line-ending = "lf" 107 | --------------------------------------------------------------------------------