|
8 | 8 | from adafruit_bno080.i2c import BNO080_I2C
|
9 | 9 | from digitalio import DigitalInOut
|
10 | 10 |
|
11 |
| -i2c = busio.I2C(board.SCL, board.SDA, frequency=400000) |
12 |
| -reset_pin = DigitalInOut(board.G0) |
13 |
| -bno = BNO080_I2C(i2c, reset=reset_pin) |
| 11 | +i2c = busio.I2C(board.SCL, board.SDA, frequency=800000) |
| 12 | +reset_pin = DigitalInOut(board.D5) |
| 13 | +bno = BNO080_I2C(i2c, reset=reset_pin, debug=False) |
14 | 14 |
|
15 | 15 | bno.enable_feature(adafruit_bno080.BNO_REPORT_ACCELEROMETER)
|
16 |
| -#bno.enable_feature(adafruit_bno080.BNO_REPORT_GYROSCOPE) |
17 |
| -#bno.enable_feature(adafruit_bno080.BNO_REPORT_MAGNETIC_FIELD) |
| 16 | +bno.enable_feature(adafruit_bno080.BNO_REPORT_GYROSCOPE) |
| 17 | +bno.enable_feature(adafruit_bno080.BNO_REPORT_MAGNETIC_FIELD) |
| 18 | +bno.enable_feature(adafruit_bno080.BNO_REPORT_LINEAR_ACCELERATION) |
| 19 | +bno.enable_feature(adafruit_bno080.BNO_REPORT_ROTATION_VECTOR) |
| 20 | +bno.enable_feature(adafruit_bno080.BNO_REPORT_GEOMAGNETIC_ROTATION_VECTOR) |
| 21 | +bno.enable_feature(adafruit_bno080.BNO_REPORT_STEP_COUNTER) |
| 22 | +bno.enable_feature(adafruit_bno080.BNO_REPORT_SHAKE_DETECTOR) |
18 | 23 |
|
19 | 24 | while True:
|
20 |
| - |
| 25 | + time.sleep(0.1) |
| 26 | + |
21 | 27 | print("Acceleration:")
|
22 | 28 | accel_x, accel_y, accel_z = bno.acceleration # pylint:disable=no-member
|
23 | 29 | print("X: %0.6f Y: %0.6f Z: %0.6f m/s^2" % (accel_x, accel_y, accel_z))
|
24 | 30 | print("")
|
25 | 31 |
|
26 |
| - """ |
27 | 32 | print("Gyro:")
|
28 | 33 | gyro_x, gyro_y, gyro_z = bno.gyro # pylint:disable=no-member
|
29 | 34 | print("X: %0.6f Y: %0.6f Z: %0.6f rads/s" % (gyro_x, gyro_y, gyro_z))
|
|
45 | 50 | % (linear_accel_x, linear_accel_y, linear_accel_z)
|
46 | 51 | )
|
47 | 52 | print("")
|
| 53 | + |
48 | 54 | print("Rotation Vector Quaternion:")
|
49 | 55 | quat_i, quat_j, quat_k, quat_real = bno.quaternion # pylint:disable=no-member
|
50 |
| -
|
51 | 56 | print(
|
52 | 57 | "I: %0.6f J: %0.6f K: %0.6f Real: %0.6f" % (quat_i, quat_j, quat_k, quat_real)
|
53 | 58 | )
|
54 | 59 | print("")
|
| 60 | + |
55 | 61 | print("Geomagnetic Rotation Vector Quaternion:")
|
56 | 62 | (
|
57 | 63 | geo_quat_i,
|
58 | 64 | geo_quat_j,
|
59 | 65 | geo_quat_k,
|
60 | 66 | geo_quat_real,
|
61 | 67 | ) = bno.geomagnetic_quaternion # pylint:disable=no-member
|
62 |
| -
|
63 | 68 | print(
|
64 | 69 | "I: %0.6f J: %0.6f K: %0.6f Real: %0.6f" % (quat_i, quat_j, quat_k, quat_real)
|
65 | 70 | )
|
66 | 71 | print("")
|
| 72 | + |
67 | 73 | print("Steps detected:", bno.steps)
|
68 | 74 | print("")
|
| 75 | + |
69 | 76 | if bno.shake:
|
70 | 77 | print("SHAKE DETECTED!")
|
71 | 78 | print("")
|
72 |
| -
|
73 |
| - sleep(0.5) |
74 |
| - """ |
|
0 commit comments