├── .github ├── PULL_REQUEST_TEMPLATE │ └── adafruit_circuitpython_pr.md └── workflows │ ├── build.yml │ ├── failure-help-text.yml │ ├── release_gh.yml │ └── release_pypi.yml ├── .gitignore ├── .pre-commit-config.yaml ├── .pylintrc ├── .readthedocs.yaml ├── CODE_OF_CONDUCT.md ├── LICENSE ├── LICENSES ├── CC-BY-4.0.txt ├── MIT.txt └── Unlicense.txt ├── README.rst ├── README.rst.license ├── docs ├── _static │ ├── favicon.ico │ └── favicon.ico.license ├── api.rst ├── api.rst.license ├── conf.py ├── examples.rst ├── examples.rst.license ├── index.rst ├── index.rst.license └── requirements.txt ├── examples ├── microosc_simplesend.py ├── microosc_simplesend_cpython.py ├── microosc_simpletest.py └── microosc_simpletest_cpython.py ├── microosc.py ├── optional_requirements.txt ├── pyproject.toml └── requirements.txt /.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | Thank you for contributing! Before you submit a pull request, please read the following. 6 | 7 | Make sure any changes you're submitting are in line with the CircuitPython Design Guide, available here: https://docs.circuitpython.org/en/latest/docs/design_guide.html 8 | 9 | If your changes are to documentation, please verify that the documentation builds locally by following the steps found here: https://adafru.it/build-docs 10 | 11 | Before submitting the pull request, make sure you've run Pylint and Black locally on your code. You can do this manually or using pre-commit. Instructions are available here: https://adafru.it/check-your-code 12 | 13 | Please remove all of this text before submitting. Include an explanation or list of changes included in your PR, as well as, if applicable, a link to any related issues. 14 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | name: Build CI 6 | 7 | on: [pull_request, push] 8 | 9 | jobs: 10 | test: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Run Build CI workflow 14 | uses: adafruit/workflows-circuitpython-libs/build@main 15 | -------------------------------------------------------------------------------- /.github/workflows/failure-help-text.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Scott Shawcroft for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | name: Failure help text 6 | 7 | on: 8 | workflow_run: 9 | workflows: ["Build CI"] 10 | types: 11 | - completed 12 | 13 | jobs: 14 | post-help: 15 | runs-on: ubuntu-latest 16 | if: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.event == 'pull_request' }} 17 | steps: 18 | - name: Post comment to help 19 | uses: adafruit/circuitpython-action-library-ci-failed@v1 20 | -------------------------------------------------------------------------------- /.github/workflows/release_gh.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | name: GitHub Release Actions 6 | 7 | on: 8 | release: 9 | types: [published] 10 | 11 | jobs: 12 | upload-release-assets: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Run GitHub Release CI workflow 16 | uses: adafruit/workflows-circuitpython-libs/release-gh@main 17 | with: 18 | github-token: ${{ secrets.GITHUB_TOKEN }} 19 | upload-url: ${{ github.event.release.upload_url }} 20 | # TODO: If you're creating a package (library is a folder), add this 21 | # argument along with the prefix (or full name) of the package folder 22 | # so the MPY bundles are built correctly:s 23 | # package-prefix: microosc 24 | -------------------------------------------------------------------------------- /.github/workflows/release_pypi.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | name: PyPI Release Actions 6 | 7 | on: 8 | release: 9 | types: [published] 10 | 11 | jobs: 12 | upload-release-assets: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Run PyPI Release CI workflow 16 | uses: adafruit/workflows-circuitpython-libs/release-pypi@main 17 | with: 18 | pypi-username: ${{ secrets.pypi_username }} 19 | pypi-password: ${{ secrets.pypi_password }} 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Kattni Rembor, written for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | # Do not include files and directories created by your personal work environment, such as the IDE 6 | # you use, except for those already listed here. Pull requests including changes to this file will 7 | # not be accepted. 8 | 9 | # This .gitignore file contains rules for files generated by working with CircuitPython libraries, 10 | # including building Sphinx, testing with pip, and creating a virual environment, as well as the 11 | # MacOS and IDE-specific files generated by using MacOS in general, or the PyCharm or VSCode IDEs. 12 | 13 | # If you find that there are files being generated on your machine that should not be included in 14 | # your git commit, you should create a .gitignore_global file on your computer to include the 15 | # files created by your personal setup. To do so, follow the two steps below. 16 | 17 | # First, create a file called .gitignore_global somewhere convenient for you, and add rules for 18 | # the files you want to exclude from git commits. 19 | 20 | # Second, configure Git to use the exclude file for all Git repositories by running the 21 | # following via commandline, replacing "path/to/your/" with the actual path to your newly created 22 | # .gitignore_global file: 23 | # git config --global core.excludesfile path/to/your/.gitignore_global 24 | 25 | # CircuitPython-specific files 26 | *.mpy 27 | 28 | # Python-specific files 29 | __pycache__ 30 | *.pyc 31 | 32 | # Sphinx build-specific files 33 | _build 34 | 35 | # This file results from running `pip -e install .` in a local repository 36 | *.egg-info 37 | 38 | # Virtual environment-specific files 39 | .env 40 | .venv 41 | 42 | # MacOS-specific files 43 | *.DS_Store 44 | 45 | # IDE-specific files 46 | .idea 47 | .vscode 48 | *~ 49 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2020 Diego Elio Pettenò 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | repos: 6 | - repo: https://github.com/python/black 7 | rev: 23.3.0 8 | hooks: 9 | - id: black 10 | - repo: https://github.com/fsfe/reuse-tool 11 | rev: v1.1.2 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: v2.17.4 22 | hooks: 23 | - id: pylint 24 | name: pylint (library code) 25 | types: [python] 26 | args: 27 | - --disable=consider-using-f-string 28 | exclude: "^(docs/|examples/|tests/|setup.py$)" 29 | - id: pylint 30 | name: pylint (example code) 31 | description: Run pylint rules on "examples/*.py" files 32 | types: [python] 33 | files: "^examples/" 34 | args: 35 | - --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code 36 | - id: pylint 37 | name: pylint (test code) 38 | description: Run pylint rules on "tests/*.py" files 39 | types: [python] 40 | files: "^tests/" 41 | args: 42 | - --disable=missing-docstring,consider-using-f-string,duplicate-code 43 | -------------------------------------------------------------------------------- /.pylintrc: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written 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 ignore-list. They should be base names, not 13 | # paths. 14 | ignore=CVS 15 | 16 | # Add files or directories matching the regex patterns to the ignore-list. 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 | 27 | # List of plugins (as comma separated values of python modules names) to load, 28 | # usually to register additional checkers. 29 | load-plugins=pylint.extensions.no_self_use 30 | 31 | # Pickle collected data for later comparisons. 32 | persistent=yes 33 | 34 | # Specify a configuration file. 35 | #rcfile= 36 | 37 | # Allow loading of arbitrary C extensions. Extensions are imported into the 38 | # active Python interpreter and may run arbitrary code. 39 | unsafe-load-any-extension=no 40 | 41 | 42 | [MESSAGES CONTROL] 43 | 44 | # Only show warnings with the listed confidence levels. Leave empty to show 45 | # all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED 46 | confidence= 47 | 48 | # Disable the message, report, category or checker with the given id(s). You 49 | # can either give multiple identifiers separated by comma (,) or put this 50 | # option multiple times (only on the command line, not in the configuration 51 | # file where it should appear only once).You can also use "--disable=all" to 52 | # disable everything first and then reenable specific checks. For example, if 53 | # you want to run only the similarities checker, you can use "--disable=all 54 | # --enable=similarities". If you want to run only the classes checker, but have 55 | # no Warning level messages displayed, use"--disable=all --enable=classes 56 | # --disable=W" 57 | # disable=import-error,raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,deprecated-str-translate-call 58 | disable=raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,import-error,pointless-string-statement,unspecified-encoding 59 | 60 | # Enable the message, report, category or checker with the given id(s). You can 61 | # either give multiple identifier separated by comma (,) or put this option 62 | # multiple time (only on the command line, not in the configuration file where 63 | # it should appear only once). See also the "--disable" option for examples. 64 | enable= 65 | 66 | 67 | [REPORTS] 68 | 69 | # Python expression which should return a note less than 10 (10 is the highest 70 | # note). You have access to the variables errors warning, statement which 71 | # respectively contain the number of errors / warnings messages and the total 72 | # number of statements analyzed. This is used by the global evaluation report 73 | # (RP0004). 74 | evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) 75 | 76 | # Template used to display messages. This is a python new-style format string 77 | # used to format the message information. See doc for all details 78 | #msg-template= 79 | 80 | # Set the output format. Available formats are text, parseable, colorized, json 81 | # and msvs (visual studio).You can also give a reporter class, eg 82 | # mypackage.mymodule.MyReporterClass. 83 | output-format=text 84 | 85 | # Tells whether to display a full report or only the messages 86 | reports=no 87 | 88 | # Activate the evaluation score. 89 | score=yes 90 | 91 | 92 | [REFACTORING] 93 | 94 | # Maximum number of nested blocks for function / method body 95 | max-nested-blocks=5 96 | 97 | 98 | [LOGGING] 99 | 100 | # Logging modules to check that the string format arguments are in logging 101 | # function parameter format 102 | logging-modules=logging 103 | 104 | 105 | [SPELLING] 106 | 107 | # Spelling dictionary name. Available dictionaries: none. To make it working 108 | # install python-enchant package. 109 | spelling-dict= 110 | 111 | # List of comma separated words that should not be checked. 112 | spelling-ignore-words= 113 | 114 | # A path to a file that contains private dictionary; one word per line. 115 | spelling-private-dict-file= 116 | 117 | # Tells whether to store unknown words to indicated private dictionary in 118 | # --spelling-private-dict-file option instead of raising a message. 119 | spelling-store-unknown-words=no 120 | 121 | 122 | [MISCELLANEOUS] 123 | 124 | # List of note tags to take in consideration, separated by a comma. 125 | # notes=FIXME,XXX,TODO 126 | notes=FIXME,XXX 127 | 128 | 129 | [TYPECHECK] 130 | 131 | # List of decorators that produce context managers, such as 132 | # contextlib.contextmanager. Add to this list to register other decorators that 133 | # produce valid context managers. 134 | contextmanager-decorators=contextlib.contextmanager 135 | 136 | # List of members which are set dynamically and missed by pylint inference 137 | # system, and so shouldn't trigger E1101 when accessed. Python regular 138 | # expressions are accepted. 139 | generated-members= 140 | 141 | # Tells whether missing members accessed in mixin class should be ignored. A 142 | # mixin class is detected if its name ends with "mixin" (case insensitive). 143 | ignore-mixin-members=yes 144 | 145 | # This flag controls whether pylint should warn about no-member and similar 146 | # checks whenever an opaque object is returned when inferring. The inference 147 | # can return multiple potential results while evaluating a Python object, but 148 | # some branches might not be evaluated, which results in partial inference. In 149 | # that case, it might be useful to still emit no-member and other checks for 150 | # the rest of the inferred objects. 151 | ignore-on-opaque-inference=yes 152 | 153 | # List of class names for which member attributes should not be checked (useful 154 | # for classes with dynamically set attributes). This supports the use of 155 | # qualified names. 156 | ignored-classes=optparse.Values,thread._local,_thread._local 157 | 158 | # List of module names for which member attributes should not be checked 159 | # (useful for modules/projects where namespaces are manipulated during runtime 160 | # and thus existing member attributes cannot be deduced by static analysis. It 161 | # supports qualified module names, as well as Unix pattern matching. 162 | ignored-modules=board 163 | 164 | # Show a hint with possible names when a member name was not found. The aspect 165 | # of finding the hint is based on edit distance. 166 | missing-member-hint=yes 167 | 168 | # The minimum edit distance a name should have in order to be considered a 169 | # similar match for a missing member name. 170 | missing-member-hint-distance=1 171 | 172 | # The total number of similar names that should be taken in consideration when 173 | # showing a hint for a missing member. 174 | missing-member-max-choices=1 175 | 176 | 177 | [VARIABLES] 178 | 179 | # List of additional names supposed to be defined in builtins. Remember that 180 | # you should avoid to define new builtins when possible. 181 | additional-builtins= 182 | 183 | # Tells whether unused global variables should be treated as a violation. 184 | allow-global-unused-variables=yes 185 | 186 | # List of strings which can identify a callback function by name. A callback 187 | # name must start or end with one of those strings. 188 | callbacks=cb_,_cb 189 | 190 | # A regular expression matching the name of dummy variables (i.e. expectedly 191 | # not used). 192 | dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ 193 | 194 | # Argument names that match this expression will be ignored. Default to name 195 | # with leading underscore 196 | ignored-argument-names=_.*|^ignored_|^unused_ 197 | 198 | # Tells whether we should check for unused import in __init__ files. 199 | init-import=no 200 | 201 | # List of qualified module names which can have objects that can redefine 202 | # builtins. 203 | redefining-builtins-modules=six.moves,future.builtins 204 | 205 | 206 | [FORMAT] 207 | 208 | # Expected format of line ending, e.g. empty (any line ending), LF or CRLF. 209 | # expected-line-ending-format= 210 | expected-line-ending-format=LF 211 | 212 | # Regexp for a line that is allowed to be longer than the limit. 213 | ignore-long-lines=^\s*(# )??$ 214 | 215 | # Number of spaces of indent required inside a hanging or continued line. 216 | indent-after-paren=4 217 | 218 | # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 219 | # tab). 220 | indent-string=' ' 221 | 222 | # Maximum number of characters on a single line. 223 | max-line-length=100 224 | 225 | # Maximum number of lines in a module 226 | max-module-lines=1000 227 | 228 | # Allow the body of a class to be on the same line as the declaration if body 229 | # contains single statement. 230 | single-line-class-stmt=no 231 | 232 | # Allow the body of an if to be on the same line as the test if there is no 233 | # else. 234 | single-line-if-stmt=no 235 | 236 | 237 | [SIMILARITIES] 238 | 239 | # Ignore comments when computing similarities. 240 | ignore-comments=yes 241 | 242 | # Ignore docstrings when computing similarities. 243 | ignore-docstrings=yes 244 | 245 | # Ignore imports when computing similarities. 246 | ignore-imports=yes 247 | 248 | # Minimum lines number of a similarity. 249 | min-similarity-lines=12 250 | 251 | 252 | [BASIC] 253 | 254 | # Regular expression matching correct argument names 255 | argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ 256 | 257 | # Regular expression matching correct attribute names 258 | attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ 259 | 260 | # Bad variable names which should always be refused, separated by a comma 261 | bad-names=foo,bar,baz,toto,tutu,tata 262 | 263 | # Regular expression matching correct class attribute names 264 | class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ 265 | 266 | # Regular expression matching correct class names 267 | # class-rgx=[A-Z_][a-zA-Z0-9]+$ 268 | class-rgx=[A-Z_][a-zA-Z0-9_]+$ 269 | 270 | # Regular expression matching correct constant names 271 | const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ 272 | 273 | # Minimum line length for functions/classes that require docstrings, shorter 274 | # ones are exempt. 275 | docstring-min-length=-1 276 | 277 | # Regular expression matching correct function names 278 | function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ 279 | 280 | # Good variable names which should always be accepted, separated by a comma 281 | # good-names=i,j,k,ex,Run,_ 282 | good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_ 283 | 284 | # Include a hint for the correct naming format with invalid-name 285 | include-naming-hint=no 286 | 287 | # Regular expression matching correct inline iteration names 288 | inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ 289 | 290 | # Regular expression matching correct method names 291 | method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ 292 | 293 | # Regular expression matching correct module names 294 | module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ 295 | 296 | # Colon-delimited sets of names that determine each other's naming style when 297 | # the name regexes allow several styles. 298 | name-group= 299 | 300 | # Regular expression which should only match function or class names that do 301 | # not require a docstring. 302 | no-docstring-rgx=^_ 303 | 304 | # List of decorators that produce properties, such as abc.abstractproperty. Add 305 | # to this list to register other decorators that produce valid properties. 306 | property-classes=abc.abstractproperty 307 | 308 | # Regular expression matching correct variable names 309 | variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ 310 | 311 | 312 | [IMPORTS] 313 | 314 | # Allow wildcard imports from modules that define __all__. 315 | allow-wildcard-with-all=no 316 | 317 | # Analyse import fallback blocks. This can be used to support both Python 2 and 318 | # 3 compatible code, which means that the block might have code that exists 319 | # only in one or another interpreter, leading to false positives when analysed. 320 | analyse-fallback-blocks=no 321 | 322 | # Deprecated modules which should not be used, separated by a comma 323 | deprecated-modules=optparse,tkinter.tix 324 | 325 | # Create a graph of external dependencies in the given file (report RP0402 must 326 | # not be disabled) 327 | ext-import-graph= 328 | 329 | # Create a graph of every (i.e. internal and external) dependencies in the 330 | # given file (report RP0402 must not be disabled) 331 | import-graph= 332 | 333 | # Create a graph of internal dependencies in the given file (report RP0402 must 334 | # not be disabled) 335 | int-import-graph= 336 | 337 | # Force import order to recognize a module as part of the standard 338 | # compatibility libraries. 339 | known-standard-library= 340 | 341 | # Force import order to recognize a module as part of a third party library. 342 | known-third-party=enchant 343 | 344 | 345 | [CLASSES] 346 | 347 | # List of method names used to declare (i.e. assign) instance attributes. 348 | defining-attr-methods=__init__,__new__,setUp 349 | 350 | # List of member names, which should be excluded from the protected access 351 | # warning. 352 | exclude-protected=_asdict,_fields,_replace,_source,_make 353 | 354 | # List of valid names for the first argument in a class method. 355 | valid-classmethod-first-arg=cls 356 | 357 | # List of valid names for the first argument in a metaclass class method. 358 | valid-metaclass-classmethod-first-arg=mcs 359 | 360 | 361 | [DESIGN] 362 | 363 | # Maximum number of arguments for function / method 364 | max-args=5 365 | 366 | # Maximum number of attributes for a class (see R0902). 367 | # max-attributes=7 368 | max-attributes=11 369 | 370 | # Maximum number of boolean expressions in a if statement 371 | max-bool-expr=5 372 | 373 | # Maximum number of branch for function / method body 374 | max-branches=12 375 | 376 | # Maximum number of locals for function / method body 377 | max-locals=15 378 | 379 | # Maximum number of parents for a class (see R0901). 380 | max-parents=7 381 | 382 | # Maximum number of public methods for a class (see R0904). 383 | max-public-methods=20 384 | 385 | # Maximum number of return / yield for function / method body 386 | max-returns=6 387 | 388 | # Maximum number of statements in function / method body 389 | max-statements=50 390 | 391 | # Minimum number of public methods for a class (see R0903). 392 | min-public-methods=1 393 | 394 | 395 | [EXCEPTIONS] 396 | 397 | # Exceptions that will emit a warning when being caught. Defaults to 398 | # "Exception" 399 | overgeneral-exceptions=builtins.Exception 400 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | # Read the Docs configuration file 6 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 7 | 8 | # Required 9 | version: 2 10 | 11 | build: 12 | os: ubuntu-20.04 13 | tools: 14 | python: "3" 15 | 16 | python: 17 | install: 18 | - requirements: docs/requirements.txt 19 | - requirements: requirements.txt 20 | -------------------------------------------------------------------------------- /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 | The MIT License (MIT) 2 | 3 | Copyright (c) 2023 Tod Kurt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSES/CC-BY-4.0.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Attribution 4.0 International Creative Commons Corporation 2 | ("Creative Commons") is not a law firm and does not provide legal services 3 | or legal advice. Distribution of Creative Commons public licenses does not 4 | create a lawyer-client or other relationship. Creative Commons makes its licenses 5 | and related information available on an "as-is" basis. Creative Commons gives 6 | no warranties regarding its licenses, any material licensed under their terms 7 | and conditions, or any related information. Creative Commons disclaims all 8 | liability for damages resulting from their use to the fullest extent possible. 9 | 10 | Using Creative Commons Public Licenses 11 | 12 | Creative Commons public licenses provide a standard set of terms and conditions 13 | that creators and other rights holders may use to share original works of 14 | authorship and other material subject to copyright and certain other rights 15 | specified in the public license below. The following considerations are for 16 | informational purposes only, are not exhaustive, and do not form part of our 17 | licenses. 18 | 19 | Considerations for licensors: Our public licenses are intended for use by 20 | those authorized to give the public permission to use material in ways otherwise 21 | restricted by copyright and certain other rights. Our licenses are irrevocable. 22 | Licensors should read and understand the terms and conditions of the license 23 | they choose before applying it. Licensors should also secure all rights necessary 24 | before applying our licenses so that the public can reuse the material as 25 | expected. Licensors should clearly mark any material not subject to the license. 26 | This includes other CC-licensed material, or material used under an exception 27 | or limitation to copyright. More considerations for licensors : wiki.creativecommons.org/Considerations_for_licensors 28 | 29 | Considerations for the public: By using one of our public licenses, a licensor 30 | grants the public permission to use the licensed material under specified 31 | terms and conditions. If the licensor's permission is not necessary for any 32 | reason–for example, because of any applicable exception or limitation to copyright–then 33 | that use is not regulated by the license. Our licenses grant only permissions 34 | under copyright and certain other rights that a licensor has authority to 35 | grant. Use of the licensed material may still be restricted for other reasons, 36 | including because others have copyright or other rights in the material. A 37 | licensor may make special requests, such as asking that all changes be marked 38 | or described. Although not required by our licenses, you are encouraged to 39 | respect those requests where reasonable. More considerations for the public 40 | : wiki.creativecommons.org/Considerations_for_licensees Creative Commons Attribution 41 | 4.0 International Public License 42 | 43 | By exercising the Licensed Rights (defined below), You accept and agree to 44 | be bound by the terms and conditions of this Creative Commons Attribution 45 | 4.0 International Public License ("Public License"). To the extent this Public 46 | License may be interpreted as a contract, You are granted the Licensed Rights 47 | in consideration of Your acceptance of these terms and conditions, and the 48 | Licensor grants You such rights in consideration of benefits the Licensor 49 | receives from making the Licensed Material available under these terms and 50 | conditions. 51 | 52 | Section 1 – Definitions. 53 | 54 | a. Adapted Material means material subject to Copyright and Similar Rights 55 | that is derived from or based upon the Licensed Material and in which the 56 | Licensed Material is translated, altered, arranged, transformed, or otherwise 57 | modified in a manner requiring permission under the Copyright and Similar 58 | Rights held by the Licensor. For purposes of this Public License, where the 59 | Licensed Material is a musical work, performance, or sound recording, Adapted 60 | Material is always produced where the Licensed Material is synched in timed 61 | relation with a moving image. 62 | 63 | b. Adapter's License means the license You apply to Your Copyright and Similar 64 | Rights in Your contributions to Adapted Material in accordance with the terms 65 | and conditions of this Public License. 66 | 67 | c. Copyright and Similar Rights means copyright and/or similar rights closely 68 | related to copyright including, without limitation, performance, broadcast, 69 | sound recording, and Sui Generis Database Rights, without regard to how the 70 | rights are labeled or categorized. For purposes of this Public License, the 71 | rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. 72 | 73 | d. Effective Technological Measures means those measures that, in the absence 74 | of proper authority, may not be circumvented under laws fulfilling obligations 75 | under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, 76 | and/or similar international agreements. 77 | 78 | e. Exceptions and Limitations means fair use, fair dealing, and/or any other 79 | exception or limitation to Copyright and Similar Rights that applies to Your 80 | use of the Licensed Material. 81 | 82 | f. Licensed Material means the artistic or literary work, database, or other 83 | material to which the Licensor applied this Public License. 84 | 85 | g. Licensed Rights means the rights granted to You subject to the terms and 86 | conditions of this Public License, which are limited to all Copyright and 87 | Similar Rights that apply to Your use of the Licensed Material and that the 88 | Licensor has authority to license. 89 | 90 | h. Licensor means the individual(s) or entity(ies) granting rights under this 91 | Public License. 92 | 93 | i. Share means to provide material to the public by any means or process that 94 | requires permission under the Licensed Rights, such as reproduction, public 95 | display, public performance, distribution, dissemination, communication, or 96 | importation, and to make material available to the public including in ways 97 | that members of the public may access the material from a place and at a time 98 | individually chosen by them. 99 | 100 | j. Sui Generis Database Rights means rights other than copyright resulting 101 | from Directive 96/9/EC of the European Parliament and of the Council of 11 102 | March 1996 on the legal protection of databases, as amended and/or succeeded, 103 | as well as other essentially equivalent rights anywhere in the world. 104 | 105 | k. You means the individual or entity exercising the Licensed Rights under 106 | this Public License. Your has a corresponding meaning. 107 | 108 | Section 2 – Scope. 109 | 110 | a. License grant. 111 | 112 | 1. Subject to the terms and conditions of this Public License, the Licensor 113 | hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, 114 | irrevocable license to exercise the Licensed Rights in the Licensed Material 115 | to: 116 | 117 | A. reproduce and Share the Licensed Material, in whole or in part; and 118 | 119 | B. produce, reproduce, and Share Adapted Material. 120 | 121 | 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions 122 | and Limitations apply to Your use, this Public License does not apply, and 123 | You do not need to comply with its terms and conditions. 124 | 125 | 3. Term. The term of this Public License is specified in Section 6(a). 126 | 127 | 4. Media and formats; technical modifications allowed. The Licensor authorizes 128 | You to exercise the Licensed Rights in all media and formats whether now known 129 | or hereafter created, and to make technical modifications necessary to do 130 | so. The Licensor waives and/or agrees not to assert any right or authority 131 | to forbid You from making technical modifications necessary to exercise the 132 | Licensed Rights, including technical modifications necessary to circumvent 133 | Effective Technological Measures. For purposes of this Public License, simply 134 | making modifications authorized by this Section 2(a)(4) never produces Adapted 135 | Material. 136 | 137 | 5. Downstream recipients. 138 | 139 | A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed 140 | Material automatically receives an offer from the Licensor to exercise the 141 | Licensed Rights under the terms and conditions of this Public License. 142 | 143 | B. No downstream restrictions. You may not offer or impose any additional 144 | or different terms or conditions on, or apply any Effective Technological 145 | Measures to, the Licensed Material if doing so restricts exercise of the Licensed 146 | Rights by any recipient of the Licensed Material. 147 | 148 | 6. No endorsement. Nothing in this Public License constitutes or may be construed 149 | as permission to assert or imply that You are, or that Your use of the Licensed 150 | Material is, connected with, or sponsored, endorsed, or granted official status 151 | by, the Licensor or others designated to receive attribution as provided in 152 | Section 3(a)(1)(A)(i). 153 | 154 | b. Other rights. 155 | 156 | 1. Moral rights, such as the right of integrity, are not licensed under this 157 | Public License, nor are publicity, privacy, and/or other similar personality 158 | rights; however, to the extent possible, the Licensor waives and/or agrees 159 | not to assert any such rights held by the Licensor to the limited extent necessary 160 | to allow You to exercise the Licensed Rights, but not otherwise. 161 | 162 | 2. Patent and trademark rights are not licensed under this Public License. 163 | 164 | 3. To the extent possible, the Licensor waives any right to collect royalties 165 | from You for the exercise of the Licensed Rights, whether directly or through 166 | a collecting society under any voluntary or waivable statutory or compulsory 167 | licensing scheme. In all other cases the Licensor expressly reserves any right 168 | to collect such royalties. 169 | 170 | Section 3 – License Conditions. 171 | 172 | Your exercise of the Licensed Rights is expressly made subject to the following 173 | conditions. 174 | 175 | a. Attribution. 176 | 177 | 1. If You Share the Licensed Material (including in modified form), You must: 178 | 179 | A. retain the following if it is supplied by the Licensor with the Licensed 180 | Material: 181 | 182 | i. identification of the creator(s) of the Licensed Material and any others 183 | designated to receive attribution, in any reasonable manner requested by the 184 | Licensor (including by pseudonym if designated); 185 | 186 | ii. a copyright notice; 187 | 188 | iii. a notice that refers to this Public License; 189 | 190 | iv. a notice that refers to the disclaimer of warranties; 191 | 192 | v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; 193 | 194 | B. indicate if You modified the Licensed Material and retain an indication 195 | of any previous modifications; and 196 | 197 | C. indicate the Licensed Material is licensed under this Public License, and 198 | include the text of, or the URI or hyperlink to, this Public License. 199 | 200 | 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner 201 | based on the medium, means, and context in which You Share the Licensed Material. 202 | For example, it may be reasonable to satisfy the conditions by providing a 203 | URI or hyperlink to a resource that includes the required information. 204 | 205 | 3. If requested by the Licensor, You must remove any of the information required 206 | by Section 3(a)(1)(A) to the extent reasonably practicable. 207 | 208 | 4. If You Share Adapted Material You produce, the Adapter's License You apply 209 | must not prevent recipients of the Adapted Material from complying with this 210 | Public License. 211 | 212 | Section 4 – Sui Generis Database Rights. 213 | 214 | Where the Licensed Rights include Sui Generis Database Rights that apply to 215 | Your use of the Licensed Material: 216 | 217 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, 218 | reuse, reproduce, and Share all or a substantial portion of the contents of 219 | the database; 220 | 221 | b. if You include all or a substantial portion of the database contents in 222 | a database in which You have Sui Generis Database Rights, then the database 223 | in which You have Sui Generis Database Rights (but not its individual contents) 224 | is Adapted Material; and 225 | 226 | c. You must comply with the conditions in Section 3(a) if You Share all or 227 | a substantial portion of the contents of the database. 228 | 229 | For the avoidance of doubt, this Section 4 supplements and does not replace 230 | Your obligations under this Public License where the Licensed Rights include 231 | other Copyright and Similar Rights. 232 | 233 | Section 5 – Disclaimer of Warranties and Limitation of Liability. 234 | 235 | a. Unless otherwise separately undertaken by the Licensor, to the extent possible, 236 | the Licensor offers the Licensed Material as-is and as-available, and makes 237 | no representations or warranties of any kind concerning the Licensed Material, 238 | whether express, implied, statutory, or other. This includes, without limitation, 239 | warranties of title, merchantability, fitness for a particular purpose, non-infringement, 240 | absence of latent or other defects, accuracy, or the presence or absence of 241 | errors, whether or not known or discoverable. Where disclaimers of warranties 242 | are not allowed in full or in part, this disclaimer may not apply to You. 243 | 244 | b. To the extent possible, in no event will the Licensor be liable to You 245 | on any legal theory (including, without limitation, negligence) or otherwise 246 | for any direct, special, indirect, incidental, consequential, punitive, exemplary, 247 | or other losses, costs, expenses, or damages arising out of this Public License 248 | or use of the Licensed Material, even if the Licensor has been advised of 249 | the possibility of such losses, costs, expenses, or damages. Where a limitation 250 | of liability is not allowed in full or in part, this limitation may not apply 251 | to You. 252 | 253 | c. The disclaimer of warranties and limitation of liability provided above 254 | shall be interpreted in a manner that, to the extent possible, most closely 255 | approximates an absolute disclaimer and waiver of all liability. 256 | 257 | Section 6 – Term and Termination. 258 | 259 | a. This Public License applies for the term of the Copyright and Similar Rights 260 | licensed here. However, if You fail to comply with this Public License, then 261 | Your rights under this Public License terminate automatically. 262 | 263 | b. Where Your right to use the Licensed Material has terminated under Section 264 | 6(a), it reinstates: 265 | 266 | 1. automatically as of the date the violation is cured, provided it is cured 267 | within 30 days of Your discovery of the violation; or 268 | 269 | 2. upon express reinstatement by the Licensor. 270 | 271 | c. For the avoidance of doubt, this Section 6(b) does not affect any right 272 | the Licensor may have to seek remedies for Your violations of this Public 273 | License. 274 | 275 | d. For the avoidance of doubt, the Licensor may also offer the Licensed Material 276 | under separate terms or conditions or stop distributing the Licensed Material 277 | at any time; however, doing so will not terminate this Public License. 278 | 279 | e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. 280 | 281 | Section 7 – Other Terms and Conditions. 282 | 283 | a. The Licensor shall not be bound by any additional or different terms or 284 | conditions communicated by You unless expressly agreed. 285 | 286 | b. Any arrangements, understandings, or agreements regarding the Licensed 287 | Material not stated herein are separate from and independent of the terms 288 | and conditions of this Public License. 289 | 290 | Section 8 – Interpretation. 291 | 292 | a. For the avoidance of doubt, this Public License does not, and shall not 293 | be interpreted to, reduce, limit, restrict, or impose conditions on any use 294 | of the Licensed Material that could lawfully be made without permission under 295 | this Public License. 296 | 297 | b. To the extent possible, if any provision of this Public License is deemed 298 | unenforceable, it shall be automatically reformed to the minimum extent necessary 299 | to make it enforceable. If the provision cannot be reformed, it shall be severed 300 | from this Public License without affecting the enforceability of the remaining 301 | terms and conditions. 302 | 303 | c. No term or condition of this Public License will be waived and no failure 304 | to comply consented to unless expressly agreed to by the Licensor. 305 | 306 | d. Nothing in this Public License constitutes or may be interpreted as a limitation 307 | upon, or waiver of, any privileges and immunities that apply to the Licensor 308 | or You, including from the legal processes of any jurisdiction or authority. 309 | 310 | Creative Commons is not a party to its public licenses. Notwithstanding, Creative 311 | Commons may elect to apply one of its public licenses to material it publishes 312 | and in those instances will be considered the "Licensor." The text of the 313 | Creative Commons public licenses is dedicated to the public domain under the 314 | CC0 Public Domain Dedication. Except for the limited purpose of indicating 315 | that material is shared under a Creative Commons public license or as otherwise 316 | permitted by the Creative Commons policies published at creativecommons.org/policies, 317 | Creative Commons does not authorize the use of the trademark "Creative Commons" 318 | or any other trademark or logo of Creative Commons without its prior written 319 | consent including, without limitation, in connection with any unauthorized 320 | modifications to any of its public licenses or any other arrangements, understandings, 321 | or agreements concerning use of licensed material. For the avoidance of doubt, 322 | this paragraph does not form part of the public licenses. 323 | 324 | Creative Commons may be contacted at creativecommons.org. 325 | -------------------------------------------------------------------------------- /LICENSES/MIT.txt: -------------------------------------------------------------------------------- 1 | MIT License Copyright (c) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice (including the next 11 | paragraph) shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 17 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 19 | OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /LICENSES/Unlicense.txt: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or distribute 4 | this software, either in source code form or as a compiled binary, for any 5 | purpose, commercial or non-commercial, and by any means. 6 | 7 | In jurisdictions that recognize copyright laws, the author or authors of this 8 | software dedicate any and all copyright interest in the software to the public 9 | domain. We make this dedication for the benefit of the public at large and 10 | to the detriment of our heirs and successors. We intend this dedication to 11 | be an overt act of relinquishment in perpetuity of all present and future 12 | rights to this software under copyright law. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 17 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 18 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH 19 | THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, 20 | please refer to 21 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | 5 | .. image:: https://readthedocs.org/projects/circuitpython-microosc/badge/?version=latest 6 | :target: https://circuitpython-microosc.readthedocs.io/ 7 | :alt: Documentation Status 8 | 9 | 10 | 11 | .. image:: https://img.shields.io/discord/327254708534116352.svg 12 | :target: https://adafru.it/discord 13 | :alt: Discord 14 | 15 | 16 | .. image:: https://github.com/todbot/CircuitPython_MicroOSC/workflows/Build%20CI/badge.svg 17 | :target: https://github.com/todbot/CircuitPython_MicroOSC/actions 18 | :alt: Build Status 19 | 20 | 21 | .. image:: https://img.shields.io/badge/code%20style-black-000000.svg 22 | :target: https://github.com/psf/black 23 | :alt: Code Style: Black 24 | 25 | Minimal OSC parser, server, and client for CircuitPython and CPython 26 | 27 | 28 | `Open Sound Control `_ is an efficient data transport 29 | encoding/protocol for real-time performance messages for music or other similar endeavors. 30 | The OSC byte encoding is designed to be semi-human readable and efficient enough for 31 | UDP packet transmission. 32 | 33 | OSC Messages are defined by an "OSC Address" (e.g. "/1/faderA") and optional "OSC Arguments", 34 | one or more possible of several data types (e.g. float32 or int32). OSC doesn't pre-define 35 | specific OSC Addresses, it is up the the sender and receiver to agree upon them. 36 | 37 | This "MicroOSC" library is a minimal UDP receiver ("OSC Server") and parser of OSC packets. 38 | The MicroOSC UDP receiver supports both unicast and multicast UDP on both CircuitPython and CPython. 39 | 40 | 41 | Requirements 42 | ============ 43 | 44 | To run this library you will need one of: 45 | 46 | * CircuitPython board with native ``wifi`` support, like those based on ESP32-S2, ESP32-S3, etc. 47 | * Desktop Python (CPython) computer 48 | 49 | To send OSC messages, you will need an OSC UDP sender (aka "OSC client"). 50 | Some easy-to-use OSC clients are: 51 | 52 | * `TouchOSC `_ 53 | * `OSCSend for Ableton Live `_ 54 | 55 | To receive OSC messages, you will need an OSC UDP receiver (aka "OSC server"). 56 | Some easy-to-use OSC clients are: 57 | 58 | * `Protokol for Mac/Win/Linux/iOS/Android `_ 59 | 60 | Dependencies 61 | ============= 62 | This driver depends on: 63 | 64 | * `Adafruit CircuitPython `_ 65 | 66 | Please ensure all dependencies are available on the CircuitPython filesystem. 67 | This is easily achieved by downloading 68 | `the Adafruit library and driver bundle `_ 69 | or individual libraries can be installed using 70 | `circup `_. 71 | 72 | Installing from PyPI 73 | ===================== 74 | 75 | On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from 76 | PyPI `_. 77 | To install for current user: 78 | 79 | .. code-block:: shell 80 | 81 | pip3 install circuitpython-microosc 82 | 83 | To install system-wide (this may be required in some cases): 84 | 85 | .. code-block:: shell 86 | 87 | sudo pip3 install circuitpython-microosc 88 | 89 | To install in a virtual environment in your current project: 90 | 91 | .. code-block:: shell 92 | 93 | mkdir project-name && cd project-name 94 | python3 -m venv .venv 95 | source .env/bin/activate 96 | pip3 install circuitpython-microosc 97 | 98 | Installing to a Connected CircuitPython Device with Circup 99 | ========================================================== 100 | 101 | Make sure that you have ``circup`` installed in your Python environment. 102 | Install it with the following command if necessary: 103 | 104 | .. code-block:: shell 105 | 106 | pip3 install circup 107 | 108 | With ``circup`` installed and your CircuitPython device connected use the 109 | following command to install: 110 | 111 | .. code-block:: shell 112 | 113 | circup install microosc 114 | 115 | Or the following command to update an existing version: 116 | 117 | .. code-block:: shell 118 | 119 | circup update 120 | 121 | Usage Example 122 | ============= 123 | 124 | .. code-block:: python 125 | 126 | import time, os, wifi, socketpool 127 | import microosc 128 | 129 | UDP_HOST = "224.0.0.1" # multicast UDP 130 | UDP_PORT = 5000 131 | 132 | ssid = os.getenv("CIRCUITPY_WIFI_SSID") 133 | password = os.getenv("CIRCUITPY_WIFI_PASSWORD") 134 | 135 | print("connecting to WiFi", ssid) 136 | wifi.radio.connect(ssid, password) 137 | 138 | socket_pool = socketpool.SocketPool(wifi.radio) 139 | 140 | def fader_handler(msg): 141 | """Used to handle 'fader' OscMsgs, printing it as a '*' text progress bar 142 | :param OscMsg msg: message with one required float32 value 143 | """ 144 | print(msg.addr, "*" * int(20 * msg.args[0])) # make a little bar chart 145 | 146 | dispatch_map = { 147 | "/": lambda msg: print("\t\tmsg:", msg.addr, msg.args), # prints all messages 148 | "/1/fader": fader_handler, 149 | "/filter1": fader_handler, 150 | } 151 | 152 | osc_server = micro_osc.Server(socket_pool, UDP_HOST, UDP_PORT, dispatch_map) 153 | 154 | print("MicroOSC server started on ", UDP_HOST, UDP_PORT) 155 | 156 | last_time = time.monotonic() 157 | 158 | while True: 159 | 160 | osc_server.poll() 161 | 162 | if time.monotonic() - last_time > 1.0: 163 | last_time = time.monotonic() 164 | print(f"waiting {last_time:.2f}") 165 | 166 | 167 | References 168 | ========== 169 | 170 | * `Open Sound Control Spec 1.0 `_ 171 | * `OSC Message examples `_ 172 | * `OSC info and tools `_ 173 | * `TouchOSC apps for Mac/Win/Linux `_ 174 | 175 | Documentation 176 | ============= 177 | API documentation for this library can be found on `Read the Docs `_. 178 | 179 | For information on building library documentation, please check out 180 | `this guide `_. 181 | 182 | Contributing 183 | ============ 184 | 185 | Contributions are welcome! Please read our `Code of Conduct 186 | `_ 187 | before contributing to help this project stay welcoming. 188 | -------------------------------------------------------------------------------- /README.rst.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | SPDX-FileCopyrightText: Copyright (c) 2023 Tod Kurt 3 | SPDX-License-Identifier: MIT 4 | -------------------------------------------------------------------------------- /docs/_static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/todbot/CircuitPython_MicroOSC/67b80a064d7fe451e4ae4a0ac0d22df060fde65a/docs/_static/favicon.ico -------------------------------------------------------------------------------- /docs/_static/favicon.ico.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries 2 | 3 | SPDX-License-Identifier: CC-BY-4.0 4 | -------------------------------------------------------------------------------- /docs/api.rst: -------------------------------------------------------------------------------- 1 | 2 | .. If you created a package, create one automodule per module in the package. 3 | 4 | .. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py) 5 | .. use this format as the module name: "adafruit_foo.foo" 6 | 7 | .. automodule:: microosc 8 | :members: 9 | -------------------------------------------------------------------------------- /docs/api.rst.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | SPDX-FileCopyrightText: Copyright (c) 2023 Tod Kurt 3 | 4 | SPDX-License-Identifier: MIT 5 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 4 | # 5 | # SPDX-License-Identifier: MIT 6 | 7 | import os 8 | import sys 9 | import datetime 10 | 11 | sys.path.insert(0, os.path.abspath("..")) 12 | 13 | # -- General configuration ------------------------------------------------ 14 | 15 | # Add any Sphinx extension module names here, as strings. They can be 16 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 17 | # ones. 18 | extensions = [ 19 | "sphinx.ext.autodoc", 20 | "sphinxcontrib.jquery", 21 | "sphinx.ext.intersphinx", 22 | "sphinx.ext.napoleon", 23 | "sphinx.ext.todo", 24 | ] 25 | 26 | # TODO: Please Read! 27 | # Uncomment the below if you use native CircuitPython modules such as 28 | # digitalio, micropython and busio. List the modules you use. Without it, the 29 | # autodoc module docs will fail to generate with a warning. 30 | # autodoc_mock_imports = ["digitalio", "busio"] 31 | 32 | autodoc_preserve_defaults = True 33 | 34 | 35 | intersphinx_mapping = { 36 | "python": ("https://docs.python.org/3", None), 37 | "CircuitPython": ("https://docs.circuitpython.org/en/latest/", None), 38 | } 39 | 40 | # Show the docstring from both the class and its __init__() method. 41 | autoclass_content = "both" 42 | 43 | # Add any paths that contain templates here, relative to this directory. 44 | templates_path = ["_templates"] 45 | 46 | source_suffix = ".rst" 47 | 48 | # The master toctree document. 49 | master_doc = "index" 50 | 51 | # General information about the project. 52 | project = "CircuitPython MicroOSC Library" 53 | creation_year = "2023" 54 | current_year = str(datetime.datetime.now().year) 55 | year_duration = ( 56 | current_year 57 | if current_year == creation_year 58 | else creation_year + " - " + current_year 59 | ) 60 | copyright = year_duration + " Tod Kurt" 61 | author = "Tod Kurt" 62 | 63 | # The version info for the project you're documenting, acts as replacement for 64 | # |version| and |release|, also used in various other places throughout the 65 | # built documents. 66 | # 67 | # The short X.Y version. 68 | version = "1.0" 69 | # The full version, including alpha/beta/rc tags. 70 | release = "1.0" 71 | 72 | # The language for content autogenerated by Sphinx. Refer to documentation 73 | # for a list of supported languages. 74 | # 75 | # This is also used if you do content translation via gettext catalogs. 76 | # Usually you set "language" from the command line for these cases. 77 | language = "en" 78 | 79 | # List of patterns, relative to source directory, that match files and 80 | # directories to ignore when looking for source files. 81 | # This patterns also effect to html_static_path and html_extra_path 82 | exclude_patterns = [ 83 | "_build", 84 | "Thumbs.db", 85 | ".DS_Store", 86 | ".env", 87 | "CODE_OF_CONDUCT.md", 88 | ] 89 | 90 | # The reST default role (used for this markup: `text`) to use for all 91 | # documents. 92 | # 93 | default_role = "any" 94 | 95 | # If true, '()' will be appended to :func: etc. cross-reference text. 96 | # 97 | add_function_parentheses = True 98 | 99 | # The name of the Pygments (syntax highlighting) style to use. 100 | pygments_style = "sphinx" 101 | 102 | # If true, `todo` and `todoList` produce output, else they produce nothing. 103 | todo_include_todos = False 104 | 105 | # If this is True, todo emits a warning for each TODO entries. The default is False. 106 | todo_emit_warnings = True 107 | 108 | napoleon_numpy_docstring = False 109 | 110 | # -- Options for HTML output ---------------------------------------------- 111 | 112 | import sphinx_rtd_theme 113 | 114 | html_theme = "sphinx_rtd_theme" 115 | html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."] 116 | 117 | # Add any paths that contain custom static files (such as style sheets) here, 118 | # relative to this directory. They are copied after the builtin static files, 119 | # so a file named "default.css" will overwrite the builtin "default.css". 120 | html_static_path = ["_static"] 121 | 122 | # The name of an image file (relative to this directory) to use as a favicon of 123 | # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 124 | # pixels large. 125 | # 126 | html_favicon = "_static/favicon.ico" 127 | 128 | # Output file base name for HTML help builder. 129 | htmlhelp_basename = "CircuitPython_Microosc_Librarydoc" 130 | 131 | # -- Options for LaTeX output --------------------------------------------- 132 | 133 | latex_elements = { 134 | # The paper size ('letterpaper' or 'a4paper'). 135 | # 'papersize': 'letterpaper', 136 | # The font size ('10pt', '11pt' or '12pt'). 137 | # 'pointsize': '10pt', 138 | # Additional stuff for the LaTeX preamble. 139 | # 'preamble': '', 140 | # Latex figure (float) alignment 141 | # 'figure_align': 'htbp', 142 | } 143 | 144 | # Grouping the document tree into LaTeX files. List of tuples 145 | # (source start file, target name, title, 146 | # author, documentclass [howto, manual, or own class]). 147 | latex_documents = [ 148 | ( 149 | master_doc, 150 | "CircuitPython_MicroOSC_Library.tex", 151 | "CircuitPython MicroOSC Library Documentation", 152 | author, 153 | "manual", 154 | ), 155 | ] 156 | 157 | # -- Options for manual page output --------------------------------------- 158 | 159 | # One entry per manual page. List of tuples 160 | # (source start file, name, description, authors, manual section). 161 | man_pages = [ 162 | ( 163 | master_doc, 164 | "CircuitPython_MicroOSC_Library", 165 | "CircuitPython MicroOSC Library Documentation", 166 | [author], 167 | 1, 168 | ), 169 | ] 170 | 171 | # -- Options for Texinfo output ------------------------------------------- 172 | 173 | # Grouping the document tree into Texinfo files. List of tuples 174 | # (source start file, target name, title, author, 175 | # dir menu entry, description, category) 176 | texinfo_documents = [ 177 | ( 178 | master_doc, 179 | "CircuitPython_MicroOSC_Library", 180 | "CircuitPython MicroOSC Library Documentation", 181 | author, 182 | "CircuitPython_MicroOSC_Library", 183 | "One line description of project.", 184 | "Miscellaneous", 185 | ), 186 | ] 187 | -------------------------------------------------------------------------------- /docs/examples.rst: -------------------------------------------------------------------------------- 1 | Simple test CircuitPython 2 | ------------------------- 3 | 4 | Create a simple CircuitPython OSC UDP Server to receive OSC Messages 5 | 6 | .. literalinclude:: ../examples/microosc_simpletest.py 7 | :caption: examples/microosc_simpletest.py 8 | :linenos: 9 | 10 | Simple test CPython 11 | ------------------- 12 | 13 | Create a simple desktop Python (CPython) OSC UDP Server to receive OSC Messages 14 | 15 | .. literalinclude:: ../examples/microosc_simpletest_cpython.py 16 | :caption: examples/microosc_simpletest_cpython.py 17 | :linenos: 18 | 19 | Simple send 20 | ----------- 21 | 22 | Create a simple CircuitPython OSC UDP Client to send OSC Messages 23 | 24 | .. literalinclude:: ../examples/microosc_simplesend.py 25 | :caption: examples/microosc_simplesend.py 26 | :linenos: 27 | 28 | Simple send CPython 29 | ------------------- 30 | 31 | Create a simple desktop Python (CPython) OSC UDP Client to send OSC Messages 32 | 33 | .. literalinclude:: ../examples/microosc_simplesend_cpython.py 34 | :caption: examples/microosc_simplesend_cpython.py 35 | :linenos: 36 | -------------------------------------------------------------------------------- /docs/examples.rst.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | SPDX-FileCopyrightText: Copyright (c) 2023 Tod Kurt 3 | 4 | SPDX-License-Identifier: MIT 5 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | 2 | .. include:: ../README.rst 3 | 4 | Table of Contents 5 | ================= 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | :hidden: 10 | 11 | self 12 | 13 | .. toctree:: 14 | :caption: Examples 15 | 16 | examples 17 | 18 | .. toctree:: 19 | :caption: API Reference 20 | :maxdepth: 3 21 | 22 | api 23 | 24 | .. toctree:: 25 | :caption: Tutorials 26 | 27 | .. toctree:: 28 | :caption: Related Products 29 | 30 | .. toctree:: 31 | :caption: Other Links 32 | 33 | Download from GitHub 34 | Download Library Bundle 35 | CircuitPython Reference Documentation 36 | CircuitPython Support Forum 37 | Discord Chat 38 | Adafruit Learning System 39 | Adafruit Blog 40 | Adafruit Store 41 | 42 | Indices and tables 43 | ================== 44 | 45 | * :ref:`genindex` 46 | * :ref:`modindex` 47 | * :ref:`search` 48 | -------------------------------------------------------------------------------- /docs/index.rst.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | SPDX-FileCopyrightText: Copyright (c) 2023 Tod Kurt 3 | 4 | SPDX-License-Identifier: MIT 5 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | sphinx>=4.0.0 6 | sphinxcontrib-jquery 7 | sphinx_rtd_theme 8 | -------------------------------------------------------------------------------- /examples/microosc_simplesend.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # SPDX-FileCopyrightText: Copyright (c) 2023 Tod Kurt 3 | # 4 | # SPDX-License-Identifier: Unlicense 5 | 6 | """Demonstrate MicroOSC library in CircuitPython, assumes native `wifi` support""" 7 | 8 | import time 9 | import os 10 | import wifi 11 | import socketpool 12 | 13 | import microosc 14 | 15 | UDP_HOST = "" # set to empty string to auto-set unicast UDP 16 | # UDP_HOST = "224.0.0.1" # multicast UDP 17 | UDP_PORT = 5000 18 | 19 | ssid = os.getenv("CIRCUITPY_WIFI_SSID") 20 | password = os.getenv("CIRCUITPY_WIFI_PASSWORD") 21 | 22 | print("connecting to WiFi", ssid) 23 | wifi.radio.connect(ssid, password) 24 | print("my ip address:", wifi.radio.ipv4_address) 25 | 26 | socket_pool = socketpool.SocketPool(wifi.radio) 27 | 28 | 29 | # test low-level functions 30 | def test_low_level(): 31 | """Test internals of microosc a little""" 32 | packet = bytearray(256) 33 | # data = bytearray(('b\x21' * 256).encode()) 34 | # msg = microosc.OscMsg('/1/fader1', [1234,], ('i',)) 35 | # msg = microosc.OscMsg('/1/fader1', [0.99,], ('f',)) 36 | msg1 = microosc.OscMsg("/1/xy1", [ 0.99, 0.3, ], ( "f", "f", ) ) # fmt: skip 37 | 38 | print("msg1:", msg1) 39 | packet_size = microosc.create_osc_packet(msg1, packet) 40 | print("packet_size:", packet_size) 41 | msg2 = microosc.parse_osc_packet(packet, packet_size) 42 | print("msg2:", msg2) 43 | 44 | 45 | test_low_level() 46 | 47 | if not UDP_HOST: 48 | # fall back to non-multicast UDP on my IP addr 49 | UDP_HOST = str(wifi.radio.ipv4_address) 50 | 51 | osc_client = microosc.OSCClient(socket_pool, "224.0.0.1", 5000) 52 | 53 | msg = microosc.OscMsg( "/1/xy1", [0.99, 0.3, ], ("f", "f", ) ) # fmt: skip 54 | 55 | i = 100 56 | while True: 57 | msg.args[0] = i * 0.01 # move the value a bit 58 | 59 | pkt_size = osc_client.send(msg) 60 | print("packet_size sent:", pkt_size, "msg:", msg) 61 | 62 | time.sleep(1) 63 | i -= 1 64 | -------------------------------------------------------------------------------- /examples/microosc_simplesend_cpython.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # SPDX-FileCopyrightText: Copyright (c) 2023 Tod Kurt 3 | # 4 | # SPDX-License-Identifier: Unlicense 5 | 6 | """Demonstrate MicroOSC library in CPython""" 7 | 8 | import time 9 | import socket 10 | 11 | import microosc 12 | 13 | 14 | # test low-level functions 15 | def test_low_level(): 16 | """Test internals of microosc a little""" 17 | packet = bytearray(256) 18 | # data = bytearray(('b\x21' * 256).encode()) 19 | # msg = microosc.OscMsg('/1/fader1', [1234,], ('i',)) 20 | # msg = microosc.OscMsg('/1/fader1', [0.99,], ('f',)) 21 | msg1 = microosc.OscMsg("/1/xy1", [ 0.99, 0.3, ], ( "f", "f", ) ) # fmt: skip 22 | 23 | print("msg1:", msg1) 24 | packet_size = microosc.create_osc_packet(msg1, packet) 25 | print("packet_size:", packet_size) 26 | msg2 = microosc.parse_osc_packet(packet, packet_size) 27 | print("msg2:", msg2) 28 | 29 | 30 | test_low_level() 31 | 32 | osc_client = microosc.OSCClient(socket, "224.0.0.1", 5000) 33 | # osc_client = microosc.OSCClient(socket, '127.0.0.1', 5000) 34 | 35 | msg = microosc.OscMsg( "/1/xy1", [0.99, 0.3, ], ("f", "f", ) ) # fmt: skip 36 | 37 | i = 100 38 | while True: 39 | msg.args[0] = i * 0.01 # move the value a bit 40 | 41 | pkt_size = osc_client.send(msg) 42 | print("packet_size sent:", pkt_size, "msg:", msg) 43 | 44 | time.sleep(1) 45 | i -= 1 46 | -------------------------------------------------------------------------------- /examples/microosc_simpletest.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # SPDX-FileCopyrightText: Copyright (c) 2023 Tod Kurt 3 | # 4 | # SPDX-License-Identifier: Unlicense 5 | 6 | """Demonstrate MicroOSC library in CircuitPython, assumes native `wifi` support""" 7 | 8 | 9 | import time 10 | import os 11 | import wifi 12 | import socketpool 13 | 14 | import microosc 15 | 16 | UDP_HOST = "" # set to empty string to auto-set unicast UDP 17 | # UDP_HOST = "224.0.0.1" # multicast UDP 18 | UDP_PORT = 5000 19 | 20 | ssid = os.getenv("CIRCUITPY_WIFI_SSID") 21 | password = os.getenv("CIRCUITPY_WIFI_PASSWORD") 22 | 23 | print("connecting to WiFi", ssid) 24 | wifi.radio.connect(ssid, password) 25 | print("my ip address:", wifi.radio.ipv4_address) 26 | 27 | socket_pool = socketpool.SocketPool(wifi.radio) 28 | 29 | 30 | def fader_handler(msg): 31 | """Used to handle 'fader' OscMsgs, printing it as a '*' text progress bar 32 | :param OscMsg msg: message with one required float32 value 33 | """ 34 | print(msg.addr, "*" * int(20 * msg.args[0])) # make a little bar chart 35 | 36 | 37 | dispatch_map = { 38 | "/": lambda msg: print("\t\tmsg:", msg.addr, msg.args), # prints all messages 39 | "/1/fader": fader_handler, 40 | "/filter1": fader_handler, 41 | } 42 | 43 | if not UDP_HOST: 44 | # fall back to non-multicast UDP on my IP addr 45 | UDP_HOST = str(wifi.radio.ipv4_address) 46 | 47 | osc_server = microosc.OSCServer(socket_pool, UDP_HOST, UDP_PORT, dispatch_map) 48 | 49 | print("MicroOSC server started on ", UDP_HOST, UDP_PORT) 50 | 51 | last_time = time.monotonic() 52 | 53 | while True: 54 | osc_server.poll() 55 | 56 | if time.monotonic() - last_time > 1.0: 57 | last_time = time.monotonic() 58 | print(f"waiting {last_time:.2f}") 59 | -------------------------------------------------------------------------------- /examples/microosc_simpletest_cpython.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # SPDX-FileCopyrightText: Copyright (c) 2023 Tod Kurt 3 | # 4 | # SPDX-License-Identifier: Unlicense 5 | 6 | """Demonstrate MicroOSC library in desktop Python (CPython)""" 7 | 8 | import sys 9 | import time 10 | import socket 11 | 12 | import microosc 13 | 14 | if len(sys.argv) < 2 or len(sys.argv) > 3: 15 | print("microosc_simpletest_cpython.py ") 16 | sys.exit(0) 17 | 18 | UDP_HOST = sys.argv[1] 19 | UDP_PORT = int(sys.argv[2]) 20 | 21 | last_velocity = 0 # pylint: disable=invalid-name 22 | 23 | 24 | def note_handler(msg): 25 | """Used to handle 'Note1' and 'Velocity1' OscMsgs from Ableton Live. 26 | Live's "OscSend" plugin sends two OSC Packets for every MIDI note. 27 | This function reconctructs that into a single print(). 28 | :param OscMsg msg: message with one required int32 value 29 | """ 30 | global last_velocity # pylint: disable=global-statement 31 | if msg.addr == "/Note1": 32 | if last_velocity != 0: 33 | print("NOTE ON ", msg.args[0], last_velocity) 34 | else: 35 | print("NOTE OFF", msg.args[0], last_velocity) 36 | elif msg.addr == "/Velocity1": 37 | last_velocity = msg.args[0] 38 | 39 | 40 | def fader_handler(msg): 41 | """Used to handle 'fader' OscMsgs, printing it as a '*' text progress bar 42 | :param OscMsg msg: message with one required float32 value 43 | """ 44 | print(msg.addr, "*" * int(20 * msg.args[0])) # make a little bar chart 45 | 46 | 47 | dispatch_map = { 48 | # matches all messages 49 | "/": lambda msg: print("\t\tmsg:", msg.addr, msg.args), 50 | # maches how Live's OSC MIDI Send plugin works 51 | "/Note1": note_handler, 52 | "/Velocity1": note_handler, 53 | # /1/fader3 matches how TouchOSC sends faders ,"/1" is screen, "fader3" is 3rd fader 54 | "/1/fader": fader_handler, 55 | "/filter1": fader_handler, 56 | } 57 | 58 | osc_server = microosc.OSCServer(socket, UDP_HOST, UDP_PORT, dispatch_map) 59 | 60 | print("MicroOSC server started on ", UDP_HOST, UDP_PORT) 61 | 62 | last_time = time.monotonic() 63 | 64 | while True: 65 | osc_server.poll() 66 | 67 | if time.monotonic() - last_time > 1.0: 68 | last_time = time.monotonic() 69 | print(f"waiting {last_time:.2f}") 70 | -------------------------------------------------------------------------------- /microosc.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # SPDX-FileCopyrightText: Copyright (c) 2023 Tod Kurt 3 | # 4 | # SPDX-License-Identifier: MIT 5 | """ 6 | `microosc` 7 | ================================================================================ 8 | 9 | Minimal OSC parser, server, and client for CircuitPython and CPython 10 | 11 | 12 | * Author(s): Tod Kurt 13 | 14 | Implementation Notes 15 | -------------------- 16 | 17 | **Hardware:** 18 | 19 | To run this library you will need one of: 20 | 21 | * CircuitPython board with native wifi support, like those based on ESP32-S2, ESP32-S3, etc. 22 | * Desktop Python (CPython) computer 23 | 24 | To send OSC messages, you will need an OSC UDP sender (aka "OSC client"). 25 | Some easy-to-use OSC clients are: 26 | 27 | * `TouchOSC for Mac/Win/Linux/iOS/Android `_ 28 | * `OSCSend for Ableton Live `_ 29 | 30 | To receive OSC messages, you will need an OSC UDP receiver (aka "OSC server"). 31 | Some easy-to-use OSC clients are: 32 | 33 | * `Protokol for Mac/Win/Linux/iOS/Android `_ 34 | 35 | **Software and Dependencies:** 36 | 37 | * Adafruit CircuitPython firmware for the supported boards: 38 | https://circuitpython.org/downloads 39 | 40 | """ 41 | 42 | # imports 43 | 44 | __version__ = "0.0.0+auto.0" 45 | __repo__ = "https://github.com/todbot/CircuitPython_MicroOSC.git" 46 | 47 | 48 | import sys 49 | import struct 50 | from collections import namedtuple 51 | 52 | impl = sys.implementation.name 53 | DEBUG = False 54 | 55 | if impl == "circuitpython": 56 | # these defines are not yet in CirPy socket, known to work for ESP32 native WiFI 57 | IPPROTO_IP = 0 # super secret from @jepler 58 | IP_MULTICAST_TTL = 5 # super secret from @jepler 59 | else: 60 | import socket 61 | 62 | IPPROTO_IP = socket.IPPROTO_IP 63 | IP_MULTICAST_TTL = socket.IP_MULTICAST_TTL 64 | 65 | 66 | OscMsg = namedtuple("OscMsg", ["addr", "args", "types"]) 67 | """Objects returned by `parse_osc_packet()`""" 68 | 69 | # fmt: off 70 | default_dispatch_map = { 71 | "/": lambda msg: print("default_map:", msg.addr, msg.args) 72 | } 73 | """Simple example of a dispatch_map""" 74 | # fmt: on 75 | 76 | 77 | def parse_osc_packet(data, packet_size): 78 | """Parse OSC packets into OscMsg objects. 79 | 80 | OSC packets contain, in order 81 | 82 | - a string that is the OSC Address (null-terminated), e.g. "/1/faderB" 83 | - a tag-type string starting with ',' and one or more 'f', 'i', 's' types, 84 | (optional, null-terminated), e.g. ",ffi" indicates two float32s, one int32 85 | - zero or more OSC Arguments in binary form, depending on tag-type string 86 | 87 | OSC packet size is always a multiple of 4 88 | 89 | :param bytearray data: a data buffer containing a binary OSC packet 90 | :param int packet_size: the size of the OSC packet (may be smaller than len(data)) 91 | """ 92 | # examples of OSC packets 93 | # https://opensoundcontrol.stanford.edu/spec-1_0-examples.html 94 | # spec: https://opensoundcontrol.stanford.edu/spec-1_0.html#osc-packets 95 | type_start = data.find(b",") 96 | type_end = type_start + 4 # OSC parts are 4-byte aligned 97 | # TODO: check type_start is 4-byte aligned 98 | 99 | oscaddr = data[:type_start].decode().rstrip("\x00") 100 | osctypes = data[type_start + 1 : type_end].decode() 101 | 102 | # fmt: off 103 | if DEBUG: 104 | print("oscaddr:", oscaddr, "osctypes:", osctypes, "data:", data[type_end:], 105 | packet_size - type_end, type_end, packet_size ) 106 | # fmt: on 107 | 108 | args = [] 109 | types = [] 110 | dpos = type_end 111 | for otype in osctypes: 112 | if otype == "f": # osc float32 113 | arg = struct.unpack(">f", data[dpos : dpos + 4]) 114 | args.append(arg[0]) 115 | types.append("f") 116 | dpos += 4 117 | elif otype == "i": # osc int32 118 | arg = struct.unpack(">i", data[dpos : dpos + 4]) 119 | args.append(arg[0]) 120 | types.append("i") 121 | dpos += 4 122 | elif otype == "s": # osc string TODO: find OSC emitter that sends string 123 | arg = data.decode() 124 | args.append(arg[0]) 125 | types.append("s") 126 | dpos += len(arg) 127 | elif otype == "\x00": # null padding 128 | pass 129 | else: 130 | args.append("unknown type:" + otype) 131 | 132 | return OscMsg(addr=oscaddr, args=args, types=types) 133 | 134 | 135 | def create_osc_packet(msg, data): 136 | """ 137 | :param OscMsg msg: OscMsg to convert into an OSC Packet 138 | :param bytearray data: an empty data buffer to write OSC Packet into 139 | 140 | :return size of actual OSC Packet written into data buffer 141 | """ 142 | # print("msg:",msg) 143 | addr_endpos = len(msg.addr) 144 | num_addr_nulls = 4 - (len(msg.addr) % 4) 145 | types_pos = addr_endpos + num_addr_nulls 146 | num_types_nulls = 4 - (len(msg.args) % 4 + 1) 147 | types_end_pos = types_pos + 1 + len(msg.args) 148 | args_pos = types_pos + 1 + len(msg.args) + num_types_nulls 149 | 150 | # print(addr_endpos, num_addr_nulls, types_pos, num_types_nulls, args_pos) 151 | 152 | # copy osc addr into data buffer, and fill out the required nulls 153 | data[0:addr_endpos] = msg.addr.encode("utf-8") 154 | data[addr_endpos : addr_endpos + num_addr_nulls] = b"\x00" * num_addr_nulls 155 | data[types_end_pos : types_end_pos + num_types_nulls] = b"\x00" * num_types_nulls 156 | 157 | # print("dat1:",data) 158 | 159 | # if there are OSC Arguments, march through them filling out the type field and arg fields 160 | if len(msg.args) > 0: 161 | data[types_pos] = ord(",") # start of type section 162 | types_pos += 1 163 | 164 | for oarg, otype in zip(msg.args, msg.types): 165 | data[types_pos] = ord(otype) # stick a type in type area 166 | types_pos += 1 167 | if otype == "f": 168 | data[args_pos : args_pos + 4] = struct.pack(">f", oarg) 169 | args_pos += 4 170 | elif otype == "i": 171 | data[args_pos : args_pos + 4] = struct.pack(">i", oarg) 172 | args_pos += 4 173 | elif otype == "s": 174 | data[args_pos : args_pos + len(oarg)] = struct.pack( 175 | f">{len(oarg)}s", oarg 176 | ) 177 | args_pos += len(oarg) 178 | 179 | # print("ret data:", len(data), data) 180 | return args_pos # actual size of osc packet constructed 181 | 182 | 183 | class OSCServer: 184 | """ 185 | In OSC parlance, a "server" is a receiver of OSC messages, usually UDP packets. 186 | This OSC server is an OSC UDP receiver. 187 | """ 188 | 189 | def __init__(self, socket_source, host, port, dispatch_map=None): 190 | """ 191 | Create an OSCServer and start it listening on a host/port. 192 | 193 | :param socket socket_source: An object that is a source of sockets. 194 | This could be a `socketpool` in CircuitPython or the `socket` module in CPython. 195 | :param str host: hostname or IP address to receive on, 196 | can use multicast addresses like '224.0.0.1' 197 | :param int port: port to receive on 198 | :param dict dispatch_map: map of OSC Addresses to functions, 199 | if no dispatch_map is specified, a default_map will be used that prints out OSC messages 200 | """ 201 | self._socket_source = socket_source 202 | self.host = host 203 | self.port = port 204 | self.dispatch_map = dispatch_map or default_dispatch_map 205 | self._server_start() 206 | 207 | def _server_start(self, buf_size=128, timeout=0.001, ttl=2): 208 | """ """ 209 | self._buf = bytearray(buf_size) 210 | self._sock = self._socket_source.socket( 211 | self._socket_source.AF_INET, self._socket_source.SOCK_DGRAM 212 | ) # UDP 213 | if self.host.startswith("224"): # multicast 214 | self._sock.setsockopt(IPPROTO_IP, IP_MULTICAST_TTL, ttl) 215 | self._sock.bind((self.host, self.port)) 216 | self._sock.settimeout(timeout) 217 | 218 | def poll(self): 219 | """ 220 | Call this method inside your main loop to get the server to check for 221 | new incoming packets. When a packet comes in, it will be parsed and 222 | dispatched to your provided handler functions specified in your dispatch_map. 223 | """ 224 | try: 225 | # pylint: disable=unused-variable 226 | datasize, addr = self._sock.recvfrom_into(self._buf) 227 | msg = parse_osc_packet(self._buf, datasize) 228 | self._dispatch(msg) 229 | except OSError: 230 | pass # timeout 231 | 232 | def _dispatch(self, msg): 233 | """:param OscMsg msg: message to be dispatched using dispatch_map""" 234 | for addr, func in self.dispatch_map.items(): 235 | if msg.addr.startswith(addr): 236 | func(msg) 237 | 238 | 239 | class OSCClient: 240 | """ 241 | In OSC parlance, a "client" is a sender of OSC messages, usually UDP packets. 242 | This OSC client is an OSC UDP sender. 243 | """ 244 | 245 | def __init__(self, socket_source, host, port, buf_size=128): 246 | """ 247 | Create an OSCClient ready to send to a host/port. 248 | 249 | :param socket socket_source: An object that is a source of sockets. 250 | This could be a `socketpool` in CircuitPython or the `socket` module in CPython. 251 | :param str host: hostname or IP address to send to, 252 | can use multicast addresses like '224.0.0.1' 253 | :param int port: port to send to 254 | :param int buf_size: size of UDP buffer to use 255 | """ 256 | self._socket_source = socket_source 257 | self.host = host 258 | self.port = port 259 | self._buf = bytearray(buf_size) 260 | self._sock = self._socket_source.socket( 261 | self._socket_source.AF_INET, self._socket_source.SOCK_DGRAM 262 | ) 263 | if self.host.startswith("224"): # multicast 264 | ttl = 2 # TODO: make this an arg? 265 | self._sock.setsockopt(IPPROTO_IP, IP_MULTICAST_TTL, ttl) 266 | 267 | def send(self, msg): 268 | """ 269 | Send an OSC Message. 270 | 271 | :param OscMsg msg: the OSC Message to send 272 | :return int: return code from socket.sendto 273 | """ 274 | 275 | pkt_size = create_osc_packet(msg, self._buf) 276 | return self._sock.sendto(self._buf[:pkt_size], (self.host, self.port)) 277 | -------------------------------------------------------------------------------- /optional_requirements.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Alec Delaney, written for Adafruit Industries 2 | # SPDX-FileCopyrightText: Copyright (c) 2023 Tod Kurt 3 | # 4 | # SPDX-License-Identifier: MIT 5 | 6 | [build-system] 7 | requires = [ 8 | "setuptools", 9 | "wheel", 10 | "setuptools-scm", 11 | ] 12 | 13 | [project] 14 | name = "circuitpython-microosc" 15 | description = "Minimal OSC parser and server for CircuitPython and CPython" 16 | version = "0.0.0+auto.0" 17 | readme = "README.rst" 18 | authors = [ 19 | {name = "Tod Kurt", email = "tod@todbot.com"} 20 | ] 21 | urls = {Homepage = "https://github.com/todbot/CircuitPython_MicroOSC"} 22 | keywords = [ 23 | "adafruit", 24 | "blinka", 25 | "circuitpython", 26 | "micropython", 27 | "microosc", 28 | "OSC", 29 | "MIDI", 30 | "OpenSoundControl", 31 | "protocol", 32 | "UDP", 33 | "multicast", 34 | ] 35 | license = {text = "MIT"} 36 | classifiers = [ 37 | "Intended Audience :: Developers", 38 | "Topic :: Software Development :: Libraries", 39 | "Topic :: Software Development :: Embedded Systems", 40 | "Topic :: System :: Hardware", 41 | "License :: OSI Approved :: MIT License", 42 | "Programming Language :: Python :: 3", 43 | ] 44 | dynamic = ["dependencies", "optional-dependencies"] 45 | 46 | [tool.setuptools] 47 | # TODO: IF LIBRARY FILES ARE A PACKAGE FOLDER, 48 | # CHANGE `py_modules = ['...']` TO `packages = ['...']` 49 | py-modules = ["microosc"] 50 | 51 | [tool.setuptools.dynamic] 52 | dependencies = {file = ["requirements.txt"]} 53 | optional-dependencies = {optional = {file = ["optional_requirements.txt"]}} 54 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # SPDX-FileCopyrightText: Copyright (c) 2023 Tod Kurt 3 | # 4 | # SPDX-License-Identifier: MIT 5 | 6 | Adafruit-Blinka 7 | --------------------------------------------------------------------------------