Skip to content

Commit 66f4850

Browse files
authored
Fix calibration error scaling (#57)
Co-authored-by: Maik Menz <[email protected]>
1 parent 071f22b commit 66f4850

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

GY521.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,14 @@ void GY521::calibrate(uint16_t times)
9797
_gze -= getGyroZ();
9898
}
9999

100-
// adjust calibration errors so read() should get all zero's on average.
101-
float factor = 1.0 / times;
100+
// scale accelerometer calibration errors so read() should get all zero's on average.
101+
float factor = _raw2g / times;
102102
axe = _axe * factor;
103103
aye = _aye * factor;
104104
aze = _aze * factor;
105+
106+
// scale gyro calibration errors so read() should get all zero's on average.
107+
factor = _raw2dps / times;
105108
gxe = _gxe * factor;
106109
gye = _gye * factor;
107110
gze = _gze * factor;

0 commit comments

Comments
 (0)