Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit 9fb2928

Browse files
committed
mip
1 parent 75f8c30 commit 9fb2928

File tree

8 files changed

+109
-51
lines changed

8 files changed

+109
-51
lines changed

README.rst

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,36 @@ Introduction
2121

2222
MicroPython Driver for the Bosch BMI160 Acc/Gyro Sensor
2323

24+
Installing with mip
25+
====================
26+
27+
To install using mpremote
28+
29+
.. code-block:: shell
30+
31+
mpremote mip install github:jposada202020/MicroPython_BMI160
32+
33+
To install directly using a WIFI capable board
34+
35+
.. code-block:: shell
36+
37+
mip install github:jposada202020/MicroPython_BMI160
38+
39+
40+
Installing Library Examples
41+
============================
42+
43+
If you want to install library examples:
44+
45+
.. code-block:: shell
46+
47+
mpremote mip install github:jposada202020/MicroPython_BMI160/examples.json
48+
49+
To install directly using a WIFI capable board
50+
51+
.. code-block:: shell
52+
53+
mip install github:jposada202020/MicroPython_BMI160/examples.json
2454
2555
2656
Installing from PyPI
@@ -58,4 +88,3 @@ Take a look at the examples directory
5888
Documentation
5989
=============
6090
API documentation for this library can be found on `Read the Docs <https://micropython-bmi160.readthedocs.io/en/latest/>`_.
61-

examples.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"urls": [
3+
["micropython_bmi160/examples/bmi160_gyro_range.py", "github:jposada202020/MicroPython_BMI160/examples/bmi160_gyro_range.py"],
4+
["micropython_bmi160/examples/bmi160_temperature.py", "github:jposada202020/MicroPython_BMI160/examples/bmi160_temperature.py"],
5+
["micropython_bmi160/examples/bmi160_gyro_datarate.py", "github:jposada202020/MicroPython_BMI160/examples/bmi160_gyro_datarate.py"],
6+
["micropython_bmi160/examples/bmi160_simpletest.py", "github:jposada202020/MicroPython_BMI160/examples/bmi160_simpletest.py"],
7+
["micropython_bmi160/examples/bmi160_acce_datarange.py", "github:jposada202020/MicroPython_BMI160/examples/bmi160_acce_datarange.py"],
8+
["micropython_bmi160/examples/bmi160_gyro_simpletest.py", "github:jposada202020/MicroPython_BMI160/examples/bmi160_gyro_simpletest.py"],
9+
["micropython_bmi160/examples/bmi160_acc_datarate.py", "github:jposada202020/MicroPython_BMI160/examples/bmi160_acc_datarate.py"]
10+
],
11+
"version": "0.1"
12+
}

examples/bmi160_acc_datarate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
i2c = I2C(1, sda=Pin(2), scl=Pin(3)) # Correct I2C pins for RP2040
1010
bmi = bmi160.BMI160(i2c)
1111

12-
bmi.acceleration_output_data_rate = BMI160.BANDWIDTH_25_32
12+
bmi.acceleration_output_data_rate = bmi160.BANDWIDTH_25_32
1313

1414
while True:
15-
for data_rate in BMI160.bandwidth_values:
15+
for data_rate in bmi160.bandwidth_values:
1616
print("Current Acceleration Data Rate: ", bmi.acceleration_output_data_rate)
1717
for _ in range(10):
1818
accx, accy, accz = bmi.acceleration

examples/bmi160_acce_datarange.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
i2c = I2C(1, sda=Pin(2), scl=Pin(3)) # Correct I2C pins for RP2040
1010
bmi = bmi160.BMI160(i2c)
1111

12-
bmi.acceleration_range = BMI160.ACCEL_RANGE_4G
12+
bmi.acceleration_range = bmi160.ACCEL_RANGE_4G
1313

1414
while True:
15-
for data_range in BMI160.acc_range_values:
15+
for data_range in bmi160.acc_range_values:
1616
print("Current Acceleration Data Rate: ", bmi.acceleration_range)
1717
for _ in range(10):
1818
accx, accy, accz = bmi.acceleration

