From 08eda760cad9cebdb4b3b1e54c00a0fa4be13c6e Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Thu, 15 Jun 2023 13:03:18 -0400 Subject: [PATCH] first commit --- .github/workflows/release_pypi.yml | 19 ++ .gitignore | 48 +++ .pre-commit-config.yaml | 38 +++ .pylintrc | 122 +++++++ .readthedocs.yaml | 15 + LICENSE | 21 ++ README.rst | 91 ++++++ docs/_static/Logo.png | Bin 0 -> 2557 bytes docs/_static/Logo.png.license | 3 + docs/_static/extra_css.css | 10 + docs/_static/extra_css.css.license | 3 + docs/_static/favicon.ico | Bin 0 -> 4414 bytes docs/_static/favicon.ico.license | 3 + docs/api.rst | 12 + docs/conf.py | 246 ++++++++++++++ docs/examples.rst | 62 ++++ docs/index.rst | 27 ++ docs/requirements.txt | 5 + examples.json | 0 examples/bma400_acc_range.py | 21 ++ examples/bma400_filter_bandwidth.py | 21 ++ examples/bma400_output_data_rate.py | 21 ++ examples/bma400_oversampling_rate.py | 21 ++ examples/bma400_power_mode.py | 21 ++ examples/bma400_simpletest.py | 15 + examples/bma400_source_data_registers.py | 21 ++ micropython_bma400/__init__.py | 0 micropython_bma400/bma400.py | 392 +++++++++++++++++++++++ micropython_bma400/i2c_helpers.py | 139 ++++++++ package.json | 8 + pyproject.toml | 47 +++ requirements.txt | 5 + 32 files changed, 1457 insertions(+) create mode 100644 .github/workflows/release_pypi.yml create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml create mode 100644 .pylintrc create mode 100644 .readthedocs.yaml create mode 100644 LICENSE create mode 100644 README.rst create mode 100644 docs/_static/Logo.png create mode 100644 docs/_static/Logo.png.license create mode 100644 docs/_static/extra_css.css create mode 100644 docs/_static/extra_css.css.license create mode 100644 docs/_static/favicon.ico create mode 100644 docs/_static/favicon.ico.license create mode 100644 docs/api.rst create mode 100644 docs/conf.py create mode 100644 docs/examples.rst create mode 100644 docs/index.rst create mode 100644 docs/requirements.txt create mode 100644 examples.json create mode 100644 examples/bma400_acc_range.py create mode 100644 examples/bma400_filter_bandwidth.py create mode 100644 examples/bma400_output_data_rate.py create mode 100644 examples/bma400_oversampling_rate.py create mode 100644 examples/bma400_power_mode.py create mode 100644 examples/bma400_simpletest.py create mode 100644 examples/bma400_source_data_registers.py create mode 100644 micropython_bma400/__init__.py create mode 100644 micropython_bma400/bma400.py create mode 100644 micropython_bma400/i2c_helpers.py create mode 100644 package.json create mode 100644 pyproject.toml create mode 100644 requirements.txt diff --git a/.github/workflows/release_pypi.yml b/.github/workflows/release_pypi.yml new file mode 100644 index 0000000..6c6aa62 --- /dev/null +++ b/.github/workflows/release_pypi.yml @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2023 Jose D. Montoya +# +# SPDX-License-Identifier: MIT + +name: PyPI Release Actions + +on: + release: + types: [published] + +jobs: + upload-release-assets: + runs-on: ubuntu-latest + steps: + - name: Run PyPI Release CI workflow + uses: jposada202020/workflows-circuitpython-libs/release-pypi@main + with: + pypi-username: ${{ secrets.pypi_username }} + pypi-password: ${{ secrets.pypi_password }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..15107ae --- /dev/null +++ b/.gitignore @@ -0,0 +1,48 @@ +# SPDX-FileCopyrightText: 2022 Kattni Rembor, written for Adafruit Industries +# +# SPDX-License-Identifier: MIT + +# Do not include files and directories created by your personal work environment, such as the IDE +# you use, except for those already listed here. Pull requests including changes to this file will +# not be accepted. + +# This .gitignore file contains rules for files generated by working with MicroPython libraries, +# including building Sphinx, testing with pip, and creating a virual environment, as well as the +# MacOS and IDE-specific files generated by using MacOS in general, or the PyCharm or VSCode IDEs. + +# If you find that there are files being generated on your machine that should not be included in +# your git commit, you should create a .gitignore_global file on your computer to include the +# files created by your personal setup. To do so, follow the two steps below. + +# First, create a file called .gitignore_global somewhere convenient for you, and add rules for +# the files you want to exclude from git commits. + +# Second, configure Git to use the exclude file for all Git repositories by running the +# following via commandline, replacing "path/to/your/" with the actual path to your newly created +# .gitignore_global file: +# git config --global core.excludesfile path/to/your/.gitignore_global + +# MicroPython-specific files +*.mpy + +# Python-specific files +__pycache__ +*.pyc + +# Sphinx build-specific files +_build + +# This file results from running `pip -e install .` in a local repository +*.egg-info + +# Virtual environment-specific files +.env +.venv + +# MacOS-specific files +*.DS_Store + +# IDE-specific files +.idea +.vscode +*~ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..3aeac95 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2023 Jose D. Montoya +# +# SPDX-License-Identifier: Unlicense + +repos: + - repo: https://github.com/python/black + rev: 22.3.0 + hooks: + - id: black + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.2.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/pycqa/pylint + rev: v2.15.5 + hooks: + - id: pylint + name: pylint (library code) + types: [python] + args: + - --disable=consider-using-f-string + exclude: "^(docs/|examples/|tests/|setup.py$)" + - id: pylint + name: pylint (example code) + description: Run pylint rules on "examples/*.py" files + types: [python] + files: "^examples/" + args: + - --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code + - id: pylint + name: pylint (test code) + description: Run pylint rules on "tests/*.py" files + types: [python] + files: "^tests/" + args: + - --disable=missing-docstring,consider-using-f-string,duplicate-code diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..c35c98f --- /dev/null +++ b/.pylintrc @@ -0,0 +1,122 @@ +# SPDX-FileCopyrightText: 2023 Jose D. Montoya +# +# SPDX-License-Identifier: Unlicense + +[MASTER] +extension-pkg-whitelist= +ignore=CVS +ignore-patterns= +#init-hook= +jobs=1 +load-plugins=pylint.extensions.no_self_use +persistent=yes +unsafe-load-any-extension=no + +[MESSAGES CONTROL] +confidence= +disable=raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,import-error,pointless-string-statement,unspecified-encoding +enable= + +[REPORTS] +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) +#msg-template= +output-format=text +reports=no +score=yes + +[REFACTORING] +max-nested-blocks=5 + +[LOGGING] +logging-modules=logging + +[SPELLING] +spelling-dict= +spelling-ignore-words= +spelling-private-dict-file= +spelling-store-unknown-words=no + +[TYPECHECK] +contextmanager-decorators=contextlib.contextmanager +generated-members= +ignore-mixin-members=yes +ignore-on-opaque-inference=yes +ignored-classes=optparse.Values,thread._local,_thread._local +ignored-modules=board +missing-member-hint=yes +missing-member-hint-distance=1 +missing-member-max-choices=1 + +[VARIABLES] +additional-builtins= +callbacks=cb_,_cb +dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ +ignored-argument-names=_.*|^ignored_|^unused_ +init-import=no +redefining-builtins-modules=six.moves,future.builtins + +[FORMAT] +expected-line-ending-format=LF +ignore-long-lines=^\s*(# )??$ +indent-after-paren=4 +indent-string=' ' +max-line-length=100 +max-module-lines=1000 +single-line-class-stmt=no +single-line-if-stmt=no + +[SIMILARITIES] +ignore-comments=yes +ignore-docstrings=yes +ignore-imports=yes +min-similarity-lines=12 + +[BASIC] +argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ +attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ +bad-names=foo,bar,baz,toto,tutu,tata +class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ +class-rgx=[A-Z_][a-zA-Z0-9_]+$ +const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ +docstring-min-length=-1 +function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ +good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_,cs +include-naming-hint=no +inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ +method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ +module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ +name-group= +no-docstring-rgx=^_ +property-classes=abc.abstractproperty +variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ + +[IMPORTS] +allow-wildcard-with-all=no +analyse-fallback-blocks=no +deprecated-modules=optparse,tkinter.tix +ext-import-graph= +import-graph= +int-import-graph= +known-standard-library= +known-third-party=enchant + +[CLASSES] +defining-attr-methods=__init__,__new__,setUp +exclude-protected=_asdict,_fields,_replace,_source,_make +valid-classmethod-first-arg=cls +valid-metaclass-classmethod-first-arg=mcs + +[DESIGN] +max-args=5 +max-attributes=30 +max-bool-expr=5 +max-branches=12 +max-locals=15 +max-parents=7 +max-public-methods=20 +max-returns=6 +max-statements=50 +min-public-methods=1 + +[EXCEPTIONS] +overgeneral-exceptions=Exception diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..6686702 --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2023 Jose D. Montoya +# +# SPDX-License-Identifier: Unlicense + +version: 2 + +build: + os: ubuntu-20.04 + tools: + python: "3" + +python: + install: + - requirements: docs/requirements.txt + - requirements: requirements.txt diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8fea87e --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2023 Jose D. Montoya + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..c5402ca --- /dev/null +++ b/README.rst @@ -0,0 +1,91 @@ +Introduction +============ + + +.. image:: https://readthedocs.org/projects/micropython-bma400/badge/?version=latest + :target: https://micropython-bma400.readthedocs.io/en/latest/ + :alt: Documentation Status + + +.. image:: https://img.shields.io/pypi/v/micropython-bma400.svg + :alt: latest version on PyPI + :target: https://pypi.python.org/pypi/micropython-bma400 + +.. image:: https://static.pepy.tech/personalized-badge/micropython-bma400?period=total&units=international_system&left_color=grey&right_color=blue&left_text=Pypi%20Downloads + :alt: Total PyPI downloads + :target: https://pepy.tech/project/micropython-bma400 + +.. image:: https://img.shields.io/badge/code%20style-black-000000.svg + :target: https://github.com/psf/black + :alt: Code Style: Black + +MicroPython Driver for the Bosch BMA400 Accelerometer + + +Installing with mip +==================== +To install using mpremote + +.. code-block:: shell + + mpremote mip install github:jposada202020/MicroPython_BMA400 + +To install directly using a WIFI capable board + +.. code-block:: shell + + mip install github:jposada202020/MicroPython_BMA400 + + +Installing Library Examples +============================ + +If you want to install library examples: + +.. code-block:: shell + + mpremote mip install github:jposada202020/MicroPython_BMA400/examples.json + +To install directly using a WIFI capable board + +.. code-block:: shell + + mip install github:jposada202020/MicroPython_BMA400/examples.json + + +Installing from PyPI +===================== + +On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from +PyPI `_. +To install for current user: + +.. code-block:: shell + + pip3 install micropython-bma400 + +To install system-wide (this may be required in some cases): + +.. code-block:: shell + + sudo pip3 install micropython-bma400 + +To install in a virtual environment in your current project: + +.. code-block:: shell + + mkdir project-name && cd project-name + python3 -m venv .venv + source .env/bin/activate + pip3 install micropython-bma400 + + +Usage Example +============= + +Take a look at the examples directory + +Documentation +============= +API documentation for this library can be found on `Read the Docs `_. + diff --git a/docs/_static/Logo.png b/docs/_static/Logo.png new file mode 100644 index 0000000000000000000000000000000000000000..79a714f93c23568d6ef2a8a76d0ca1b74bcb3036 GIT binary patch literal 2557 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 label { + white-space: normal; + line-height: inherit; + padding-top: 3.5rem; +} diff --git a/docs/_static/extra_css.css.license b/docs/_static/extra_css.css.license new file mode 100644 index 0000000..73106f4 --- /dev/null +++ b/docs/_static/extra_css.css.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2023 Sphinx-immaterial + +SPDX-License-Identifier: MIT diff --git a/docs/_static/favicon.ico b/docs/_static/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..5aca98376a1f7e593ebd9cf41a808512c2135635 GIT binary patch literal 4414 zcmd^BX;4#F6n=SG-XmlONeGrD5E6J{RVh+e928U#MG!$jWvO+UsvWh`x&VqGNx*en zx=qox7Dqv{kPwo%fZC$dDwVpRtz{HzTkSs8QhG0)%Y=-3@Kt!4ag|JcIo?$-F|?bXVS9UDUyev>MVZQ(H8K4#;BQW-t2CPorj8^KJrMX}QK zp+e<;4ldpXz~=)2GxNy811&)gt-}Q*yVQpsxr@VMoA##{)$1~=bZ1MmjeFw?uT(`8 z^g=09<=zW%r%buwN%iHtuKSg|+r7HkT0PYN*_u9k1;^Ss-Z!RBfJ?Un4w(awqp2b3 z%+myoFis_lTlCrGx2z$0BQdh+7?!JK#9K9@Z!VrG zNj6gK5r(b4?YDOLw|DPRoN7bdP{(>GEG41YcN~4r_SUHU2hgVtUwZG@s%edC;k7Sn zC)RvEnlq~raE2mY2ko64^m1KQL}3riixh?#J{o)IT+K-RdHae2eRX91-+g!y`8^># z-zI0ir>P%Xon)!@xp-BK2bDYUB9k613NRrY6%lVjbFcQc*pRqiK~8xtkNPLxt}e?&QsTB}^!39t_%Qb)~Ukn0O%iC;zt z<&A-y;3h++)>c1br`5VFM~5(83!HKx$L+my8sW_c#@x*|*vB1yU)_dt3vH;2hqPWx zAl^6@?ipx&U7pf`a*>Yq6C85nb+B=Fnn+(id$W#WB^uHAcZVG`qg;rWB}ubvi(Y>D z$ei>REw$#xp0SHAd^|1hq&9HJ=jKK8^zTH~nk)G?yUcmTh9vUM6Y0LMw4(gYVY$D$ zGl&WY&H<)BbJ&3sYbKjx1j^=3-0Q#f^}(aP1?8^`&FUWMp|rmtpK)bLQ1Zo?^s4jqK=Lfg*9&geMGVQ z#^-*!V`fG@;H&{M9S8%+;|h&Qrxym0Ar>WT4BCVLR8cGXF=JmEYN(sNT(9vl+S|%g z8r7nXQ(95i^`=+XHo|){$vf2$?=`F$^&wFlYXyXg$B{a>$-Fp+V}+D;9k=~Xl~?C4 zAB-;RKXdUzBJE{V&d&%R>aEfFe;vxqI$0@hwVM}gFeQR@j}a>DDxR+n+-*6|_)k%% z*mSpDV|=5I9!&VC&9tD%fcVygWZV!iIo2qFtm#!*(s|@ZT33*Ad;+<|3^+yrp*;oH zBSYLV(H1zTU?2WjrCQoQW)Z>J2a=dTriuvezBmu16`tM2fm7Q@d4^iqII-xFpwHGI zn9CL}QE*1vdj2PX{PIuqOe5dracsciH6OlAZATvE8rj6ykqdIjal2 z0S0S~PwHb-5?OQ-tU-^KTG@XNrEVSvo|HIP?H;7ZhYeZkhSqh-{reE!5di;1zk$#Y zCe7rOnlzFYJ6Z#Hm$GoidKB=2HBCwm`BbZVeZY4ukmG%1uz7p2URs6c9j-Gjj^oQV zsdDb3@k2e`C$1I5ML5U0Qs0C1GAp^?!*`=|Nm(vWz3j*j*8ucum2;r0^-6Aca=Gv) zc%}&;!+_*S2tlnnJnz0EKeRmw-Y!@9ob!XQBwiv}^u9MkaXHvM=!<3YX;+2#5Cj5pp?FEK750S3BgeSDtaE^ zXUM@xoV6yBFKfzvY20V&Lr0yC diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..8a9508b --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2023 Jose D. Montoya +# +# SPDX-License-Identifier: Unlicense + +sphinx-immaterial diff --git a/examples.json b/examples.json new file mode 100644 index 0000000..e69de29 diff --git a/examples/bma400_acc_range.py b/examples/bma400_acc_range.py new file mode 100644 index 0000000..743da61 --- /dev/null +++ b/examples/bma400_acc_range.py @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya +# +# SPDX-License-Identifier: MIT + +import time +from machine import Pin, I2C +from micropython_bma400 import bma400 + +i2c = I2C(1, sda=Pin(2), scl=Pin(3)) # Correct I2C pins for RP2040 +bma = bma400.BMA400(i2c) + +bma.acc_range = bma400.ACC_RANGE_16 + +while True: + for acc_range in bma400.acc_range_values: + print("Current Acc range setting: ", bma.acc_range) + for _ in range(10): + accx, accy, accz = bma.acceleration + print("x:{:.2f}Gs, y:{:.2f}Gs, z:{:.2f}Gs".format(accx, accy, accz)) + time.sleep(0.5) + bma.acc_range = acc_range diff --git a/examples/bma400_filter_bandwidth.py b/examples/bma400_filter_bandwidth.py new file mode 100644 index 0000000..7fcc40f --- /dev/null +++ b/examples/bma400_filter_bandwidth.py @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya +# +# SPDX-License-Identifier: MIT + +import time +from machine import Pin, I2C +from micropython_bma400 import bma400 + +i2c = I2C(1, sda=Pin(2), scl=Pin(3)) # Correct I2C pins for RP2040 +bma = bma400.BMA400(i2c) + +bma.filter_bandwidth = bma400.ACC_FILT_BW0 + +while True: + for filter_bandwidth in bma400.filter_bandwidth_values: + print("Current Filter bandwidth setting: ", bma.filter_bandwidth) + for _ in range(10): + accx, accy, accz = bma.acceleration + print("x:{:.2f}Gs, y:{:.2f}Gs, z:{:.2f}Gs".format(accx, accy, accz)) + time.sleep(0.5) + bma.filter_bandwidth = filter_bandwidth diff --git a/examples/bma400_output_data_rate.py b/examples/bma400_output_data_rate.py new file mode 100644 index 0000000..cecfef0 --- /dev/null +++ b/examples/bma400_output_data_rate.py @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya +# +# SPDX-License-Identifier: MIT + +import time +from machine import Pin, I2C +from micropython_bma400 import bma400 + +i2c = I2C(1, sda=Pin(2), scl=Pin(3)) # Correct I2C pins for RP2040 +bma = bma400.BMA400(i2c) + +bma.output_data_rate = bma400.ACCEL_50HZ + +while True: + for output_data_rate in bma400.output_data_rate_values: + print("Current Output data rate setting: ", bma.output_data_rate) + for _ in range(10): + accx, accy, accz = bma.acceleration + print("x:{:.2f}Gs, y:{:.2f}Gs, z:{:.2f}Gs".format(accx, accy, accz)) + time.sleep(0.5) + bma.output_data_rate = output_data_rate diff --git a/examples/bma400_oversampling_rate.py b/examples/bma400_oversampling_rate.py new file mode 100644 index 0000000..3946c53 --- /dev/null +++ b/examples/bma400_oversampling_rate.py @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya +# +# SPDX-License-Identifier: MIT + +import time +from machine import Pin, I2C +from micropython_bma400 import bma400 + +i2c = I2C(1, sda=Pin(2), scl=Pin(3)) # Correct I2C pins for RP2040 +bma = bma400.BMA400(i2c) + +bma.oversampling_rate = bma400.OVERSAMPLING_2 + +while True: + for oversampling_rate in bma400.oversampling_rate_values: + print("Current Oversampling rate setting: ", bma.oversampling_rate) + for _ in range(10): + accx, accy, accz = bma.acceleration + print("x:{:.2f}Gs, y:{:.2f}Gs, z:{:.2f}Gs".format(accx, accy, accz)) + time.sleep(0.5) + bma.oversampling_rate = oversampling_rate diff --git a/examples/bma400_power_mode.py b/examples/bma400_power_mode.py new file mode 100644 index 0000000..4643780 --- /dev/null +++ b/examples/bma400_power_mode.py @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya +# +# SPDX-License-Identifier: MIT + +import time +from machine import Pin, I2C +from micropython_bma400 import bma400 + +i2c = I2C(1, sda=Pin(2), scl=Pin(3)) # Correct I2C pins for RP2040 +bma = bma400.BMA400(i2c) + +bma.power_mode = bma400.LOW_POWER_MODE + +while True: + for power_mode in bma400.power_mode_values: + print("Current Power mode setting: ", bma.power_mode) + for _ in range(10): + accx, accy, accz = bma.acceleration + print("x:{:.2f}Gs, y:{:.2f}Gs, z:{:.2f}Gs".format(accx, accy, accz)) + time.sleep(0.5) + bma.power_mode = power_mode diff --git a/examples/bma400_simpletest.py b/examples/bma400_simpletest.py new file mode 100644 index 0000000..3ecce83 --- /dev/null +++ b/examples/bma400_simpletest.py @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya +# +# SPDX-License-Identifier: MIT + +import time +from machine import Pin, I2C +from micropython_bma400 import bma400 + +i2c = I2C(1, sda=Pin(2), scl=Pin(3)) # Correct I2C pins for RP2040 +bma = bma400.BMA400(i2c) + +while True: + accx, accy, accz = bma.acceleration + print("x:{:.2f}G y:{:.2f}G z:{:.2f}G".format(accx, accy, accz)) + time.sleep(0.5) \ No newline at end of file diff --git a/examples/bma400_source_data_registers.py b/examples/bma400_source_data_registers.py new file mode 100644 index 0000000..d19b1c4 --- /dev/null +++ b/examples/bma400_source_data_registers.py @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya +# +# SPDX-License-Identifier: MIT + +import time +from machine import Pin, I2C +from micropython_bma400 import bma400 + +i2c = I2C(1, sda=Pin(2), scl=Pin(3)) # Correct I2C pins for RP2040 +bma = bma400.BMA400(i2c) + +bma.source_data_registers = bma400.ACC_FILT2 + +while True: + for source_data_registers in bma400.source_data_registers_values: + print("Current Source data registers setting: ", bma.source_data_registers) + for _ in range(10): + accx, accy, accz = bma.acceleration + print("x:{:.2f}Gs, y:{:.2f}Gs, z:{:.2f}Gs".format(accx, accy, accz)) + time.sleep(0.5) + bma.source_data_registers = source_data_registers diff --git a/micropython_bma400/__init__.py b/micropython_bma400/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/micropython_bma400/bma400.py b/micropython_bma400/bma400.py new file mode 100644 index 0000000..eaeac90 --- /dev/null +++ b/micropython_bma400/bma400.py @@ -0,0 +1,392 @@ +# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya +# +# SPDX-License-Identifier: MIT +""" +`bma400` +================================================================================ + +MicroPython Driver for the Bosch BMA400 Accelerometer + + +* Author(s): Jose D. Montoya + + +""" + +from micropython import const +from micropython_bma400.i2c_helpers import CBits, RegisterStruct + +try: + from typing import Tuple +except ImportError: + pass + + +__version__ = "0.0.0+auto.0" +__repo__ = "https://github.com/jposada202020/MicroPython_BMA400.git" + +_REG_WHOAMI = const(0x00) +_ACC_CONFIG0 = const(0x19) +_ACC_CONFIG1 = const(0x1A) +_ACC_CONFIG2 = const(0x1B) + +# Power Modes +SLEEP_MODE = const(0x00) +LOW_POWER_MODE = const(0x01) +NORMAL_MODE = const(0x02) +SWITCH_TO_SLEEP = const(0x03) +power_mode_values = (SLEEP_MODE, LOW_POWER_MODE, NORMAL_MODE, SWITCH_TO_SLEEP) + +# Output Data rate +ACCEL_12_5HZ = const(0x05) +ACCEL_25HZ = const(0x06) +ACCEL_50HZ = const(0x07) +ACCEL_100HZ = const(0x08) +ACCEL_200HZ = const(0x09) +ACCEL_400HZ = const(0xA4) +ACCEL_800HZ = const(0xB8) +output_data_rate_values = ( + ACCEL_12_5HZ, + ACCEL_25HZ, + ACCEL_50HZ, + ACCEL_100HZ, + ACCEL_200HZ, + ACCEL_400HZ, + ACCEL_800HZ, +) + +# Filter Bandwidth +ACC_FILT_BW0 = const(0x00) +ACC_FILT_BW1 = const(0x01) +filter_bandwidth_values = (ACC_FILT_BW0, ACC_FILT_BW1) + +# Oversampling +OVERSAMPLING_0 = const(0x00) +OVERSAMPLING_1 = const(0x01) +OVERSAMPLING_2 = const(0x02) +OVERSAMPLING_3 = const(0x03) +oversampling_rate_values = ( + OVERSAMPLING_0, + OVERSAMPLING_1, + OVERSAMPLING_2, + OVERSAMPLING_3, +) + +# Acceleration range +ACC_RANGE_2 = const(0x00) +ACC_RANGE_4 = const(0x01) +ACC_RANGE_8 = const(0x02) +ACC_RANGE_16 = const(0x03) +acc_range_values = (ACC_RANGE_2, ACC_RANGE_4, ACC_RANGE_8, ACC_RANGE_16) +acc_range_factor = {0x00: 1024, 0x01: 512, 0x02: 256, 0x03: 128} + +# Source Data registers +ACC_FILT1 = const(0x00) +ACC_FILT2 = const(0x01) +ACC_FILT_LP = const(0x02) +source_data_registers_values = (ACC_FILT1, ACC_FILT2, ACC_FILT_LP) + + +class BMA400: + """Driver for the BMA400 Sensor connected over I2C. + + :param ~machine.I2C i2c: The I2C bus the BMA400 is connected to. + :param int address: The I2C device address. Defaults to :const:`0x14` + + :raises RuntimeError: if the sensor is not found + + **Quickstart: Importing and using the device** + + Here is an example of using the :class:`BMA400` class. + First you will need to import the libraries to use the sensor + + .. code-block:: python + + from machine import Pin, I2C + import bma400 + + Once this is done you can define your `machine.I2C` object and define your sensor object + + .. code-block:: python + + i2c = I2C(sda=Pin28), scl=Pin(3)) + bma400 = bma400.BMA400(i2c) + + Now you have access to the attributes + + .. code-block:: python + + accx, accy, accz = bma.acceleration + + """ + + _device_id = RegisterStruct(_REG_WHOAMI, "B") + + # ACC_CONFIG0 (0x19) + # | filt1_bw | osr_lp(1) | osr_lp(0) | ---- | ---- | ---- | power_mode(1) | power_mode(0) | + _power_mode = CBits(2, _ACC_CONFIG0, 0) + _filter_bandwidth = CBits(1, _ACC_CONFIG0, 7) + + # ACC_CONFIG1 (0x1A) + # | acc_range(1) | acc_range(0) | osr(1) | osr(0) | odr(3) | odr(2) | odr(1) | odr(0) | + _output_data_rate = CBits(4, _ACC_CONFIG1, 0) + _oversampling_rate = CBits(2, _ACC_CONFIG1, 4) + _acc_range = CBits(2, _ACC_CONFIG1, 6) + + # ACC_CONFIG2 (0x1A) + # | ---- | ---- | ---- | ---- | data_src_reg(1) | data_src_reg(0) | ---- | ---- | + _source_data_registers = CBits(2, _ACC_CONFIG2, 2) + + # Acceleration Data + _acceleration = RegisterStruct(0x04, " None: + self._i2c = i2c + self._address = address + + if self._device_id != 0x90: + raise RuntimeError("Failed to find BMA400") + + self._power_mode = NORMAL_MODE + self._acc_range_mem = self._acc_range + + @property + def power_mode(self) -> str: + """ + Sensor power_mode + + In sleep mode, data conversions are stopped as well as sensortime functionality. + + In low power mode, data conversion runs with a fixed rate of 25Hz. + The low power mode should be mainly used in combination + with activity detection as self wake-up mode. + + In normal mode, output data rates between 800Hz and 12.5Hz. + + +------------------------------------+------------------+ + | Mode | Value | + +====================================+==================+ + | :py:const:`bma400.SLEEP_MODE` | :py:const:`0x00` | + +------------------------------------+------------------+ + | :py:const:`bma400.LOW_POWER_MODE` | :py:const:`0x01` | + +------------------------------------+------------------+ + | :py:const:`bma400.NORMAL_MODE` | :py:const:`0x02` | + +------------------------------------+------------------+ + | :py:const:`bma400.SWITCH_TO_SLEEP` | :py:const:`0x03` | + +------------------------------------+------------------+ + """ + values = ( + "SLEEP_MODE", + "LOW_POWER_MODE", + "NORMAL_MODE", + "SWITCH_TO_SLEEP", + ) + return values[self._power_mode] + + @power_mode.setter + def power_mode(self, value: int) -> None: + if value not in power_mode_values: + raise ValueError("Value must be a valid power_mode setting") + self._power_mode = value + + @property + def output_data_rate(self) -> str: + """ + Sensor output_data_rate + + +---------------------------------+------------------+ + | Mode | Value | + +=================================+==================+ + | :py:const:`bma400.ACCEL_12_5HZ` | :py:const:`0x05` | + +---------------------------------+------------------+ + | :py:const:`bma400.ACCEL_25HZ` | :py:const:`0x06` | + +---------------------------------+------------------+ + | :py:const:`bma400.ACCEL_50HZ` | :py:const:`0x07` | + +---------------------------------+------------------+ + | :py:const:`bma400.ACCEL_100HZ` | :py:const:`0x08` | + +---------------------------------+------------------+ + | :py:const:`bma400.ACCEL_200HZ` | :py:const:`0x09` | + +---------------------------------+------------------+ + | :py:const:`bma400.ACCEL_400HZ` | :py:const:`0xA4` | + +---------------------------------+------------------+ + | :py:const:`bma400.ACCEL_800HZ` | :py:const:`0xB8` | + +---------------------------------+------------------+ + """ + values = { + 0x05: "ACCEL_12_5HZ", + 0x06: "ACCEL_25HZ", + 0x07: "ACCEL_50HZ", + 0x08: "ACCEL_100HZ", + 0x09: "ACCEL_200HZ", + 0xA4: "ACCEL_400HZ", + 0xB8: "ACCEL_800HZ", + } + return values[self._output_data_rate] + + @output_data_rate.setter + def output_data_rate(self, value: int) -> None: + if value not in output_data_rate_values: + raise ValueError("Value must be a valid output_data_rate setting") + self._output_data_rate = value + + @property + def oversampling_rate(self) -> str: + """ + Sensor oversampling_rate + oversampling rate 0/1/2/3 for normal mode + osr=0: lowest power, lowest oversampling rate, lowest accuracy + osr=3: highest accuracy, highest oversampling rate, highest power + settings 0, 1, 2 and 3 allow linearly trading power versus accuracy(noise) + + +-----------------------------------+------------------+ + | Mode | Value | + +===================================+==================+ + | :py:const:`bma400.OVERSAMPLING_0` | :py:const:`0x00` | + +-----------------------------------+------------------+ + | :py:const:`bma400.OVERSAMPLING_1` | :py:const:`0x01` | + +-----------------------------------+------------------+ + | :py:const:`bma400.OVERSAMPLING_2` | :py:const:`0x02` | + +-----------------------------------+------------------+ + | :py:const:`bma400.OVERSAMPLING_3` | :py:const:`0x03` | + +-----------------------------------+------------------+ + """ + values = ( + "OVERSAMPLING_0", + "OVERSAMPLING_1", + "OVERSAMPLING_2", + "OVERSAMPLING_3", + ) + return values[self._oversampling_rate] + + @oversampling_rate.setter + def oversampling_rate(self, value: int) -> None: + if value not in oversampling_rate_values: + raise ValueError("Value must be a valid oversampling_rate setting") + self._oversampling_rate = value + + @property + def acc_range(self) -> str: + """ + Sensor acc_range + + +---------------------------------+------------------+ + | Mode | Value | + +=================================+==================+ + | :py:const:`bma400.ACC_RANGE_2` | :py:const:`0x00` | + +---------------------------------+------------------+ + | :py:const:`bma400.ACC_RANGE_4` | :py:const:`0x01` | + +---------------------------------+------------------+ + | :py:const:`bma400.ACC_RANGE_8` | :py:const:`0x02` | + +---------------------------------+------------------+ + | :py:const:`bma400.ACC_RANGE_16` | :py:const:`0x03` | + +---------------------------------+------------------+ + """ + values = ( + "ACC_RANGE_2", + "ACC_RANGE_4", + "ACC_RANGE_8", + "ACC_RANGE_16", + ) + return values[self._acc_range_mem] + + @acc_range.setter + def acc_range(self, value: int) -> None: + if value not in acc_range_values: + raise ValueError("Value must be a valid acc_range setting") + self._acc_range = value + self._acc_range_mem = value + + @property + def filter_bandwidth(self) -> str: + """ + Sensor filter_bandwidth + Data rate between 800Hz and 12.5Hz, controlled by :attr:`output_data_rate`. + Its bandwidth can be configured additionally by :attr:`filter_bandwidth`: + + +---------------------------------+-----------------------------+ + | Mode | Value | + +=================================+=============================+ + | :py:const:`bma400.ACC_FILT_BW0` | :py:const:`0x00` 0.48 x ODR | + +---------------------------------+-----------------------------+ + | :py:const:`bma400.ACC_FILT_BW1` | :py:const:`0x01` 0.24 x ODR | + +---------------------------------+-----------------------------+ + """ + values = ( + "ACC_FILT_BW0", + "ACC_FILT_BW1", + ) + return values[self._filter_bandwidth] + + @filter_bandwidth.setter + def filter_bandwidth(self, value: int) -> None: + if value not in filter_bandwidth_values: + raise ValueError("Value must be a valid filter_bandwidth setting") + self._filter_bandwidth = value + + @property + def source_data_registers(self) -> str: + """ + Sensor source_data_registers + + +--------------------------------+------------------+ + | Mode | Value | + +================================+==================+ + | :py:const:`bma400.ACC_FILT1` | :py:const:`0x00` | + +--------------------------------+------------------+ + | :py:const:`bma400.ACC_FILT2` | :py:const:`0x01` | + +--------------------------------+------------------+ + | :py:const:`bma400.ACC_FILT_LP` | :py:const:`0x02` | + +--------------------------------+------------------+ + """ + values = ( + "ACC_FILT1", + "ACC_FILT2", + "ACC_FILT_LP", + ) + return values[self._source_data_registers] + + @source_data_registers.setter + def source_data_registers(self, value: int) -> None: + if value not in source_data_registers_values: + raise ValueError("Value must be a valid source_data_registers setting") + self._source_data_registers = value + + @property + def acceleration(self) -> Tuple[int, int, int]: + """ + Acceleration + :return: acceleration + """ + rawx, rawy, rawz = self._acceleration + + if rawx > 2047: + rawx = rawx - 4096 + + if rawy > 2047: + rawy = rawy - 4096 + + if rawz > 2047: + rawz = rawz - 4096 + + factor = acc_range_factor[self._acc_range_mem] + + return rawx / factor, rawy / factor, rawz / factor + + @property + def temperature(self) -> float: + """ + The temperature sensor is calibrated with a precision of +/-5°C. + :return: Temperature + """ + raw_temp = self._temperature + time.sleep(0.16) + temp = self._twos_comp(raw_temp, 8) + return (temp * 0.5) + 23 + + @staticmethod + def _twos_comp(val: int, bits: int) -> int: + + if val & (1 << (bits - 1)) != 0: + return val - (1 << bits) + return val diff --git a/micropython_bma400/i2c_helpers.py b/micropython_bma400/i2c_helpers.py new file mode 100644 index 0000000..a33dc2b --- /dev/null +++ b/micropython_bma400/i2c_helpers.py @@ -0,0 +1,139 @@ +# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya +# +# SPDX-License-Identifier: MIT +""" +`i2c_helpers` +================================================================================ + +I2C Communications helpers + + +* Author(s): Jose D. Montoya + +Based on + +* adafruit_register.i2c_struct. Author(s): Scott Shawcroft +* adafruit_register.i2c_bits. Author(s): Scott Shawcroft + +MIT License + +Copyright (c) 2016 Adafruit Industries + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +""" +# pylint: disable=too-many-arguments +try: + import struct +except ImportError: + import ustruct as struct + + +class CBits: + """ + Changes bits from a byte register + """ + + def __init__( + self, + num_bits: int, + register_address: int, + start_bit: int, + register_width=1, + lsb_first=True, + ) -> None: + self.bit_mask = ((1 << num_bits) - 1) << start_bit + self.register = register_address + self.star_bit = start_bit + self.lenght = register_width + self.lsb_first = lsb_first + + def __get__( + self, + obj, + objtype=None, + ) -> int: + + mem_value = obj._i2c.readfrom_mem(obj._address, self.register, self.lenght) + + reg = 0 + order = range(len(mem_value) - 1, -1, -1) + if not self.lsb_first: + order = reversed(order) + for i in order: + reg = (reg << 8) | mem_value[i] + + reg = (reg & self.bit_mask) >> self.star_bit + + return reg + + def __set__(self, obj, value: int) -> None: + + memory_value = obj._i2c.readfrom_mem(obj._address, self.register, self.lenght) + + reg = 0 + order = range(len(memory_value) - 1, -1, -1) + if not self.lsb_first: + order = range(0, len(memory_value)) + for i in order: + reg = (reg << 8) | memory_value[i] + reg &= ~self.bit_mask + + value <<= self.star_bit + reg |= value + reg = reg.to_bytes(self.lenght, "big") + + obj._i2c.writeto_mem(obj._address, self.register, reg) + + +class RegisterStruct: + """ + Register Struct + """ + + def __init__(self, register_address: int, form: str) -> None: + self.format = form + self.register = register_address + self.lenght = struct.calcsize(form) + + def __get__( + self, + obj, + objtype=None, + ): + + if self.lenght <= 2: + value = struct.unpack( + self.format, + memoryview( + obj._i2c.readfrom_mem(obj._address, self.register, self.lenght) + ), + )[0] + else: + value = struct.unpack( + self.format, + memoryview( + obj._i2c.readfrom_mem(obj._address, self.register, self.lenght) + ), + ) + return value + + def __set__(self, obj, value): + mem_value = value.to_bytes(self.lenght, "big") + obj._i2c.writeto_mem(obj._address, self.register, mem_value) diff --git a/package.json b/package.json new file mode 100644 index 0000000..8254d54 --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "urls": [ + ["micropython_bma400/__init__.py", "github:jposada202020/MicroPython_BMA400/micropython_bma400/__init__.py"], + ["micropython_bma400/i2c_helpers.py", "github:jposada202020/MicroPython_BMA400/micropython_bma400/i2c_helpers.py"], + ["micropython_bma400/bma400.py", "github:jposada202020/MicroPython_BMA400/micropython_bma400/bma400.py"] + ], + "version": "0.1" +} diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..01fbf6b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,47 @@ +# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya +# +# SPDX-License-Identifier: MIT + +[build-system] +requires = [ + "setuptools", + "wheel", + "setuptools-scm", +] + +[project] +name = "micropython-bma400" +description = "MicroPython Driver for the Bosch BMA400 Accelerometer" +version = "0.0.0+auto.0" +readme = "README.rst" +authors = [ + {name = "JDM", email = "xxyx@mailmeto.mozmail.com"} +] +urls = {Homepage = "https://github.com/jposada202020/MicroPython_BMA400"} +keywords = [ + "sensor", + "micropython", + "bma400", + "acceleration", + "gravity", + "sensor", + "bosch", + "bma400", + "accelerometer", +] +license = {text = "MIT"} +classifiers = [ + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries", + "Topic :: Software Development :: Embedded Systems", + "Topic :: System :: Hardware", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", +] +dynamic = ["dependencies", "optional-dependencies"] + +[tool.setuptools] +py-modules = ["bma400"] + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..11fd7c4 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya +# +# SPDX-License-Identifier: MIT + +Adafruit-Blinka