Skip to content

Commit

Permalink
adding examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jposada202020 committed Jul 10, 2023
1 parent 9763a67 commit 23f61b7
Show file tree
Hide file tree
Showing 15 changed files with 310 additions and 317 deletions.
283 changes: 3 additions & 280 deletions .pylintrc

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
version: 2

build:
os: ubuntu-20.04
os: ubuntu-22.04
tools:
python: "3"

Expand Down
3 changes: 0 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
#
# SPDX-License-Identifier: MIT
Expand Down Expand Up @@ -33,7 +31,6 @@
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"sphinx_immaterial",
]
Expand Down
54 changes: 54 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,57 @@ Ensure your device works with this simple test.
.. literalinclude:: ../examples/icm20948_simpletest.py
:caption: examples/icm20948_simpletest.py
:linenos:

Clock select settings
----------------------

Example showing the Clock select setting

.. literalinclude:: ../examples/icm20948_clock_select.py
:caption: examples/icm20948_clock_select.py
:lines: 5-

Accelerometer range settings
-----------------------------

Example showing the Accelerometer range setting

.. literalinclude:: ../examples/icm20948_accelerometer_range.py
:caption: examples/icm20948_accelerometer_range.py
:lines: 5-

Acc dlpf cutoff settings
-------------------------

Example showing the Acc dlpf cutoff setting

.. literalinclude:: ../examples/icm20948_acc_dlpf_cutoff.py
:caption: examples/icm20948_acc_dlpf_cutoff.py
:lines: 5-

Gyro full scale settings
-------------------------

Example showing the Gyro full scale setting

.. literalinclude:: ../examples/icm20948_gyro_full_scale.py
:caption: examples/icm20948_gyro_full_scale.py
:lines: 5-

Gyro dlpf cutoff settings
--------------------------

Example showing the Gyro dlpf cutoff setting

.. literalinclude:: ../examples/icm20948_gyro_dlpf_cutoff.py
:caption: examples/icm20948_gyro_dlpf_cutoff.py
:lines: 5-

Temperature Example
--------------------------

Example showing the how to get the temperature

.. literalinclude:: ../examples/icm20948_temperature.py
:caption: examples/icm20948_temperature.py
:lines: 5-
5 changes: 5 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ Table of Contents
:maxdepth: 3

api

.. toctree::
:caption: Other Links

Download from GitHub <https://github.com/jposada202020/MicroPython_ICM20948/releases/latest>
31 changes: 29 additions & 2 deletions examples.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
{
"urls": [
["micropython_icm20948/examples/icm20948_simpletest.py", "github:jposada202020/MicroPython_ICM20948/examples/icm20948_simpletest.py"]
[
"micropython_icm20948/examples/icm20948_acc_dlpf_cutoff.py",
"github:jposada202020/MicroPython_ICM20948/examples/icm20948_acc_dlpf_cutoff.py"
],
[
"micropython_icm20948/examples/icm20948_temperature.py",
"github:jposada202020/MicroPython_ICM20948/examples/icm20948_temperature.py"
],
[
"micropython_icm20948/examples/icm20948_simpletest.py",
"github:jposada202020/MicroPython_ICM20948/examples/icm20948_simpletest.py"
],
[
"micropython_icm20948/examples/icm20948_gyro_full_scale.py",
"github:jposada202020/MicroPython_ICM20948/examples/icm20948_gyro_full_scale.py"
],
[
"micropython_icm20948/examples/icm20948_accelerometer_range.py",
"github:jposada202020/MicroPython_ICM20948/examples/icm20948_accelerometer_range.py"
],
[
"micropython_icm20948/examples/icm20948_clock_select.py",
"github:jposada202020/MicroPython_ICM20948/examples/icm20948_clock_select.py"
],
[
"micropython_icm20948/examples/icm20948_gyro_dlpf_cutoff.py",
"github:jposada202020/MicroPython_ICM20948/examples/icm20948_gyro_dlpf_cutoff.py"
]
],
"version": "0.1"
"version": "1"
}
22 changes: 22 additions & 0 deletions examples/icm20948_acc_dlpf_cutoff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT

import time
from machine import Pin, I2C
from micropython_icm20948 import icm20948

i2c = I2C(1, sda=Pin(2), scl=Pin(3)) # Correct I2C pins for RP2040
icm = icm20948.ICM20948(i2c)

icm.acc_dlpf_cutoff = icm20948.FREQ_246_0

