├── .gitattributes ├── .github ├── PULL_REQUEST_TEMPLATE │ └── adafruit_circuitpython_pr.md └── workflows │ ├── build.yml │ ├── failure-help-text.yml │ ├── release_gh.yml │ └── release_pypi.yml ├── .gitignore ├── .pre-commit-config.yaml ├── .readthedocs.yaml ├── CODE_OF_CONDUCT.md ├── LICENSE ├── LICENSES ├── CC-BY-4.0.txt ├── MIT.txt └── Unlicense.txt ├── README.rst ├── README.rst.license ├── adafruit_lsm6ds ├── __init__.py ├── ism330dhcx.py ├── lsm6ds3.py ├── lsm6ds33.py ├── lsm6ds3trc.py ├── lsm6dso32.py └── lsm6dsox.py ├── docs ├── _static │ ├── favicon.ico │ └── favicon.ico.license ├── api.rst ├── api.rst.license ├── conf.py ├── examples.rst ├── examples.rst.license ├── index.rst ├── index.rst.license └── requirements.txt ├── examples ├── lsm6ds_full_test.py ├── lsm6ds_ism330dhcx_simpletest.py ├── lsm6ds_lsm6ds33_simpletest.py ├── lsm6ds_lsm6ds3_simpletest.py ├── lsm6ds_lsm6ds3trc_simpletest.py ├── lsm6ds_lsm6dso32_simpletest.py ├── lsm6ds_lsm6dsox_mlc_test.py ├── lsm6ds_lsm6dsox_simpletest.py ├── lsm6ds_pedometer.py └── lsm6ds_rate_test.py ├── optional_requirements.txt ├── pyproject.toml ├── requirements.txt └── ruff.toml /.gitattributes: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | .py text eol=lf 6 | .rst text eol=lf 7 | .txt text eol=lf 8 | .yaml text eol=lf 9 | .toml text eol=lf 10 | .license text eol=lf 11 | .md text eol=lf 12 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | Thank you for contributing! Before you submit a pull request, please read the following. 6 | 7 | Make sure any changes you're submitting are in line with the CircuitPython Design Guide, available here: https://docs.circuitpython.org/en/latest/docs/design_guide.html 8 | 9 | If your changes are to documentation, please verify that the documentation builds locally by following the steps found here: https://adafru.it/build-docs 10 | 11 | Before submitting the pull request, make sure you've run Pylint and Black locally on your code. You can do this manually or using pre-commit. Instructions are available here: https://adafru.it/check-your-code 12 | 13 | Please remove all of this text before submitting. Include an explanation or list of changes included in your PR, as well as, if applicable, a link to any related issues. 14 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | name: Build CI 6 | 7 | on: [pull_request, push] 8 | 9 | jobs: 10 | test: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Run Build CI workflow 14 | uses: adafruit/workflows-circuitpython-libs/build@main 15 | -------------------------------------------------------------------------------- /.github/workflows/failure-help-text.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Scott Shawcroft for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | name: Failure help text 6 | 7 | on: 8 | workflow_run: 9 | workflows: ["Build CI"] 10 | types: 11 | - completed 12 | 13 | jobs: 14 | post-help: 15 | runs-on: ubuntu-latest 16 | if: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.event == 'pull_request' }} 17 | steps: 18 | - name: Post comment to help 19 | uses: adafruit/circuitpython-action-library-ci-failed@v1 20 | -------------------------------------------------------------------------------- /.github/workflows/release_gh.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | name: GitHub Release Actions 6 | 7 | on: 8 | release: 9 | types: [published] 10 | 11 | jobs: 12 | upload-release-assets: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Run GitHub Release CI workflow 16 | uses: adafruit/workflows-circuitpython-libs/release-gh@main 17 | with: 18 | github-token: ${{ secrets.GITHUB_TOKEN }} 19 | upload-url: ${{ github.event.release.upload_url }} 20 | -------------------------------------------------------------------------------- /.github/workflows/release_pypi.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | name: PyPI Release Actions 6 | 7 | on: 8 | release: 9 | types: [published] 10 | 11 | jobs: 12 | upload-release-assets: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Run PyPI Release CI workflow 16 | uses: adafruit/workflows-circuitpython-libs/release-pypi@main 17 | with: 18 | pypi-username: ${{ secrets.pypi_username }} 19 | pypi-password: ${{ secrets.pypi_password }} 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Kattni Rembor, written for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | # Do not include files and directories created by your personal work environment, such as the IDE 6 | # you use, except for those already listed here. Pull requests including changes to this file will 7 | # not be accepted. 8 | 9 | # This .gitignore file contains rules for files generated by working with CircuitPython libraries, 10 | # including building Sphinx, testing with pip, and creating a virual environment, as well as the 11 | # MacOS and IDE-specific files generated by using MacOS in general, or the PyCharm or VSCode IDEs. 12 | 13 | # If you find that there are files being generated on your machine that should not be included in 14 | # your git commit, you should create a .gitignore_global file on your computer to include the 15 | # files created by your personal setup. To do so, follow the two steps below. 16 | 17 | # First, create a file called .gitignore_global somewhere convenient for you, and add rules for 18 | # the files you want to exclude from git commits. 19 | 20 | # Second, configure Git to use the exclude file for all Git repositories by running the 21 | # following via commandline, replacing "path/to/your/" with the actual path to your newly created 22 | # .gitignore_global file: 23 | # git config --global core.excludesfile path/to/your/.gitignore_global 24 | 25 | # CircuitPython-specific files 26 | *.mpy 27 | 28 | # Python-specific files 29 | __pycache__ 30 | *.pyc 31 | 32 | # Sphinx build-specific files 33 | _build 34 | 35 | # This file results from running `pip -e install .` in a local repository 36 | *.egg-info 37 | 38 | # Virtual environment-specific files 39 | .env 40 | .venv 41 | 42 | # MacOS-specific files 43 | *.DS_Store 44 | 45 | # IDE-specific files 46 | .idea 47 | .vscode 48 | *~ 49 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | repos: 6 | - repo: https://github.com/pre-commit/pre-commit-hooks 7 | rev: v4.5.0 8 | hooks: 9 | - id: check-yaml 10 | - id: end-of-file-fixer 11 | - id: trailing-whitespace 12 | - repo: https://github.com/astral-sh/ruff-pre-commit 13 | rev: v0.3.4 14 | hooks: 15 | - id: ruff-format 16 | - id: ruff 17 | args: ["--fix"] 18 | - repo: https://github.com/fsfe/reuse-tool 19 | rev: v3.0.1 20 | hooks: 21 | - id: reuse 22 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | # Read the Docs configuration file 6 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 7 | 8 | # Required 9 | version: 2 10 | 11 | sphinx: 12 | configuration: docs/conf.py 13 | 14 | build: 15 | os: ubuntu-20.04 16 | tools: 17 | python: "3" 18 | 19 | python: 20 | install: 21 | - requirements: docs/requirements.txt 22 | - requirements: requirements.txt 23 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 7 | # Adafruit Community Code of Conduct 8 | 9 | ## Our Pledge 10 | 11 | In the interest of fostering an open and welcoming environment, we as 12 | contributors and leaders pledge to making participation in our project and 13 | our community a harassment-free experience for everyone, regardless of age, body 14 | size, disability, ethnicity, gender identity and expression, level or type of 15 | experience, education, socio-economic status, nationality, personal appearance, 16 | race, religion, or sexual identity and orientation. 17 | 18 | ## Our Standards 19 | 20 | We are committed to providing a friendly, safe and welcoming environment for 21 | all. 22 | 23 | Examples of behavior that contributes to creating a positive environment 24 | include: 25 | 26 | * Be kind and courteous to others 27 | * Using welcoming and inclusive language 28 | * Being respectful of differing viewpoints and experiences 29 | * Collaborating with other community members 30 | * Gracefully accepting constructive criticism 31 | * Focusing on what is best for the community 32 | * Showing empathy towards other community members 33 | 34 | Examples of unacceptable behavior by participants include: 35 | 36 | * The use of sexualized language or imagery and sexual attention or advances 37 | * The use of inappropriate images, including in a community member's avatar 38 | * The use of inappropriate language, including in a community member's nickname 39 | * Any spamming, flaming, baiting or other attention-stealing behavior 40 | * Excessive or unwelcome helping; answering outside the scope of the question 41 | asked 42 | * Trolling, insulting/derogatory comments, and personal or political attacks 43 | * Promoting or spreading disinformation, lies, or conspiracy theories against 44 | a person, group, organisation, project, or community 45 | * Public or private harassment 46 | * Publishing others' private information, such as a physical or electronic 47 | address, without explicit permission 48 | * Other conduct which could reasonably be considered inappropriate 49 | 50 | The goal of the standards and moderation guidelines outlined here is to build 51 | and maintain a respectful community. We ask that you don’t just aim to be 52 | "technically unimpeachable", but rather try to be your best self. 53 | 54 | We value many things beyond technical expertise, including collaboration and 55 | supporting others within our community. Providing a positive experience for 56 | other community members can have a much more significant impact than simply 57 | providing the correct answer. 58 | 59 | ## Our Responsibilities 60 | 61 | Project leaders are responsible for clarifying the standards of acceptable 62 | behavior and are expected to take appropriate and fair corrective action in 63 | response to any instances of unacceptable behavior. 64 | 65 | Project leaders have the right and responsibility to remove, edit, or 66 | reject messages, comments, commits, code, issues, and other contributions 67 | that are not aligned to this Code of Conduct, or to ban temporarily or 68 | permanently any community member for other behaviors that they deem 69 | inappropriate, threatening, offensive, or harmful. 70 | 71 | ## Moderation 72 | 73 | Instances of behaviors that violate the Adafruit Community Code of Conduct 74 | may be reported by any member of the community. Community members are 75 | encouraged to report these situations, including situations they witness 76 | involving other community members. 77 | 78 | You may report in the following ways: 79 | 80 | In any situation, you may send an email to . 81 | 82 | On the Adafruit Discord, you may send an open message from any channel 83 | to all Community Moderators by tagging @community moderators. You may 84 | also send an open message from any channel, or a direct message to 85 | @kattni#1507, @tannewt#4653, @danh#1614, @cater#2442, 86 | @sommersoft#0222, @Mr. Certainly#0472 or @Andon#8175. 87 | 88 | Email and direct message reports will be kept confidential. 89 | 90 | In situations on Discord where the issue is particularly egregious, possibly 91 | illegal, requires immediate action, or violates the Discord terms of service, 92 | you should also report the message directly to Discord. 93 | 94 | These are the steps for upholding our community’s standards of conduct. 95 | 96 | 1. Any member of the community may report any situation that violates the 97 | Adafruit Community Code of Conduct. All reports will be reviewed and 98 | investigated. 99 | 2. If the behavior is an egregious violation, the community member who 100 | committed the violation may be banned immediately, without warning. 101 | 3. Otherwise, moderators will first respond to such behavior with a warning. 102 | 4. Moderators follow a soft "three strikes" policy - the community member may 103 | be given another chance, if they are receptive to the warning and change their 104 | behavior. 105 | 5. If the community member is unreceptive or unreasonable when warned by a 106 | moderator, or the warning goes unheeded, they may be banned for a first or 107 | second offense. Repeated offenses will result in the community member being 108 | banned. 109 | 110 | ## Scope 111 | 112 | This Code of Conduct and the enforcement policies listed above apply to all 113 | Adafruit Community venues. This includes but is not limited to any community 114 | spaces (both public and private), the entire Adafruit Discord server, and 115 | Adafruit GitHub repositories. Examples of Adafruit Community spaces include 116 | but are not limited to meet-ups, audio chats on the Adafruit Discord, or 117 | interaction at a conference. 118 | 119 | This Code of Conduct applies both within project spaces and in public spaces 120 | when an individual is representing the project or its community. As a community 121 | member, you are representing our community, and are expected to behave 122 | accordingly. 123 | 124 | ## Attribution 125 | 126 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 127 | version 1.4, available at 128 | , 129 | and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html). 130 | 131 | For other projects adopting the Adafruit Community Code of 132 | Conduct, please contact the maintainers of those projects for enforcement. 133 | If you wish to use this code of conduct for your own project, consider 134 | explicitly mentioning your moderation policy or making a copy with your 135 | own moderation policy so as to avoid confusion. 136 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Bryan Siepert for Adafruit Industries 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSES/CC-BY-4.0.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Attribution 4.0 International Creative Commons Corporation 2 | ("Creative Commons") is not a law firm and does not provide legal services 3 | or legal advice. Distribution of Creative Commons public licenses does not 4 | create a lawyer-client or other relationship. Creative Commons makes its licenses 5 | and related information available on an "as-is" basis. Creative Commons gives 6 | no warranties regarding its licenses, any material licensed under their terms 7 | and conditions, or any related information. Creative Commons disclaims all 8 | liability for damages resulting from their use to the fullest extent possible. 9 | 10 | Using Creative Commons Public Licenses 11 | 12 | Creative Commons public licenses provide a standard set of terms and conditions 13 | that creators and other rights holders may use to share original works of 14 | authorship and other material subject to copyright and certain other rights 15 | specified in the public license below. The following considerations are for 16 | informational purposes only, are not exhaustive, and do not form part of our 17 | licenses. 18 | 19 | Considerations for licensors: Our public licenses are intended for use by 20 | those authorized to give the public permission to use material in ways otherwise 21 | restricted by copyright and certain other rights. Our licenses are irrevocable. 22 | Licensors should read and understand the terms and conditions of the license 23 | they choose before applying it. Licensors should also secure all rights necessary 24 | before applying our licenses so that the public can reuse the material as 25 | expected. Licensors should clearly mark any material not subject to the license. 26 | This includes other CC-licensed material, or material used under an exception 27 | or limitation to copyright. More considerations for licensors : wiki.creativecommons.org/Considerations_for_licensors 28 | 29 | Considerations for the public: By using one of our public licenses, a licensor 30 | grants the public permission to use the licensed material under specified 31 | terms and conditions. If the licensor's permission is not necessary for any 32 | reason–for example, because of any applicable exception or limitation to copyright–then 33 | that use is not regulated by the license. Our licenses grant only permissions 34 | under copyright and certain other rights that a licensor has authority to 35 | grant. Use of the licensed material may still be restricted for other reasons, 36 | including because others have copyright or other rights in the material. A 37 | licensor may make special requests, such as asking that all changes be marked 38 | or described. Although not required by our licenses, you are encouraged to 39 | respect those requests where reasonable. More considerations for the public 40 | : wiki.creativecommons.org/Considerations_for_licensees Creative Commons Attribution 41 | 4.0 International Public License 42 | 43 | By exercising the Licensed Rights (defined below), You accept and agree to 44 | be bound by the terms and conditions of this Creative Commons Attribution 45 | 4.0 International Public License ("Public License"). To the extent this Public 46 | License may be interpreted as a contract, You are granted the Licensed Rights 47 | in consideration of Your acceptance of these terms and conditions, and the 48 | Licensor grants You such rights in consideration of benefits the Licensor 49 | receives from making the Licensed Material available under these terms and 50 | conditions. 51 | 52 | Section 1 – Definitions. 53 | 54 | a. Adapted Material means material subject to Copyright and Similar Rights 55 | that is derived from or based upon the Licensed Material and in which the 56 | Licensed Material is translated, altered, arranged, transformed, or otherwise 57 | modified in a manner requiring permission under the Copyright and Similar 58 | Rights held by the Licensor. For purposes of this Public License, where the 59 | Licensed Material is a musical work, performance, or sound recording, Adapted 60 | Material is always produced where the Licensed Material is synched in timed 61 | relation with a moving image. 62 | 63 | b. Adapter's License means the license You apply to Your Copyright and Similar 64 | Rights in Your contributions to Adapted Material in accordance with the terms 65 | and conditions of this Public License. 66 | 67 | c. Copyright and Similar Rights means copyright and/or similar rights closely 68 | related to copyright including, without limitation, performance, broadcast, 69 | sound recording, and Sui Generis Database Rights, without regard to how the 70 | rights are labeled or categorized. For purposes of this Public License, the 71 | rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. 72 | 73 | d. Effective Technological Measures means those measures that, in the absence 74 | of proper authority, may not be circumvented under laws fulfilling obligations 75 | under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, 76 | and/or similar international agreements. 77 | 78 | e. Exceptions and Limitations means fair use, fair dealing, and/or any other 79 | exception or limitation to Copyright and Similar Rights that applies to Your 80 | use of the Licensed Material. 81 | 82 | f. Licensed Material means the artistic or literary work, database, or other 83 | material to which the Licensor applied this Public License. 84 | 85 | g. Licensed Rights means the rights granted to You subject to the terms and 86 | conditions of this Public License, which are limited to all Copyright and 87 | Similar Rights that apply to Your use of the Licensed Material and that the 88 | Licensor has authority to license. 89 | 90 | h. Licensor means the individual(s) or entity(ies) granting rights under this 91 | Public License. 92 | 93 | i. Share means to provide material to the public by any means or process that 94 | requires permission under the Licensed Rights, such as reproduction, public 95 | display, public performance, distribution, dissemination, communication, or 96 | importation, and to make material available to the public including in ways 97 | that members of the public may access the material from a place and at a time 98 | individually chosen by them. 99 | 100 | j. Sui Generis Database Rights means rights other than copyright resulting 101 | from Directive 96/9/EC of the European Parliament and of the Council of 11 102 | March 1996 on the legal protection of databases, as amended and/or succeeded, 103 | as well as other essentially equivalent rights anywhere in the world. 104 | 105 | k. You means the individual or entity exercising the Licensed Rights under 106 | this Public License. Your has a corresponding meaning. 107 | 108 | Section 2 – Scope. 109 | 110 | a. License grant. 111 | 112 | 1. Subject to the terms and conditions of this Public License, the Licensor 113 | hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, 114 | irrevocable license to exercise the Licensed Rights in the Licensed Material 115 | to: 116 | 117 | A. reproduce and Share the Licensed Material, in whole or in part; and 118 | 119 | B. produce, reproduce, and Share Adapted Material. 120 | 121 | 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions 122 | and Limitations apply to Your use, this Public License does not apply, and 123 | You do not need to comply with its terms and conditions. 124 | 125 | 3. Term. The term of this Public License is specified in Section 6(a). 126 | 127 | 4. Media and formats; technical modifications allowed. The Licensor authorizes 128 | You to exercise the Licensed Rights in all media and formats whether now known 129 | or hereafter created, and to make technical modifications necessary to do 130 | so. The Licensor waives and/or agrees not to assert any right or authority 131 | to forbid You from making technical modifications necessary to exercise the 132 | Licensed Rights, including technical modifications necessary to circumvent 133 | Effective Technological Measures. For purposes of this Public License, simply 134 | making modifications authorized by this Section 2(a)(4) never produces Adapted 135 | Material. 136 | 137 | 5. Downstream recipients. 138 | 139 | A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed 140 | Material automatically receives an offer from the Licensor to exercise the 141 | Licensed Rights under the terms and conditions of this Public License. 142 | 143 | B. No downstream restrictions. You may not offer or impose any additional 144 | or different terms or conditions on, or apply any Effective Technological 145 | Measures to, the Licensed Material if doing so restricts exercise of the Licensed 146 | Rights by any recipient of the Licensed Material. 147 | 148 | 6. No endorsement. Nothing in this Public License constitutes or may be construed 149 | as permission to assert or imply that You are, or that Your use of the Licensed 150 | Material is, connected with, or sponsored, endorsed, or granted official status 151 | by, the Licensor or others designated to receive attribution as provided in 152 | Section 3(a)(1)(A)(i). 153 | 154 | b. Other rights. 155 | 156 | 1. Moral rights, such as the right of integrity, are not licensed under this 157 | Public License, nor are publicity, privacy, and/or other similar personality 158 | rights; however, to the extent possible, the Licensor waives and/or agrees 159 | not to assert any such rights held by the Licensor to the limited extent necessary 160 | to allow You to exercise the Licensed Rights, but not otherwise. 161 | 162 | 2. Patent and trademark rights are not licensed under this Public License. 163 | 164 | 3. To the extent possible, the Licensor waives any right to collect royalties 165 | from You for the exercise of the Licensed Rights, whether directly or through 166 | a collecting society under any voluntary or waivable statutory or compulsory 167 | licensing scheme. In all other cases the Licensor expressly reserves any right 168 | to collect such royalties. 169 | 170 | Section 3 – License Conditions. 171 | 172 | Your exercise of the Licensed Rights is expressly made subject to the following 173 | conditions. 174 | 175 | a. Attribution. 176 | 177 | 1. If You Share the Licensed Material (including in modified form), You must: 178 | 179 | A. retain the following if it is supplied by the Licensor with the Licensed 180 | Material: 181 | 182 | i. identification of the creator(s) of the Licensed Material and any others 183 | designated to receive attribution, in any reasonable manner requested by the 184 | Licensor (including by pseudonym if designated); 185 | 186 | ii. a copyright notice; 187 | 188 | iii. a notice that refers to this Public License; 189 | 190 | iv. a notice that refers to the disclaimer of warranties; 191 | 192 | v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; 193 | 194 | B. indicate if You modified the Licensed Material and retain an indication 195 | of any previous modifications; and 196 | 197 | C. indicate the Licensed Material is licensed under this Public License, and 198 | include the text of, or the URI or hyperlink to, this Public License. 199 | 200 | 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner 201 | based on the medium, means, and context in which You Share the Licensed Material. 202 | For example, it may be reasonable to satisfy the conditions by providing a 203 | URI or hyperlink to a resource that includes the required information. 204 | 205 | 3. If requested by the Licensor, You must remove any of the information required 206 | by Section 3(a)(1)(A) to the extent reasonably practicable. 207 | 208 | 4. If You Share Adapted Material You produce, the Adapter's License You apply 209 | must not prevent recipients of the Adapted Material from complying with this 210 | Public License. 211 | 212 | Section 4 – Sui Generis Database Rights. 213 | 214 | Where the Licensed Rights include Sui Generis Database Rights that apply to 215 | Your use of the Licensed Material: 216 | 217 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, 218 | reuse, reproduce, and Share all or a substantial portion of the contents of 219 | the database; 220 | 221 | b. if You include all or a substantial portion of the database contents in 222 | a database in which You have Sui Generis Database Rights, then the database 223 | in which You have Sui Generis Database Rights (but not its individual contents) 224 | is Adapted Material; and 225 | 226 | c. You must comply with the conditions in Section 3(a) if You Share all or 227 | a substantial portion of the contents of the database. 228 | 229 | For the avoidance of doubt, this Section 4 supplements and does not replace 230 | Your obligations under this Public License where the Licensed Rights include 231 | other Copyright and Similar Rights. 232 | 233 | Section 5 – Disclaimer of Warranties and Limitation of Liability. 234 | 235 | a. Unless otherwise separately undertaken by the Licensor, to the extent possible, 236 | the Licensor offers the Licensed Material as-is and as-available, and makes 237 | no representations or warranties of any kind concerning the Licensed Material, 238 | whether express, implied, statutory, or other. This includes, without limitation, 239 | warranties of title, merchantability, fitness for a particular purpose, non-infringement, 240 | absence of latent or other defects, accuracy, or the presence or absence of 241 | errors, whether or not known or discoverable. Where disclaimers of warranties 242 | are not allowed in full or in part, this disclaimer may not apply to You. 243 | 244 | b. To the extent possible, in no event will the Licensor be liable to You 245 | on any legal theory (including, without limitation, negligence) or otherwise 246 | for any direct, special, indirect, incidental, consequential, punitive, exemplary, 247 | or other losses, costs, expenses, or damages arising out of this Public License 248 | or use of the Licensed Material, even if the Licensor has been advised of 249 | the possibility of such losses, costs, expenses, or damages. Where a limitation 250 | of liability is not allowed in full or in part, this limitation may not apply 251 | to You. 252 | 253 | c. The disclaimer of warranties and limitation of liability provided above 254 | shall be interpreted in a manner that, to the extent possible, most closely 255 | approximates an absolute disclaimer and waiver of all liability. 256 | 257 | Section 6 – Term and Termination. 258 | 259 | a. This Public License applies for the term of the Copyright and Similar Rights 260 | licensed here. However, if You fail to comply with this Public License, then 261 | Your rights under this Public License terminate automatically. 262 | 263 | b. Where Your right to use the Licensed Material has terminated under Section 264 | 6(a), it reinstates: 265 | 266 | 1. automatically as of the date the violation is cured, provided it is cured 267 | within 30 days of Your discovery of the violation; or 268 | 269 | 2. upon express reinstatement by the Licensor. 270 | 271 | c. For the avoidance of doubt, this Section 6(b) does not affect any right 272 | the Licensor may have to seek remedies for Your violations of this Public 273 | License. 274 | 275 | d. For the avoidance of doubt, the Licensor may also offer the Licensed Material 276 | under separate terms or conditions or stop distributing the Licensed Material 277 | at any time; however, doing so will not terminate this Public License. 278 | 279 | e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. 280 | 281 | Section 7 – Other Terms and Conditions. 282 | 283 | a. The Licensor shall not be bound by any additional or different terms or 284 | conditions communicated by You unless expressly agreed. 285 | 286 | b. Any arrangements, understandings, or agreements regarding the Licensed 287 | Material not stated herein are separate from and independent of the terms 288 | and conditions of this Public License. 289 | 290 | Section 8 – Interpretation. 291 | 292 | a. For the avoidance of doubt, this Public License does not, and shall not 293 | be interpreted to, reduce, limit, restrict, or impose conditions on any use 294 | of the Licensed Material that could lawfully be made without permission under 295 | this Public License. 296 | 297 | b. To the extent possible, if any provision of this Public License is deemed 298 | unenforceable, it shall be automatically reformed to the minimum extent necessary 299 | to make it enforceable. If the provision cannot be reformed, it shall be severed 300 | from this Public License without affecting the enforceability of the remaining 301 | terms and conditions. 302 | 303 | c. No term or condition of this Public License will be waived and no failure 304 | to comply consented to unless expressly agreed to by the Licensor. 305 | 306 | d. Nothing in this Public License constitutes or may be interpreted as a limitation 307 | upon, or waiver of, any privileges and immunities that apply to the Licensor 308 | or You, including from the legal processes of any jurisdiction or authority. 309 | 310 | Creative Commons is not a party to its public licenses. Notwithstanding, Creative 311 | Commons may elect to apply one of its public licenses to material it publishes 312 | and in those instances will be considered the "Licensor." The text of the 313 | Creative Commons public licenses is dedicated to the public domain under the 314 | CC0 Public Domain Dedication. Except for the limited purpose of indicating 315 | that material is shared under a Creative Commons public license or as otherwise 316 | permitted by the Creative Commons policies published at creativecommons.org/policies, 317 | Creative Commons does not authorize the use of the trademark "Creative Commons" 318 | or any other trademark or logo of Creative Commons without its prior written 319 | consent including, without limitation, in connection with any unauthorized 320 | modifications to any of its public licenses or any other arrangements, understandings, 321 | or agreements concerning use of licensed material. For the avoidance of doubt, 322 | this paragraph does not form part of the public licenses. 323 | 324 | Creative Commons may be contacted at creativecommons.org. 325 | -------------------------------------------------------------------------------- /LICENSES/MIT.txt: -------------------------------------------------------------------------------- 1 | MIT License Copyright (c) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice (including the next 11 | paragraph) shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 17 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 19 | OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /LICENSES/Unlicense.txt: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or distribute 4 | this software, either in source code form or as a compiled binary, for any 5 | purpose, commercial or non-commercial, and by any means. 6 | 7 | In jurisdictions that recognize copyright laws, the author or authors of this 8 | software dedicate any and all copyright interest in the software to the public 9 | domain. We make this dedication for the benefit of the public at large and 10 | to the detriment of our heirs and successors. We intend this dedication to 11 | be an overt act of relinquishment in perpetuity of all present and future 12 | rights to this software under copyright law. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 17 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 18 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH 19 | THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, 20 | please refer to 21 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | .. image:: https://readthedocs.org/projects/adafruit-circuitpython-lsm6dsox/badge/?version=latest 5 | :target: https://docs.circuitpython.org/projects/lsm6dsox/en/latest/ 6 | :alt: Documentation Status 7 | 8 | .. image:: https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_Bundle/main/badges/adafruit_discord.svg 9 | :target: https://adafru.it/discord 10 | :alt: Discord 11 | 12 | 13 | .. image:: https://github.com/adafruit/Adafruit_CircuitPython_LSM6DS/workflows/Build%20CI/badge.svg 14 | :target: https://github.com/adafruit/Adafruit_CircuitPython_LSM6DS/actions 15 | :alt: Build Status 16 | 17 | .. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json 18 | :target: https://github.com/astral-sh/ruff 19 | :alt: Code Style: Ruff 20 | 21 | CircuitPython helper library for the LSM6DS family of motion sensors from ST 22 | 23 | 24 | Dependencies 25 | ============= 26 | This driver depends on: 27 | 28 | * `Adafruit CircuitPython `_ 29 | * `Bus Device `_ 30 | * `Register `_ 31 | 32 | Please ensure all dependencies are available on the CircuitPython filesystem. 33 | This is easily achieved by downloading 34 | `the Adafruit library and driver bundle `_. 35 | 36 | Installing from PyPI 37 | ===================== 38 | 39 | On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from 40 | PyPI `_. To install for current user: 41 | 42 | .. code-block:: shell 43 | 44 | pip3 install adafruit-circuitpython-lsm6ds 45 | 46 | To install system-wide (this may be required in some cases): 47 | 48 | .. code-block:: shell 49 | 50 | sudo pip3 install adafruit-circuitpython-lsm6ds 51 | 52 | To install in a virtual environment in your current project: 53 | 54 | .. code-block:: shell 55 | 56 | mkdir project-name && cd project-name 57 | python3 -m venv .venv 58 | source .venv/bin/activate 59 | pip3 install adafruit-circuitpython-lsm6ds 60 | 61 | Usage Example 62 | ============= 63 | .. code-block:: python3 64 | 65 | import time 66 | import board 67 | from adafruit_lsm6ds.lsm6dsox import LSM6DSOX 68 | 69 | i2c = board.I2C() # uses board.SCL and board.SDA 70 | sox = LSM6DSOX(i2c) 71 | 72 | while True: 73 | print("Acceleration: X:%.2f, Y: %.2f, Z: %.2f m/s^2"%(sox.acceleration)) 74 | print("Gyro X:%.2f, Y: %.2f, Z: %.2f radians/s"%(sox.gyro)) 75 | print("") 76 | time.sleep(0.5) 77 | 78 | Documentation 79 | ============= 80 | 81 | API documentation for this library can be found on `Read the Docs `_. 82 | 83 | For information on building library documentation, please check out `this guide `_. 84 | 85 | Contributing 86 | ============ 87 | 88 | Contributions are welcome! Please read our `Code of Conduct 89 | `_ 90 | before contributing to help this project stay welcoming. 91 | -------------------------------------------------------------------------------- /README.rst.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | 3 | SPDX-License-Identifier: MIT 4 | -------------------------------------------------------------------------------- /adafruit_lsm6ds/__init__.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | """ 6 | `adafruit_lsm6ds` 7 | ================================================================================ 8 | 9 | CircuitPython helper library for the LSM6DS family of motion sensors from ST 10 | 11 | 12 | * Author(s): Bryan Siepert, Jose David M. 13 | 14 | Implementation Notes 15 | -------------------- 16 | 17 | **Hardware:** 18 | 19 | * `Adafruit LSM6DSOX 6 DoF Accelerometer and Gyroscope 20 | `_ (Product ID: 4438) 21 | 22 | * `Adafruit ISM330DHCX - 6 DoF IMU - Accelerometer and Gyroscope 23 | `_ (Product ID: 4502) 24 | 25 | * `Adafruit LSM6DSO32 6-DoF Accelerometer and Gyroscope 26 | `_ (Product ID: 4692) 27 | 28 | * `Adafruit LSM6DS33 6-DoF Accel + Gyro IMU 29 | `_ (Product ID: 4480) 30 | 31 | * `Adafruit ISM330DHCX + LIS3MDL FeatherWing - High Precision 9-DoF IMU 32 | `_ (Product ID: 4569) 33 | 34 | * `Adafruit LSM6DSOX + LIS3MDL - Precision 9 DoF IMU 35 | `_ (Product ID: 4517) 36 | 37 | * `Adafruit LSM6DS33 + LIS3MDL - 9 DoF IMU with Accel / Gyro / Mag 38 | `_ (Product ID: 4485) 39 | 40 | * `Adafruit LSM6DSOX + LIS3MDL FeatherWing - Precision 9-DoF IMU 41 | `_ (Product ID: 4565) 42 | 43 | 44 | **Software and Dependencies:** 45 | 46 | * Adafruit CircuitPython firmware for the supported boards: 47 | https://circuitpython.org/downloads 48 | * Adafruit's Bus Device library: 49 | https://github.com/adafruit/Adafruit_CircuitPython_BusDevice 50 | * Adafruit's Register library: 51 | https://github.com/adafruit/Adafruit_CircuitPython_Register 52 | 53 | """ 54 | 55 | __version__ = "0.0.0+auto.0" 56 | __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_LSM6DS.git" 57 | 58 | import struct 59 | from math import radians 60 | from time import sleep 61 | 62 | from adafruit_bus_device import i2c_device 63 | from adafruit_register.i2c_bit import ROBit, RWBit 64 | from adafruit_register.i2c_bits import RWBits 65 | from adafruit_register.i2c_struct import ROUnaryStruct, Struct 66 | from micropython import const 67 | 68 | try: 69 | from typing import Optional, Tuple 70 | 71 | from busio import I2C 72 | except ImportError: 73 | pass 74 | 75 | 76 | class CV: 77 | """struct helper""" 78 | 79 | @classmethod 80 | def add_values(cls, value_tuples: Tuple[str, int, float, Optional[float]]) -> None: 81 | "creates CV entires" 82 | cls.string = {} 83 | cls.lsb = {} 84 | 85 | for value_tuple in value_tuples: 86 | name, value, string, lsb = value_tuple 87 | setattr(cls, name, value) 88 | cls.string[value] = string 89 | cls.lsb[value] = lsb 90 | 91 | @classmethod 92 | def is_valid(cls, value: int) -> bool: 93 | """Returns true if the given value is a member of the CV""" 94 | return value in cls.string 95 | 96 | 97 | class AccelRange(CV): 98 | """Options for ``accelerometer_range``""" 99 | 100 | 101 | class GyroRange(CV): 102 | """Options for ``gyro_data_range``""" 103 | 104 | 105 | class Rate(CV): 106 | """Options for ``accelerometer_data_rate`` and ``gyro_data_rate``""" 107 | 108 | 109 | Rate.add_values( 110 | ( 111 | ("RATE_SHUTDOWN", 0, 0, None), 112 | ("RATE_12_5_HZ", 1, 12.5, None), 113 | ("RATE_26_HZ", 2, 26.0, None), 114 | ("RATE_52_HZ", 3, 52.0, None), 115 | ("RATE_104_HZ", 4, 104.0, None), 116 | ("RATE_208_HZ", 5, 208.0, None), 117 | ("RATE_416_HZ", 6, 416.0, None), 118 | ("RATE_833_HZ", 7, 833.0, None), 119 | ("RATE_1_66K_HZ", 8, 1666.0, None), 120 | ("RATE_3_33K_HZ", 9, 3332.0, None), 121 | ("RATE_6_66K_HZ", 10, 6664.0, None), 122 | ("RATE_1_6_HZ", 11, 1.6, None), 123 | ) 124 | ) 125 | 126 | 127 | class AccelHPF(CV): 128 | """Options for the accelerometer high pass filter""" 129 | 130 | 131 | AccelHPF.add_values( 132 | ( 133 | ("SLOPE", 0, 0, None), 134 | ("HPF_DIV100", 1, 0, None), 135 | ("HPF_DIV9", 2, 0, None), 136 | ("HPF_DIV400", 3, 0, None), 137 | ) 138 | ) 139 | 140 | LSM6DS_DEFAULT_ADDRESS = const(0x6A) 141 | 142 | LSM6DS_CHIP_ID = const(0x6C) 143 | 144 | _LSM6DS_MLC_INT1 = const(0x0D) 145 | _LSM6DS_WHOAMI = const(0xF) 146 | _LSM6DS_CTRL1_XL = const(0x10) 147 | _LSM6DS_CTRL2_G = const(0x11) 148 | _LSM6DS_CTRL3_C = const(0x12) 149 | _LSM6DS_CTRL8_XL = const(0x17) 150 | _LSM6DS_CTRL9_XL = const(0x18) 151 | _LSM6DS_CTRL10_C = const(0x19) 152 | _LSM6DS_ALL_INT_SRC = const(0x1A) 153 | _LSM6DS_OUT_TEMP_L = const(0x20) 154 | _LSM6DS_OUTX_L_G = const(0x22) 155 | _LSM6DS_OUTX_L_A = const(0x28) 156 | _LSM6DS_MLC_STATUS = const(0x38) 157 | _LSM6DS_STEP_COUNTER = const(0x4B) 158 | _LSM6DS_TAP_CFG0 = const(0x56) 159 | _LSM6DS_TAP_CFG = const(0x58) 160 | _LSM6DS_MLC0_SRC = const(0x70) 161 | _MILLI_G_TO_ACCEL = 0.00980665 162 | _TEMPERATURE_SENSITIVITY = 256 163 | _TEMPERATURE_OFFSET = 25.0 164 | 165 | _LSM6DS_EMB_FUNC_EN_A = const(0x04) 166 | _LSM6DS_EMB_FUNC_EN_B = const(0x05) 167 | _LSM6DS_FUNC_CFG_ACCESS = const(0x01) 168 | _LSM6DS_FUNC_CFG_BANK_USER = const(0) 169 | _LSM6DS_FUNC_CFG_BANK_HUB = const(1) 170 | _LSM6DS_FUNC_CFG_BANK_EMBED = const(2) 171 | 172 | 173 | class LSM6DS: 174 | """Driver for the LSM6DSOX 6-axis accelerometer and gyroscope. 175 | 176 | :param ~busio.I2C i2c_bus: The I2C bus the LSM6DSOX is connected to. 177 | :param int address: TThe I2C device address. Defaults to :const:`0x6A` 178 | 179 | """ 180 | 181 | # ROUnaryStructs: 182 | _chip_id = ROUnaryStruct(_LSM6DS_WHOAMI, " None: 222 | self._cached_accel_range = None 223 | self._cached_gyro_range = None 224 | 225 | self.i2c_device = i2c_device.I2CDevice(i2c_bus, address) 226 | if self.CHIP_ID is None: 227 | raise AttributeError("LSM6DS Parent Class cannot be directly instantiated") 228 | if self._chip_id != self.CHIP_ID: 229 | raise RuntimeError("Failed to find %s - check your wiring!" % self.__class__.__name__) 230 | self.reset() 231 | if not hasattr(GyroRange, "string"): 232 | self._add_gyro_ranges() 233 | self._bdu = True 234 | 235 | self._add_accel_ranges() 236 | self.accelerometer_data_rate = Rate.RATE_104_HZ 237 | self.gyro_data_rate = Rate.RATE_104_HZ 238 | 239 | self.accelerometer_range = AccelRange.RANGE_4G 240 | self.gyro_range = GyroRange.RANGE_250_DPS 241 | # Load and configure MLC if UCF file is provided 242 | if ucf is not None: 243 | self.load_mlc(ucf) 244 | 245 | def reset(self) -> None: 246 | "Resets the sensor's configuration into an initial state" 247 | self._sw_reset = True 248 | while self._sw_reset: 249 | sleep(0.001) 250 | 251 | @staticmethod 252 | def _add_gyro_ranges() -> None: 253 | GyroRange.add_values( 254 | ( 255 | ("RANGE_125_DPS", 125, 125, 4.375), 256 | ("RANGE_250_DPS", 0, 250, 8.75), 257 | ("RANGE_500_DPS", 1, 500, 17.50), 258 | ("RANGE_1000_DPS", 2, 1000, 35.0), 259 | ("RANGE_2000_DPS", 3, 2000, 70.0), 260 | ) 261 | ) 262 | 263 | @staticmethod 264 | def _add_accel_ranges() -> None: 265 | AccelRange.add_values( 266 | ( 267 | ("RANGE_2G", 0, 2, 0.061), 268 | ("RANGE_16G", 1, 16, 0.488), 269 | ("RANGE_4G", 2, 4, 0.122), 270 | ("RANGE_8G", 3, 8, 0.244), 271 | ) 272 | ) 273 | 274 | @property 275 | def acceleration(self) -> Tuple[float, float, float]: 276 | """The x, y, z acceleration values returned in a 3-tuple and are in m / s ^ 2.""" 277 | raw_accel_data = self._raw_accel_data 278 | 279 | x = self._scale_xl_data(raw_accel_data[0]) 280 | y = self._scale_xl_data(raw_accel_data[1]) 281 | z = self._scale_xl_data(raw_accel_data[2]) 282 | 283 | return (x, y, z) 284 | 285 | @property 286 | def gyro(self) -> Tuple[float, float, float]: 287 | """The x, y, z angular velocity values returned in a 3-tuple and are in radians / second""" 288 | raw_gyro_data = self._raw_gyro_data 289 | x, y, z = (radians(self._scale_gyro_data(i)) for i in raw_gyro_data) 290 | return (x, y, z) 291 | 292 | def _scale_xl_data(self, raw_measurement: int) -> float: 293 | return raw_measurement * AccelRange.lsb[self._cached_accel_range] * _MILLI_G_TO_ACCEL 294 | 295 | def _scale_gyro_data(self, raw_measurement: int) -> float: 296 | return raw_measurement * GyroRange.lsb[self._cached_gyro_range] / 1000 297 | 298 | @property 299 | def accelerometer_range(self) -> int: 300 | """Adjusts the range of values that the sensor can measure, from +/- 2G to +/-16G 301 | Note that larger ranges will be less accurate. Must be an ``AccelRange``""" 302 | return self._cached_accel_range 303 | 304 | @accelerometer_range.setter 305 | def accelerometer_range(self, value: int) -> None: 306 | if not AccelRange.is_valid(value): 307 | raise AttributeError("range must be an `AccelRange`") 308 | self._accel_range = value 309 | self._cached_accel_range = value 310 | sleep(0.2) # needed to let new range settle 311 | 312 | @property 313 | def gyro_range(self) -> int: 314 | """Adjusts the range of values that the sensor can measure, from 125 Degrees/s to 2000 315 | degrees/s. Note that larger ranges will be less accurate. Must be a ``GyroRange``. 316 | """ 317 | return self._cached_gyro_range 318 | 319 | @gyro_range.setter 320 | def gyro_range(self, value: int) -> None: 321 | self._set_gyro_range(value) 322 | sleep(0.2) 323 | 324 | def _set_gyro_range(self, value: int) -> None: 325 | if not GyroRange.is_valid(value): 326 | raise AttributeError("range must be a `GyroRange`") 327 | 328 | # range uses `FS_G` enum 329 | if value <= GyroRange.RANGE_2000_DPS: 330 | self._gyro_range_125dps = False 331 | self._gyro_range = value 332 | # range uses the `FS_125` bit 333 | if value is GyroRange.RANGE_125_DPS: 334 | self._gyro_range_125dps = True 335 | 336 | self._cached_gyro_range = value # needed to let new range settle 337 | 338 | @property 339 | def accelerometer_data_rate(self) -> int: 340 | """Select the rate at which the accelerometer takes measurements. Must be a ``Rate``""" 341 | return self._accel_data_rate 342 | 343 | @accelerometer_data_rate.setter 344 | def accelerometer_data_rate(self, value: int) -> None: 345 | if not Rate.is_valid(value): 346 | raise AttributeError("accelerometer_data_rate must be a `Rate`") 347 | 348 | self._accel_data_rate = value 349 | # sleep(.2) # needed to let new range settle 350 | 351 | @property 352 | def gyro_data_rate(self) -> int: 353 | """Select the rate at which the gyro takes measurements. Must be a ``Rate``""" 354 | return self._gyro_data_rate 355 | 356 | @gyro_data_rate.setter 357 | def gyro_data_rate(self, value: int) -> None: 358 | if not Rate.is_valid(value): 359 | raise AttributeError("gyro_data_rate must be a `Rate`") 360 | 361 | self._gyro_data_rate = value 362 | # sleep(.2) # needed to let new range settle 363 | 364 | @property 365 | def pedometer_enable(self) -> bool: 366 | """Whether the pedometer function on the accelerometer is enabled""" 367 | return self._ped_enable and self._func_enable 368 | 369 | @pedometer_enable.setter 370 | def pedometer_enable(self, enable: bool) -> None: 371 | self._ped_enable = enable 372 | self._func_enable = enable 373 | self._pedometer_reset = enable 374 | 375 | @property 376 | def high_pass_filter(self) -> int: 377 | """The high pass filter applied to accelerometer data""" 378 | return self._high_pass_filter 379 | 380 | @high_pass_filter.setter 381 | def high_pass_filter(self, value: int) -> None: 382 | if not AccelHPF.is_valid(value): 383 | raise AttributeError("range must be an `AccelHPF`") 384 | self._high_pass_filter = value 385 | 386 | @property 387 | def temperature(self) -> float: 388 | """Temperature in Celsius""" 389 | # Data from Datasheet Table 4.3 390 | # Temp range -40 to 85 Celsius 391 | # T_ADC_RES = ADC Res 16 bit 392 | # Stabilization time 500 μs 393 | 394 | temp = self._raw_temp_data[0] 395 | 396 | return temp / _TEMPERATURE_SENSITIVITY + _TEMPERATURE_OFFSET 397 | 398 | def _set_embedded_functions(self, enable, emb_ab=None): 399 | """Enable/disable embedded functions - returns prior settings when disabled""" 400 | self._mem_bank = 1 401 | if enable: 402 | self._emb_func_en_a = emb_ab[0] 403 | self._emb_func_en_b = emb_ab[1] 404 | else: 405 | emb_a = self._emb_func_en_a 406 | emb_b = self._emb_func_en_b 407 | self._emb_func_en_a = (emb_a[0] & 0xC7,) 408 | self._emb_func_en_b = (emb_b[0] & 0xE6,) 409 | emb_ab = (emb_a, emb_b) 410 | 411 | self._mem_bank = 0 412 | return emb_ab 413 | 414 | def load_mlc(self, ucf): 415 | """Load MLC configuration file into sensor""" 416 | buf = bytearray(2) 417 | with self.i2c_device as i2c: 418 | # Load MLC config from file 419 | with open(ucf) as ucf_file: 420 | for line in ucf_file: 421 | if line.startswith("Ac"): 422 | command = [int(v, 16) for v in line.strip().split(" ")[1:3]] 423 | buf[0] = command[0] 424 | buf[1] = command[1] 425 | i2c.write(buf) 426 | 427 | # Disable embudded function -- save current settings 428 | emb_ab = self._set_embedded_functions(False) 429 | 430 | # Disable I3C interface 431 | self._i3c_disable = 1 432 | 433 | # Enable Block Data Update 434 | self._block_data_enable = 1 435 | 436 | # Route signals on interrupt pin 1 437 | self._mem_bank = 1 438 | self._route_int1 &= 1 439 | self._mem_bank = 0 440 | 441 | # Configure interrupt pin mode 442 | self._tap_latch = 1 443 | self._tap_clear = 1 444 | 445 | # Enabble Embedded Functions using previously stored settings 446 | self._set_embedded_functions(True, emb_ab) 447 | 448 | def read_mlc_output(self): 449 | """Read MLC results""" 450 | buf = None 451 | if self._mlc_status: 452 | self._mem_bank = 1 453 | buf = self._mlc0_src 454 | self._mem_bank = 0 455 | return buf 456 | -------------------------------------------------------------------------------- /adafruit_lsm6ds/ism330dhcx.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | """ 5 | This module provides the `adafruit_lsm6ds.ism330dhcx` subclass of LSM6DS sensors 6 | ================================================================================== 7 | """ 8 | 9 | from time import sleep 10 | 11 | from . import LSM6DS, LSM6DS_DEFAULT_ADDRESS, GyroRange, RWBit, const 12 | 13 | try: 14 | import typing 15 | 16 | from busio import I2C 17 | except ImportError: 18 | pass 19 | 20 | _LSM6DS_CTRL2_G = const(0x11) 21 | 22 | 23 | class ISM330DHCX(LSM6DS): 24 | """Driver for the ISM330DHCX 6-axis accelerometer and gyroscope. 25 | 26 | :param ~busio.I2C i2c_bus: The I2C bus the device is connected to. 27 | :param int address: The I2C device address. Defaults to :const:`0x6A` 28 | 29 | 30 | **Quickstart: Importing and using the device** 31 | 32 | Here is an example of using the :class:`ISM330DHCX` class. 33 | First you will need to import the libraries to use the sensor 34 | 35 | .. code-block:: python 36 | 37 | import board 38 | from adafruit_lsm6ds.ism330dhcx import ISM330DHCX 39 | 40 | Once this is done you can define your `board.I2C` object and define your sensor object 41 | 42 | .. code-block:: python 43 | 44 | i2c = board.I2C() # uses board.SCL and board.SDA 45 | sensor = ISM330DHCX(i2c) 46 | 47 | Now you have access to the :attr:`acceleration` and :attr:`gyro`: attributes 48 | 49 | .. code-block:: python 50 | 51 | acc_x, acc_y, acc_z = sensor.acceleration 52 | gyro_x, gyro_z, gyro_z = sensor.gyro 53 | 54 | 55 | """ 56 | 57 | CHIP_ID = 0x6B 58 | _gyro_range_4000dps = RWBit(_LSM6DS_CTRL2_G, 0) 59 | 60 | def __init__(self, i2c_bus: I2C, address: int = LSM6DS_DEFAULT_ADDRESS) -> None: 61 | GyroRange.add_values( 62 | ( 63 | ("RANGE_125_DPS", 125, 125, 4.375), 64 | ("RANGE_250_DPS", 0, 250, 8.75), 65 | ("RANGE_500_DPS", 1, 500, 17.50), 66 | ("RANGE_1000_DPS", 2, 1000, 35.0), 67 | ("RANGE_2000_DPS", 3, 2000, 70.0), 68 | ("RANGE_4000_DPS", 4000, 4000, 140.0), 69 | ) 70 | ) 71 | super().__init__(i2c_bus, address) 72 | 73 | # Called DEVICE_CONF in the datasheet, but it recommends setting it 74 | self._i3c_disable = True 75 | 76 | @property 77 | def gyro_range(self) -> int: 78 | """Adjusts the range of values that the sensor can measure, from 125 Degrees/s to 4000 79 | degrees/s. Note that larger ranges will be less accurate. Must be a ``GyroRange``. 4000 DPS 80 | is only available for the ISM330DHCX""" 81 | return self._cached_gyro_range 82 | 83 | @gyro_range.setter 84 | def gyro_range(self, value: int) -> None: 85 | super()._set_gyro_range(value) 86 | 87 | # range uses the `FS_4000` bit 88 | if value is GyroRange.RANGE_4000_DPS: 89 | self._gyro_range_125dps = False 90 | self._gyro_range_4000dps = True 91 | else: 92 | self._gyro_range_4000dps = False 93 | 94 | sleep(0.2) # needed to let new range settle 95 | -------------------------------------------------------------------------------- /adafruit_lsm6ds/lsm6ds3.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright (c) 2022 Edrig 2 | # 3 | # SPDX-License-Identifier: MIT 4 | """ 5 | This module provides the `adafruit_lsm6ds.lsm6ds33` subclass of LSM6DS sensors 6 | =============================================================================== 7 | """ 8 | 9 | from . import LSM6DS 10 | 11 | 12 | class LSM6DS3(LSM6DS): 13 | """Driver for the LSM6DS3 6-axis accelerometer and gyroscope. 14 | 15 | :param ~busio.I2C i2c_bus: The I2C bus the LSM6DS3 is connected to. 16 | :param int address: The I2C device address. Defaults to :const:`0x6A` 17 | 18 | 19 | **Quickstart: Importing and using the device** 20 | 21 | Here is an example of using the :class:`LSM6DS3` class. 22 | First you will need to import the libraries to use the sensor 23 | 24 | .. code-block:: python 25 | 26 | import board 27 | from adafruit_lsm6ds.lsm6ds3 import LSM6DS3 28 | 29 | Once this is done you can define your `board.I2C` object and define your sensor object 30 | 31 | .. code-block:: python 32 | 33 | i2c = board.I2C() # uses board.SCL and board.SDA 34 | sensor = LSM6DS3(i2c) 35 | 36 | Now you have access to the :attr:`acceleration` and :attr:`gyro`: attributes 37 | 38 | .. code-block:: python 39 | 40 | acc_x, acc_y, acc_z = sensor.acceleration 41 | gyro_x, gyro_z, gyro_z = sensor.gyro 42 | 43 | """ 44 | 45 | CHIP_ID = 0x6A 46 | -------------------------------------------------------------------------------- /adafruit_lsm6ds/lsm6ds33.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | """ 5 | This module provides the `adafruit_lsm6ds.lsm6ds33` subclass of LSM6DS sensors 6 | =============================================================================== 7 | """ 8 | 9 | from . import LSM6DS 10 | 11 | 12 | class LSM6DS33(LSM6DS): 13 | """Driver for the LSM6DS33 6-axis accelerometer and gyroscope. 14 | 15 | :param ~busio.I2C i2c_bus: The I2C bus the LSM6DS33 is connected to. 16 | :param int address: The I2C device address. Defaults to :const:`0x6A` 17 | 18 | 19 | **Quickstart: Importing and using the device** 20 | 21 | Here is an example of using the :class:`LSM6DS33` class. 22 | First you will need to import the libraries to use the sensor 23 | 24 | .. code-block:: python 25 | 26 | import board 27 | from adafruit_lsm6ds.lsm6ds33 import LSM6DS33 28 | 29 | Once this is done you can define your `board.I2C` object and define your sensor object 30 | 31 | .. code-block:: python 32 | 33 | i2c = board.I2C() # uses board.SCL and board.SDA 34 | sensor = LSM6DS33(i2c) 35 | 36 | Now you have access to the :attr:`acceleration` and :attr:`gyro`: attributes 37 | 38 | .. code-block:: python 39 | 40 | acc_x, acc_y, acc_z = sensor.acceleration 41 | gyro_x, gyro_z, gyro_z = sensor.gyro 42 | 43 | """ 44 | 45 | CHIP_ID = 0x69 46 | -------------------------------------------------------------------------------- /adafruit_lsm6ds/lsm6ds3trc.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | """ 5 | This module provides the `adafruit_lsm6ds.lsm6ds3trc` subclass of LSM6DS sensors 6 | =============================================================================== 7 | """ 8 | 9 | from . import LSM6DS, RWBit, const 10 | 11 | _LSM6DS_CTRL10_C = const(0x19) 12 | 13 | 14 | class LSM6DS3TRC(LSM6DS): 15 | """Driver for the LSM6DS3TR-C 6-axis accelerometer and gyroscope. 16 | 17 | :param ~busio.I2C i2c_bus: The I2C bus the LSM6DS3TR-C is connected to. 18 | :param int address: The I2C device address. Defaults to :const:`0x6A` 19 | 20 | 21 | **Quickstart: Importing and using the device** 22 | 23 | Here is an example of using the :class:`LSM6DS3TRC` class. 24 | First you will need to import the libraries to use the sensor 25 | 26 | .. code-block:: python 27 | 28 | import board 29 | from adafruit_lsm6ds.lsm6ds3trc import LSM6DS3TRC 30 | 31 | Once this is done you can define your `board.I2C` object and define your sensor object 32 | 33 | .. code-block:: python 34 | 35 | i2c = board.I2C() # uses board.SCL and board.SDA 36 | sensor = LSM6DS3TRC(i2c) 37 | 38 | Now you have access to the :attr:`acceleration` and :attr:`gyro`: attributes 39 | 40 | .. code-block:: python 41 | 42 | acc_x, acc_y, acc_z = sensor.acceleration 43 | gyro_x, gyro_y, gyro_z = sensor.gyro 44 | 45 | """ 46 | 47 | CHIP_ID = 0x6A 48 | 49 | # This version of the IMU has a different register for enabling the pedometer 50 | # https://www.st.com/resource/en/datasheet/lsm6ds3tr-c.pdf 51 | _ped_enable = RWBit(_LSM6DS_CTRL10_C, 4) 52 | -------------------------------------------------------------------------------- /adafruit_lsm6ds/lsm6dso32.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | """ 5 | This module provides the `adafruit_lsm6ds.lsm6dso32` subclass of LSM6DS sensors 6 | ================================================================================= 7 | """ 8 | 9 | from . import LSM6DS, LSM6DS_CHIP_ID, LSM6DS_DEFAULT_ADDRESS, AccelRange 10 | 11 | try: 12 | import typing 13 | 14 | from busio import I2C 15 | except ImportError: 16 | pass 17 | 18 | 19 | class LSM6DSO32(LSM6DS): 20 | """Driver for the LSM6DSO32 6-axis accelerometer and gyroscope. 21 | 22 | :param ~busio.I2C i2c_bus: The I2C bus the LSM6DSO32 is connected to. 23 | :param address: The I2C device address. Defaults to :const:`0x6A` 24 | 25 | 26 | **Quickstart: Importing and using the device** 27 | 28 | Here is an example of using the :class:`LSM6DSO32` class. 29 | First you will need to import the libraries to use the sensor 30 | 31 | .. code-block:: python 32 | 33 | import board 34 | from adafruit_lsm6ds.lsm6dso32 import LSM6DSO32 35 | 36 | Once this is done you can define your `board.I2C` object and define your sensor object 37 | 38 | .. code-block:: python 39 | 40 | i2c = board.I2C() # uses board.SCL and board.SDA 41 | sensor = LSM6DSO32(i2c) 42 | 43 | Now you have access to the :attr:`acceleration` and :attr:`gyro`: attributes 44 | 45 | .. code-block:: python 46 | 47 | acc_x, acc_y, acc_z = sensor.acceleration 48 | gyro_x, gyro_z, gyro_z = sensor.gyro 49 | 50 | 51 | """ 52 | 53 | CHIP_ID = LSM6DS_CHIP_ID 54 | 55 | def __init__(self, i2c_bus: I2C, address: int = LSM6DS_DEFAULT_ADDRESS) -> None: 56 | super().__init__(i2c_bus, address) 57 | self._i3c_disable = True 58 | self.accelerometer_range = AccelRange.RANGE_8G # pylint:disable=no-member 59 | 60 | @staticmethod 61 | def _add_accel_ranges() -> None: 62 | AccelRange.add_values( 63 | ( 64 | ("RANGE_4G", 0, 4, 0.122), 65 | ("RANGE_32G", 1, 32, 0.976), 66 | ("RANGE_8G", 2, 8, 0.244), 67 | ("RANGE_16G", 3, 16, 0.488), 68 | ) 69 | ) 70 | -------------------------------------------------------------------------------- /adafruit_lsm6ds/lsm6dsox.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | """ 5 | This module provides the `adafruit_lsm6ds.lsm6dsox` subclass of LSM6DS sensors 6 | ============================================================================== 7 | """ 8 | 9 | from . import LSM6DS, LSM6DS_CHIP_ID, LSM6DS_DEFAULT_ADDRESS 10 | 11 | try: 12 | import typing 13 | 14 | from busio import I2C 15 | except ImportError: 16 | pass 17 | 18 | 19 | class LSM6DSOX(LSM6DS): 20 | """Driver for the LSM6DSOX 6-axis accelerometer and gyroscope. 21 | 22 | :param ~busio.I2C i2c_bus: The I2C bus the LSM6DSOX is connected to. 23 | :param int address: The I2C device address. Defaults to :const:`0x6A` 24 | 25 | 26 | **Quickstart: Importing and using the device** 27 | 28 | Here is an example of using the :class:`LSM6DSOX` class. 29 | First you will need to import the libraries to use the sensor 30 | 31 | .. code-block:: python 32 | 33 | import board 34 | from adafruit_lsm6ds.lsm6dsox import LSM6DSOX 35 | 36 | Once this is done you can define your `board.I2C` object and define your sensor object 37 | 38 | .. code-block:: python 39 | 40 | i2c = board.I2C() # uses board.SCL and board.SDA 41 | sensor = LSM6DSOX(i2c) 42 | 43 | Now you have access to the :attr:`acceleration` and :attr:`gyro`: attributes 44 | 45 | .. code-block:: python 46 | 47 | acc_x, acc_y, acc_z = sensor.acceleration 48 | gyro_x, gyro_z, gyro_z = sensor.gyro 49 | 50 | """ 51 | 52 | CHIP_ID = LSM6DS_CHIP_ID 53 | 54 | def __init__( 55 | self, i2c_bus: I2C, address: int = LSM6DS_DEFAULT_ADDRESS, ucf: str = None 56 | ) -> None: 57 | super().__init__(i2c_bus, address, ucf) 58 | self._i3c_disable = True 59 | -------------------------------------------------------------------------------- /docs/_static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_LSM6DS/42c6c88dae6eacffb4e2b6daf4a601a27c805c3b/docs/_static/favicon.ico -------------------------------------------------------------------------------- /docs/_static/favicon.ico.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries 2 | 3 | SPDX-License-Identifier: CC-BY-4.0 4 | -------------------------------------------------------------------------------- /docs/api.rst: -------------------------------------------------------------------------------- 1 | 2 | .. If you created a package, create one automodule per module in the package. 3 | 4 | .. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py) 5 | .. use this format as the module name: "adafruit_foo.foo" 6 | 7 | API Reference 8 | ############# 9 | 10 | .. automodule:: adafruit_lsm6ds 11 | :members: 12 | :exclude-members: CV, AccelRange, GyroRange, AccelHPF, Rate 13 | :member-order: bysource 14 | 15 | 16 | .. automodule:: adafruit_lsm6ds.ism330dhcx 17 | :members: 18 | 19 | .. automodule:: adafruit_lsm6ds.lsm6ds33 20 | :members: 21 | 22 | .. automodule:: adafruit_lsm6ds.lsm6dso32 23 | :members: 24 | 25 | .. automodule:: adafruit_lsm6ds.lsm6dsox 26 | :members: 27 | -------------------------------------------------------------------------------- /docs/api.rst.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | 3 | SPDX-License-Identifier: MIT 4 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | import datetime 6 | import os 7 | import sys 8 | 9 | sys.path.insert(0, os.path.abspath("..")) 10 | 11 | # -- General configuration ------------------------------------------------ 12 | 13 | # Add any Sphinx extension module names here, as strings. They can be 14 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 15 | # ones. 16 | extensions = [ 17 | "sphinx.ext.autodoc", 18 | "sphinxcontrib.jquery", 19 | "sphinx.ext.intersphinx", 20 | "sphinx.ext.napoleon", 21 | "sphinx.ext.todo", 22 | ] 23 | 24 | # TODO: Please Read! 25 | # Uncomment the below if you use native CircuitPython modules such as 26 | # digitalio, micropython and busio. List the modules you use. Without it, the 27 | # autodoc module docs will fail to generate with a warning. 28 | autodoc_mock_imports = ["micropython", "adafruit_bus_device", "adafruit_register"] 29 | 30 | 31 | intersphinx_mapping = { 32 | "python": ("https://docs.python.org/3", None), 33 | "BusDevice": ( 34 | "https://docs.circuitpython.org/projects/busdevice/en/latest/", 35 | None, 36 | ), 37 | "Register": ( 38 | "https://docs.circuitpython.org/projects/register/en/latest/", 39 | None, 40 | ), 41 | "CircuitPython": ("https://docs.circuitpython.org/en/latest/", None), 42 | } 43 | 44 | # Add any paths that contain templates here, relative to this directory. 45 | templates_path = ["_templates"] 46 | 47 | source_suffix = ".rst" 48 | 49 | # The master toctree document. 50 | master_doc = "index" 51 | 52 | # General information about the project. 53 | project = "Adafruit LSM6DS Library" 54 | creation_year = "2019" 55 | current_year = str(datetime.datetime.now().year) 56 | year_duration = ( 57 | current_year if current_year == creation_year else creation_year + " - " + current_year 58 | ) 59 | copyright = year_duration + " Bryan Siepert" 60 | author = "Bryan Siepert" 61 | 62 | # The version info for the project you're documenting, acts as replacement for 63 | # |version| and |release|, also used in various other places throughout the 64 | # built documents. 65 | # 66 | # The short X.Y version. 67 | version = "1.0" 68 | # The full version, including alpha/beta/rc tags. 69 | release = "1.0" 70 | 71 | # The language for content autogenerated by Sphinx. Refer to documentation 72 | # for a list of supported languages. 73 | # 74 | # This is also used if you do content translation via gettext catalogs. 75 | # Usually you set "language" from the command line for these cases. 76 | language = "en" 77 | 78 | # List of patterns, relative to source directory, that match files and 79 | # directories to ignore when looking for source files. 80 | # This patterns also effect to html_static_path and html_extra_path 81 | exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"] 82 | 83 | # The reST default role (used for this markup: `text`) to use for all 84 | # documents. 85 | # 86 | default_role = "any" 87 | 88 | # If true, '()' will be appended to :func: etc. cross-reference text. 89 | # 90 | add_function_parentheses = True 91 | 92 | # The name of the Pygments (syntax highlighting) style to use. 93 | pygments_style = "sphinx" 94 | 95 | # If true, `todo` and `todoList` produce output, else they produce nothing. 96 | todo_include_todos = False 97 | 98 | # If this is True, todo emits a warning for each TODO entries. The default is False. 99 | todo_emit_warnings = True 100 | 101 | napoleon_numpy_docstring = False 102 | 103 | # -- Options for HTML output ---------------------------------------------- 104 | 105 | # The theme to use for HTML and HTML Help pages. See the documentation for 106 | # a list of builtin themes. 107 | # 108 | import sphinx_rtd_theme 109 | 110 | html_theme = "sphinx_rtd_theme" 111 | 112 | # Add any paths that contain custom static files (such as style sheets) here, 113 | # relative to this directory. They are copied after the builtin static files, 114 | # so a file named "default.css" will overwrite the builtin "default.css". 115 | html_static_path = ["_static"] 116 | 117 | # The name of an image file (relative to this directory) to use as a favicon of 118 | # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 119 | # pixels large. 120 | # 121 | html_favicon = "_static/favicon.ico" 122 | 123 | # Output file base name for HTML help builder. 124 | htmlhelp_basename = "AdafruitLsm6dsLibrarydoc" 125 | 126 | # -- Options for LaTeX output --------------------------------------------- 127 | 128 | latex_elements = { 129 | # The paper size ('letterpaper' or 'a4paper'). 130 | # 131 | # 'papersize': 'letterpaper', 132 | # The font size ('10pt', '11pt' or '12pt'). 133 | # 134 | # 'pointsize': '10pt', 135 | # Additional stuff for the LaTeX preamble. 136 | # 137 | # 'preamble': '', 138 | # Latex figure (float) alignment 139 | # 140 | # 'figure_align': 'htbp', 141 | } 142 | 143 | # Grouping the document tree into LaTeX files. List of tuples 144 | # (source start file, target name, title, 145 | # author, documentclass [howto, manual, or own class]). 146 | latex_documents = [ 147 | ( 148 | master_doc, 149 | "AdafruitLSM6DSLibrary.tex", 150 | "AdafruitLSM6DS Library Documentation", 151 | author, 152 | "manual", 153 | ), 154 | ] 155 | 156 | # -- Options for manual page output --------------------------------------- 157 | 158 | # One entry per manual page. List of tuples 159 | # (source start file, name, description, authors, manual section). 160 | man_pages = [ 161 | ( 162 | master_doc, 163 | "AdafruitLSM6DSlibrary", 164 | "Adafruit LSM6DS Library Documentation", 165 | [author], 166 | 1, 167 | ), 168 | ] 169 | 170 | # -- Options for Texinfo output ------------------------------------------- 171 | 172 | # Grouping the document tree into Texinfo files. List of tuples 173 | # (source start file, target name, title, author, 174 | # dir menu entry, description, category) 175 | texinfo_documents = [ 176 | ( 177 | master_doc, 178 | "AdafruitLSM6DSLibrary", 179 | "Adafruit LSM6DS Library Documentation", 180 | author, 181 | "AdafruitLSM6DSLibrary", 182 | "One line description of project.", 183 | "Miscellaneous", 184 | ), 185 | ] 186 | -------------------------------------------------------------------------------- /docs/examples.rst: -------------------------------------------------------------------------------- 1 | LSM6DSOX Simple test 2 | -------------------- 3 | 4 | Ensure your LSM6DSOX device works with this simple test. 5 | 6 | .. literalinclude:: ../examples/lsm6ds_lsm6dsox_simpletest.py 7 | :caption: examples/lsm6ds_lsm6dsox_simpletest.py 8 | :linenos: 9 | 10 | 11 | LSM6DSO32 Simple test 12 | --------------------- 13 | 14 | Ensure your LSM6DSO32 device works with this simple test. 15 | 16 | .. literalinclude:: ../examples/lsm6ds_lsm6dso32_simpletest.py 17 | :caption: examples/lsm6ds_lsm6dso32_simpletest.py 18 | :linenos: 19 | 20 | 21 | LSM6DS Simple test 22 | ------------------ 23 | 24 | Ensure your LSM6DS device works with this simple test. 25 | 26 | .. literalinclude:: ../examples/lsm6ds_lsm6ds33_simpletest.py 27 | :caption: examples/lsm6ds_lsm6ds33_simpletest.py 28 | :linenos: 29 | 30 | 31 | ISM330DHCX Simple test 32 | ---------------------- 33 | 34 | Ensure your ISM330DHCX device works with this simple test. 35 | 36 | .. literalinclude:: ../examples/lsm6ds_ism330dhcx_simpletest.py 37 | :caption: examples/lsm6ds_ism330dhcx_simpletest.py 38 | :linenos: 39 | 40 | 41 | LSM6DS Full test 42 | ---------------- 43 | 44 | LSM6DS Full tests 45 | 46 | .. literalinclude:: ../examples/lsm6ds_full_test.py 47 | :caption: examples/lsm6ds_full_test.py 48 | :linenos: 49 | 50 | 51 | Pedometer Example 52 | ----------------- 53 | 54 | Example showing how to use the device as a pedometer 55 | 56 | .. literalinclude:: ../examples/lsm6ds_pedometer.py 57 | :caption: examples/lsm6ds_pedometer.py 58 | :linenos: 59 | 60 | 61 | Rate test 62 | ------------ 63 | 64 | Example showing a Rate test 65 | 66 | .. literalinclude:: ../examples/lsm6ds_rate_test.py 67 | :caption: examples/lsm6ds_rate_test.py 68 | :linenos: 69 | -------------------------------------------------------------------------------- /docs/examples.rst.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | 3 | SPDX-License-Identifier: MIT 4 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../README.rst 2 | 3 | Table of Contents 4 | ================= 5 | 6 | .. toctree:: 7 | :maxdepth: 4 8 | :hidden: 9 | 10 | self 11 | 12 | .. toctree:: 13 | :caption: Examples 14 | 15 | examples 16 | 17 | .. toctree:: 18 | :caption: API Reference 19 | :maxdepth: 3 20 | 21 | api 22 | 23 | .. toctree:: 24 | :caption: Tutorials 25 | 26 | LSM6DSOX and ISM330DHC 6 DoF IMU Guide 27 | Adafruit LSM6DS33 6-DoF IMU Breakout Guide 28 | ST 9-DoF Combo Breakouts and Wings Guide 29 | 30 | .. toctree:: 31 | :caption: Related Products 32 | 33 | * Adafruit LSM6DSOX Breakout 34 | 35 | * Adafruit ISM330DHCX Breakout 36 | 37 | * Adafruit LSM6DSO32 Breakout 38 | 39 | * Adafruit LSM6DS33 Breakout 40 | 41 | * Adafruit ISM330DHCX + LIS3MDL FEATHERWING 42 | 43 | * Adafruit LSM6DSOX + LIS3MDL - 9 DOF IMU Breakout 44 | 45 | * Adafruit LSM6DS33 + LIS3MDL - 9 DOF IMU Breakout 46 | 47 | * Adafruit LSM6DSOX + LIS3MDL 9 DOF IMU FeatherWing 48 | 49 | 50 | .. toctree:: 51 | :caption: Other Links 52 | 53 | Download from GitHub 54 | Download Library Bundle 55 | CircuitPython Reference Documentation 56 | CircuitPython Support Forum 57 | Discord Chat 58 | Adafruit Learning System 59 | Adafruit Blog 60 | Adafruit Store 61 | 62 | Indices and tables 63 | ================== 64 | 65 | * :ref:`genindex` 66 | * :ref:`modindex` 67 | * :ref:`search` 68 | -------------------------------------------------------------------------------- /docs/index.rst.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries 2 | 3 | SPDX-License-Identifier: MIT 4 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | sphinx 6 | sphinxcontrib-jquery 7 | sphinx-rtd-theme 8 | -------------------------------------------------------------------------------- /examples/lsm6ds_full_test.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | import time 5 | 6 | import board 7 | 8 | # pylint:disable=no-member 9 | from adafruit_lsm6ds import AccelRange, GyroRange, Rate 10 | from adafruit_lsm6ds.lsm6dsox import LSM6DSOX as LSM6DS 11 | 12 | # from adafruit_lsm6ds.lsm6ds33 import LSM6DS33 as LSM6DS 13 | # from adafruit_lsm6ds.lsm6dso32 import LSM6DSO32 as LSM6DS 14 | # from adafruit_lsm6ds.ism330dhcx import ISM330DHCX as LSM6DS 15 | 16 | i2c = board.I2C() # uses board.SCL and board.SDA 17 | # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller 18 | sensor = LSM6DS(i2c) 19 | 20 | sensor.accelerometer_range = AccelRange.RANGE_8G 21 | print("Accelerometer range set to: %d G" % AccelRange.string[sensor.accelerometer_range]) 22 | 23 | sensor.gyro_range = GyroRange.RANGE_2000_DPS 24 | print("Gyro range set to: %d DPS" % GyroRange.string[sensor.gyro_range]) 25 | 26 | sensor.accelerometer_data_rate = Rate.RATE_1_66K_HZ 27 | # sensor.accelerometer_data_rate = Rate.RATE_12_5_HZ 28 | print("Accelerometer rate set to: %d HZ" % Rate.string[sensor.accelerometer_data_rate]) 29 | 30 | sensor.gyro_data_rate = Rate.RATE_1_66K_HZ 31 | print("Gyro rate set to: %d HZ" % Rate.string[sensor.gyro_data_rate]) 32 | 33 | while True: 34 | print( 35 | "Accel X:%.2f Y:%.2f Z:%.2f ms^2 Gyro X:%.2f Y:%.2f Z:%.2f radians/s" 36 | % (sensor.acceleration + sensor.gyro) 37 | ) 38 | time.sleep(0.05) 39 | -------------------------------------------------------------------------------- /examples/lsm6ds_ism330dhcx_simpletest.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | import time 5 | 6 | import board 7 | 8 | from adafruit_lsm6ds.ism330dhcx import ISM330DHCX 9 | 10 | i2c = board.I2C() # uses board.SCL and board.SDA 11 | # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller 12 | sensor = ISM330DHCX(i2c) 13 | 14 | while True: 15 | accel_x, accel_y, accel_z = sensor.acceleration 16 | print(f"Acceleration: X:{accel_x:.2f}, Y: {accel_y:.2f}, Z: {accel_z:.2f} m/s^2") 17 | gyro_x, gyro_y, gyro_z = sensor.gyro 18 | print(f"Gyro X:{gyro_x:.2f}, Y: {gyro_y:.2f}, Z: {gyro_z:.2f} radians/s") 19 | print("") 20 | time.sleep(0.5) 21 | -------------------------------------------------------------------------------- /examples/lsm6ds_lsm6ds33_simpletest.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | import time 5 | 6 | import board 7 | 8 | from adafruit_lsm6ds.lsm6ds33 import LSM6DS33 9 | 10 | i2c = board.I2C() # uses board.SCL and board.SDA 11 | # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller 12 | sensor = LSM6DS33(i2c) 13 | 14 | while True: 15 | accel_x, accel_y, accel_z = sensor.acceleration 16 | print(f"Acceleration: X:{accel_x:.2f}, Y: {accel_y:.2f}, Z: {accel_z:.2f} m/s^2") 17 | gyro_x, gyro_y, gyro_z = sensor.gyro 18 | print(f"Gyro X:{gyro_x:.2f}, Y: {gyro_y:.2f}, Z: {gyro_z:.2f} radians/s") 19 | print("") 20 | time.sleep(0.5) 21 | -------------------------------------------------------------------------------- /examples/lsm6ds_lsm6ds3_simpletest.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright (c) 2022 Edrig 2 | # 3 | # SPDX-License-Identifier: MIT 4 | import time 5 | 6 | import board 7 | 8 | from adafruit_lsm6ds.lsm6ds3 import LSM6DS3 9 | 10 | i2c = board.I2C() # uses board.SCL and board.SDA 11 | # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller 12 | sensor = LSM6DS3(i2c) 13 | 14 | while True: 15 | accel_x, accel_y, accel_z = sensor.acceleration 16 | print(f"Acceleration: X:{accel_x:.2f}, Y: {accel_y:.2f}, Z: {accel_z:.2f} m/s^2") 17 | gyro_x, gyro_y, gyro_z = sensor.gyro 18 | print(f"Gyro X:{gyro_x:.2f}, Y: {gyro_y:.2f}, Z: {gyro_z:.2f} radians/s") 19 | print("") 20 | time.sleep(0.5) 21 | -------------------------------------------------------------------------------- /examples/lsm6ds_lsm6ds3trc_simpletest.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | import time 5 | 6 | import board 7 | import busio 8 | import digitalio 9 | 10 | from adafruit_lsm6ds.lsm6ds3trc import LSM6DS3TRC 11 | 12 | # On the Seeed XIAO nRF52840 Sense the LSM6DS3TR-C IMU is connected on a separate 13 | # I2C bus and it has its own power pin that we need to enable. 14 | imupwr = digitalio.DigitalInOut(board.IMU_PWR) 15 | imupwr.direction = digitalio.Direction.OUTPUT 16 | imupwr.value = True 17 | time.sleep(0.1) 18 | 19 | imu_i2c = busio.I2C(board.IMU_SCL, board.IMU_SDA) 20 | sensor = LSM6DS3TRC(imu_i2c) 21 | 22 | while True: 23 | accel_x, accel_y, accel_z = sensor.acceleration 24 | print(f"Acceleration: X:{accel_x:.2f}, Y: {accel_y:.2f}, Z: {accel_z:.2f} m/s^2") 25 | gyro_x, gyro_y, gyro_z = sensor.gyro 26 | print(f"Gyro X:{gyro_x:.2f}, Y: {gyro_y:.2f}, Z: {gyro_z:.2f} radians/s") 27 | print("") 28 | time.sleep(0.5) 29 | -------------------------------------------------------------------------------- /examples/lsm6ds_lsm6dso32_simpletest.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | import time 5 | 6 | import board 7 | 8 | from adafruit_lsm6ds.lsm6dso32 import LSM6DSO32 9 | 10 | i2c = board.I2C() # uses board.SCL and board.SDA 11 | # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller 12 | sensor = LSM6DSO32(i2c) 13 | 14 | while True: 15 | accel_x, accel_y, accel_z = sensor.acceleration 16 | print(f"Acceleration: X:{accel_x:.2f}, Y: {accel_y:.2f}, Z: {accel_z:.2f} m/s^2") 17 | gyro_x, gyro_y, gyro_z = sensor.gyro 18 | print(f"Gyro X:{gyro_x:.2f}, Y: {gyro_y:.2f}, Z: {gyro_z:.2f} radians/s") 19 | print("") 20 | time.sleep(0.5) 21 | -------------------------------------------------------------------------------- /examples/lsm6ds_lsm6dsox_mlc_test.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | # LSM6DSOX IMU MLC (Machine Learning Core) Example. 5 | # Download the raw UCF file, copy to storage and reset. 6 | 7 | # NOTE: The pre-trained models (UCF files) for the examples can be found here: 8 | # https://github.com/STMicroelectronics/STMems_Machine_Learning_Core/tree/master/application_examples/lsm6dsox 9 | 10 | import time 11 | 12 | import board 13 | 14 | from adafruit_lsm6ds import AccelRange, GyroRange, Rate 15 | from adafruit_lsm6ds.lsm6dsox import LSM6DSOX 16 | 17 | i2c = board.STEMMA_I2C() # uses board.SCL and board.SDA 18 | 19 | 20 | # Vibration detection example 21 | UCF_FILE = "lsm6dsox_vibration_monitoring.ucf" 22 | UCF_LABELS = {0: "no vibration", 1: "low vibration", 2: "high vibration"} 23 | # NOTE: Selected data rate and scale must match the MLC data rate and scale. 24 | lsm = LSM6DSOX(i2c, ucf=UCF_FILE) 25 | lsm.gyro_range = GyroRange.RANGE_2000_DPS 26 | lsm.accelerometer_range = AccelRange.RANGE_4G 27 | lsm.accelerometer_data_rate = Rate.RATE_26_HZ 28 | lsm.gyro_data_rate = Rate.RATE_26_HZ 29 | 30 | 31 | # Head gestures example 32 | # UCF_FILE = "lsm6dsox_head_gestures.ucf" 33 | # UCF_LABELS = {0:"Nod", 1:"Shake", 2:"Stationary", 3:"Swing", 4:"Walk"} 34 | # NOTE: Selected data rate and scale must match the MLC data rate and scale. 35 | # lsm = LSM6DSOX(i2c, ucf=UCF_FILE) 36 | # lsm.gyro_range = GyroRange.RANGE_250_DPS 37 | # lsm.accelerometer_range = AccelRange.RANGE_2G 38 | # lsm.accelerometer_data_rate = Rate.RATE_26_HZ 39 | # lsm.gyro_data_rate = Rate.RATE_26_HZ 40 | 41 | # 6 DOF Position example 42 | # UCF_FILE = "lsm6dsox_six_d_position.ucf" 43 | # UCF_LABELS = {0:"None", 1:"X-UP", 2:"X-DOWN", 3:"Y-UP", 4:"Y-DOWN", 5:"Z-UP", 6:"Z-DOWN"} 44 | # NOTE: Selected data rate and scale must match the MLC data rate and scale. 45 | # lsm = LSM6DSOX(i2c, ucf=UCF_FILE) 46 | # lsm.gyro_range = GyroRange.RANGE_250_DPS 47 | # lsm.accelerometer_range = AccelRange.RANGE_2G 48 | # lsm.accelerometer_data_rate = Rate.RATE_26_HZ 49 | # lsm.gyro_data_rate = Rate.RATE_26_HZ 50 | 51 | 52 | print("MLC configured...") 53 | 54 | while True: 55 | buf = lsm.read_mlc_output() 56 | if buf is not None: 57 | print(UCF_LABELS[buf[0]]) 58 | # delay to allow interrupt flag to clear 59 | # interrupt stays high for one sample interval 60 | # (38.4 ms @ 26 Hz ot 19.2 ms @ 52Hz) 61 | time.sleep(0.05) 62 | -------------------------------------------------------------------------------- /examples/lsm6ds_lsm6dsox_simpletest.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | import time 5 | 6 | import board 7 | 8 | from adafruit_lsm6ds.lsm6dsox import LSM6DSOX 9 | 10 | i2c = board.I2C() # uses board.SCL and board.SDA 11 | # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller 12 | sensor = LSM6DSOX(i2c) 13 | 14 | while True: 15 | accel_x, accel_y, accel_z = sensor.acceleration 16 | print(f"Acceleration: X:{accel_x:.2f}, Y: {accel_y:.2f}, Z: {accel_z:.2f} m/s^2") 17 | gyro_x, gyro_y, gyro_z = sensor.gyro 18 | print(f"Gyro X:{gyro_x:.2f}, Y: {gyro_y:.2f}, Z: {gyro_z:.2f} radians/s") 19 | print("") 20 | time.sleep(0.5) 21 | -------------------------------------------------------------------------------- /examples/lsm6ds_pedometer.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | """This example shows off how to use the step counter built 5 | into the ST LSM6DS series IMUs. The steps are calculated in 6 | the chip so you don't have to do any calculations!""" 7 | 8 | import time 9 | 10 | import board 11 | 12 | from adafruit_lsm6ds import AccelRange, Rate 13 | 14 | # pylint:disable=no-member 15 | from adafruit_lsm6ds.lsm6ds33 import LSM6DS33 16 | 17 | i2c = board.I2C() # uses board.SCL and board.SDA 18 | # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller 19 | sensor = LSM6DS33(i2c) 20 | 21 | # enable accelerometer sensor @ 2G and 26 Hz 22 | sensor.accelerometer_range = AccelRange.RANGE_2G 23 | sensor.accelerometer_data_rate = Rate.RATE_26_HZ 24 | # no gyro used for step detection 25 | sensor.gyro_data_rate = Rate.RATE_SHUTDOWN 26 | 27 | # enable the pedometer 28 | sensor.pedometer_enable = True 29 | 30 | while True: 31 | print("Steps: ", sensor.pedometer_steps) 32 | time.sleep(1) 33 | -------------------------------------------------------------------------------- /examples/lsm6ds_rate_test.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | import board 5 | 6 | # pylint:disable=no-member,unused-import 7 | from adafruit_lsm6ds import Rate 8 | from adafruit_lsm6ds.lsm6dsox import LSM6DSOX as LSM6DS 9 | 10 | # from adafruit_lsm6ds.lsm6ds33 import LSM6DS33 as LSM6DS 11 | # from adafruit_lsm6ds.lsm6dso32 import LSM6DSO32 as LSM6DS 12 | # from adafruit_lsm6ds.ism330dhcx import ISM330DHCX as LSM6DS 13 | 14 | i2c = board.I2C() # uses board.SCL and board.SDA 15 | # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller 16 | sensor = LSM6DS(i2c) 17 | 18 | while True: 19 | sensor.accelerometer_data_rate = Rate.RATE_12_5_HZ 20 | sensor.gyro_data_rate = Rate.RATE_12_5_HZ 21 | for i in range(100): 22 | print("(%.2f, %.2f, %.2f, %.2f, %.2f, %.2f" % (sensor.acceleration + sensor.gyro)) 23 | print() 24 | 25 | sensor.accelerometer_data_rate = Rate.RATE_52_HZ 26 | sensor.gyro_data_rate = Rate.RATE_52_HZ 27 | for i in range(100): 28 | print("(%.2f, %.2f, %.2f, %.2f, %.2f, %.2f" % (sensor.acceleration + sensor.gyro)) 29 | print() 30 | 31 | sensor.accelerometer_data_rate = Rate.RATE_416_HZ 32 | sensor.gyro_data_rate = Rate.RATE_416_HZ 33 | for i in range(100): 34 | print("(%.2f, %.2f, %.2f, %.2f, %.2f, %.2f" % (sensor.acceleration + sensor.gyro)) 35 | print() 36 | -------------------------------------------------------------------------------- /optional_requirements.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Alec Delaney for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | [build-system] 6 | requires = [ 7 | "setuptools", 8 | "wheel", 9 | "setuptools-scm", 10 | ] 11 | 12 | [project] 13 | name = "adafruit-circuitpython-lsm6ds" 14 | description = "CircuitPython helper library for the LSM6DS family of motion sensors from ST" 15 | version = "0.0.0+auto.0" 16 | readme = "README.rst" 17 | authors = [ 18 | {name = "Adafruit Industries", email = "circuitpython@adafruit.com"} 19 | ] 20 | urls = {Homepage = "https://github.com/adafruit/Adafruit_CircuitPython_LSM6DS"} 21 | keywords = [ 22 | "adafruit", 23 | "blinka", 24 | "circuitpython", 25 | "micropython", 26 | "lsm6ds", 27 | "lsm6dsox", 28 | "lsmds33", 29 | "lsm6dso32", 30 | "st", 31 | "imu", 32 | "gyro", 33 | "accelerometer", 34 | "ism330dhcx", 35 | "imu", 36 | "gyro", 37 | "gyroscope", 38 | "inemo", 39 | ] 40 | license = {text = "MIT"} 41 | classifiers = [ 42 | "Intended Audience :: Developers", 43 | "Topic :: Software Development :: Libraries", 44 | "Topic :: Software Development :: Embedded Systems", 45 | "Topic :: System :: Hardware", 46 | "License :: OSI Approved :: MIT License", 47 | "Programming Language :: Python :: 3", 48 | ] 49 | dynamic = ["dependencies", "optional-dependencies"] 50 | 51 | [tool.setuptools] 52 | packages = ["adafruit_lsm6ds"] 53 | 54 | [tool.setuptools.dynamic] 55 | dependencies = {file = ["requirements.txt"]} 56 | optional-dependencies = {optional = {file = ["optional_requirements.txt"]}} 57 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: Unlicense 4 | 5 | Adafruit-Blinka 6 | adafruit-circuitpython-register 7 | adafruit-circuitpython-busdevice 8 | -------------------------------------------------------------------------------- /ruff.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | target-version = "py38" 6 | line-length = 100 7 | 8 | [lint] 9 | preview = true 10 | select = ["I", "PL", "UP"] 11 | 12 | extend-select = [ 13 | "D419", # empty-docstring 14 | "E501", # line-too-long 15 | "W291", # trailing-whitespace 16 | "PLC0414", # useless-import-alias 17 | "PLC2401", # non-ascii-name 18 | "PLC2801", # unnecessary-dunder-call 19 | "PLC3002", # unnecessary-direct-lambda-call 20 | "E999", # syntax-error 21 | "PLE0101", # return-in-init 22 | "F706", # return-outside-function 23 | "F704", # yield-outside-function 24 | "PLE0116", # continue-in-finally 25 | "PLE0117", # nonlocal-without-binding 26 | "PLE0241", # duplicate-bases 27 | "PLE0302", # unexpected-special-method-signature 28 | "PLE0604", # invalid-all-object 29 | "PLE0605", # invalid-all-format 30 | "PLE0643", # potential-index-error 31 | "PLE0704", # misplaced-bare-raise 32 | "PLE1141", # dict-iter-missing-items 33 | "PLE1142", # await-outside-async 34 | "PLE1205", # logging-too-many-args 35 | "PLE1206", # logging-too-few-args 36 | "PLE1307", # bad-string-format-type 37 | "PLE1310", # bad-str-strip-call 38 | "PLE1507", # invalid-envvar-value 39 | "PLE2502", # bidirectional-unicode 40 | "PLE2510", # invalid-character-backspace 41 | "PLE2512", # invalid-character-sub 42 | "PLE2513", # invalid-character-esc 43 | "PLE2514", # invalid-character-nul 44 | "PLE2515", # invalid-character-zero-width-space 45 | "PLR0124", # comparison-with-itself 46 | "PLR0202", # no-classmethod-decorator 47 | "PLR0203", # no-staticmethod-decorator 48 | "UP004", # useless-object-inheritance 49 | "PLR0206", # property-with-parameters 50 | "PLR0904", # too-many-public-methods 51 | "PLR0911", # too-many-return-statements 52 | "PLR0912", # too-many-branches 53 | "PLR0913", # too-many-arguments 54 | "PLR0914", # too-many-locals 55 | "PLR0915", # too-many-statements 56 | "PLR0916", # too-many-boolean-expressions 57 | "PLR1702", # too-many-nested-blocks 58 | "PLR1704", # redefined-argument-from-local 59 | "PLR1711", # useless-return 60 | "C416", # unnecessary-comprehension 61 | "PLR1733", # unnecessary-dict-index-lookup 62 | "PLR1736", # unnecessary-list-index-lookup 63 | 64 | # ruff reports this rule is unstable 65 | #"PLR6301", # no-self-use 66 | 67 | "PLW0108", # unnecessary-lambda 68 | "PLW0120", # useless-else-on-loop 69 | "PLW0127", # self-assigning-variable 70 | "PLW0129", # assert-on-string-literal 71 | "B033", # duplicate-value 72 | "PLW0131", # named-expr-without-context 73 | "PLW0245", # super-without-brackets 74 | "PLW0406", # import-self 75 | "PLW0602", # global-variable-not-assigned 76 | "PLW0603", # global-statement 77 | "PLW0604", # global-at-module-level 78 | 79 | # fails on the try: import typing used by libraries 80 | #"F401", # unused-import 81 | 82 | "F841", # unused-variable 83 | "E722", # bare-except 84 | "PLW0711", # binary-op-exception 85 | "PLW1501", # bad-open-mode 86 | "PLW1508", # invalid-envvar-default 87 | "PLW1509", # subprocess-popen-preexec-fn 88 | "PLW2101", # useless-with-lock 89 | "PLW3301", # nested-min-max 90 | ] 91 | 92 | ignore = [ 93 | "PLR2004", # magic-value-comparison 94 | "UP030", # format literals 95 | "PLW1514", # unspecified-encoding 96 | "PLR0913", # too-many-arguments 97 | "PLR0915", # too-many-statements 98 | "PLR0917", # too-many-positional-arguments 99 | "PLR0904", # too-many-public-methods 100 | "PLR0912", # too-many-branches 101 | "PLR0916", # too-many-boolean-expressions 102 | ] 103 | 104 | [format] 105 | line-ending = "lf" 106 | --------------------------------------------------------------------------------