Skip to content

Commit 808614f

Browse files
committed
not update tilt when shaking
1 parent 9647c27 commit 808614f

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

src/Arduino_AlvikCarrier.cpp

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -704,20 +704,23 @@ void Arduino_AlvikCarrier::updateImu(){
704704
is_shaking = false;
705705
}
706706

707-
imu->Get_6D_Orientation_XL(&xl);
708-
imu->Get_6D_Orientation_XH(&xh);
709-
imu->Get_6D_Orientation_YL(&yl);
710-
imu->Get_6D_Orientation_YH(&yh);
711-
imu->Get_6D_Orientation_ZL(&zl);
712-
imu->Get_6D_Orientation_ZH(&zh);
713-
714-
tilt_status = 0;
715-
tilt_status |= xl<<4;
716-
tilt_status |= xh<<5;
717-
tilt_status |= zl<<7;
718-
tilt_status |= zh<<6;
719-
tilt_status |= yh<<3;
720-
tilt_status |= yl<<2;
707+
if (!is_shaking){
708+
imu->Get_6D_Orientation_XL(&xl);
709+
imu->Get_6D_Orientation_XH(&xh);
710+
imu->Get_6D_Orientation_YL(&yl);
711+
imu->Get_6D_Orientation_YH(&yh);
712+
imu->Get_6D_Orientation_ZL(&zl);
713+
imu->Get_6D_Orientation_ZH(&zh);
714+
715+
tilt_status = 0;
716+
tilt_status |= xl<<4;
717+
tilt_status |= xh<<5;
718+
tilt_status |= zl<<7;
719+
tilt_status |= zh<<6;
720+
tilt_status |= yh<<3;
721+
tilt_status |= yl<<2;
722+
}
723+
721724
}
722725

723726
float Arduino_AlvikCarrier::getAccelerationX(){
@@ -761,12 +764,7 @@ bool Arduino_AlvikCarrier::isShaking(){
761764
}
762765

763766
uint8_t Arduino_AlvikCarrier::getMotion(){
764-
if (isShaking()){
765-
return 0x01;
766-
}
767-
else{
768-
return tilt_status;
769-
}
767+
return tilt_status | isShaking();
770768
}
771769

772770

0 commit comments

Comments
 (0)