examples/bmi160_gyro_datarate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
i2c = I2C(1, sda=Pin(2), scl=Pin(3)) # Correct I2C pins for RP2040
1010
bmi = bmi160.BMI160(i2c)
1111

12-
bmi.gyro_output_data_rate = BMI160.BANDWIDTH_200
12+
bmi.gyro_output_data_rate = bmi160.BANDWIDTH_200
1313

1414
while True:
15-
for data_rate in BMI160.gyro_bandwidth_values:
15+
for data_rate in bmi160.gyro_bandwidth_values:
1616
print("Current Gyro Data Range: ", bmi.gyro_output_data_rate)
1717
for _ in range(10):
1818
gyrox, gyroy, gyroz = bmi.gyro

examples/bmi160_gyro_range.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
i2c = I2C(1, sda=Pin(2), scl=Pin(3)) # Correct I2C pins for RP2040
1010
bmi = bmi160.BMI160(i2c)
1111

12-
bmi.gyro_range = BMI160.GYRO_RANGE_500
12+
bmi.gyro_range = bmi160.GYRO_RANGE_500
1313

1414
while True:
15-
for data_range in BMI160.gyro_values:
15+
for data_range in bmi160.gyro_values:
1616
print("Current Gyro Data Range: ", bmi.gyro_range)
1717
for _ in range(10):
1818
gyrox, gyroy, gyroz = bmi.gyro

