├── .github ├── PULL_REQUEST_TEMPLATE │ └── adafruit_circuitpython_pr.md └── workflows │ ├── build.yml │ ├── failure-help-text.yml │ └── release.yml ├── .gitignore ├── .pre-commit-config.yaml ├── .pylintrc ├── CODE_OF_CONDUCT.md ├── LICENSE ├── LICENSES ├── Apache-2.0.txt ├── CC-BY-4.0.txt ├── MIT.txt └── Unlicense.txt ├── README.rst ├── README.rst.license ├── bluepad32 ├── bluepad32.py └── gamepad.py ├── examples └── bluepad32_simpletest.py ├── img ├── bluepad32-circuitpython-logo.png ├── bluepad32-circuitpython-logo.png.license ├── bluepad32-how-does-it-work.png ├── bluepad32-how-does-it-work.png.license ├── bluepad32-how-does-it-work.xcf └── bluepad32-how-does-it-work.xcf.license ├── pyproject.toml ├── requirements.txt └── setup.py.disabled /.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://circuitpython.readthedocs.io/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: Dump GitHub context 14 | env: 15 | GITHUB_CONTEXT: ${{ toJson(github) }} 16 | run: echo "$GITHUB_CONTEXT" 17 | - name: Translate Repo Name For Build Tools filename_prefix 18 | id: repo-name 19 | run: | 20 | echo ::set-output name=repo-name::$( 21 | echo ${{ github.repository }} | 22 | awk -F '\/' '{ print tolower($2) }' | 23 | tr '_' '-' 24 | ) 25 | - name: Set up Python 3.7 26 | uses: actions/setup-python@v1 27 | with: 28 | python-version: 3.7 29 | - name: Versions 30 | run: | 31 | python3 --version 32 | - name: Checkout Current Repo 33 | uses: actions/checkout@v1 34 | with: 35 | submodules: true 36 | - name: Checkout tools repo 37 | uses: actions/checkout@v2 38 | with: 39 | repository: adafruit/actions-ci-circuitpython-libs 40 | path: actions-ci 41 | - name: Install dependencies 42 | # (e.g. - apt-get: gettext, etc; pip: circuitpython-build-tools, requirements.txt; etc.) 43 | run: | 44 | source actions-ci/install.sh 45 | - name: Pip install pylint, Sphinx, pre-commit 46 | run: | 47 | pip install --force-reinstall pylint Sphinx sphinx-rtd-theme pre-commit 48 | - name: Library version 49 | run: git describe --dirty --always --tags 50 | - name: Setup problem matchers 51 | uses: adafruit/circuitpython-action-library-ci-problem-matchers@v1 52 | - name: Pre-commit hooks 53 | run: | 54 | pre-commit run --all-files 55 | - name: Build assets 56 | run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location . 57 | - name: Archive bundles 58 | uses: actions/upload-artifact@v2 59 | with: 60 | name: bundles 61 | path: ${{ github.workspace }}/bundles/ 62 | - name: Check For docs folder 63 | id: need-docs 64 | run: | 65 | echo ::set-output name=docs::$( find . -wholename './docs' ) 66 | - name: Build docs 67 | if: contains(steps.need-docs.outputs.docs, 'docs') 68 | working-directory: docs 69 | run: sphinx-build -E -W -b html . _build/html 70 | - name: Check For setup.py 71 | id: need-pypi 72 | run: | 73 | echo ::set-output name=setup-py::$( find . -wholename './setup.py' ) 74 | - name: Build Python package 75 | if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') 76 | run: | 77 | pip install --upgrade setuptools wheel twine readme_renderer testresources 78 | python setup.py sdist 79 | python setup.py bdist_wheel --universal 80 | twine check dist/* 81 | -------------------------------------------------------------------------------- /.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.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | name: 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: Dump GitHub context 16 | env: 17 | GITHUB_CONTEXT: ${{ toJson(github) }} 18 | run: echo "$GITHUB_CONTEXT" 19 | - name: Translate Repo Name For Build Tools filename_prefix 20 | id: repo-name 21 | run: | 22 | echo ::set-output name=repo-name::$( 23 | echo ${{ github.repository }} | 24 | awk -F '\/' '{ print tolower($2) }' | 25 | tr '_' '-' 26 | ) 27 | - name: Set up Python 3.6 28 | uses: actions/setup-python@v1 29 | with: 30 | python-version: 3.6 31 | - name: Versions 32 | run: | 33 | python3 --version 34 | - name: Checkout Current Repo 35 | uses: actions/checkout@v1 36 | with: 37 | submodules: true 38 | - name: Checkout tools repo 39 | uses: actions/checkout@v2 40 | with: 41 | repository: adafruit/actions-ci-circuitpython-libs 42 | path: actions-ci 43 | - name: Install deps 44 | run: | 45 | source actions-ci/install.sh 46 | - name: Build assets 47 | run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location . 48 | - name: Upload Release Assets 49 | # the 'official' actions version does not yet support dynamically 50 | # supplying asset names to upload. @csexton's version chosen based on 51 | # discussion in the issue below, as its the simplest to implement and 52 | # allows for selecting files with a pattern. 53 | # https://github.com/actions/upload-release-asset/issues/4 54 | #uses: actions/upload-release-asset@v1.0.1 55 | uses: csexton/release-asset-action@master 56 | with: 57 | pattern: "bundles/*" 58 | github-token: ${{ secrets.GITHUB_TOKEN }} 59 | 60 | upload-pypi: 61 | runs-on: ubuntu-latest 62 | steps: 63 | - uses: actions/checkout@v1 64 | - name: Check For setup.py 65 | id: need-pypi 66 | run: | 67 | echo ::set-output name=setup-py::$( find . -wholename './setup.py' ) 68 | - name: Set up Python 69 | if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') 70 | uses: actions/setup-python@v1 71 | with: 72 | python-version: '3.x' 73 | - name: Install dependencies 74 | if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') 75 | run: | 76 | python -m pip install --upgrade pip 77 | pip install setuptools wheel twine 78 | - name: Build and publish 79 | if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') 80 | env: 81 | TWINE_USERNAME: ${{ secrets.pypi_username }} 82 | TWINE_PASSWORD: ${{ secrets.pypi_password }} 83 | run: | 84 | python setup.py sdist 85 | # After the dist file is packaged, extract it, update the __version__ 86 | # lines and repackage it. 87 | cd dist 88 | ZIP_FILE=`ls | sed -e "s/\.tar\.gz$//"` 89 | echo "ZIP FILE = ${ZIP_FILE}" 90 | tar xzf "${ZIP_FILE}.tar.gz" 91 | echo The latest release version is \"${{github.event.release.tag_name}}\". 92 | # Don't descend into ./.env, ./.eggs, or ./docs 93 | for file in $(find -not -path "./.*" -not -path "./docs*" -name "*.py"); do 94 | sed -i -e "s/0.0.0-auto.0/${{github.event.release.tag_name}}/" $file; 95 | done; 96 | tar czf "${ZIP_FILE}.tar.gz" "${ZIP_FILE}" 97 | rm -rf "${ZIP_FILE}" 98 | cd .. 99 | twine upload dist/* 100 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | *.mpy 6 | .idea 7 | __pycache__ 8 | _build 9 | *.pyc 10 | .env 11 | .python-version 12 | build*/ 13 | bundles 14 | *.DS_Store 15 | .eggs 16 | dist 17 | **/*.egg-info 18 | .vscode 19 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2020 Diego Elio Pettenò 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | repos: 6 | - repo: https://github.com/python/black 7 | rev: 23.7.0 8 | hooks: 9 | - id: black 10 | - repo: https://github.com/fsfe/reuse-tool 11 | rev: v2.1.0 12 | hooks: 13 | - id: reuse 14 | - repo: https://github.com/pre-commit/pre-commit-hooks 15 | rev: v4.4.0 16 | hooks: 17 | - id: check-yaml 18 | - id: end-of-file-fixer 19 | - id: trailing-whitespace 20 | - repo: https://github.com/pycqa/pylint 21 | rev: v3.0.0a6 22 | hooks: 23 | - id: pylint 24 | name: pylint (library code) 25 | types: [python] 26 | exclude: "^(docs/|examples/|tests/|setup.py$)" 27 | - repo: local 28 | hooks: 29 | - id: pylint_examples 30 | name: pylint (examples code) 31 | description: Run pylint rules on "examples/*.py" files 32 | entry: /usr/bin/env bash -c 33 | args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name $example; done)'] 34 | language: system 35 | - id: pylint_tests 36 | name: pylint (tests code) 37 | description: Run pylint rules on "tests/*.py" files 38 | entry: /usr/bin/env bash -c 39 | args: ['([[ ! -d "tests" ]] || for test in $(find . -path "./tests/*.py"); do pylint --disable=missing-docstring $test; done)'] 40 | language: system 41 | -------------------------------------------------------------------------------- /.pylintrc: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2019 ladyada for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | [MASTER] 6 | 7 | # A comma-separated list of package or module names from where C extensions may 8 | # be loaded. Extensions are loading into the active Python interpreter and may 9 | # run arbitrary code 10 | extension-pkg-whitelist= 11 | 12 | # Add files or directories to the blacklist. They should be base names, not 13 | # paths. 14 | ignore=CVS 15 | 16 | # Add files or directories matching the regex patterns to the blacklist. The 17 | # regex matches against base names, not paths. 18 | ignore-patterns= 19 | 20 | # Python code to execute, usually for sys.path manipulation such as 21 | # pygtk.require(). 22 | #init-hook= 23 | 24 | # Use multiple processes to speed up Pylint. 25 | # jobs=1 26 | jobs=2 27 | 28 | # List of plugins (as comma separated values of python modules names) to load, 29 | # usually to register additional checkers. 30 | load-plugins= 31 | 32 | # Pickle collected data for later comparisons. 33 | persistent=yes 34 | 35 | # Specify a configuration file. 36 | #rcfile= 37 | 38 | # Allow loading of arbitrary C extensions. Extensions are imported into the 39 | # active Python interpreter and may run arbitrary code. 40 | unsafe-load-any-extension=no 41 | 42 | 43 | [MESSAGES CONTROL] 44 | 45 | # Only show warnings with the listed confidence levels. Leave empty to show 46 | # all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED 47 | confidence= 48 | 49 | # Disable the message, report, category or checker with the given id(s). You 50 | # can either give multiple identifiers separated by comma (,) or put this 51 | # option multiple times (only on the command line, not in the configuration 52 | # file where it should appear only once).You can also use "--disable=all" to 53 | # disable everything first and then reenable specific checks. For example, if 54 | # you want to run only the similarities checker, you can use "--disable=all 55 | # --enable=similarities". If you want to run only the classes checker, but have 56 | # no Warning level messages displayed, use"--disable=all --enable=classes 57 | # --disable=W" 58 | # disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call 59 | disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,bad-continuation 60 | 61 | # Enable the message, report, category or checker with the given id(s). You can 62 | # either give multiple identifier separated by comma (,) or put this option 63 | # multiple time (only on the command line, not in the configuration file where 64 | # it should appear only once). See also the "--disable" option for examples. 65 | enable= 66 | 67 | 68 | [REPORTS] 69 | 70 | # Python expression which should return a note less than 10 (10 is the highest 71 | # note). You have access to the variables errors warning, statement which 72 | # respectively contain the number of errors / warnings messages and the total 73 | # number of statements analyzed. This is used by the global evaluation report 74 | # (RP0004). 75 | evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) 76 | 77 | # Template used to display messages. This is a python new-style format string 78 | # used to format the message information. See doc for all details 79 | #msg-template= 80 | 81 | # Set the output format. Available formats are text, parseable, colorized, json 82 | # and msvs (visual studio).You can also give a reporter class, eg 83 | # mypackage.mymodule.MyReporterClass. 84 | output-format=text 85 | 86 | # Tells whether to display a full report or only the messages 87 | reports=no 88 | 89 | # Activate the evaluation score. 90 | score=yes 91 | 92 | 93 | [REFACTORING] 94 | 95 | # Maximum number of nested blocks for function / method body 96 | max-nested-blocks=5 97 | 98 | 99 | [LOGGING] 100 | 101 | # Logging modules to check that the string format arguments are in logging 102 | # function parameter format 103 | logging-modules=logging 104 | 105 | 106 | [SPELLING] 107 | 108 | # Spelling dictionary name. Available dictionaries: none. To make it working 109 | # install python-enchant package. 110 | spelling-dict= 111 | 112 | # List of comma separated words that should not be checked. 113 | spelling-ignore-words= 114 | 115 | # A path to a file that contains private dictionary; one word per line. 116 | spelling-private-dict-file= 117 | 118 | # Tells whether to store unknown words to indicated private dictionary in 119 | # --spelling-private-dict-file option instead of raising a message. 120 | spelling-store-unknown-words=no 121 | 122 | 123 | [MISCELLANEOUS] 124 | 125 | # List of note tags to take in consideration, separated by a comma. 126 | # notes=FIXME,XXX,TODO 127 | notes=FIXME,XXX 128 | 129 | 130 | [TYPECHECK] 131 | 132 | # List of decorators that produce context managers, such as 133 | # contextlib.contextmanager. Add to this list to register other decorators that 134 | # produce valid context managers. 135 | contextmanager-decorators=contextlib.contextmanager 136 | 137 | # List of members which are set dynamically and missed by pylint inference 138 | # system, and so shouldn't trigger E1101 when accessed. Python regular 139 | # expressions are accepted. 140 | generated-members= 141 | 142 | # Tells whether missing members accessed in mixin class should be ignored. A 143 | # mixin class is detected if its name ends with "mixin" (case insensitive). 144 | ignore-mixin-members=yes 145 | 146 | # This flag controls whether pylint should warn about no-member and similar 147 | # checks whenever an opaque object is returned when inferring. The inference 148 | # can return multiple potential results while evaluating a Python object, but 149 | # some branches might not be evaluated, which results in partial inference. In 150 | # that case, it might be useful to still emit no-member and other checks for 151 | # the rest of the inferred objects. 152 | ignore-on-opaque-inference=yes 153 | 154 | # List of class names for which member attributes should not be checked (useful 155 | # for classes with dynamically set attributes). This supports the use of 156 | # qualified names. 157 | ignored-classes=optparse.Values,thread._local,_thread._local 158 | 159 | # List of module names for which member attributes should not be checked 160 | # (useful for modules/projects where namespaces are manipulated during runtime 161 | # and thus existing member attributes cannot be deduced by static analysis. It 162 | # supports qualified module names, as well as Unix pattern matching. 163 | ignored-modules=board 164 | 165 | # Show a hint with possible names when a member name was not found. The aspect 166 | # of finding the hint is based on edit distance. 167 | missing-member-hint=yes 168 | 169 | # The minimum edit distance a name should have in order to be considered a 170 | # similar match for a missing member name. 171 | missing-member-hint-distance=1 172 | 173 | # The total number of similar names that should be taken in consideration when 174 | # showing a hint for a missing member. 175 | missing-member-max-choices=1 176 | 177 | 178 | [VARIABLES] 179 | 180 | # List of additional names supposed to be defined in builtins. Remember that 181 | # you should avoid to define new builtins when possible. 182 | additional-builtins= 183 | 184 | # Tells whether unused global variables should be treated as a violation. 185 | allow-global-unused-variables=yes 186 | 187 | # List of strings which can identify a callback function by name. A callback 188 | # name must start or end with one of those strings. 189 | callbacks=cb_,_cb 190 | 191 | # A regular expression matching the name of dummy variables (i.e. expectedly 192 | # not used). 193 | dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ 194 | 195 | # Argument names that match this expression will be ignored. Default to name 196 | # with leading underscore 197 | ignored-argument-names=_.*|^ignored_|^unused_ 198 | 199 | # Tells whether we should check for unused import in __init__ files. 200 | init-import=no 201 | 202 | # List of qualified module names which can have objects that can redefine 203 | # builtins. 204 | redefining-builtins-modules=six.moves,future.builtins 205 | 206 | 207 | [FORMAT] 208 | 209 | # Expected format of line ending, e.g. empty (any line ending), LF or CRLF. 210 | # expected-line-ending-format= 211 | expected-line-ending-format=LF 212 | 213 | # Regexp for a line that is allowed to be longer than the limit. 214 | ignore-long-lines=^\s*(# )??$ 215 | 216 | # Number of spaces of indent required inside a hanging or continued line. 217 | indent-after-paren=4 218 | 219 | # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 220 | # tab). 221 | indent-string=' ' 222 | 223 | # Maximum number of characters on a single line. 224 | max-line-length=100 225 | 226 | # Maximum number of lines in a module 227 | max-module-lines=1000 228 | 229 | # List of optional constructs for which whitespace checking is disabled. `dict- 230 | # separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. 231 | # `trailing-comma` allows a space between comma and closing bracket: (a, ). 232 | # `empty-line` allows space-only lines. 233 | no-space-check=trailing-comma,dict-separator 234 | 235 | # Allow the body of a class to be on the same line as the declaration if body 236 | # contains single statement. 237 | single-line-class-stmt=no 238 | 239 | # Allow the body of an if to be on the same line as the test if there is no 240 | # else. 241 | single-line-if-stmt=no 242 | 243 | 244 | [SIMILARITIES] 245 | 246 | # Ignore comments when computing similarities. 247 | ignore-comments=yes 248 | 249 | # Ignore docstrings when computing similarities. 250 | ignore-docstrings=yes 251 | 252 | # Ignore imports when computing similarities. 253 | ignore-imports=no 254 | 255 | # Minimum lines number of a similarity. 256 | min-similarity-lines=4 257 | 258 | 259 | [BASIC] 260 | 261 | # Naming hint for argument names 262 | argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ 263 | 264 | # Regular expression matching correct argument names 265 | argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ 266 | 267 | # Naming hint for attribute names 268 | attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ 269 | 270 | # Regular expression matching correct attribute names 271 | attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ 272 | 273 | # Bad variable names which should always be refused, separated by a comma 274 | bad-names=foo,bar,baz,toto,tutu,tata 275 | 276 | # Naming hint for class attribute names 277 | class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ 278 | 279 | # Regular expression matching correct class attribute names 280 | class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ 281 | 282 | # Naming hint for class names 283 | # class-name-hint=[A-Z_][a-zA-Z0-9]+$ 284 | class-name-hint=[A-Z_][a-zA-Z0-9_]+$ 285 | 286 | # Regular expression matching correct class names 287 | # class-rgx=[A-Z_][a-zA-Z0-9]+$ 288 | class-rgx=[A-Z_][a-zA-Z0-9_]+$ 289 | 290 | # Naming hint for constant names 291 | const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$ 292 | 293 | # Regular expression matching correct constant names 294 | const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ 295 | 296 | # Minimum line length for functions/classes that require docstrings, shorter 297 | # ones are exempt. 298 | docstring-min-length=-1 299 | 300 | # Naming hint for function names 301 | function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ 302 | 303 | # Regular expression matching correct function names 304 | function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ 305 | 306 | # Good variable names which should always be accepted, separated by a comma 307 | # good-names=i,j,k,ex,Run,_ 308 | good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_ 309 | 310 | # Include a hint for the correct naming format with invalid-name 311 | include-naming-hint=no 312 | 313 | # Naming hint for inline iteration names 314 | inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$ 315 | 316 | # Regular expression matching correct inline iteration names 317 | inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ 318 | 319 | # Naming hint for method names 320 | method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ 321 | 322 | # Regular expression matching correct method names 323 | method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ 324 | 325 | # Naming hint for module names 326 | module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ 327 | 328 | # Regular expression matching correct module names 329 | module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ 330 | 331 | # Colon-delimited sets of names that determine each other's naming style when 332 | # the name regexes allow several styles. 333 | name-group= 334 | 335 | # Regular expression which should only match function or class names that do 336 | # not require a docstring. 337 | no-docstring-rgx=^_ 338 | 339 | # List of decorators that produce properties, such as abc.abstractproperty. Add 340 | # to this list to register other decorators that produce valid properties. 341 | property-classes=abc.abstractproperty 342 | 343 | # Naming hint for variable names 344 | variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ 345 | 346 | # Regular expression matching correct variable names 347 | variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ 348 | 349 | 350 | [IMPORTS] 351 | 352 | # Allow wildcard imports from modules that define __all__. 353 | allow-wildcard-with-all=no 354 | 355 | # Analyse import fallback blocks. This can be used to support both Python 2 and 356 | # 3 compatible code, which means that the block might have code that exists 357 | # only in one or another interpreter, leading to false positives when analysed. 358 | analyse-fallback-blocks=no 359 | 360 | # Deprecated modules which should not be used, separated by a comma 361 | deprecated-modules=optparse,tkinter.tix 362 | 363 | # Create a graph of external dependencies in the given file (report RP0402 must 364 | # not be disabled) 365 | ext-import-graph= 366 | 367 | # Create a graph of every (i.e. internal and external) dependencies in the 368 | # given file (report RP0402 must not be disabled) 369 | import-graph= 370 | 371 | # Create a graph of internal dependencies in the given file (report RP0402 must 372 | # not be disabled) 373 | int-import-graph= 374 | 375 | # Force import order to recognize a module as part of the standard 376 | # compatibility libraries. 377 | known-standard-library= 378 | 379 | # Force import order to recognize a module as part of a third party library. 380 | known-third-party=enchant 381 | 382 | 383 | [CLASSES] 384 | 385 | # List of method names used to declare (i.e. assign) instance attributes. 386 | defining-attr-methods=__init__,__new__,setUp 387 | 388 | # List of member names, which should be excluded from the protected access 389 | # warning. 390 | exclude-protected=_asdict,_fields,_replace,_source,_make 391 | 392 | # List of valid names for the first argument in a class method. 393 | valid-classmethod-first-arg=cls 394 | 395 | # List of valid names for the first argument in a metaclass class method. 396 | valid-metaclass-classmethod-first-arg=mcs 397 | 398 | 399 | [DESIGN] 400 | 401 | # Maximum number of arguments for function / method 402 | max-args=5 403 | 404 | # Maximum number of attributes for a class (see R0902). 405 | # max-attributes=7 406 | max-attributes=11 407 | 408 | # Maximum number of boolean expressions in a if statement 409 | max-bool-expr=5 410 | 411 | # Maximum number of branch for function / method body 412 | max-branches=12 413 | 414 | # Maximum number of locals for function / method body 415 | max-locals=15 416 | 417 | # Maximum number of parents for a class (see R0901). 418 | max-parents=7 419 | 420 | # Maximum number of public methods for a class (see R0904). 421 | max-public-methods=20 422 | 423 | # Maximum number of return / yield for function / method body 424 | max-returns=6 425 | 426 | # Maximum number of statements in function / method body 427 | max-statements=50 428 | 429 | # Minimum number of public methods for a class (see R0903). 430 | min-public-methods=1 431 | 432 | 433 | [EXCEPTIONS] 434 | 435 | # Exceptions that will emit a warning when being caught. Defaults to 436 | # "Exception" 437 | overgeneral-exceptions=Exception 438 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 7 | # CircuitPython 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 | * Discussion or promotion of activities or projects that intend or pose a risk of 43 | significant harm 44 | * Trolling, insulting/derogatory comments, and personal or political attacks 45 | * Promoting or spreading disinformation, lies, or conspiracy theories against 46 | a person, group, organisation, project, or community 47 | * Public or private harassment 48 | * Publishing others' private information, such as a physical or electronic 49 | address, without explicit permission 50 | * Other conduct which could reasonably be considered inappropriate 51 | 52 | The goal of the standards and moderation guidelines outlined here is to build 53 | and maintain a respectful community. We ask that you don’t just aim to be 54 | "technically unimpeachable", but rather try to be your best self. 55 | 56 | We value many things beyond technical expertise, including collaboration and 57 | supporting others within our community. Providing a positive experience for 58 | other community members can have a much more significant impact than simply 59 | providing the correct answer. 60 | 61 | ## Our Responsibilities 62 | 63 | Project leaders are responsible for clarifying the standards of acceptable 64 | behavior and are expected to take appropriate and fair corrective action in 65 | response to any instances of unacceptable behavior. 66 | 67 | Project leaders have the right and responsibility to remove, edit, or 68 | reject messages, comments, commits, code, issues, and other contributions 69 | that are not aligned to this Code of Conduct, or to ban temporarily or 70 | permanently any community member for other behaviors that they deem 71 | inappropriate, threatening, offensive, or harmful. 72 | 73 | ## Moderation 74 | 75 | Instances of behaviors that violate the CircuitPython Community Code of Conduct 76 | may be reported by any member of the community. Community members are 77 | encouraged to report these situations, including situations they witness 78 | involving other community members. 79 | 80 | You may report in the following ways: 81 | 82 | In any situation, you may email the project maintainer. 83 | 84 | Email reports will be kept confidential. 85 | 86 | In situations on GitHub where the issue is particularly offensive, possibly 87 | illegal, requires immediate action, or violates the GitHub terms of service, 88 | you should also report the message directly to GitHub via the comment, or via 89 | [GitHub Support](https://support.github.com/contact/report-abuse?category=report-abuse&report=other&report_type=unspecified). 90 | 91 | These are the steps for upholding our community’s standards of conduct. 92 | 93 | 1. Any member of the community may report any situation that violates the 94 | CircuitPython Community Code of Conduct. All reports will be reviewed and 95 | investigated. 96 | 2. If the behavior is a severe violation, the community member who 97 | committed the violation may be banned immediately, without warning. 98 | 3. Otherwise, moderators will first respond to such behavior with a warning. 99 | 4. Moderators follow a soft "three strikes" policy - the community member may 100 | be given another chance, if they are receptive to the warning and change their 101 | behavior. 102 | 5. If the community member is unreceptive or unreasonable when warned by a 103 | moderator, or the warning goes unheeded, they may be banned for a first or 104 | second offense. Repeated offenses will result in the community member being 105 | banned. 106 | 6. Disciplinary actions (warnings, bans, etc) for Code of Conduct violations apply 107 | to the platform where the violation occurred. However, depending on the severity 108 | of the violation, the disciplinary action may be applied across CircuitPython's 109 | other community platforms. For example, a severe violation in one Community forum 110 | may result in a ban on not only the CircuitPython GitHub organisation, 111 | but also on the CircuitPython Twitter, live stream text chats, etc. 112 | 113 | ## Scope 114 | 115 | This Code of Conduct and the enforcement policies listed above apply to all 116 | CircuitPython Community venues. This includes but is not limited to any community 117 | spaces (both public and private), and CircuitPython repositories. Examples of 118 | CircuitPython Community spaces include but are not limited to meet-ups, issue 119 | threads on GitHub, text chats during a live stream, or interaction at a conference. 120 | 121 | This Code of Conduct applies both within project spaces and in public spaces 122 | when an individual is representing the project or its community. As a community 123 | member, you are representing our community, and are expected to behave 124 | accordingly. 125 | 126 | ## Attribution 127 | 128 | This Code of Conduct is adapted from the 129 | [Adafruit Community Code of Conduct](https://github.com/adafruit/Adafruit_Community_Code_of_Conduct), 130 | which is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), 131 | version 1.4, available on [contributor-covenant.org](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html), 132 | and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html). 133 | 134 | For other projects adopting the CircuitPython Community Code of 135 | Conduct, please contact the maintainers of those projects for enforcement. 136 | If you wish to use this code of conduct for your own project, consider 137 | explicitly mentioning your moderation policy or making a copy with your 138 | own moderation policy so as to avoid confusion. 139 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /LICENSES/Apache-2.0.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /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 | 5 | .. image:: https://github.com/ricardoquesada/bluepad32-circuitpython/workflows/Build%20CI/badge.svg 6 | :target: https://github.com/ricardoquesada/bluepad32-circuitpython/actions/ 7 | :alt: Build Status 8 | 9 | 10 | .. image:: https://img.shields.io/discord/775177861665521725.svg 11 | :target: https://discord.gg/r5aMn6Cw5q 12 | :alt: Discord 13 | 14 | 15 | .. image:: img/bluepad32-circuitpython-logo.png 16 | :alt: Logo 17 | 18 | Enables gamepad support for CircuitPython. Requires a board with an AirLift (ESP32) module, 19 | like: 20 | 21 | * `Adafruit Metro M7 RT1011 with AirLift `_ 22 | * `Adafruit MatrixPortal M4 `_ 23 | * `Adafruit Metro M4 Express AirLift `_ 24 | * `Adafruit PyPortal `_ 25 | * `Adafruit PyBadge `_ 26 | 27 | Supported gamepads 28 | ================== 29 | 30 | .. image:: https://lh3.googleusercontent.com/pw/AM-JKLWUZS_vlkMmd3o8EKzXlYCS0uriEW_gXfOoiFqZlABJi_dM1GWYHGafrdMnTP-VHgVdCdVA4pUageZgyI98RH1SHtydac2yyrx_vJVXgWPYBFN-SJoOikdlGuOowPoDqYOwfKU39yketYPJyRJlIPwjEw=-no 31 | :alt: Supported gamepads 32 | 33 | Supports, most if not all, modern Bluetooth gamepads like: 34 | 35 | * Sony family: DualSense (PS5), DualShock 4 (PS4), DualShock 3 (PS3) 36 | * Nintendo family: Switch gamepads, Switch JoyCons, Wii, Wii U 37 | * Xbox Wireless family: models 1708, 1914, adaptive 38 | * Steam controller 39 | * Stadia controller 40 | * Android gamepads 41 | * Window gamepads 42 | * 8BitDo controllers 43 | * and more 44 | 45 | For a complete list, see: https://bluepad32.readthedocs.io/en/latest/supported_gamepads/ 46 | 47 | 48 | How does it work 49 | ================ 50 | 51 | As mentioned above, only boards with the AirLift (ESP32) co-processor are supported. 52 | This is because the project consists of two parts: 53 | 54 | * "Bluepad32 library for CircuitPython", runs on the main processor: "C" 55 | * "Bluepad32 firmware", runs on the AirLift co-processor: "B" 56 | 57 | .. image:: img/bluepad32-how-does-it-work.png 58 | :alt: How does it work 59 | 60 | The gamepad (A), using Bluetooth, connects to the AirLift co-processor (B). 61 | 62 | And AirLift (B) sends the gamepad data to the main processor (C). In the case 63 | of the MatrixPortal M4, the main processor is the SAMD51. But it could be 64 | different on other boards. 65 | 66 | So, in order to use the library you have to flash the "Bluepad32 firmware" on AirLift. 67 | This is a simple step that needs to be done just once, and can be undone at any time. 68 | Info about Bluepad32 firmware is available here: 69 | 70 | 71 | * Bluepad32 firmware doc: https://bluepad32.readthedocs.io/en/latest/plat_airlift/ 72 | * Download: https://github.com/ricardoquesada/bluepad32/releases 73 | 74 | Dependencies 75 | ============ 76 | 77 | This driver depends on: 78 | 79 | * `Adafruit ESP32SPI `_ 80 | 81 | Please ensure all dependencies are available on the CircuitPython filesystem. 82 | This is easily achieved by downloading 83 | `the Adafruit library and driver bundle `_ 84 | or individual libraries can be installed using 85 | `circup `_. 86 | 87 | 88 | 89 | Installing to a Connected CircuitPython Device with Circup 90 | ========================================================== 91 | 92 | Make sure that you have ``circup`` installed in your Python environment. 93 | Install it with the following command if necessary: 94 | 95 | .. code-block:: shell 96 | 97 | pip3 install circup 98 | 99 | With ``circup`` installed and your CircuitPython device connected use the 100 | following command to install: 101 | 102 | .. code-block:: shell 103 | 104 | circup install bluepad32 105 | 106 | Or the following command to update an existing version: 107 | 108 | .. code-block:: shell 109 | 110 | circup update 111 | 112 | Usage Example 113 | ============= 114 | 115 | .. code-block:: python 116 | 117 | import time 118 | import board 119 | import busio 120 | from digitalio import DigitalInOut 121 | from bluepad32.bluepad32 import Bluepad32 122 | 123 | # Connected gamepad 124 | gamepad = None 125 | 126 | # Callback that will be called once a gamepad is connected 127 | def on_connect(gp): 128 | global gamepad 129 | gamepad = gp 130 | 131 | print("on_connect: ", gp) 132 | # Change ligthbar to Green: Red, Green, Blue 133 | gp.set_lightbar_color((0x00, 0xFF, 0x00)) 134 | 135 | 136 | # Callback that will be called when a gamepad is disconnected 137 | def on_disconnect(gp): 138 | global gamepad 139 | gamepad = None 140 | print("on_disconnect: ", gp) 141 | 142 | 143 | # If you are using a board with pre-defined ESP32 Pins: 144 | 145 | esp32_cs = DigitalInOut(board.ESP_CS) 146 | esp32_ready = DigitalInOut(board.ESP_BUSY) 147 | esp32_reset = DigitalInOut(board.ESP_RESET) 148 | 149 | spi = busio.SPI(board.SCK, board.MOSI, board.MISO) 150 | bp32 = Bluepad32(spi, esp32_cs, esp32_ready, esp32_reset, debug=0) 151 | bp32.setup_callbacks(on_connect, on_disconnect) 152 | 153 | # For Arduino Nano RP2040 Connect, instead you should use: 154 | # board.CS1, board.SCK1, board.MOSI1, board.MISO1 155 | 156 | # Should display "Bluepad32 for Airlift vXXX" 157 | print("Firmware version:", bp32.firmware_version) 158 | 159 | while True: 160 | # Fetches data from Bluepad32 firmware, triggers callbaks, and more. 161 | # Must be called once per frame. 162 | bp32.update() 163 | 164 | if gamepad is None: 165 | continue 166 | 167 | if gamepad.button_a: # button A pressed ? 168 | # Change color to Blue 169 | gamepad.set_lightbar_color((0x00, 0x00, 0xFF)) 170 | 171 | if gamepad.button_b: # Button B pressed ? 172 | # Turn on all 4 player LEDs 173 | gamepad.set_player_leds(0x0f) 174 | 175 | if gamepad.button_x: # Button X pressed ? 176 | force = 128 # 0-255 177 | duration = 10 # 0-255 178 | gamepad.set_rumble(force, duration) 179 | 180 | # Small delay, simulates a 30 FPS game 181 | time.sleep(0.032) 182 | 183 | 184 | Contributing 185 | ============ 186 | 187 | Contributions are welcome! Please read our `Code of Conduct 188 | `_ 189 | before contributing to help this project stay welcoming. 190 | -------------------------------------------------------------------------------- /README.rst.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | SPDX-FileCopyrightText: Copyright (c) 2021 Ricardo Quesada 3 | SPDX-License-Identifier: MIT 4 | -------------------------------------------------------------------------------- /bluepad32/bluepad32.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 - 2023, Ricardo Quesada, http://retro.moe 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | # Bluepad32 support for CircuitPython. 5 | # Requires the Bluepad32 firmware (instead of Nina-fw). 6 | 7 | """ 8 | `bluepad32_bluepad32` 9 | ================================================================================ 10 | 11 | Gamepad support for Airlift-based board. 12 | 13 | 14 | * Author(s): Ricardo Quesada 15 | 16 | Implementation Notes 17 | -------------------- 18 | 19 | **Hardware:** 20 | 21 | **Software and Dependencies:** 22 | 23 | .. todo:: Add links to any specific hardware product page(s), or category page(s). 24 | Use unordered list & hyperlink rST inline format: "* `Link Text `_" 25 | 26 | * Adafruit ESP32SPI: https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI 27 | """ 28 | 29 | # imports 30 | 31 | __version__ = "0.0.0-auto.0" 32 | __repo__ = "https://gitlab.com/ricardoquesada/bluepad32-circuitpython.git" 33 | 34 | import struct 35 | 36 | from adafruit_esp32spi import adafruit_esp32spi 37 | from micropython import const 38 | from bluepad32.gamepad import Gamepad # pylint: disable=no-name-in-module 39 | 40 | 41 | # Nina-fw commands stopped at 0x50. Bluepad32 extensions start at 0x60. See: 42 | # https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI/blob/master/adafruit_esp32spi/adafruit_esp32spi.py 43 | _GET_PROTOCOL_VERSION = const(0x00) 44 | _GET_GAMEPADS_DATA = const(0x01) 45 | _SET_GAMEPAD_PLAYER_LEDS = const(0x02) 46 | _SET_GAMEPAD_LIGHTBAR_COLOR = const(0x03) 47 | _SET_GAMEPAD_RUMBLE = const(0x04) 48 | _FORGET_BLUETOOTH_KEYS = const(0x05) 49 | _ENABLE_BLUETOOTH_CONNECTIONS = const(0x07) 50 | _GET_CONTROLLERS_DATA = const(0x09) 51 | 52 | _MAX_GAMEPADS = const(4) 53 | 54 | _PROTOCOL_VERSION_HI = const(1) 55 | _PROTOCOL_VERSION_LO = const(0) 56 | 57 | 58 | class Bluepad32(adafruit_esp32spi.ESP_SPIcontrol): 59 | """Implement the SPI commands for Bluepad32""" 60 | 61 | def __init__(self, *args, **kwargs): 62 | super().__init__(*args, **kwargs) 63 | 64 | # callbacks for when a gamepad gets connected / disconnected 65 | self._on_connect = None 66 | self._on_disconnect = None 67 | 68 | # known connected gamepads: bitmask 69 | self._prev_connected_gamepads = 0 70 | 71 | # gamepads 72 | self._gamepads = ( 73 | Gamepad(self, 0, {}), 74 | Gamepad(self, 1, {}), 75 | Gamepad(self, 2, {}), 76 | Gamepad(self, 3, {}), 77 | ) 78 | 79 | self._check_protocol() 80 | 81 | def update(self) -> list: 82 | """ 83 | Return a list of connected gamepads. 84 | 85 | Each gamepad entry is a dictionary that represents the gamepad state: 86 | gamepad index, buttons pressed, axis values, dpad and more. 87 | 88 | :returns: List of connected gamepads. 89 | """ 90 | self._send_command(_GET_CONTROLLERS_DATA) 91 | resp = self._wait_response_cmd(_GET_CONTROLLERS_DATA) 92 | 93 | connected_gamepads = 0 94 | 95 | # Update gamepads state 96 | for g in resp: 97 | unp = struct.unpack("= len(self._gamepads): 121 | return 122 | 123 | self._gamepads[state["idx"]].set_state(state) 124 | 125 | # Update connected gamepads bitmask 126 | connected_gamepads |= 1 << state["idx"] 127 | 128 | # Any change from prev state? 129 | if connected_gamepads == self._prev_connected_gamepads: 130 | return 131 | 132 | for idx in range(_MAX_GAMEPADS): 133 | bit = 1 << idx 134 | current = connected_gamepads & bit 135 | prev = self._prev_connected_gamepads & bit 136 | 137 | # No change in state 138 | if current == prev: 139 | continue 140 | 141 | if current != 0: 142 | self._on_connect(self._gamepads[idx]) 143 | else: 144 | self._on_disconnect(self._gamepads[idx]) 145 | self._prev_connected_gamepads = connected_gamepads 146 | 147 | def set_gamepad_player_leds(self, gamepad_idx: int, leds: int) -> bool: 148 | """ 149 | Set the gamepad's player LEDs. 150 | 151 | Some gamepads have 4 LEDs that are used to indicate, among other things, 152 | the "player number". 153 | 154 | Applicable only to gamepads that have a player's LEDs like Nintendo Wii, 155 | Nintendo Switch, etc. 156 | 157 | :param int gamepad_idx: Gamepad index, returned by get_gamepads_data(). 158 | :param int leds: Only the 4 LSB bits are used. Each bit indicates a LED. 159 | :return: True if the request was successful, False otherwise. 160 | """ 161 | resp = self._send_command_get_response( 162 | _SET_GAMEPAD_PLAYER_LEDS, ((gamepad_idx,), (leds,)) 163 | ) 164 | return resp[0][0] == 1 165 | 166 | def set_gamepad_lightbar_color(self, gamepad_idx: int, rgb) -> bool: 167 | """ 168 | Set the gamepad's lightbar color. 169 | 170 | Applicable only to gamepads that have a color LED like the Sony 171 | DualShok 4 or DualSense. 172 | 173 | :param int gamepad_idx: Gamepad index, returned by get_gamepads_data(). 174 | :param tuple[int, int, int] rgb: Red,Green,Blue values to set. 175 | :return: True if the request was successful, False otherwise. 176 | """ 177 | # Typing is not supported in CircuitPython. Parameter "rgb" should be: 178 | # Typing.tuple[int, int, int] 179 | resp = self._send_command_get_response( 180 | _SET_GAMEPAD_LIGHTBAR_COLOR, ((gamepad_idx,), rgb) 181 | ) 182 | return resp[0][0] == 1 183 | 184 | def set_gamepad_rumble(self, gamepad_idx: int, force: int, duration: int) -> bool: 185 | """ 186 | Set the gamepad's rumble (AKA force-feedback). 187 | 188 | Applicable only to gamepads that have rumble support, like Xbox One, 189 | DualShok 4, Nintendo Switch, etc. 190 | 191 | :param int gamepad_idx: Gamepad index, returned by get_gamepads_data(). 192 | :param int force: 8-bit value where 255 is max force, 0 nothing. 193 | :param int duration: 8-bit value, where 255 is about 1 second. 194 | :return: True if the request was successful, False otherwise. 195 | """ 196 | resp = self._send_command_get_response( 197 | _SET_GAMEPAD_RUMBLE, ((gamepad_idx,), (force, duration)) 198 | ) 199 | return resp[0][0] == 1 200 | 201 | def forget_bluetooth_keys(self) -> bool: 202 | """ 203 | Forget stored Bluetooth keys. 204 | 205 | After establishing a Bluetooth connection, a key is saved in the ESP32. 206 | This is useful for a quick reconnect. Removing the keys requires to 207 | establish a new connection, something that might be needed in some 208 | circumstances. 209 | 210 | :return: True if the request was successful, False otherwise. 211 | """ 212 | resp = self._send_command_get_response(_FORGET_BLUETOOTH_KEYS) 213 | return resp[0][0] == 1 214 | 215 | def enable_bluetooth_connections(self, enabled: bool) -> bool: 216 | """ 217 | Enable / Disable new Bluetooth connections. 218 | 219 | When enabled, the device is put in Discovery mode, and new pairings are 220 | accepted. When disabled, only devices that have paired before can connect. 221 | Established connections are not affected. 222 | 223 | :return: True if the request was successful, False otherwise. 224 | """ 225 | resp = self._send_command_get_response( 226 | _ENABLE_BLUETOOTH_CONNECTIONS, ((bool(enabled),),) 227 | ) 228 | return resp[0][0] == 1 229 | 230 | def setup_callbacks(self, on_connect, on_disconnect) -> None: 231 | """ 232 | Setup "on gamepad connect" and "on gamepad disconnect" callbacks. 233 | """ 234 | self._on_connect = on_connect 235 | self._on_disconnect = on_disconnect 236 | 237 | def _check_protocol(self) -> bool: 238 | resp = self._send_command_get_response(_GET_PROTOCOL_VERSION) 239 | ver_hi = resp[0][0] 240 | if ver_hi != _PROTOCOL_VERSION_HI: 241 | ver_lo = resp[0][1] 242 | print( 243 | "ERROR: Invalid protocol version. " 244 | + f"Expected {_PROTOCOL_VERSION_HI}.{_PROTOCOL_VERSION_LO}, got: {ver_hi}.{ver_lo}" 245 | ) 246 | return False 247 | return True 248 | -------------------------------------------------------------------------------- /bluepad32/gamepad.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 - 2023, Ricardo Quesada, http://retro.moe 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | # Bluepad32 support for CircuitPython. 5 | # Requires the Bluepad32 firmware (instead of Nina-fw). 6 | 7 | """ 8 | `bluepad32_gamepad` 9 | ================================================================================ 10 | 11 | Gamepad abstraction used for Bluepad32 12 | 13 | 14 | * Author(s): Ricardo Quesada 15 | 16 | Implementation Notes 17 | -------------------- 18 | 19 | **Hardware:** 20 | 21 | **Software and Dependencies:** 22 | 23 | .. todo:: Add links to any specific hardware product page(s), or category page(s). 24 | Use unordered list & hyperlink rST inline format: "* `Link Text `_" 25 | 26 | * Adafruit ESP32SPI: https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI 27 | """ 28 | 29 | # imports 30 | from micropython import const 31 | 32 | __version__ = "0.0.0-auto.0" 33 | __repo__ = "https://gitlab.com/ricardoquesada/bluepad32-circuitpython.git" 34 | 35 | # DPAD constants. 36 | DPAD_UP = const(1 << 0) 37 | DPAD_DOWN = const(1 << 1) 38 | DPAD_RIGHT = const(1 << 2) 39 | DPAD_LEFT = const(1 << 3) 40 | 41 | # Regular gamepad buttons. 42 | BUTTON_A = const(1 << 0) 43 | BUTTON_B = const(1 << 1) 44 | BUTTON_X = const(1 << 2) 45 | BUTTON_Y = const(1 << 3) 46 | BUTTON_L1 = const(1 << 4) 47 | BUTTON_R1 = const(1 << 5) 48 | BUTTON_L2 = const(1 << 6) 49 | BUTTON_R2 = const(1 << 7) 50 | BUTTON_THUMB_L = const(1 << 8) 51 | BUTTON_THUMB_R = const(1 << 9) 52 | 53 | 54 | # MISC_BUTTONS_ are buttons that are usually not used in the game, but are 55 | # helpers like "back", "home", etc. 56 | MISC_BUTTON_SYSTEM = const(1 << 0) # AKA: PS, Xbox, etc. 57 | MISC_BUTTON_BACK = const(1 << 1) # AKA: Select, Share, - 58 | MISC_BUTTON_HOME = const(1 << 2) # AKA: Start, Options, + 59 | 60 | 61 | class Gamepad: # pylint: disable=too-many-public-methods 62 | """Implement gamepad abstraction""" 63 | 64 | def __init__(self, bp32, idx: int, state: dict): 65 | self._state = state 66 | self._bp32 = bp32 67 | self._idx = idx 68 | 69 | def set_player_leds(self, leds: int) -> bool: 70 | """ 71 | Set the gamepad's player LEDs. 72 | 73 | Some gamepads have 4 LEDs that are used to indicate, among other things, 74 | the "player number". 75 | 76 | Applicable only to gamepads that have a player's LEDs like Nintendo Wii, 77 | Nintendo Switch, etc. 78 | 79 | :param int leds: Only the 4 LSB bits are used. Each bit indicates a LED. 80 | :return: True if the request was successful, False otherwise. 81 | """ 82 | return self._bp32.set_gamepad_player_leds(self._idx, leds) 83 | 84 | def set_lightbar_color(self, rgb) -> bool: 85 | """ 86 | Set the gamepad's lightbar color. 87 | 88 | Applicable only to gamepads that have a color LED like the Sony 89 | DualShok 4 or DualSense. 90 | 91 | :param tuple[int, int, int] rgb: Red,Green,Blue values to set. 92 | :return: True if the request was successful, False otherwise. 93 | """ 94 | return self._bp32.set_gamepad_lightbar_color(self._idx, rgb) 95 | 96 | def set_rumble(self, force: int, duration: int) -> bool: 97 | """ 98 | Set the gamepad's rumble (AKA force-feedback). 99 | 100 | Applicable only to gamepads that have rumble support, like Xbox One, 101 | DualShok 4, Nintendo Switch, etc. 102 | 103 | :param int force: 8-bit value where 255 is max force, 0 nothing. 104 | :param int duration: 8-bit value, where 255 is about 1 second. 105 | :return: True if the request was successful, False otherwise. 106 | """ 107 | return self._bp32.set_gamepad_rumble(self._idx, force, duration) 108 | 109 | def set_state(self, state): 110 | """Set the gamepad state""" 111 | self._state = state 112 | 113 | @property 114 | def buttons(self) -> int: 115 | """Return the a bitmaks that represents the buttons state""" 116 | return self._state["buttons"] 117 | 118 | @property 119 | def misc_buttons(self) -> int: 120 | """Return the a bitmaks that represents the 'misc buttons' state""" 121 | return self._state["misc_buttons"] 122 | 123 | @property 124 | def axis_x(self) -> int: 125 | """Return the value of Axis X. 126 | 127 | Value goes from -511 to 512. 128 | """ 129 | return self._state["axis_x"] 130 | 131 | @property 132 | def axis_y(self) -> int: 133 | """Return the value of Axis Y. 134 | 135 | Value goes from -511 to 512. 136 | """ 137 | return self._state["axis_y"] 138 | 139 | @property 140 | def axis_rx(self) -> int: 141 | """Return the value of the right Axis X. 142 | 143 | Value goes from -511 to 512. 144 | """ 145 | return self._state["axis_rx"] 146 | 147 | @property 148 | def axis_ry(self) -> int: 149 | """Return the value of the right Axis Y. 150 | 151 | Value goes from -511 to 512. 152 | """ 153 | return self._state["axis_ry"] 154 | 155 | @property 156 | def brake(self) -> int: 157 | """Return the value of the Brake. 158 | 159 | Value goes from 0 to 1023. 160 | """ 161 | return self._state["brake"] 162 | 163 | @property 164 | def throttle(self) -> int: 165 | """Return the value of the Throttle. 166 | 167 | Value goes from 0 to 1023. 168 | """ 169 | return self._state["throttle"] 170 | 171 | @property 172 | def gyro_x(self) -> int: 173 | """Return the value of Gyroscope X. 174 | 175 | Value goes from -511 to 512. 176 | """ 177 | return self._state["gyro_x"] 178 | 179 | @property 180 | def gyro_y(self) -> int: 181 | """Return the value of Gyroscope Y. 182 | 183 | Value goes from -511 to 512. 184 | """ 185 | return self._state["gyro_y"] 186 | 187 | @property 188 | def gyro_z(self) -> int: 189 | """Return the value of Gyroscope Z. 190 | 191 | Value goes from -511 to 512. 192 | """ 193 | return self._state["gyro_z"] 194 | 195 | @property 196 | def accel_x(self) -> int: 197 | """Return the value of Accelerometer X. 198 | 199 | Value goes from -511 to 512. 200 | """ 201 | return self._state["accel_x"] 202 | 203 | @property 204 | def accel_y(self) -> int: 205 | """Return the value of Accelerometer Y. 206 | 207 | Value goes from -511 to 512. 208 | """ 209 | return self._state["accel_y"] 210 | 211 | @property 212 | def accel_z(self) -> int: 213 | """Return the value of Accelerometer Z. 214 | 215 | Value goes from -511 to 512. 216 | """ 217 | return self._state["accel_z"] 218 | 219 | @property 220 | def dpad(self) -> int: 221 | """Return the DPAD state""" 222 | return self._state["dpad"] 223 | 224 | @property 225 | def button_a(self) -> int: 226 | """Return whether button A is pressed""" 227 | return self._state["buttons"] & BUTTON_A 228 | 229 | @property 230 | def button_b(self) -> int: 231 | """Return whether button B is pressed""" 232 | return self._state["buttons"] & BUTTON_B 233 | 234 | @property 235 | def button_x(self) -> int: 236 | """Return whether button X is pressed""" 237 | return self._state["buttons"] & BUTTON_X 238 | 239 | @property 240 | def button_y(self) -> int: 241 | """Return whether button Y is pressed""" 242 | return self._state["buttons"] & BUTTON_Y 243 | 244 | @property 245 | def button_l1(self) -> int: 246 | """Return whether button L1 is pressed""" 247 | return self._state["buttons"] & BUTTON_L1 248 | 249 | @property 250 | def button_l2(self) -> int: 251 | """Return whether button L2 is pressed""" 252 | return self._state["buttons"] & BUTTON_L2 253 | 254 | @property 255 | def button_r1(self) -> int: 256 | """Return whether button R1 is pressed""" 257 | return self._state["buttons"] & BUTTON_R1 258 | 259 | @property 260 | def button_r2(self) -> int: 261 | """Return whether button R2 is pressed""" 262 | return self._state["buttons"] & BUTTON_R2 263 | 264 | @property 265 | def button_thumb_l(self) -> int: 266 | """Return whether left thumb buttons is pressed""" 267 | return self._state["buttons"] & BUTTON_THUMB_L 268 | 269 | @property 270 | def button_thumb_r(self) -> int: 271 | """Return whether right thumb buttons is pressed""" 272 | return self._state["buttons"] & BUTTON_THUMB_R 273 | 274 | @property 275 | def type(self) -> int: 276 | """Return the gamepad type (AKA model)""" 277 | return self._state["type"] 278 | 279 | def __str__(self): 280 | return self._state 281 | -------------------------------------------------------------------------------- /examples/bluepad32_simpletest.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 - 2023, Ricardo Quesada, http://retro.moe 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import time 5 | 6 | import board 7 | import busio 8 | from digitalio import DigitalInOut 9 | 10 | from bluepad32.bluepad32 import Bluepad32 11 | 12 | # Connected gamepad 13 | gamepad = None 14 | 15 | 16 | # Callback that will be called once a gamepad is connected 17 | def on_connect(gp): 18 | global gamepad # pylint: disable=global-statement 19 | gamepad = gp 20 | 21 | print("on_connect: ", gp) 22 | # Change ligthbar to Green: Red, Green, Blue 23 | gp.set_lightbar_color((0x00, 0xFF, 0x00)) 24 | 25 | 26 | # Callback that will be called when a gamepad is disconnected 27 | def on_disconnect(gp): 28 | global gamepad # pylint: disable=global-statement 29 | gamepad = None 30 | print("on_disconnect: ", gp) 31 | 32 | 33 | # If you are using a board with pre-defined ESP32 Pins: 34 | esp32_cs = DigitalInOut(board.ESP_CS) 35 | esp32_ready = DigitalInOut(board.ESP_BUSY) 36 | esp32_reset = DigitalInOut(board.ESP_RESET) 37 | 38 | # If you have an AirLift Shield: 39 | # esp32_cs = DigitalInOut(board.D10) 40 | # esp32_ready = DigitalInOut(board.D7) 41 | # esp32_reset = DigitalInOut(board.D5) 42 | 43 | # If you have an AirLift Featherwing or ItsyBitsy Airlift: 44 | # esp32_cs = DigitalInOut(board.D13) 45 | # esp32_ready = DigitalInOut(board.D11) 46 | # esp32_reset = DigitalInOut(board.D12) 47 | 48 | # If you have an externally connected ESP32: 49 | # NOTE: You may need to change the pins to reflect your wiring 50 | # esp32_cs = DigitalInOut(board.D10) 51 | # esp32_ready = DigitalInOut(board.D9) 52 | # esp32_reset = DigitalInOut(board.D6) 53 | 54 | # For Arduino Nano RP2040 Connect the pins will be: 55 | # esp32_cs = DigitalInOut(board.CS1) 56 | # spi = busio.SPI(board.SCK1, board.MOSI1, board.MISO1) 57 | 58 | spi = busio.SPI(board.SCK, board.MOSI, board.MISO) 59 | bp32 = Bluepad32(spi, esp32_cs, esp32_ready, esp32_reset, debug=0) 60 | bp32.setup_callbacks(on_connect, on_disconnect) 61 | 62 | # Should display "Bluepad32 for Airlift vXXX" 63 | print("Firmware version:", bp32.firmware_version) 64 | print("BT addr:", [hex(i) for i in bp32.MAC_address]) 65 | 66 | color = [0xFF, 0x00, 0x00] 67 | players_led = 0x01 68 | enable_bt_connections = False 69 | 70 | while True: 71 | # Fetches data from Bluepad32 firmware, triggers callbaks, and more. 72 | # Must be called once per frame. 73 | bp32.update() 74 | 75 | if gamepad is None: 76 | continue 77 | 78 | if gamepad.button_a: # button A pressed ? 79 | # Shuffle colors. "random.shuffle" not preset in CircuitPython 80 | color = (color[2], color[0], color[1]) 81 | gamepad.set_lightbar_color(color) 82 | # Quick hack: prevent pressing it multiple times 83 | time.sleep(0.2) 84 | 85 | if gamepad.button_b: # Button B pressed ? 86 | gamepad.set_player_leds(players_led) 87 | players_led += 1 88 | players_led &= 0x0F 89 | # Quick hack: prevent pressing it multiple times 90 | time.sleep(0.2) 91 | 92 | if gamepad.button_x: # Button X pressed ? 93 | force = 128 # 0-255 94 | duration = 10 # 0-255 95 | gamepad.set_rumble(force, duration) 96 | 97 | if gamepad.button_y: # Button Y pressed ? 98 | bp32.enable_bluetooth_connections(enable_bt_connections) 99 | msg = "enabled" if enable_bt_connections else "disabled" 100 | print(f"Bluetooth connections are {msg}") 101 | 102 | enable_bt_connections = not enable_bt_connections 103 | # Quick hack: prevent pressing it multiple times 104 | time.sleep(0.2) 105 | print(gamepad) 106 | 107 | time.sleep(0.032) 108 | -------------------------------------------------------------------------------- /img/bluepad32-circuitpython-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardoquesada/bluepad32-circuitpython/19c0a9545998771f59c561ec796eec50925ab702/img/bluepad32-circuitpython-logo.png -------------------------------------------------------------------------------- /img/bluepad32-circuitpython-logo.png.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: CC-BY-4.0 2 | SPDX-FileCopyrightText: Adafruit/CircuitPython authors (?) 3 | -------------------------------------------------------------------------------- /img/bluepad32-how-does-it-work.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardoquesada/bluepad32-circuitpython/19c0a9545998771f59c561ec796eec50925ab702/img/bluepad32-how-does-it-work.png -------------------------------------------------------------------------------- /img/bluepad32-how-does-it-work.png.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: CC-BY-4.0 2 | SPDX-FileCopyrightText: Adafruit/CircuitPython authors (?) 3 | -------------------------------------------------------------------------------- /img/bluepad32-how-does-it-work.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardoquesada/bluepad32-circuitpython/19c0a9545998771f59c561ec796eec50925ab702/img/bluepad32-how-does-it-work.xcf -------------------------------------------------------------------------------- /img/bluepad32-how-does-it-work.xcf.license: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: CC-BY-4.0 2 | SPDX-FileCopyrightText: Adafruit/CircuitPython authors (?) 3 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2020 Diego Elio Pettenò 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | [tool.black] 6 | target-version = ['py35'] 7 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # SPDX-FileCopyrightText: Copyright (c) 2021 Ricardo Quesada 3 | # 4 | # SPDX-License-Identifier: MIT 5 | 6 | Adafruit-Blinka 7 | adafruit-circuitpython-esp32spi 8 | -------------------------------------------------------------------------------- /setup.py.disabled: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # SPDX-FileCopyrightText: Copyright (c) 2021 Ricardo Quesada 3 | # 4 | # SPDX-License-Identifier: MIT 5 | 6 | """ 7 | This library is not deployed to PyPI. It is either a board-specific helper library, or 8 | does not make sense for use on or is incompatible with single board computers and Linux. 9 | """ 10 | --------------------------------------------------------------------------------