|
9 | 9 | from utime import ticks_ms, sleep_ms |
10 | 10 | import math |
11 | 11 | from bno08x import * |
| 12 | +import gc |
| 13 | +gc.collect() |
| 14 | +# print(gc.mem_free()) # Check available memory |
12 | 15 |
|
13 | 16 | I2C1_SDA = Pin(21) |
14 | 17 | I2C1_SCL = Pin(22) |
|
19 | 22 | print("BNO08x I2C connection : Done") |
20 | 23 |
|
21 | 24 | bno.enable_feature(BNO_REPORT_ACCELEROMETER, 20) |
22 | | -bno.enable_feature(BNO_REPORT_MAGNETOMETER,20 ) |
23 | | -bno.enable_feature(BNO_REPORT_GYROSCOPE,20 ) |
| 25 | +bno.enable_feature(BNO_REPORT_MAGNETOMETER, 20) |
| 26 | +bno.enable_feature(BNO_REPORT_GYROSCOPE, 20) |
24 | 27 | bno.enable_feature(BNO_REPORT_GAME_ROTATION_VECTOR, 10) |
25 | 28 | bno.set_quaternion_euler_vector(BNO_REPORT_GAME_ROTATION_VECTOR) |
26 | 29 |
|
|
37 | 40 | sleep_ms(50) |
38 | 41 | cpt += 1 |
39 | 42 | # print("cpt", cpt) |
40 | | -# accel_x, accel_y, accel_z = bno.acc |
41 | | -# print("Acceleration\tX: {:+.3f}\tY: {:+.3f}\tZ: {:+.3f}\tm/s²".format(accel_x, accel_y, accel_z)) |
42 | | -# gyro_x, gyro_y, gyro_z = bno.gyro |
43 | | -# print("Gyroscope\tX: {:+.3f}\tY: {:+.3f}\tZ: {:+.3f}\trads/s".format(gyro_x, gyro_y, gyro_z)) |
44 | | -# mag_x, mag_y, mag_z = bno.mag |
45 | | -# print("Magnetometer\tX: {:+.3f}\tY: {:+.3f}\tZ: {:+.3f}\tuT".format(mag_x, mag_y, mag_z)) |
46 | | -# quat_i, quat_j, quat_k, quat_real = bno.quaternion |
47 | | -# print("Rot Vect Quat\tI: {:+.3f}\tJ: {:+.3f}\tK: {:+.3f}\tReal: {:+.3f}".format(quat_i, quat_j, quat_k, quat_real)) |
| 43 | + # accel_x, accel_y, accel_z = bno.acc |
| 44 | + # print("Acceleration\tX: {:+.3f}\tY: {:+.3f}\tZ: {:+.3f}\tm/s²".format(accel_x, accel_y, accel_z)) |
| 45 | + # gyro_x, gyro_y, gyro_z = bno.gyro |
| 46 | + # print("Gyroscope\tX: {:+.3f}\tY: {:+.3f}\tZ: {:+.3f}\trads/s".format(gyro_x, gyro_y, gyro_z)) |
| 47 | + # mag_x, mag_y, mag_z = bno.mag |
| 48 | + # print("Magnetometer\tX: {:+.3f}\tY: {:+.3f}\tZ: {:+.3f}\tuT".format(mag_x, mag_y, mag_z)) |
| 49 | + # quat_i, quat_j, quat_k, quat_real = bno.quaternion |
| 50 | + # print("Rot Vect Quat\tI: {:+.3f}\tJ: {:+.3f}\tK: {:+.3f}\tReal: {:+.3f}".format(quat_i, quat_j, quat_k, quat_real)) |
48 | 51 | R, T, P = bno.euler |
49 | 52 | print("Euler Angle\tX: {:+.3f}\tY: {:+.3f}\tZ: {:+.3f}".format(R, T, P)) |
50 | 53 | # print("===================================") |
|
61 | 64 | print("Program stopped. Exiting...") |
62 | 65 |
|
63 | 66 | # Optional cleanup code |
| 67 | + gc.collect() # Garbage collector (GC), Free unused memory |
0 commit comments