├── .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 ├── MIT.txt └── Unlicense.txt ├── README.rst ├── README.rst.license ├── adafruit_is31fl3731 ├── __init__.py ├── charlie_bonnet.py ├── charlie_wing.py ├── keybow2040.py ├── led_shim.py ├── matrix.py ├── matrix_11x7.py ├── rgbmatrix5x5.py └── scroll_phat_hd.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 ├── is31fl3731_16x9_charlieplexed_pwm.py ├── is31fl3731_blink_example.py ├── is31fl3731_frame_example.py ├── is31fl3731_keybow_2040_rainbow.py ├── is31fl3731_ledshim_fade.py ├── is31fl3731_ledshim_rainbow.py ├── is31fl3731_pillow_animated_gif.py ├── is31fl3731_pillow_marquee.py ├── is31fl3731_pillow_numbers.py ├── is31fl3731_rgbmatrix5x5_rainbow.py ├── is31fl3731_simpletest.py ├── is31fl3731_text_example.py └── is31fl3731_wave_example.py ├── optional_requirements.txt ├── pyproject.toml ├── requirements.txt └── ruff.toml /.gitattributes: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2024 Justin Myers 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | * text eol=lf 6 | -------------------------------------------------------------------------------- /.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 | venv 42 | 43 | # MacOS-specific files 44 | *.DS_Store 45 | 46 | # IDE-specific files 47 | .idea 48 | .vscode 49 | *~ 50 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2020 Diego Elio Pettenò 2 | # SPDX-FileCopyrightText: 2024 Justin Myers 3 | # 4 | # SPDX-License-Identifier: Unlicense 5 | 6 | repos: 7 | - repo: https://github.com/pre-commit/pre-commit-hooks 8 | rev: v4.5.0 9 | hooks: 10 | - id: check-yaml 11 | - id: end-of-file-fixer 12 | - id: trailing-whitespace 13 | - repo: https://github.com/astral-sh/ruff-pre-commit 14 | rev: v0.3.4 15 | hooks: 16 | - id: ruff-format 17 | - id: ruff 18 | args: ["--fix"] 19 | - repo: https://github.com/fsfe/reuse-tool 20 | rev: v3.0.1 21 | hooks: 22 | - id: reuse 23 | -------------------------------------------------------------------------------- /.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 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Radomir Dopieralski 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/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-is31fl3731/badge/?version=latest 5 | :target: https://docs.circuitpython.org/projects/is31fl3731/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_IS31FL3731/workflows/Build%20CI/badge.svg 13 | :target: https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3731/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 | CircuitPython driver for the IS31FL3731 charlieplex IC. 21 | 22 | This driver supports the following hardware: 23 | 24 | * `Adafruit 16x9 Charlieplexed PWM LED Matrix Driver - IS31FL3731 `_ 25 | * `Adafruit 15x7 CharliePlex LED Matrix Display FeatherWings `_ 26 | * `Adafruit 16x8 CharliePlex LED Matrix Bonnets `_ 27 | * `Pimoroni 17x7 Scroll pHAT HD `_ 28 | * `Pimoroni 28x3 (r,g,b) Led Shim `_ 29 | * `Pimoroni Keybow 2040 with 4x4 matrix of RGB LEDs `_ 30 | * `Pimoroni 5x5 RGB Matrix Breakout `_ 31 | 32 | 33 | Dependencies 34 | ============= 35 | This driver depends on: 36 | 37 | * `Adafruit CircuitPython `_ 38 | 39 | Please ensure all dependencies are available on the CircuitPython filesystem. 40 | This is easily achieved by downloading 41 | `the Adafruit library and driver bundle `_. 42 | 43 | Installing from PyPI 44 | ==================== 45 | 46 | On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from 47 | PyPI `_. To install for current user: 48 | 49 | .. code-block:: shell 50 | 51 | pip3 install adafruit-circuitpython-is31fl3731 52 | 53 | To install system-wide (this may be required in some cases): 54 | 55 | .. code-block:: shell 56 | 57 | sudo pip3 install adafruit-circuitpython-is31fl3731 58 | 59 | To install in a virtual environment in your current project: 60 | 61 | .. code-block:: shell 62 | 63 | mkdir project-name && cd project-name 64 | python3 -m venv .venv 65 | source .venv/bin/activate 66 | pip3 install adafruit-circuitpython-is31fl3731 67 | 68 | Usage Example 69 | ============= 70 | 71 | Matrix: 72 | 73 | .. code:: python 74 | 75 | from adafruit_is31fl3731.matrix import Matrix 76 | import board 77 | import busio 78 | with busio.I2C(board.SCL, board.SDA) as i2c: 79 | display = Matrix(i2c) 80 | display.fill(127) 81 | 82 | 83 | Charlie Wing: 84 | 85 | .. code:: python 86 | 87 | from adafruit_is31fl3731.charlie_wing import CharlieWing 88 | import board 89 | import busio 90 | with busio.I2C(board.SCL, board.SDA) as i2c: 91 | display = CharlieWing(i2c) 92 | display.fill(127) 93 | 94 | # Turn off pixel 4,4, change its brightness and turn it back on 95 | display.pixel(4, 4, 0) # Turn off. 96 | display.pixel(4, 4, 50) # Low brightness (50) 97 | display.pixel(4, 4, 192) # Higher brightness (192) 98 | 99 | Documentation 100 | ============= 101 | 102 | API documentation for this library can be found on `Read the Docs `_. 103 | 104 | For information on building library documentation, please check out `this guide `_. 105 | 106 | Contributing 107 | ============ 108 | 109 | Contributions are welcome! Please read our `Code of Conduct 110 | `_ 111 | before contributing to help this project stay welcoming. 112 | -------------------------------------------------------------------------------- /README.rst.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | 3 | SPDX-License-Identifier: MIT 4 | -------------------------------------------------------------------------------- /adafruit_is31fl3731/__init__.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | """ 6 | `adafruit_is31fl3731` 7 | ==================================================== 8 | 9 | CircuitPython driver for the IS31FL3731 charlieplex IC. 10 | 11 | Base library. 12 | 13 | * Author(s): Tony DiCola, Melissa LeBlanc-Williams, David Glaude, E. A. Graham Jr. 14 | 15 | Implementation Notes 16 | -------------------- 17 | 18 | **Hardware:** 19 | 20 | * `Adafruit 16x9 Charlieplexed PWM LED Matrix Driver - IS31FL3731 21 | `_ 22 | 23 | * `Adafruit 15x7 CharliePlex LED Matrix Display FeatherWings 24 | `_ 25 | 26 | * `Adafruit 16x8 CharliePlex LED Matrix Bonnets 27 | `_ 28 | 29 | * `Pimoroni 17x7 Scroll pHAT HD 30 | `_ 31 | 32 | * `Pimoroni 28x3 (r,g,b) Led Shim 33 | `_ 34 | 35 | * `Pimoroni LED SHIM 36 | `_ 37 | 38 | * `Pimoroni Keybow 2040 39 | `_ 40 | 41 | * `Pimoroni 11x7 LED Matrix Breakout 42 | `_ 43 | 44 | **Software and Dependencies:** 45 | 46 | * Adafruit CircuitPython firmware for the supported boards: 47 | https://github.com/adafruit/circuitpython/releases 48 | 49 | """ 50 | 51 | # imports 52 | import math 53 | import time 54 | 55 | from adafruit_bus_device.i2c_device import I2CDevice 56 | from micropython import const 57 | 58 | try: 59 | import typing 60 | 61 | # Import ReadableBuffer here 62 | from typing import ( 63 | TYPE_CHECKING, 64 | Iterable, 65 | List, 66 | Optional, 67 | Tuple, 68 | ) 69 | 70 | import busio 71 | from circuitpython_typing import ( 72 | ReadableBuffer, 73 | TypeAlias, 74 | Union, 75 | WriteableBuffer, 76 | ) 77 | from PIL import Image 78 | 79 | except ImportError: 80 | pass 81 | 82 | 83 | __version__ = "0.0.0+auto.0" 84 | __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3731.git" 85 | 86 | _MODE_REGISTER = const(0x00) 87 | _FRAME_REGISTER = const(0x01) 88 | _AUTOPLAY1_REGISTER = const(0x02) 89 | _AUTOPLAY2_REGISTER = const(0x03) 90 | _BLINK_REGISTER = const(0x05) 91 | _AUDIOSYNC_REGISTER = const(0x06) 92 | _BREATH1_REGISTER = const(0x08) 93 | _BREATH2_REGISTER = const(0x09) 94 | _SHUTDOWN_REGISTER = const(0x0A) 95 | _GAIN_REGISTER = const(0x0B) 96 | _ADC_REGISTER = const(0x0C) 97 | 98 | _CONFIG_BANK = const(0x0B) 99 | _BANK_ADDRESS = const(0xFD) 100 | 101 | _PICTURE_MODE = const(0x00) 102 | _AUTOPLAY_MODE = const(0x08) 103 | _AUDIOPLAY_MODE = const(0x18) 104 | 105 | _ENABLE_OFFSET = const(0x00) 106 | _BLINK_OFFSET = const(0x12) 107 | _COLOR_OFFSET = const(0x24) 108 | 109 | 110 | class IS31FL3731: 111 | """ 112 | The IS31FL3731 is an abstract class contain the main function related to this chip. 113 | Each board needs to define width, height and pixel_addr. 114 | 115 | :param ~busio.I2C i2c: the connected i2c bus i2c_device 116 | :param int address: the device address; defaults to 0x74 117 | :param Iterable frames: list of frame indexes to use. int's 0-7. 118 | """ 119 | 120 | width: int = 16 121 | height: int = 9 122 | 123 | def __init__( 124 | self, 125 | i2c: busio.I2C, 126 | frames: Optional[Iterable] = None, 127 | address: int = 0x74, 128 | ): 129 | self.i2c_device = I2CDevice(i2c, address) 130 | self._frame = None 131 | self._init(frames=frames) 132 | 133 | def _i2c_read_reg( 134 | self, reg: Optional[int] = None, result: Optional[WriteableBuffer] = None 135 | ) -> Optional[WriteableBuffer]: 136 | # Read a buffer of data from the specified 8-bit I2C register address. 137 | # The provided result parameter will be filled to capacity with bytes 138 | # of data read from the register. 139 | with self.i2c_device as i2c: 140 | i2c.write_then_readinto(bytes([reg]), result) 141 | return result 142 | return None 143 | 144 | def _i2c_write_reg( 145 | self, reg: Optional[int] = None, data: Optional[ReadableBuffer] = None 146 | ) -> None: 147 | # Write a contiguous block of data (bytearray) starting at the 148 | # specified I2C register address (register passed as argument). 149 | self._i2c_write_block(bytes([reg]) + data) 150 | 151 | def _i2c_write_block(self, data: Optional[ReadableBuffer]) -> None: 152 | # Write a buffer of data (byte array) to the specified I2C register 153 | # address. 154 | with self.i2c_device as i2c: 155 | i2c.write(data) 156 | 157 | def _bank(self, bank: Optional[int] = None) -> Optional[int]: 158 | if bank is None: 159 | result = bytearray(1) 160 | return self._i2c_read_reg(_BANK_ADDRESS, result)[0] 161 | self._i2c_write_reg(_BANK_ADDRESS, bytearray([bank])) 162 | return None 163 | 164 | def _register( 165 | self, 166 | bank: Optional[int] = None, 167 | register: Optional[int] = None, 168 | value: Optional[int] = None, 169 | ) -> Optional[int]: 170 | self._bank(bank) 171 | if value is None: 172 | result = bytearray(1) 173 | return self._i2c_read_reg(register, result)[0] 174 | self._i2c_write_reg(register, bytearray([value])) 175 | return None 176 | 177 | def _mode(self, mode: Optional[int] = None) -> int: 178 | """Function for setting _register mode""" 179 | return self._register(_CONFIG_BANK, _MODE_REGISTER, mode) 180 | 181 | def _init(self, frames: Iterable) -> None: 182 | self.sleep(True) 183 | # Clear config; sets to Picture Mode, no audio sync, maintains sleep 184 | self._bank(_CONFIG_BANK) 185 | self._i2c_write_block(bytes([0] * 14)) 186 | enable_data = bytes([_ENABLE_OFFSET] + [255] * 18) 187 | fill_data = bytearray([0] * 25) 188 | # Initialize requested frames, or all 8 if unspecified 189 | for frame in frames if frames else range(8): 190 | self._bank(frame) 191 | self._i2c_write_block(enable_data) # Set all enable bits 192 | for row in range(6): # Barebones quick fill() w/0 193 | fill_data[0] = _COLOR_OFFSET + row * 24 194 | self._i2c_write_block(fill_data) 195 | self._frame = 0 # To match config bytes above 196 | self.sleep(False) 197 | 198 | def reset(self) -> None: 199 | """Kill the display for 10MS""" 200 | self.sleep(True) 201 | time.sleep(0.01) # 10 MS pause to reset. 202 | self.sleep(False) 203 | 204 | def sleep(self, value: bool) -> Optional[int]: 205 | """ 206 | Set the Software Shutdown Register bit 207 | 208 | :param value: True to set software shutdown bit; False unset 209 | """ 210 | return self._register(_CONFIG_BANK, _SHUTDOWN_REGISTER, not value) 211 | 212 | def autoplay( 213 | self, 214 | delay: int = 0, 215 | loops: int = 0, 216 | frames: int = 0, 217 | ) -> None: 218 | """ 219 | Start autoplay 220 | 221 | :param delay: in ms 222 | :param loops: number of loops - 0->7 223 | :param frames: number of frames: 0->7 224 | """ 225 | if delay == 0: 226 | self._mode(_PICTURE_MODE) 227 | return 228 | delay //= 11 229 | if not 0 <= loops <= 7: 230 | raise ValueError("Loops out of range") 231 | if not 0 <= frames <= 7: 232 | raise ValueError("Frames out of range") 233 | if not 1 <= delay <= 64: 234 | raise ValueError("Delay out of range") 235 | self._register(_CONFIG_BANK, _AUTOPLAY1_REGISTER, loops << 4 | frames) 236 | self._register(_CONFIG_BANK, _AUTOPLAY2_REGISTER, delay % 64) 237 | self._mode(_AUTOPLAY_MODE | self._frame) 238 | 239 | def fade( 240 | self, 241 | fade_in: Optional[int] = None, 242 | fade_out: Optional[int] = None, 243 | pause: int = 0, 244 | ) -> int: 245 | """ 246 | Start and stop the fade feature. If both fade_in and fade_out are None (the 247 | default), the breath feature is used for fading. if fade_in is None, then 248 | fade_in = fade_out. If fade_out is None, then fade_out = fade_in 249 | 250 | :param fade_in: fade time in ms, range = 26 to 3328 251 | :param fade-out: fade time in ms, range = 26 to 3328 252 | :param pause: pause time in ms, range = 3.5 to 448 253 | """ 254 | if fade_in is None and fade_out is None: 255 | self._register(_CONFIG_BANK, _BREATH2_REGISTER, 0) 256 | return 257 | if fade_in is None: 258 | fade_in = fade_out 259 | elif fade_out is None: 260 | fade_out = fade_in 261 | 262 | if fade_in != 0: 263 | fade_in = int(math.log(fade_in / 26, 2)) 264 | if fade_out != 0: 265 | fade_out = int(math.log(fade_out / 26, 2)) 266 | if pause != 0: 267 | pause = int(math.log(pause / 3.5, 2)) 268 | if not 0 <= fade_in <= 7: 269 | raise ValueError("Fade in out of range") 270 | if not 0 <= fade_out <= 7: 271 | raise ValueError("Fade out out of range") 272 | if not 0 <= pause <= 7: 273 | raise ValueError("Pause out of range") 274 | 275 | self._register(_CONFIG_BANK, _BREATH1_REGISTER, fade_out << 4 | fade_in) 276 | self._register(_CONFIG_BANK, _BREATH2_REGISTER, 1 << 4 | pause) 277 | 278 | def frame(self, frame: Optional[int] = None, show: bool = True) -> Optional[int]: 279 | """ 280 | Set the current frame 281 | 282 | :param frame: int frame number; 0-7 or None. If None function returns current frame 283 | :param show: bool True to show the frame; False to not show. 284 | """ 285 | if frame is None: 286 | return self._frame 287 | if not 0 <= frame <= 8: 288 | raise ValueError("Frame out of range") 289 | self._frame = frame 290 | if show: 291 | self._register(_CONFIG_BANK, _FRAME_REGISTER, frame) 292 | return None 293 | 294 | def audio_sync(self, value: Optional[int]) -> Optional[int]: 295 | """Set the audio sync feature register""" 296 | return self._register(_CONFIG_BANK, _AUDIOSYNC_REGISTER, value) 297 | 298 | def audio_play( 299 | self, 300 | sample_rate: int, 301 | audio_gain: int = 0, 302 | agc_enable: bool = False, 303 | agc_fast: bool = False, 304 | ) -> None: 305 | """Controls the audio play feature""" 306 | if sample_rate == 0: 307 | self._mode(_PICTURE_MODE) 308 | return 309 | sample_rate //= 46 310 | if not 1 <= sample_rate <= 256: 311 | raise ValueError("Sample rate out of range") 312 | self._register(_CONFIG_BANK, _ADC_REGISTER, sample_rate % 256) 313 | audio_gain //= 3 314 | if not 0 <= audio_gain <= 7: 315 | raise ValueError("Audio gain out of range") 316 | self._register( 317 | _CONFIG_BANK, 318 | _GAIN_REGISTER, 319 | bool(agc_enable) << 3 | bool(agc_fast) << 4 | audio_gain, 320 | ) 321 | self._mode(_AUDIOPLAY_MODE) 322 | 323 | def blink(self, rate: Optional[int] = None) -> Optional[int]: 324 | """Updates the blink register""" 325 | # This needs to be refactored when it can be tested 326 | if rate is None: 327 | return (self._register(_CONFIG_BANK, _BLINK_REGISTER) & 0x07) * 270 328 | elif rate == 0: 329 | self._register(_CONFIG_BANK, _BLINK_REGISTER, 0x00) 330 | return None 331 | rate //= 270 332 | self._register(_CONFIG_BANK, _BLINK_REGISTER, rate & 0x07 | 0x08) 333 | return None 334 | 335 | def fill( 336 | self, 337 | color: Optional[int] = None, 338 | frame: Optional[int] = None, 339 | blink: bool = False, 340 | ): 341 | """ 342 | Fill the display with a brightness level 343 | 344 | :param color: brightness 0->255 345 | :param blink: bool True to blink 346 | :param frame: int the frame to set the pixel, default 0 347 | """ 348 | if frame is None: 349 | frame = self._frame 350 | self._bank(frame) 351 | if color is not None: 352 | if not 0 <= color <= 255: 353 | raise ValueError("Color out of range") 354 | data = bytearray([color] * 25) # Extra byte at front for address. 355 | with self.i2c_device as i2c: 356 | for row in range(6): 357 | data[0] = _COLOR_OFFSET + row * 24 358 | i2c.write(data) 359 | if blink is not None: 360 | data = bool(blink) * 0xFF 361 | for col in range(18): 362 | self._register(frame, _BLINK_OFFSET + col, data) 363 | 364 | # This function must be replaced for each board 365 | @staticmethod 366 | def pixel_addr(x: int, y: int) -> int: 367 | """Calulate the offset into the device array for x,y pixel""" 368 | return x + y * 16 369 | 370 | def pixel( # noqa: PLR0913, PLR0912, Too many arguments in function definition, Too many branches 371 | self, 372 | x: int, 373 | y: int, 374 | color: Optional[int] = None, 375 | frame: Optional[int] = None, 376 | blink: bool = False, 377 | rotate: int = 0, 378 | ) -> Optional[int]: 379 | """ 380 | Matrix display configuration 381 | 382 | :param x: int horizontal pixel position 383 | :param y: int vertical pixel position 384 | :param color: int brightness value 0->255 385 | :param blink: bool True to blink 386 | :param frame: int the frame to set the pixel, default 0 387 | :param rotate: int display rotation (0, 90, 180, 270) 388 | """ 389 | 390 | if rotate not in (0, 90, 180, 270): 391 | raise ValueError("Rotation must be 0, 90, 180, or 270 degrees") 392 | 393 | if rotate == 0: 394 | check_x = 0 <= x <= self.width 395 | check_y = 0 <= y <= self.height 396 | if not (check_x and check_y): 397 | return None 398 | pixel = self.pixel_addr(x, y) 399 | elif rotate == 90: 400 | check_x = 0 <= y <= self.width 401 | check_y = 0 <= x <= self.height 402 | if not (check_x and check_y): 403 | return None 404 | pixel = self.pixel_addr(y, self.height - x - 1) 405 | elif rotate == 180: 406 | check_x = 0 <= x <= self.width 407 | check_y = 0 <= y <= self.height 408 | if not (check_x and check_y): 409 | return None 410 | pixel = self.pixel_addr(self.width - x - 1, self.height - y - 1) 411 | elif rotate == 270: 412 | check_x = 0 <= y <= self.width 413 | check_y = 0 <= x <= self.height 414 | if not (check_x and check_y): 415 | return None 416 | pixel = self.pixel_addr(self.width - y - 1, x) 417 | 418 | if color is None and blink is None: 419 | return self._register(self._frame, pixel) 420 | # frames other than 0 only used in animation. allow None. 421 | if frame is None: 422 | frame = self._frame 423 | # Brightness 424 | if color is not None: 425 | if not 0 <= color <= 255: 426 | raise ValueError("Brightness or Color out of range (0-255)") 427 | self._register(frame, _COLOR_OFFSET + pixel, color) 428 | # Blink works but not well while animated 429 | if blink: 430 | addr, bit = divmod(pixel, 8) 431 | bits = self._register(frame, _BLINK_OFFSET + addr) 432 | if blink: 433 | bits |= 1 << bit 434 | else: 435 | bits &= ~(1 << bit) 436 | self._register(frame, _BLINK_OFFSET + addr, bits) 437 | return None 438 | 439 | def image(self, img: Image, frame: Optional[int] = None, blink: bool = False) -> None: 440 | """Set buffer to value of Python Imaging Library image. The image should 441 | be in 8-bit mode (L) and a size equal to the display size. 442 | 443 | :param img: Python Imaging Library image 444 | :param blink: True to blink 445 | :param frame: the frame to set the image, default 0 446 | """ 447 | if img.mode != "L": 448 | raise ValueError("Image must be in mode L.") 449 | imwidth, imheight = img.size 450 | if imwidth != self.width or imheight != self.height: 451 | raise ValueError( 452 | f"Image must be same dimensions as display ({self.width}x{self.height})." 453 | ) 454 | # Grab all the pixels from the image, faster than getpixel. 455 | pixels = img.load() 456 | 457 | # Iterate through the pixels 458 | for x in range(self.width): # yes this double loop is slow, 459 | for y in range(self.height): # but these displays are small! 460 | self.pixel(x, y, pixels[(x, y)], blink=blink, frame=frame) 461 | -------------------------------------------------------------------------------- /adafruit_is31fl3731/charlie_bonnet.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | """ 6 | `adafruit_is31fl3731.charlie_bonnet` 7 | ==================================================== 8 | 9 | CircuitPython driver for the IS31FL3731 charlieplex IC. 10 | 11 | 12 | * Author(s): Tony DiCola, Melissa LeBlanc-Williams 13 | 14 | Implementation Notes 15 | -------------------- 16 | 17 | **Hardware:** 18 | 19 | * `Adafruit 16x8 CharliePlex LED Matrix Bonnets 20 | `_ 21 | 22 | 23 | **Software and Dependencies:** 24 | 25 | * Adafruit CircuitPython firmware for the supported boards: 26 | https://github.com/adafruit/circuitpython/releases 27 | 28 | """ 29 | 30 | # imports 31 | from . import IS31FL3731 32 | 33 | 34 | class CharlieBonnet(IS31FL3731): 35 | """Supports the Charlieplexed bonnet""" 36 | 37 | width = 16 38 | height = 8 39 | 40 | @staticmethod 41 | def pixel_addr(x, y): 42 | """Calulate the offset into the device array for x,y pixel""" 43 | if x >= 8: 44 | return (x - 6) * 16 - (y + 1) 45 | return (x + 1) * 16 + (7 - y) 46 | -------------------------------------------------------------------------------- /adafruit_is31fl3731/charlie_wing.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | """ 6 | `adafruit_is31fl3731.charlie_wing` 7 | ==================================================== 8 | 9 | CircuitPython driver for the IS31FL3731 charlieplex IC. 10 | 11 | 12 | * Author(s): Tony DiCola, Melissa LeBlanc-Williams 13 | 14 | Implementation Notes 15 | -------------------- 16 | 17 | **Hardware:** 18 | 19 | * `Adafruit 15x7 CharliePlex LED Matrix Display FeatherWings 20 | `_ 21 | 22 | **Software and Dependencies:** 23 | 24 | * Adafruit CircuitPython firmware for the supported boards: 25 | https://github.com/adafruit/circuitpython/releases 26 | 27 | """ 28 | 29 | # imports 30 | from . import IS31FL3731 31 | 32 | 33 | class CharlieWing(IS31FL3731): 34 | """Supports the Charlieplexed feather wing""" 35 | 36 | width = 15 37 | height = 7 38 | 39 | @staticmethod 40 | def pixel_addr(x, y): 41 | """Calulate the offset into the device array for x,y pixel""" 42 | if x > 7: 43 | x = 15 - x 44 | y += 8 45 | else: 46 | y = 7 - y 47 | return x * 16 + y 48 | -------------------------------------------------------------------------------- /adafruit_is31fl3731/keybow2040.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | """ 6 | `adafruit_is31fl3731.keybow2040` 7 | ==================================================== 8 | 9 | CircuitPython driver for the IS31FL3731 charlieplex IC. 10 | 11 | 12 | * Author(s): Tony DiCola, Melissa LeBlanc-Williams 13 | 14 | Implementation Notes 15 | -------------------- 16 | 17 | **Hardware:** 18 | 19 | * `Pimoroni Keybow 2040 20 | `_ 21 | 22 | 23 | **Software and Dependencies:** 24 | 25 | * Adafruit CircuitPython firmware for the supported boards: 26 | https://github.com/adafruit/circuitpython/releases 27 | 28 | """ 29 | 30 | # imports 31 | from . import IS31FL3731 32 | 33 | 34 | class Keybow2040(IS31FL3731): 35 | """Supports the Pimoroni Keybow 2040 with 4x4 matrix of RGB LEDs""" 36 | 37 | width = 16 38 | height = 3 39 | 40 | def pixelrgb( # noqa: PLR0913 Too many arguments in function definition 41 | self, x, y, r, g, b, blink=None, frame=None 42 | ): 43 | """ 44 | Blink or brightness for x, y-pixel 45 | 46 | :param x: horizontal pixel position 47 | :param y: vertical pixel position 48 | :param r: red brightness value 0->255 49 | :param g: green brightness value 0->255 50 | :param b: blue brightness value 0->255 51 | :param blink: True to blink 52 | :param frame: the frame to set the pixel 53 | """ 54 | x = (4 * (3 - x)) + y 55 | 56 | super().pixel(x, 0, r, blink, frame) 57 | super().pixel(x, 1, g, blink, frame) 58 | super().pixel(x, 2, b, blink, frame) 59 | 60 | @staticmethod 61 | def pixel_addr(x, y): 62 | lookup = [ 63 | (120, 88, 104), # 0, 0 64 | (136, 40, 72), # 1, 0 65 | (112, 80, 96), # 2, 0 66 | (128, 32, 64), # 3, 0 67 | (121, 89, 105), # 0, 1 68 | (137, 41, 73), # 1, 1 69 | (113, 81, 97), # 2, 1 70 | (129, 33, 65), # 3, 1 71 | (122, 90, 106), # 0, 2 72 | (138, 25, 74), # 1, 2 73 | (114, 82, 98), # 2, 2 74 | (130, 17, 66), # 3, 2 75 | (123, 91, 107), # 0, 3 76 | (139, 26, 75), # 1, 3 77 | (115, 83, 99), # 2, 3 78 | (131, 18, 67), # 3, 3 79 | ] 80 | 81 | return lookup[x][y] 82 | -------------------------------------------------------------------------------- /adafruit_is31fl3731/led_shim.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | """ 6 | `adafruit_is31fl3731.led_shim` 7 | ==================================================== 8 | 9 | CircuitPython driver for the IS31FL3731 charlieplex IC. 10 | 11 | 12 | * Author: David Glaude 13 | 14 | Implementation Notes 15 | -------------------- 16 | 17 | **Hardware:** 18 | 19 | * `Pimoroni 28 RGB Led Shim 20 | `_ 21 | 22 | **Software and Dependencies:** 23 | 24 | * Adafruit CircuitPython firmware for the supported boards: 25 | https://github.com/adafruit/circuitpython/releases 26 | 27 | """ 28 | 29 | # imports 30 | from . import IS31FL3731 31 | 32 | 33 | class LedShim(IS31FL3731): 34 | """Supports the LED SHIM by Pimoroni""" 35 | 36 | width = 28 37 | height = 3 38 | 39 | def __init__(self, i2c, address=0x75): 40 | super().__init__(i2c, address) 41 | 42 | def pixelrgb( # noqa: PLR0913 Too many arguments in function definition 43 | self, x, r, g, b, blink=None, frame=None 44 | ): 45 | """ 46 | Blink or brightness for x-pixel 47 | 48 | :param x: horizontal pixel position 49 | :param r: red brightness value 0->255 50 | :param g: green brightness value 0->255 51 | :param b: blue brightness value 0->255 52 | :param blink: True to blink 53 | :param frame: the frame to set the pixel 54 | """ 55 | super().pixel(x, 0, r, blink, frame) 56 | super().pixel(x, 1, g, blink, frame) 57 | super().pixel(x, 2, b, blink, frame) 58 | 59 | @staticmethod 60 | def pixel_addr(x, y): # noqa: PLR0911, PLR0912, Too many return statements, Too many branches 61 | """Translate an x,y coordinate to a pixel index.""" 62 | if y == 0: 63 | if x < 7: 64 | return 118 - x 65 | if x < 15: 66 | return 141 - x 67 | if x < 21: 68 | return 106 + x 69 | if x == 21: 70 | return 15 71 | return x - 14 72 | 73 | if y == 1: 74 | if x < 2: 75 | return 69 - x 76 | if x < 7: 77 | return 86 - x 78 | if x < 12: 79 | return 28 - x 80 | if x < 14: 81 | return 45 - x 82 | if x == 14: 83 | return 47 84 | if x == 15: 85 | return 41 86 | if x < 21: 87 | return x + 9 88 | if x == 21: 89 | return 95 90 | if x < 26: 91 | return x + 67 92 | return x + 50 93 | 94 | if x == 0: 95 | return 85 96 | if x < 7: 97 | return 102 - x 98 | if x < 11: 99 | return 44 - x 100 | if x < 14: 101 | return 61 - x 102 | if x == 14: 103 | return 63 104 | if x < 17: 105 | return 42 + x 106 | if x < 21: 107 | return x + 25 108 | if x == 21: 109 | return 111 110 | if x < 27: 111 | return x + 83 112 | return 93 113 | -------------------------------------------------------------------------------- /adafruit_is31fl3731/matrix.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | """ 6 | `adafruit_is31fl3731.matrix` 7 | ==================================================== 8 | 9 | CircuitPython driver for the IS31FL3731 charlieplex IC. 10 | 11 | 12 | * Author(s): Tony DiCola, Melissa LeBlanc-Williams 13 | 14 | Implementation Notes 15 | -------------------- 16 | 17 | **Hardware:** 18 | 19 | * `Adafruit 16x9 Charlieplexed PWM LED Matrix Driver - IS31FL3731 20 | `_ 21 | 22 | **Software and Dependencies:** 23 | 24 | * Adafruit CircuitPython firmware for the supported boards: 25 | https://github.com/adafruit/circuitpython/releases 26 | 27 | """ 28 | 29 | # imports 30 | from . import IS31FL3731 31 | 32 | try: 33 | from typing import Optional 34 | 35 | try: 36 | from PIL import Image 37 | except ImportError: 38 | # placeholder if PIL unavailable 39 | Image = None 40 | except ImportError: 41 | pass 42 | 43 | 44 | class Matrix(IS31FL3731): 45 | """Charlieplexed Featherwing & IS31FL3731 I2C Modules""" 46 | 47 | width: int = 16 48 | height: int = 9 49 | 50 | @staticmethod 51 | def pixel_addr(x: int, y: int) -> int: 52 | """Calulate the offset into the device array for x,y pixel""" 53 | return x + y * 16 54 | 55 | # This takes precedence over image() in __init__ and is tuned for the 56 | # Matrix class. Some shortcuts can be taken because matrix layout is 57 | # very straightforward, and a few large write operations are used 58 | # rather than pixel-by-pixel writes, yielding significant speed gains 59 | # for animation. Buffering the full matrix for a quick write is not a 60 | # memory concern here, as by definition this method is used with PIL 61 | # images; we're not running on a RAM-constrained microcontroller. 62 | def image(self, img: Image, frame: Optional[int] = None, blink: bool = False): 63 | """Set buffer to value of Python Imaging Library image. 64 | The image should be in 8-bit mode (L) and a size equal to the 65 | display size. 66 | 67 | :param img: Python Imaging Library image 68 | :param blink: True to blink 69 | :param frame: the frame to set the image 70 | """ 71 | if img.mode != "L": 72 | raise ValueError("Image must be in mode L.") 73 | if img.size[0] != self.width or img.size[1] != self.height: 74 | raise ValueError(f"Image must be same dimensions as display {self.width}x{self.height}") 75 | 76 | # Frame-select and then write pixel data in one big operation 77 | if frame is not None: 78 | self._bank(frame) 79 | # We can safely reduce the image to a "flat" byte sequence because 80 | # the matrix layout is known linear; no need to go through a 2D 81 | # pixel array or invoke pixel_addr(). 82 | self._i2c_write_block(bytes([0x24]) + img.tobytes()) 83 | # Set or clear blink state if requested, for all pixels at once 84 | if blink: 85 | # 0x12 is _BLINK_OFFSET in __init__.py 86 | self._i2c_write_block(bytes([0x12] + [1 if blink else 0] * 18)) 87 | -------------------------------------------------------------------------------- /adafruit_is31fl3731/matrix_11x7.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | """ 6 | `adafruit_is31fl3731.charlie_bonnet` 7 | ==================================================== 8 | 9 | CircuitPython driver for the IS31FL3731 charlieplex IC. 10 | 11 | 12 | * Author(s): Tony DiCola, Melissa LeBlanc-Williams 13 | 14 | Implementation Notes 15 | -------------------- 16 | 17 | **Hardware:** 18 | 19 | * `Pimoroni 11x7 LED Matrix Breakout `_ 20 | 21 | 22 | **Software and Dependencies:** 23 | 24 | * Adafruit CircuitPython firmware for the supported boards: 25 | https://github.com/adafruit/circuitpython/releases 26 | 27 | """ 28 | 29 | # imports 30 | from . import IS31FL3731 31 | 32 | 33 | class Matrix11x7(IS31FL3731): 34 | """Supports the 11x7 LED Matrix Breakout by Pimoroni""" 35 | 36 | width = 11 37 | height = 7 38 | 39 | def __init__(self, i2c, address=0x75): 40 | super().__init__(i2c, address) 41 | 42 | @staticmethod 43 | def pixel_addr(x, y): 44 | """Translate an x,y coordinate to a pixel index.""" 45 | return (x << 4) - y + (6 if x <= 5 else -82) 46 | -------------------------------------------------------------------------------- /adafruit_is31fl3731/rgbmatrix5x5.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries 2 | # SPDX-FileCopyrightText: Melissa LeBlanc-Williams 2021 for Adafruit Industries 3 | # SPDX-FileCopyrightText: David Glaude 2021 4 | # SPDX-FileCopyrightText: James Carr 2021 5 | 6 | # 7 | # SPDX-License-Identifier: MIT 8 | 9 | """ 10 | `adafruit_is31fl3731.rgbmatrix5x5` 11 | ==================================================== 12 | 13 | CircuitPython driver for the IS31FL3731 charlieplex IC. 14 | 15 | 16 | * Author(s): Tony DiCola, Melissa LeBlanc-Williams, David Glaude, James Carr 17 | 18 | Implementation Notes 19 | -------------------- 20 | 21 | **Hardware:** 22 | 23 | * `5x5 RGB Matrix Breakout 24 | `_ 25 | 26 | 27 | **Software and Dependencies:** 28 | 29 | * Adafruit CircuitPython firmware for the supported boards: 30 | https://github.com/adafruit/circuitpython/releases 31 | 32 | """ 33 | 34 | # imports 35 | from . import IS31FL3731 36 | 37 | 38 | class RGBmatrix5x5(IS31FL3731): 39 | """Supports the Pimoroni RGBmatrix5x5 with 5x5 matrix of RGB LEDs""" 40 | 41 | width = 25 42 | height = 3 43 | 44 | def pixelrgb( # noqa: PLR0913 Too many arguments in function definition 45 | self, x, y, r, g, b, blink=None, frame=None 46 | ): 47 | """ 48 | Blink or brightness for x, y-pixel 49 | 50 | :param x: horizontal pixel position 51 | :param y: vertical pixel position 52 | :param r: red brightness value 0->255 53 | :param g: green brightness value 0->255 54 | :param b: blue brightness value 0->255 55 | :param blink: True to blink 56 | :param frame: the frame to set the pixel 57 | """ 58 | x += y * 5 59 | 60 | super().pixel(x, 0, r, blink, frame) 61 | super().pixel(x, 1, g, blink, frame) 62 | super().pixel(x, 2, b, blink, frame) 63 | 64 | @staticmethod 65 | def pixel_addr(x, y): 66 | lookup = [ 67 | (118, 69, 85), 68 | (117, 68, 101), 69 | (116, 84, 100), 70 | (115, 83, 99), 71 | (114, 82, 98), 72 | (132, 19, 35), 73 | (133, 20, 36), 74 | (134, 21, 37), 75 | (112, 80, 96), 76 | (113, 81, 97), 77 | (131, 18, 34), 78 | (130, 17, 50), 79 | (129, 33, 49), 80 | (128, 32, 48), 81 | (127, 47, 63), 82 | (125, 28, 44), 83 | (124, 27, 43), 84 | (123, 26, 42), 85 | (122, 25, 58), 86 | (121, 41, 57), 87 | (126, 29, 45), 88 | (15, 95, 111), 89 | (8, 89, 105), 90 | (9, 90, 106), 91 | (10, 91, 107), 92 | ] 93 | 94 | return lookup[x][y] 95 | -------------------------------------------------------------------------------- /adafruit_is31fl3731/scroll_phat_hd.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Tony DiCola 2017 for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | """ 6 | `adafruit_is31fl3731.scroll_phat_hd` 7 | ==================================================== 8 | 9 | CircuitPython driver for the Pimoroni 17x7 Scroll pHAT HD. 10 | 11 | 12 | * Author: David Glaude 13 | 14 | Implementation Notes 15 | -------------------- 16 | 17 | **Hardware:** 18 | 19 | * `Pimoroni 17x7 Scroll pHAT HD 20 | `_ 21 | 22 | **Software and Dependencies:** 23 | 24 | * Adafruit CircuitPython firmware for the supported boards: 25 | https://github.com/adafruit/circuitpython/releases 26 | 27 | """ 28 | 29 | # imports 30 | from . import IS31FL3731 31 | 32 | 33 | class ScrollPhatHD(IS31FL3731): 34 | """Supports the Scroll pHAT HD by Pimoroni""" 35 | 36 | width = 17 37 | height = 7 38 | 39 | @staticmethod 40 | def pixel_addr(x, y): 41 | """Translate an x,y coordinate to a pixel index.""" 42 | if x <= 8: 43 | x = 8 - x 44 | y = 6 - y 45 | else: 46 | x = x - 8 47 | y = y - 8 48 | return x * 16 + y 49 | -------------------------------------------------------------------------------- /docs/_static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_IS31FL3731/0cd04eb83ed210b9f565c204f3cff685781702f5/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 | .. automodule:: adafruit_is31fl3731 5 | :members: 6 | 7 | .. automodule:: adafruit_is31fl3731.charlie_bonnet 8 | :members: 9 | 10 | .. automodule:: adafruit_is31fl3731.charlie_wing 11 | :members: 12 | 13 | .. automodule:: adafruit_is31fl3731.keybow2040 14 | :members: 15 | 16 | .. automodule:: adafruit_is31fl3731.led_shim 17 | :members: 18 | 19 | .. automodule:: adafruit_is31fl3731.matrix 20 | :members: 21 | 22 | .. automodule:: adafruit_is31fl3731.matrix_11x7 23 | :members: 24 | 25 | .. automodule:: adafruit_is31fl3731.rgbmatrix5x5 26 | :members: 27 | 28 | .. automodule:: adafruit_is31fl3731.scroll_phat_hd 29 | :members: 30 | -------------------------------------------------------------------------------- /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.viewcode", 21 | ] 22 | 23 | # Uncomment the below if you use native CircuitPython modules such as 24 | # digitalio, micropython and busio. List the modules you use. Without it, the 25 | # autodoc module docs will fail to generate with a warning. 26 | # autodoc_mock_imports = ["micropython"] 27 | 28 | intersphinx_mapping = { 29 | "python": ("https://docs.python.org/3", None), 30 | "BusDevice": ( 31 | "https://docs.circuitpython.org/projects/busdevice/en/latest/", 32 | None, 33 | ), 34 | "CircuitPython": ("https://docs.circuitpython.org/en/latest/", None), 35 | } 36 | 37 | # Add any paths that contain templates here, relative to this directory. 38 | templates_path = ["_templates"] 39 | 40 | source_suffix = ".rst" 41 | 42 | # The master toctree document. 43 | master_doc = "index" 44 | 45 | # General information about the project. 46 | project = "Adafruit IS31FL3731 Library" 47 | creation_year = "2017" 48 | current_year = str(datetime.datetime.now().year) 49 | year_duration = ( 50 | current_year if current_year == creation_year else creation_year + " - " + current_year 51 | ) 52 | copyright = year_duration + " Radomir Dopieralski" 53 | author = "Radomir Dopieralski" 54 | 55 | # The version info for the project you're documenting, acts as replacement for 56 | # |version| and |release|, also used in various other places throughout the 57 | # built documents. 58 | # 59 | # The short X.Y version. 60 | version = "1.0" 61 | # The full version, including alpha/beta/rc tags. 62 | release = "1.0" 63 | 64 | # The language for content autogenerated by Sphinx. Refer to documentation 65 | # for a list of supported languages. 66 | # 67 | # This is also used if you do content translation via gettext catalogs. 68 | # Usually you set "language" from the command line for these cases. 69 | language = "en" 70 | 71 | # List of patterns, relative to source directory, that match files and 72 | # directories to ignore when looking for source files. 73 | # This patterns also effect to html_static_path and html_extra_path 74 | exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"] 75 | 76 | # The reST default role (used for this markup: `text`) to use for all 77 | # documents. 78 | # 79 | default_role = "any" 80 | 81 | # If true, '()' will be appended to :func: etc. cross-reference text. 82 | # 83 | add_function_parentheses = True 84 | 85 | # The name of the Pygments (syntax highlighting) style to use. 86 | pygments_style = "sphinx" 87 | 88 | # If true, `todo` and `todoList` produce output, else they produce nothing. 89 | todo_include_todos = False 90 | 91 | # If this is True, todo emits a warning for each TODO entries. The default is False. 92 | todo_emit_warnings = True 93 | 94 | 95 | # -- Options for HTML output ---------------------------------------------- 96 | 97 | # The theme to use for HTML and HTML Help pages. See the documentation for 98 | # a list of builtin themes. 99 | # 100 | import sphinx_rtd_theme 101 | 102 | html_theme = "sphinx_rtd_theme" 103 | 104 | # Add any paths that contain custom static files (such as style sheets) here, 105 | # relative to this directory. They are copied after the builtin static files, 106 | # so a file named "default.css" will overwrite the builtin "default.css". 107 | html_static_path = ["_static"] 108 | 109 | # The name of an image file (relative to this directory) to use as a favicon of 110 | # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 111 | # pixels large. 112 | # 113 | html_favicon = "_static/favicon.ico" 114 | 115 | # Output file base name for HTML help builder. 116 | htmlhelp_basename = "AdafruitIS31FL3731Librarydoc" 117 | 118 | # -- Options for LaTeX output --------------------------------------------- 119 | 120 | latex_elements = { 121 | # The paper size ('letterpaper' or 'a4paper'). 122 | # 123 | # 'papersize': 'letterpaper', 124 | # The font size ('10pt', '11pt' or '12pt'). 125 | # 126 | # 'pointsize': '10pt', 127 | # Additional stuff for the LaTeX preamble. 128 | # 129 | # 'preamble': '', 130 | # Latex figure (float) alignment 131 | # 132 | # 'figure_align': 'htbp', 133 | } 134 | 135 | # Grouping the document tree into LaTeX files. List of tuples 136 | # (source start file, target name, title, 137 | # author, documentclass [howto, manual, or own class]). 138 | latex_documents = [ 139 | ( 140 | master_doc, 141 | "AdafruitIS31FL3731Library.tex", 142 | "Adafruit IS31FL3731 Library Documentation", 143 | author, 144 | "manual", 145 | ), 146 | ] 147 | 148 | # -- Options for manual page output --------------------------------------- 149 | 150 | # One entry per manual page. List of tuples 151 | # (source start file, name, description, authors, manual section). 152 | man_pages = [ 153 | ( 154 | master_doc, 155 | "adafruitIS31FL3731library", 156 | "Adafruit IS31FL3731 Library Documentation", 157 | [author], 158 | 1, 159 | ) 160 | ] 161 | 162 | # -- Options for Texinfo output ------------------------------------------- 163 | 164 | # Grouping the document tree into Texinfo files. List of tuples 165 | # (source start file, target name, title, author, 166 | # dir menu entry, description, category) 167 | texinfo_documents = [ 168 | ( 169 | master_doc, 170 | "AdafruitIS31FL3731Library", 171 | "Adafruit IS31FL3731 Library Documentation", 172 | author, 173 | "AdafruitIS31FL3731Library", 174 | "One line description of project.", 175 | "Miscellaneous", 176 | ), 177 | ] 178 | -------------------------------------------------------------------------------- /docs/examples.rst: -------------------------------------------------------------------------------- 1 | Simple test 2 | ------------ 3 | 4 | Ensure your device works with this simple test. 5 | 6 | .. literalinclude:: ../examples/is31fl3731_simpletest.py 7 | :caption: examples/is31fl3731_simpletest.py 8 | :linenos: 9 | 10 | Matrix Examples 11 | --------------- 12 | 13 | Other examples working on matrix display. 14 | 15 | .. literalinclude:: ../examples/is31fl3731_blink_example.py 16 | :caption: examples/is31fl3731_blink_example.py 17 | :linenos: 18 | 19 | .. literalinclude:: ../examples/is31fl3731_frame_example.py 20 | :caption: examples/is31fl3731_frame_example.py 21 | :linenos: 22 | 23 | .. literalinclude:: ../examples/is31fl3731_text_example.py 24 | :caption: examples/is31fl3731_text_example.py 25 | :linenos: 26 | 27 | .. literalinclude:: ../examples/is31fl3731_wave_example.py 28 | :caption: examples/is31fl3731_wave_example.py 29 | :linenos: 30 | 31 | Pillow Examples 32 | --------------- 33 | 34 | Examples that utilize the Python Imaging Library (Pillow) for use on (Linux) 35 | computers that are using CPython with Adafruit Blinka to support CircuitPython 36 | libraries. CircuitPython does not support PIL/pillow (python imaging library)! 37 | 38 | .. literalinclude:: ../examples/is31fl3731_pillow_animated_gif.py 39 | :caption: examples/is31fl3731_pillow_animated_gif.py 40 | :linenos: 41 | 42 | .. literalinclude:: ../examples/is31fl3731_pillow_marquee.py 43 | :caption: examples/is31fl3731_pillow_marquee.py 44 | :linenos: 45 | 46 | .. literalinclude:: ../examples/is31fl3731_pillow_numbers.py 47 | :caption: examples/is31fl3731_pillow_numbers.py 48 | :linenos: 49 | 50 | Colorful Examples 51 | ----------------- 52 | 53 | Example that works on the RGB Led Shim. 54 | 55 | .. literalinclude:: ../examples/is31fl3731_ledshim_rainbow.py 56 | :caption: examples/is31fl3731_ledshim_rainbow.py 57 | :linenos: 58 | 59 | Example that works on the RGB Matrix 5x5. 60 | 61 | .. literalinclude:: ../examples/is31fl3731_rgbmatrix5x5_rainbow.py 62 | :caption: examples/is31fl3731_rgbmatrix5x5_rainbow.py 63 | :linenos: 64 | -------------------------------------------------------------------------------- /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 | .. toctree:: 27 | :caption: Related Products 28 | 29 | Charlieplex Devices 30 | 31 | .. toctree:: 32 | :caption: Other Links 33 | 34 | Download from GitHub 35 | Download Library Bundle 36 | CircuitPython Reference Documentation 37 | CircuitPython Support Forum 38 | Discord Chat 39 | Adafruit Learning System 40 | Adafruit Blog 41 | Adafruit Store 42 | 43 | Indices and tables 44 | ================== 45 | 46 | * :ref:`genindex` 47 | * :ref:`modindex` 48 | * :ref:`search` 49 | -------------------------------------------------------------------------------- /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/is31fl3731_16x9_charlieplexed_pwm.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2024 DJDevon3 2 | # SPDX-License-Identifier: MIT 3 | """Adafruit 16x9 Charlieplexed PWM LED Matrix Example""" 4 | 5 | import adafruit_framebuf 6 | import board 7 | 8 | from adafruit_is31fl3731.matrix import Matrix as Display 9 | 10 | # Uncomment for Pi Pico 11 | # import busio 12 | # i2c = busio.I2C(board.GP21, board.GP20) 13 | 14 | i2c = board.STEMMA_I2C() 15 | display = Display(i2c, address=0x74) 16 | 17 | PIXEL_ROTATION = 0 # display rotation (0,90,180,270) 18 | PIXEL_BRIGHTNESS = 20 # values (0-255) 19 | PIXEL_BLINK = False # blink entire display 20 | 21 | TEXT = "Hello World!" # Scrolling marquee text 22 | 23 | print(f"Display Dimensions: {display.width}x{display.height}") 24 | print(f"Text: {TEXT}") 25 | 26 | # Create a framebuffer for our display 27 | buf = bytearray(32) # 2 bytes tall x 16 wide = 32 bytes (9 bits is 2 bytes) 28 | buffer = adafruit_framebuf.FrameBuffer(buf, display.width, display.height, adafruit_framebuf.MVLSB) 29 | 30 | FRAME = 0 # start with frame 0 31 | while True: 32 | # Looping marquee 33 | for i in range(len(TEXT) * 9): 34 | buffer.fill(0) 35 | buffer.text(TEXT, -i + display.width, 0, color=1) 36 | display.frame(FRAME, show=False) 37 | display.fill(0) 38 | for x in range(display.width): 39 | # using the FrameBuffer text result 40 | bite = buf[x] 41 | for y in range(display.height): 42 | bit = 1 << y & bite 43 | # if bit > 0 then set the pixel brightness 44 | if bit: 45 | display.pixel(x, y, PIXEL_BRIGHTNESS, blink=PIXEL_BLINK, rotate=PIXEL_ROTATION) 46 | -------------------------------------------------------------------------------- /examples/is31fl3731_blink_example.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | import board 5 | import busio 6 | 7 | # uncomment next line if you are using Feather CharlieWing LED 15 x 7 8 | from adafruit_is31fl3731.charlie_wing import CharlieWing as Display 9 | 10 | # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix 11 | # from adafruit_is31fl3731.matrix import Matrix as Display 12 | # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet 13 | # from adafruit_is31fl3731.charlie_bonnet import CharlieBonnet as Display 14 | # uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 15 | # from adafruit_is31fl3731.scroll_phat_hd import ScrollPhatHD as Display 16 | # uncomment next line if you are using Pimoroni 11x7 LED Matrix Breakout 17 | # from adafruit_is31fl3731.matrix_11x7 import Matrix11x7 as Display 18 | 19 | # uncomment this line if you use a Pico, here with SCL=GP21 and SDA=GP20. 20 | # i2c = busio.I2C(board.GP21, board.GP20) 21 | 22 | i2c = busio.I2C(board.SCL, board.SDA) 23 | 24 | # array pattern in bits; top row-> bottom row, 8 bits in each row 25 | an_arrow = bytearray((0x08, 0x0C, 0xFE, 0xFF, 0xFE, 0x0C, 0x08, 0x00, 0x00)) 26 | 27 | display = Display(i2c) 28 | 29 | offset = (display.width - 8) // 2 30 | 31 | # first load the frame with the arrows; moves the an_arrow to the right in each 32 | # frame 33 | display.sleep(True) # turn display off while updating blink bits 34 | display.fill(0) 35 | for y in range(display.height): 36 | row = an_arrow[y] 37 | for x in range(8): 38 | bit = 1 << (7 - x) & row 39 | if bit: 40 | display.pixel(x + offset, y, 50, blink=True) 41 | 42 | display.blink(1000) # ranges from 270 to 2159; smaller the number to faster blink 43 | display.sleep(False) # turn display on 44 | -------------------------------------------------------------------------------- /examples/is31fl3731_frame_example.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | import time 5 | 6 | import board 7 | import busio 8 | 9 | # uncomment next line if you are using Feather CharlieWing LED 15 x 7 10 | from adafruit_is31fl3731.charlie_wing import CharlieWing as Display 11 | 12 | # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix 13 | # from adafruit_is31fl3731.matrix import Matrix as Display 14 | # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet 15 | # from adafruit_is31fl3731.charlie_bonnet import CharlieBonnet as Display 16 | # uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 17 | # from adafruit_is31fl3731.scroll_phat_hd import ScrollPhatHD as Display 18 | # uncomment next line if you are using Pimoroni 11x7 LED Matrix Breakout 19 | # from adafruit_is31fl3731.matrix_11x7 import Matrix11x7 as Display 20 | 21 | # uncomment this line if you use a Pico, here with SCL=GP21 and SDA=GP20. 22 | # i2c = busio.I2C(board.GP21, board.GP20) 23 | 24 | i2c = busio.I2C(board.SCL, board.SDA) 25 | 26 | # arrow pattern in bits; top row-> bottom row, 8 bits in each row 27 | arrow = bytearray((0x08, 0x0C, 0xFE, 0xFF, 0xFE, 0x0C, 0x08, 0x00, 0x00)) 28 | 29 | display = Display(i2c) 30 | 31 | # first load the frame with the arrows; moves the arrow to the right in each 32 | # frame 33 | display.sleep(True) # turn display off while frames are updated 34 | for frame in range(display.width - 8): 35 | display.frame(frame, show=False) 36 | display.fill(0) 37 | for y in range(display.height): 38 | row = arrow[y] 39 | for x in range(8): 40 | bit = 1 << (7 - x) & row 41 | # display the pixel into selected frame with varying intensity 42 | if bit: 43 | display.pixel(x + frame, y, frame**2 + 1) 44 | display.sleep(False) 45 | # now tell the display to show the frame one at time 46 | while True: 47 | for frame in range(8): 48 | display.frame(frame) 49 | time.sleep(0.1) 50 | -------------------------------------------------------------------------------- /examples/is31fl3731_keybow_2040_rainbow.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Sandy Macdonald 2 | # SPDX-License-Identifier: MIT 3 | 4 | """ 5 | Example to display a rainbow animation on the RGB LED keys of the 6 | Keybow 2040. 7 | 8 | Usage: 9 | Rename this file code.py and pop it on your Keybow 2040's 10 | CIRCUITPY drive. 11 | 12 | This example is for use on the Keybow 2040 only, due to the way 13 | that the LEDs are mapped out. 14 | 15 | Author(s): Sandy Macdonald. 16 | """ 17 | 18 | import math 19 | import time 20 | 21 | import board 22 | 23 | from adafruit_is31fl3731.keybow2040 import Keybow2040 as Display 24 | 25 | 26 | def hsv_to_rgb( # noqa: PLR0911 Too many return statements 27 | hue, sat, val 28 | ): 29 | """ 30 | Convert HSV colour to RGB 31 | 32 | :param hue: hue; 0.0-1.0 33 | :param sat: saturation; 0.0-1.0 34 | :param val: value; 0.0-1.0 35 | """ 36 | 37 | if sat == 0.0: 38 | return (val, val, val) 39 | 40 | i = int(hue * 6.0) 41 | 42 | p = val * (1.0 - sat) 43 | f = (hue * 6.0) - i 44 | q = val * (1.0 - sat * f) 45 | t = val * (1.0 - sat * (1.0 - f)) 46 | 47 | i %= 6 48 | 49 | if i == 0: 50 | return (val, t, p) 51 | if i == 1: 52 | return (q, val, p) 53 | if i == 2: 54 | return (p, val, t) 55 | if i == 3: 56 | return (p, q, val) 57 | if i == 4: 58 | return (t, p, val) 59 | if i == 5: 60 | return (val, p, q) 61 | 62 | 63 | i2c = board.I2C() # uses board.SCL and board.SDA 64 | # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller 65 | 66 | # Set up 4x4 RGB matrix of Keybow 2040 67 | display = Display(i2c) 68 | 69 | step = 0 70 | 71 | while True: 72 | step += 1 73 | for y in range(0, 4): 74 | for x in range(0, 4): 75 | pixel_hue = (x + y + (step / 20)) / 8 76 | pixel_hue = pixel_hue - int(pixel_hue) 77 | pixel_hue += 0 78 | pixel_hue = pixel_hue - math.floor(pixel_hue) 79 | 80 | rgb = hsv_to_rgb(pixel_hue, 1, 1) 81 | 82 | display.pixelrgb(x, y, int(rgb[0] * 255), int(rgb[1] * 255), int(rgb[2] * 255)) 83 | 84 | time.sleep(0.01) 85 | -------------------------------------------------------------------------------- /examples/is31fl3731_ledshim_fade.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 E. A. Graham, Jr. 2 | # SPDX-License-Identifier: MIT 3 | 4 | import time 5 | 6 | import board 7 | import busio 8 | 9 | from adafruit_is31fl3731.led_shim import LedShim as Display 10 | 11 | i2c = busio.I2C(board.SCL, board.SDA) 12 | 13 | # initial display if you are using Pimoroni LED SHIM 14 | display = Display(i2c) 15 | 16 | y = 1 17 | for x in range(28): 18 | display.pixel(x, y, 255) 19 | 20 | display.fade(fade_in=104, pause=250) 21 | 22 | try: 23 | while True: 24 | time.sleep(10) 25 | except KeyboardInterrupt: 26 | display.sleep(True) 27 | -------------------------------------------------------------------------------- /examples/is31fl3731_ledshim_rainbow.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | import time 5 | 6 | import board 7 | import busio 8 | 9 | from adafruit_is31fl3731.led_shim import LedShim as Display 10 | 11 | i2c = busio.I2C(board.SCL, board.SDA) 12 | 13 | # initial display if you are using Pimoroni LED SHIM 14 | display = Display(i2c) 15 | 16 | # fmt: off 17 | # This list 28 colors from a rainbow... 18 | rainbow = [ 19 | (255, 0, 0), (255, 54, 0), (255, 109, 0), (255, 163, 0), 20 | (255, 218, 0), (236, 255, 0), (182, 255, 0), (127, 255, 0), 21 | (72, 255, 0), (18, 255, 0), (0, 255, 36), (0, 255, 91), 22 | (0, 255, 145), (0, 255, 200), (0, 255, 255), (0, 200, 255), 23 | (0, 145, 255), (0, 91, 255), (0, 36, 255), (18, 0, 255), 24 | (72, 0, 255), (127, 0, 255), (182, 0, 255), (236, 0, 255), 25 | (255, 0, 218), (255, 0, 163), (255, 0, 109), (255, 0, 54), 26 | ] 27 | # fmt: on 28 | 29 | 30 | for y in range(3): 31 | for x in range(28): 32 | display.pixel(x, y, 255) 33 | time.sleep(0.1) 34 | display.pixel(x, y, 0) 35 | 36 | while True: 37 | for offset in range(28): 38 | for x in range(28): 39 | r, g, b = rainbow[(x + offset) % 28] 40 | display.pixelrgb(x, r, g, b) 41 | -------------------------------------------------------------------------------- /examples/is31fl3731_pillow_animated_gif.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | """ 5 | Example to extract the frames and other parameters from an animated gif 6 | and then run the animation on the display. 7 | 8 | Usage: 9 | python3 is31fl3731_pillow_animated_gif.py animated.gif 10 | 11 | This example is for use on (Linux) computers that are using CPython with 12 | Adafruit Blinka to support CircuitPython libraries. CircuitPython does 13 | not support PIL/pillow (python imaging library)! 14 | 15 | Author(s): Melissa LeBlanc-Williams for Adafruit Industries 16 | """ 17 | 18 | import sys 19 | 20 | import board 21 | from PIL import Image 22 | 23 | # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix 24 | # from adafruit_is31fl3731.matrix import Matrix as Display 25 | # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet 26 | from adafruit_is31fl3731.charlie_bonnet import CharlieBonnet as Display 27 | 28 | # uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 29 | # from adafruit_is31fl3731.scroll_phat_hd import ScrollPhatHD as Display 30 | 31 | i2c = board.I2C() # uses board.SCL and board.SDA 32 | # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller 33 | 34 | display = Display(i2c) 35 | 36 | 37 | # Open the gif 38 | if len(sys.argv) < 2: 39 | print("No image file specified") 40 | print("Usage: python3 is31fl3731_pillow_animated_gif.py animated.gif") 41 | sys.exit() 42 | 43 | image = Image.open(sys.argv[1]) 44 | 45 | # Make sure it's animated 46 | if not image.is_animated: 47 | print("Specified image is not animated") 48 | sys.exit() 49 | 50 | # Get the autoplay information from the gif 51 | delay = image.info["duration"] 52 | 53 | # Figure out the correct loop count 54 | if "loop" in image.info: 55 | loops = image.info["loop"] 56 | if loops > 0: 57 | loops += 1 58 | else: 59 | loops = 1 60 | 61 | # IS31FL3731 only supports 0-7 62 | loops = min(loops, 7) 63 | 64 | # Get the frame count (maximum 8 frames) 65 | frame_count = min(image.n_frames, 8) 66 | 67 | # Load each frame of the gif onto the Matrix 68 | for frame in range(frame_count): 69 | image.seek(frame) 70 | frame_image = Image.new("L", (display.width, display.height)) 71 | frame_image.paste( 72 | image.convert("L"), 73 | ( 74 | display.width // 2 - image.width // 2, 75 | display.height // 2 - image.height // 2, 76 | ), 77 | ) 78 | display.image(frame_image, frame=frame) 79 | 80 | display.autoplay(delay=delay, loops=loops) 81 | -------------------------------------------------------------------------------- /examples/is31fl3731_pillow_marquee.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | """ 5 | Example to scroll some text as a marquee 6 | 7 | This example is for use on (Linux) computers that are using CPython with 8 | Adafruit Blinka to support CircuitPython libraries. CircuitPython does 9 | not support PIL/pillow (python imaging library)! 10 | 11 | Author(s): Melissa LeBlanc-Williams for Adafruit Industries 12 | """ 13 | 14 | import board 15 | from PIL import Image, ImageDraw, ImageFont 16 | 17 | # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix 18 | # from adafruit_is31fl3731.matrix import Matrix as Display 19 | # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet 20 | from adafruit_is31fl3731.charlie_bonnet import CharlieBonnet as Display 21 | 22 | # uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 23 | # from adafruit_is31fl3731.scroll_phat_hd import ScrollPhatHD as Display 24 | 25 | SCROLLING_TEXT = "You can display a personal message here..." 26 | BRIGHTNESS = 64 # Brightness can be between 0-255 27 | 28 | i2c = board.I2C() # uses board.SCL and board.SDA 29 | # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller 30 | 31 | display = Display(i2c) 32 | 33 | # Load a font 34 | font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 8) 35 | 36 | # Create an image that contains the text 37 | text_width, text_height = font.getsize(SCROLLING_TEXT) 38 | text_image = Image.new("L", (text_width, text_height)) 39 | text_draw = ImageDraw.Draw(text_image) 40 | text_draw.text((0, 0), SCROLLING_TEXT, font=font, fill=BRIGHTNESS) 41 | 42 | # Create an image for the display 43 | image = Image.new("L", (display.width, display.height)) 44 | draw = ImageDraw.Draw(image) 45 | 46 | # Load the text in each frame 47 | while True: 48 | for x in range(text_width + display.width): 49 | draw.rectangle((0, 0, display.width, display.height), outline=0, fill=0) 50 | image.paste(text_image, (display.width - x, display.height // 2 - text_height // 2 - 1)) 51 | display.image(image) 52 | -------------------------------------------------------------------------------- /examples/is31fl3731_pillow_numbers.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | """ 5 | Example to utilize the Python Imaging Library (Pillow) and draw bitmapped text 6 | to 8 frames and then run autoplay on those frames. 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 | Author(s): Melissa LeBlanc-Williams for Adafruit Industries 13 | """ 14 | 15 | import board 16 | from PIL import Image, ImageDraw, ImageFont 17 | 18 | # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix 19 | # from adafruit_is31fl3731.matrix import Matrix as Display 20 | # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet 21 | from adafruit_is31fl3731.charlie_bonnet import CharlieBonnet as Display 22 | 23 | # uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 24 | # from adafruit_is31fl3731.scroll_phat_hd import ScrollPhatHD as Display 25 | 26 | BRIGHTNESS = 32 # Brightness can be between 0-255 27 | 28 | i2c = board.I2C() # uses board.SCL and board.SDA 29 | # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller 30 | 31 | display = Display(i2c) 32 | 33 | display.fill(0) 34 | 35 | # 256 Color Grayscale Mode 36 | image = Image.new("L", (display.width, display.height)) 37 | draw = ImageDraw.Draw(image) 38 | 39 | # Load a font in 2 different sizes. 40 | font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 10) 41 | 42 | # Load the text in each frame 43 | for x in range(8): 44 | draw.rectangle((0, 0, display.width, display.height), outline=0, fill=0) 45 | draw.text((x + 1, -2), str(x + 1), font=font, fill=BRIGHTNESS) 46 | display.image(image, frame=x) 47 | 48 | display.autoplay(delay=500) 49 | -------------------------------------------------------------------------------- /examples/is31fl3731_rgbmatrix5x5_rainbow.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Sandy Macdonald, David Glaude, James Carr 2 | # SPDX-License-Identifier: MIT 3 | 4 | """ 5 | Example to display a rainbow animation on the 5x5 RGB Matrix Breakout. 6 | 7 | Usage: 8 | Rename this file code.py and pop it on your Raspberry Pico's 9 | CIRCUITPY drive. 10 | 11 | This example is for use on the Pico Explorer Base or other board that use the same SDA/SCL pin. 12 | 13 | Author(s): Sandy Macdonald, David Glaude, James Carr 14 | """ 15 | 16 | import math 17 | import time 18 | 19 | import board 20 | import busio 21 | 22 | from adafruit_is31fl3731.rgbmatrix5x5 import RGBmatrix5x5 as Display 23 | 24 | 25 | def hsv_to_rgb( # noqa: PLR0911 Too many return statements 26 | hue, sat, val 27 | ): 28 | """ 29 | Convert HSV colour to RGB 30 | 31 | :param hue: hue; 0.0-1.0 32 | :param sat: saturation; 0.0-1.0 33 | :param val: value; 0.0-1.0 34 | """ 35 | 36 | if sat == 0.0: 37 | return val, val, val 38 | 39 | i = int(hue * 6.0) 40 | 41 | p = val * (1.0 - sat) 42 | f = (hue * 6.0) - i 43 | q = val * (1.0 - sat * f) 44 | t = val * (1.0 - sat * (1.0 - f)) 45 | 46 | i %= 6 47 | 48 | if i == 0: 49 | return val, t, p 50 | if i == 1: 51 | return q, val, p 52 | if i == 2: 53 | return p, val, t 54 | if i == 3: 55 | return p, q, val 56 | if i == 4: 57 | return t, p, val 58 | if i == 5: 59 | return val, p, q 60 | 61 | 62 | # Create the I2C bus on a Pico Explorer Base 63 | i2c = busio.I2C(board.GP5, board.GP4) 64 | 65 | # Set up 5x5 RGB matrix Breakout 66 | display = Display(i2c) 67 | 68 | 69 | def test_pixels(r, g, b): 70 | # Draw each row from left to right, top to bottom 71 | for y in range(0, 5): 72 | for x in range(0, 5): 73 | display.fill(0) # Clear display 74 | display.pixelrgb(x, y, r, g, b) 75 | time.sleep(0.05) 76 | 77 | 78 | def test_rows(r, g, b): 79 | # Draw full rows from top to bottom 80 | for y in range(0, 5): 81 | display.fill(0) # Clear display 82 | for x in range(0, 5): 83 | display.pixelrgb(x, y, r, g, b) 84 | time.sleep(0.2) 85 | 86 | 87 | def test_columns(r, g, b): 88 | # Draw full columns from left to right 89 | for x in range(0, 5): 90 | display.fill(0) # Clear display 91 | for y in range(0, 5): 92 | display.pixelrgb(x, y, r, g, b) 93 | time.sleep(0.2) 94 | 95 | 96 | def test_rainbow_sweep(): 97 | step = 0 98 | 99 | for _ in range(100): 100 | for y in range(0, 5): 101 | for x in range(0, 5): 102 | pixel_hue = (x + y + (step / 20)) / 8 103 | pixel_hue = pixel_hue - int(pixel_hue) 104 | pixel_hue += 0 105 | pixel_hue = pixel_hue - math.floor(pixel_hue) 106 | 107 | rgb = hsv_to_rgb(pixel_hue, 1, 1) 108 | 109 | display.pixelrgb(x, y, int(rgb[0] * 255), int(rgb[1] * 255), int(rgb[2] * 255)) 110 | 111 | time.sleep(0.01) 112 | step += 3 113 | 114 | 115 | while True: 116 | test_pixels(64, 0, 0) # RED 117 | test_pixels(0, 64, 0) # GREEN 118 | test_pixels(0, 0, 64) # BLUE 119 | test_pixels(64, 64, 64) # WHITE 120 | 121 | test_rows(64, 0, 0) # RED 122 | test_rows(0, 64, 0) # GREEN 123 | test_rows(0, 0, 64) # BLUE 124 | test_rows(64, 64, 64) # WHITE 125 | 126 | test_columns(64, 0, 0) # RED 127 | test_columns(0, 64, 0) # GREEN 128 | test_columns(0, 0, 64) # BLUE 129 | test_columns(64, 64, 64) # WHITE 130 | 131 | test_rainbow_sweep() 132 | -------------------------------------------------------------------------------- /examples/is31fl3731_simpletest.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | import board 5 | import busio 6 | 7 | # uncomment next line if you are using Feather CharlieWing LED 15 x 7 8 | from adafruit_is31fl3731.charlie_wing import CharlieWing as Display 9 | 10 | # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix 11 | # from adafruit_is31fl3731.matrix import Matrix as Display 12 | # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet 13 | # from adafruit_is31fl3731.charlie_bonnet import CharlieBonnet as Display 14 | # uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 15 | # from adafruit_is31fl3731.scroll_phat_hd import ScrollPhatHD as Display 16 | # uncomment next line if you are using Pimoroni 11x7 LED Matrix Breakout 17 | # from adafruit_is31fl3731.matrix_11x7 import Matrix11x7 as Display 18 | 19 | # uncomment this line if you use a Pico, here with SCL=GP21 and SDA=GP20. 20 | # i2c = busio.I2C(board.GP21, board.GP20) 21 | 22 | i2c = busio.I2C(board.SCL, board.SDA) 23 | 24 | display = Display(i2c) 25 | 26 | # draw a box on the display 27 | # first draw the top and bottom edges 28 | for x in range(display.width): 29 | display.pixel(x, 0, 50) 30 | display.pixel(x, display.height - 1, 50) 31 | # now draw the left and right edges 32 | for y in range(display.height): 33 | display.pixel(0, y, 50) 34 | display.pixel(display.width - 1, y, 50) 35 | -------------------------------------------------------------------------------- /examples/is31fl3731_text_example.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | import adafruit_framebuf 5 | import board 6 | import busio 7 | 8 | # uncomment next line if you are using Feather CharlieWing LED 15 x 7 9 | # from adafruit_is31fl3731.charlie_wing import CharlieWing as Display 10 | # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix 11 | # from adafruit_is31fl3731.matrix import Matrix as Display 12 | # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet 13 | from adafruit_is31fl3731.charlie_bonnet import CharlieBonnet as Display 14 | 15 | # uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 16 | # from adafruit_is31fl3731.scroll_phat_hd import ScrollPhatHD as Display 17 | # uncomment next line if you are using Pimoroni 11x7 LED Matrix Breakout 18 | # from adafruit_is31fl3731.matrix_11x7 import Matrix11x7 as Display 19 | 20 | # uncomment this line if you use a Pico, here with SCL=GP21 and SDA=GP20. 21 | # i2c = busio.I2C(board.GP21, board.GP20) 22 | 23 | i2c = busio.I2C(board.SCL, board.SDA) 24 | 25 | display = Display(i2c) 26 | 27 | text_to_show = "Adafruit!!" 28 | 29 | # Create a framebuffer for our display 30 | buf = bytearray(32) # 2 bytes tall x 16 wide = 32 bytes (9 bits is 2 bytes) 31 | fb = adafruit_framebuf.FrameBuffer(buf, display.width, display.height, adafruit_framebuf.MVLSB) 32 | 33 | 34 | frame = 0 # start with frame 0 35 | while True: 36 | for i in range(len(text_to_show) * 9): 37 | fb.fill(0) 38 | fb.text(text_to_show, -i + display.width, 0, color=1) 39 | 40 | # to improve the display flicker we can use two frame 41 | # fill the next frame with scrolling text, then 42 | # show it. 43 | display.frame(frame, show=False) 44 | # turn all LEDs off 45 | display.fill(0) 46 | for x in range(display.width): 47 | # using the FrameBuffer text result 48 | bite = buf[x] 49 | for y in range(display.height): 50 | bit = 1 << y & bite 51 | # if bit > 0 then set the pixel brightness 52 | if bit: 53 | display.pixel(x, y, 50) 54 | 55 | # now that the frame is filled, show it. 56 | display.frame(frame, show=True) 57 | frame = 0 if frame else 1 58 | -------------------------------------------------------------------------------- /examples/is31fl3731_wave_example.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2 | # SPDX-License-Identifier: MIT 3 | 4 | import board 5 | import busio 6 | 7 | # uncomment next line if you are using Feather CharlieWing LED 15 x 7 8 | from adafruit_is31fl3731.charlie_wing import CharlieWing as Display 9 | 10 | # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix 11 | # from adafruit_is31fl3731.matrix import Matrix as Display 12 | # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet 13 | # from adafruit_is31fl3731.charlie_bonnet import CharlieBonnet as Display 14 | # uncomment next line if you are using Pimoroni Scroll Phat HD LED 17 x 7 15 | # from adafruit_is31fl3731.scroll_phat_hd import ScrollPhatHD as Display 16 | # uncomment next line if you are using Pimoroni 11x7 LED Matrix Breakout 17 | # from adafruit_is31fl3731.matrix_11x7 import Matrix11x7 as Display 18 | 19 | # uncomment this line if you use a Pico, here with SCL=GP21 and SDA=GP20. 20 | # i2c = busio.I2C(board.GP21, board.GP20) 21 | 22 | i2c = busio.I2C(board.SCL, board.SDA) 23 | 24 | # fmt: off 25 | sweep = [ 1, 2, 3, 4, 6, 8, 10, 15, 20, 30, 40, 60, 26 | 60, 40, 30, 20, 15, 10, 8, 6, 4, 3, 2, 1, ] 27 | # fmt: on 28 | 29 | frame = 0 30 | 31 | display = Display(i2c) 32 | 33 | while True: 34 | for incr in range(24): 35 | # to reduce update flicker, use two frames 36 | # make a frame active, don't show it yet 37 | display.frame(frame, show=False) 38 | # fill the display with the next frame 39 | for x in range(display.width): 40 | for y in range(display.height): 41 | display.pixel(x, y, sweep[(x + y + incr) % 24]) 42 | # show the next frame 43 | display.frame(frame, show=True) 44 | if frame: 45 | frame = 0 46 | else: 47 | frame = 1 48 | -------------------------------------------------------------------------------- /optional_requirements.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | adafruit-circuitpython-framebuf 6 | pillow 7 | -------------------------------------------------------------------------------- /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-is31fl3731" 14 | description = "CircuitPython library for IS31FL3731 charlieplex LED matrices." 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_IS31FL3731"} 21 | keywords = [ 22 | "adafruit", 23 | "is31fl3731", 24 | "led", 25 | "matrix", 26 | "charlieplex", 27 | "featherwingbreakout", 28 | "hardware", 29 | "micropython", 30 | "circuitpython", 31 | ] 32 | license = {text = "MIT"} 33 | classifiers = [ 34 | "Intended Audience :: Developers", 35 | "Topic :: Software Development :: Libraries", 36 | "Topic :: Software Development :: Embedded Systems", 37 | "Topic :: System :: Hardware", 38 | "License :: OSI Approved :: MIT License", 39 | "Programming Language :: Python :: 3", 40 | ] 41 | dynamic = ["dependencies", "optional-dependencies"] 42 | 43 | [tool.setuptools] 44 | packages = ["adafruit_is31fl3731"] 45 | 46 | [tool.setuptools.dynamic] 47 | dependencies = {file = ["requirements.txt"]} 48 | optional-dependencies = {optional = {file = ["optional_requirements.txt"]}} 49 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | select = ["I", "PL", "UP"] 10 | 11 | extend-select = [ 12 | "D419", # empty-docstring 13 | "E501", # line-too-long 14 | "W291", # trailing-whitespace 15 | "PLC0414", # useless-import-alias 16 | "PLC2401", # non-ascii-name 17 | "PLC2801", # unnecessary-dunder-call 18 | "PLC3002", # unnecessary-direct-lambda-call 19 | "E999", # syntax-error 20 | "PLE0101", # return-in-init 21 | "F706", # return-outside-function 22 | "F704", # yield-outside-function 23 | "PLE0116", # continue-in-finally 24 | "PLE0117", # nonlocal-without-binding 25 | "PLE0241", # duplicate-bases 26 | "PLE0302", # unexpected-special-method-signature 27 | "PLE0604", # invalid-all-object 28 | "PLE0605", # invalid-all-format 29 | "PLE0643", # potential-index-error 30 | "PLE0704", # misplaced-bare-raise 31 | "PLE1141", # dict-iter-missing-items 32 | "PLE1142", # await-outside-async 33 | "PLE1205", # logging-too-many-args 34 | "PLE1206", # logging-too-few-args 35 | "PLE1307", # bad-string-format-type 36 | "PLE1310", # bad-str-strip-call 37 | "PLE1507", # invalid-envvar-value 38 | "PLE2502", # bidirectional-unicode 39 | "PLE2510", # invalid-character-backspace 40 | "PLE2512", # invalid-character-sub 41 | "PLE2513", # invalid-character-esc 42 | "PLE2514", # invalid-character-nul 43 | "PLE2515", # invalid-character-zero-width-space 44 | "PLR0124", # comparison-with-itself 45 | "PLR0202", # no-classmethod-decorator 46 | "PLR0203", # no-staticmethod-decorator 47 | "UP004", # useless-object-inheritance 48 | "PLR0206", # property-with-parameters 49 | "PLR0904", # too-many-public-methods 50 | "PLR0911", # too-many-return-statements 51 | "PLR0912", # too-many-branches 52 | "PLR0913", # too-many-arguments 53 | "PLR0914", # too-many-locals 54 | "PLR0915", # too-many-statements 55 | "PLR0916", # too-many-boolean-expressions 56 | "PLR1702", # too-many-nested-blocks 57 | "PLR1704", # redefined-argument-from-local 58 | "PLR1711", # useless-return 59 | "C416", # unnecessary-comprehension 60 | "PLR1733", # unnecessary-dict-index-lookup 61 | "PLR1736", # unnecessary-list-index-lookup 62 | 63 | # ruff reports this rule is unstable 64 | #"PLR6301", # no-self-use 65 | 66 | "PLW0108", # unnecessary-lambda 67 | "PLW0120", # useless-else-on-loop 68 | "PLW0127", # self-assigning-variable 69 | "PLW0129", # assert-on-string-literal 70 | "B033", # duplicate-value 71 | "PLW0131", # named-expr-without-context 72 | "PLW0245", # super-without-brackets 73 | "PLW0406", # import-self 74 | "PLW0602", # global-variable-not-assigned 75 | "PLW0603", # global-statement 76 | "PLW0604", # global-at-module-level 77 | 78 | # fails on the try: import typing used by libraries 79 | #"F401", # unused-import 80 | 81 | "F841", # unused-variable 82 | "E722", # bare-except 83 | "PLW0711", # binary-op-exception 84 | "PLW1501", # bad-open-mode 85 | "PLW1508", # invalid-envvar-default 86 | "PLW1509", # subprocess-popen-preexec-fn 87 | "PLW2101", # useless-with-lock 88 | "PLW3301", # nested-min-max 89 | ] 90 | 91 | ignore = [ 92 | "PLR2004", # magic-value-comparison 93 | "UP030", # format literals 94 | "PLW1514", # unspecified-encoding 95 | 96 | ] 97 | 98 | [format] 99 | line-ending = "lf" 100 | --------------------------------------------------------------------------------