Skip to content

Commit 754d6e7

Browse files
committed
optimize imu ahrs app for different device
1 parent 6f818ad commit 754d6e7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

projects/app_imu_ahrs/main.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,17 @@ def main(disp):
9090
ret_btn = [0, disp.height() - 50, 100, 50]
9191
dir_btn = [disp.width() // 2 - dir_font_size.width() // 2 - 10, disp.height() - 50, dir_font_size.width() + 20, 50]
9292

93-
sensor = imu.IMU("qmi8658")
93+
try:
94+
sensor = imu.IMU("default")
95+
except Exception:
96+
img = image.Image(disp.width(), disp.height())
97+
msg = "Init IMU failed, maybe no IMU"
98+
size = image.string_size(msg, scale=1.2, font="hershey_complex_small")
99+
img.draw_string((img.width() - size.width()) // 2, (img.height() - size.height()) // 2 , msg, image.COLOR_WHITE, scale=1.2, font="hershey_complex_small")
100+
disp.show(img)
101+
while not app.need_exit():
102+
time.sleep(0.2)
103+
return 0
94104
filter = ahrs.MahonyAHRS(kp, ki)
95105

96106
# if not sensor.calib_gyro_exists():

0 commit comments

Comments
 (0)