while True:
for acc_dlpf_cutoff in icm20948.acc_filter_values:
print("Current Acc dlpf cutoff setting: ", icm.acc_dlpf_cutoff)
for _ in range(10):
accx, accy, accz = icm.acceleration
print("x:{:.2f}m/s2, y:{:.2f}m/s2, z:{:.2f}m/s2".format(accx, accy, accz))
print()
time.sleep(0.5)
icm.acc_dlpf_cutoff = acc_dlpf_cutoff
22 changes: 22 additions & 0 deletions examples/icm20948_accelerometer_range.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT

import time
from machine import Pin, I2C
from micropython_icm20948 import icm20948

i2c = I2C(1, sda=Pin(2), scl=Pin(3)) # Correct I2C pins for RP2040
icm = icm20948.ICM20948(i2c)

icm.accelerometer_range = icm20948.RANGE_2G

while True:
for accelerometer_range in icm20948.acc_range_values:
print("Current Accelerometer range setting: ", icm.accelerometer_range)
for _ in range(10):
accx, accy, accz = icm.acceleration
print("x:{:.2f}m/s2, y:{:.2f}m/s2, z:{:.2f}m/s2".format(accx, accy, accz))
print()
time.sleep(0.5)
icm.accelerometer_range = accelerometer_range
22 changes: 22 additions & 0 deletions examples/icm20948_clock_select.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT

import time
from machine import Pin, I2C
from micropython_icm20948 import icm20948

i2c = I2C(1, sda=Pin(2), scl=Pin(3)) # Correct I2C pins for RP2040
icm = icm20948.ICM20948(i2c)

icm.clock_select = icm20948.CLK_SELECT_INTERNAL

while True:
for clock_select in icm20948.clk_values:
print("Current Clock select setting: ", icm.clock_select)
for _ in range(10):
accx, accy, accz = icm.acceleration
print("x:{:.2f}m/s2, y:{:.2f}m/s2, z:{:.2f}m/s2".format(accx, accy, accz))
print()
time.sleep(0.5)
icm.clock_select = clock_select
22 changes: 22 additions & 0 deletions examples/icm20948_gyro_dlpf_cutoff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT

import time
from machine import Pin, I2C
from micropython_icm20948 import icm20948

i2c = I2C(1, sda=Pin(2), scl=Pin(3)) # Correct I2C pins for RP2040
icm = icm20948.ICM20948(i2c)

icm.gyro_dlpf_cutoff = icm20948.G_FREQ_11_6

while True:
for gyro_dlpf_cutoff in icm20948.gyro_filter_values:
print("Current Gyro dlpf cutoff setting: ", icm.gyro_dlpf_cutoff)
for _ in range(10):
gyrox, gyroy, gyroz = icm.gyro
print("x:{:.2f}°/s, y:{:.2f}°/s, z:{:.2f}°/s".format(gyrox, gyroy, gyroz))
print()
time.sleep(0.5)
icm.gyro_dlpf_cutoff = gyro_dlpf_cutoff
22 changes: 22 additions & 0 deletions examples/icm20948_gyro_full_scale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT

import time
from machine import Pin, I2C
from micropython_icm20948 import icm20948

i2c = I2C(1, sda=Pin(2), scl=Pin(3)) # Correct I2C pins for RP2040
icm = icm20948.ICM20948(i2c)

icm.gyro_full_scale = icm20948.FS_250_DPS

while True:
for gyro_full_scale in icm20948.gyro_full_scale_values:
print("Current Gyro full scale setting: ", icm.gyro_full_scale)
for _ in range(10):
gyrox, gyroy, gyroz = icm.gyro
print("x:{:.2f}°/s, y:{:.2f}°/s, z:{:.2f}°/s".format(gyrox, gyroy, gyroz))
print()
time.sleep(0.5)
icm.gyro_full_scale = gyro_full_scale
5 changes: 4 additions & 1 deletion examples/icm20948_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@


while True:
print("Acceleration : ", icm.acceleration)
accx, accy, accz = icm.acceleration
gyrox, gyroy, gyroz = icm.gyro
print(f"x: {accx}m/s2, y: {accy},m/s2 z: {accz}m/s2")
print(f"x: {gyrox}°/s, y: {gyroy}°/s, z: {gyroz}°/s")
time.sleep(1)
14 changes: 14 additions & 0 deletions examples/icm20948_temperature.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya

import time
from machine import Pin, I2C
from micropython_icm20948 import icm20948

i2c = I2C(sda=Pin(8), scl=Pin(9)) # Correct I2C pins for UM FeatherS2
icm = icm20948.ICM20948(i2c)


while True:
print(f"Temperature: {icm.temperature}°C")
print()
time.sleep(1)
Loading

0 comments on commit 23f61b7

Please sign in to comment.