micropython_bmi160/bmi160.py

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,9 @@ def acceleration_undersample(self) -> str:
303303
+----------------------------------------+-------------------------+
304304
| Mode | Value |
305305
+========================================+=========================+
306-
| :py:const:`BMI160.NO_UNDERSAMPLE` | :py:const:`0` |
306+
| :py:const:`bmi160.NO_UNDERSAMPLE` | :py:const:`0` |
307307
+----------------------------------------+-------------------------+
308-
| :py:const:`BMI160.UNDERSAMPLE` | :py:const:`1` |
308+
| :py:const:`bmi160.UNDERSAMPLE` | :py:const:`1` |
309309
+----------------------------------------+-------------------------+
310310
311311
"""
@@ -327,9 +327,9 @@ def acceleration_bandwidth_parameter(self) -> str:
327327
+----------------------------------------+-------------------------+
328328
| Mode | Value |
329329
+========================================+=========================+
330-
| :py:const:`BMI160.FILTER` | :py:const:`0` |
330+
| :py:const:`bmi160.FILTER` | :py:const:`0` |
331331
+----------------------------------------+-------------------------+
332-
| :py:const:`BMI160.AVERAGING` | :py:const:`1` |
332+
| :py:const:`bmi160.AVERAGING` | :py:const:`1` |
333333
+----------------------------------------+-------------------------+
334334
335335
"""
@@ -356,29 +356,29 @@ def acceleration_output_data_rate(self) -> str:
356356
+----------------------------------------+---------------------------------+
357357
| Mode | Value |
358358
+========================================+=================================+
359-
| :py:const:`BMI160.BANDWIDTH_25_32` | :py:const:`0b0001` 25/32 Hz |
359+
| :py:const:`bmi160.BANDWIDTH_25_32` | :py:const:`0b0001` 25/32 Hz |
360360
+----------------------------------------+---------------------------------+
361-
| :py:const:`BMI160.BANDWIDTH_25_16` | :py:const:`0b0010` 25/16 Hz |
361+
| :py:const:`bmi160.BANDWIDTH_25_16` | :py:const:`0b0010` 25/16 Hz |
362362
+----------------------------------------+---------------------------------+
363-
| :py:const:`BMI160.BANDWIDTH_25_8` | :py:const:`0b0011` 25/8 Hz |
363+
| :py:const:`bmi160.BANDWIDTH_25_8` | :py:const:`0b0011` 25/8 Hz |
364364
+----------------------------------------+---------------------------------+
365-
| :py:const:`BMI160.BANDWIDTH_25_4` | :py:const:`0b0100` 25/4 Hz |
365+
| :py:const:`bmi160.BANDWIDTH_25_4` | :py:const:`0b0100` 25/4 Hz |
366366
+----------------------------------------+---------------------------------+
367-
| :py:const:`BMI160.BANDWIDTH_25_2` | :py:const:`0b0101` 25/2 Hz |
367+
| :py:const:`bmi160.BANDWIDTH_25_2` | :py:const:`0b0101` 25/2 Hz |
368368
+----------------------------------------+---------------------------------+
369-
| :py:const:`BMI160.BANDWIDTH_25` | :py:const:`0b0110` 25 Hz |
369+
| :py:const:`bmi160.BANDWIDTH_25` | :py:const:`0b0110` 25 Hz |
370370
+----------------------------------------+---------------------------------+
371-
| :py:const:`BMI160.BANDWIDTH_50` | :py:const:`0b0111` 50 Hz |
371+
| :py:const:`bmi160.BANDWIDTH_50` | :py:const:`0b0111` 50 Hz |
372372
+----------------------------------------+---------------------------------+
373-
| :py:const:`BMI160.BANDWIDTH_100` | :py:const:`0b1000` 100 Hz |
373+
| :py:const:`bmi160.BANDWIDTH_100` | :py:const:`0b1000` 100 Hz |
374374
+----------------------------------------+---------------------------------+
375-
| :py:const:`BMI160.BANDWIDTH_200` | :py:const:`0b1001` 200 Hz |
375+
| :py:const:`bmi160.BANDWIDTH_200` | :py:const:`0b1001` 200 Hz |
376376
+----------------------------------------+---------------------------------+
377-
| :py:const:`BMI160.BANDWIDTH_400` | :py:const:`0b1010` 400 Hz |
377+
| :py:const:`bmi160.BANDWIDTH_400` | :py:const:`0b1010` 400 Hz |
378378
+----------------------------------------+---------------------------------+
379-
| :py:const:`BMI160.BANDWIDTH_800` | :py:const:`0b1011` 800 Hz |
379+
| :py:const:`bmi160.BANDWIDTH_800` | :py:const:`0b1011` 800 Hz |
380380
+----------------------------------------+---------------------------------+
381-
| :py:const:`BMI160.BANDWIDTH_1600` | :py:const:`0b1100` 1600 Hz |
381+
| :py:const:`bmi160.BANDWIDTH_1600` | :py:const:`0b1100` 1600 Hz |
382382
+----------------------------------------+---------------------------------+
383383
384384
"""
@@ -417,13 +417,13 @@ def acceleration_range(self) -> str:
417417
+----------------------------------------+-------------------------+
418418
| Mode | Value |
419419
+========================================+=========================+
420-
| :py:const:`BMI160.ACCEL_RANGE_2G` | :py:const:`0b0011` |
420+
| :py:const:`bmi160.ACCEL_RANGE_2G` | :py:const:`0b0011` |
421421
+----------------------------------------+-------------------------+
422-
| :py:const:`BMI160.ACCEL_RANGE_4G` | :py:const:`0b0101` |
422+
| :py:const:`bmi160.ACCEL_RANGE_4G` | :py:const:`0b0101` |
423423
+----------------------------------------+-------------------------+
424-
| :py:const:`BMI160.ACCEL_RANGE_8G` | :py:const:`0b1000` |
424+
| :py:const:`bmi160.ACCEL_RANGE_8G` | :py:const:`0b1000` |
425425
+----------------------------------------+-------------------------+
426-
| :py:const:`BMI160.ACCEL_RANGE_16G` | :py:const:`0b1100` |
426+
| :py:const:`bmi160.ACCEL_RANGE_16G` | :py:const:`0b1100` |
427427
+----------------------------------------+-------------------------+
428428
429429
"""
@@ -443,6 +443,9 @@ def acceleration_range(self, value: int) -> None:
443443

444444
@property
445445
def acceleration(self) -> Tuple[int, int, int]:
446+
"""
447+
Sensor Acceleration
448+
"""
446449

447450
factor = self.acceleration_scale[self.acceleration_range]
448451

@@ -452,6 +455,9 @@ def acceleration(self) -> Tuple[int, int, int]:
452455
return x, y, z
453456

454457
def power_mode_status(self) -> None:
458+
"""
459+
Returns Power mode status
460+
"""
455461
values = self._power_mode
456462

457463
acc_pmu_status = (values & 0x18) >> 4
@@ -471,11 +477,11 @@ def acc_power_mode(self, value: int) -> None:
471477
+----------------------------------------+-------------------------+
472478
| Mode | Value |
473479
+========================================+=========================+
474-
| :py:const:`BMI160.ACC_POWER_SUSPEND` | :py:const:`0x10` |
480+
| :py:const:`bmi160.ACC_POWER_SUSPEND` | :py:const:`0x10` |
475481
+----------------------------------------+-------------------------+
476-
| :py:const:`BMI160.ACC_POWER_NORMAL` | :py:const:`0x11` |
482+
| :py:const:`bmi160.ACC_POWER_NORMAL` | :py:const:`0x11` |
477483
+----------------------------------------+-------------------------+
478-
| :py:const:`BMI160.POWER_LOWPOWER` | :py:const:`0x12` |
484+
| :py:const:`bmi160.POWER_LOWPOWER` | :py:const:`0x12` |
479485
+----------------------------------------+-------------------------+
480486
481487
"""
@@ -501,6 +507,9 @@ def temperature(self) -> int:
501507

502508
@property
503509
def gyro(self) -> Tuple[int, int, int]:
510+
"""
511+
Gyro values
512+
"""
504513

505514
factor = self.gyro_scale[self.gyro_range]
506515

@@ -527,21 +536,21 @@ def gyro_output_data_rate(self) -> str:
527536
+----------------------------------------+---------------------------------+
528537
| Mode | Value |
529538
+========================================+=================================+
530-
| :py:const:`BMI160.BANDWIDTH_25` | :py:const:`0b0110` 25 Hz |
539+
| :py:const:`bmi160.BANDWIDTH_25` | :py:const:`0b0110` 25 Hz |
531540
+----------------------------------------+---------------------------------+
532-
| :py:const:`BMI160.BANDWIDTH_50` | :py:const:`0b0111` 50 Hz |
541+
| :py:const:`bmi160.BANDWIDTH_50` | :py:const:`0b0111` 50 Hz |
533542
+----------------------------------------+---------------------------------+
534-
| :py:const:`BMI160.BANDWIDTH_100` | :py:const:`0b1000` 100 Hz |
543+
| :py:const:`bmi160.BANDWIDTH_100` | :py:const:`0b1000` 100 Hz |
535544
+----------------------------------------+---------------------------------+
536-
| :py:const:`BMI160.BANDWIDTH_200` | :py:const:`0b1001` 200 Hz |
545+
| :py:const:`bmi160.BANDWIDTH_200` | :py:const:`0b1001` 200 Hz |
537546
+----------------------------------------+---------------------------------+
538-
| :py:const:`BMI160.BANDWIDTH_400` | :py:const:`0b1010` 400 Hz |
547+
| :py:const:`bmi160.BANDWIDTH_400` | :py:const:`0b1010` 400 Hz |
539548
+----------------------------------------+---------------------------------+
540-
| :py:const:`BMI160.BANDWIDTH_800` | :py:const:`0b1011` 800 Hz |
549+
| :py:const:`bmi160.BANDWIDTH_800` | :py:const:`0b1011` 800 Hz |
541550
+----------------------------------------+---------------------------------+
542-
| :py:const:`BMI160.BANDWIDTH_1600` | :py:const:`0b1100` 1600 Hz |
551+
| :py:const:`bmi160.BANDWIDTH_1600` | :py:const:`0b1100` 1600 Hz |
543552
+----------------------------------------+---------------------------------+
544-
| :py:const:`BMI160.BANDWIDTH_3200` | :py:const:`0b1101` 3200 Hz |
553+
| :py:const:`bmi160.BANDWIDTH_3200` | :py:const:`0b1101` 3200 Hz |
545554
+----------------------------------------+---------------------------------+
546555
547556
"""
@@ -597,11 +606,11 @@ def gyro_bandwidth_parameter(self) -> str:
597606
+----------------------------------------+-------------------------+
598607
| Mode | Value |
599608
+========================================+=========================+
600-
| :py:const:`BMI160.GYRO_NORMAL` | :py:const:`0b10` |
609+
| :py:const:`bmi160.GYRO_NORMAL` | :py:const:`0b10` |
601610
+----------------------------------------+-------------------------+
602-
| :py:const:`BMI160.GYRO_OSR2` | :py:const:`0b01` |
611+
| :py:const:`bmi160.GYRO_OSR2` | :py:const:`0b01` |
603612
+----------------------------------------+-------------------------+
604-
| :py:const:`BMI160.GYRO_OSR4` | :py:const:`0b00` |
613+
| :py:const:`bmi160.GYRO_OSR4` | :py:const:`0b00` |
605614
+----------------------------------------+-------------------------+
606615
607616
"""
@@ -620,11 +629,11 @@ def gyro_power_mode(self) -> str:
620629
+-------------------------------------------+-------------------------+
621630
| Mode | Value |
622631
+===========================================+=========================+
623-
| :py:const:`BMI160.GYRO_POWER_SUSPEND` | :py:const:`0x14` |
632+
| :py:const:`bmi160.GYRO_POWER_SUSPEND` | :py:const:`0x14` |
624633
+-------------------------------------------+-------------------------+
625-
| :py:const:`BMI160.GYRO_POWER_NORMAL` | :py:const:`0x15` |
634+
| :py:const:`bmi160.GYRO_POWER_NORMAL` | :py:const:`0x15` |
626635
+-------------------------------------------+-------------------------+
627-
| :py:const:`BMI160.GYRO_POWER_FASTSTARTUP` | :py:const:`0x17` |
636+
| :py:const:`bmi160.GYRO_POWER_FASTSTARTUP` | :py:const:`0x17` |
628637
+-------------------------------------------+-------------------------+
629638
630639
"""
@@ -656,15 +665,15 @@ def gyro_range(self) -> str:
656665
+----------------------------------------+-------------------------+
657666
| Mode | Value |
658667
+========================================+=========================+
659-
| :py:const:`BMI160.GYRO_RANGE_2000` | :py:const:`0b000` |
668+
| :py:const:`bmi160.GYRO_RANGE_2000` | :py:const:`0b000` |
660669
+----------------------------------------+-------------------------+
661-
| :py:const:`BMI160.GYRO_RANGE_1000` | :py:const:`0b001` |
670+
| :py:const:`bmi160.GYRO_RANGE_1000` | :py:const:`0b001` |
662671
+----------------------------------------+-------------------------+
663-
| :py:const:`BMI160.GYRO_RANGE_500` | :py:const:`0b010` |
672+
| :py:const:`bmi160.GYRO_RANGE_500` | :py:const:`0b010` |
664673
+----------------------------------------+-------------------------+
665-
| :py:const:`BMI160.GYRO_RANGE_250` | :py:const:`0b011` |
674+
| :py:const:`bmi160.GYRO_RANGE_250` | :py:const:`0b011` |
666675
+----------------------------------------+-------------------------+
667-
| :py:const:`BMI160.GYRO_RANGE_125` | :py:const:`0b100` |
676+
| :py:const:`bmi160.GYRO_RANGE_125` | :py:const:`0b100` |
668677
+----------------------------------------+-------------------------+
669678
670679
"""

packages.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"urls": [
3+
["micropython_bmi160/bmi160.py", "github:jposada202020/MicroPython_BMI160/micropython_bmi160/bmi160.py"],
4+
["micropython_bmi160/i2c_helpers.py", "github:jposada202020/MicroPython_BMI160/micropython_bmi160/i2c_helpers.py"],
5+
["micropython_bmi160/__init__.py", "github:jposada202020/MicroPython_BMI160/micropython_bmi160/__init__.py"]
6+
],
7+
"version": "0.1"
8+
}

0 commit comments

Comments
 (0)