Skip to content

Commit

Permalink
Fix calibration error scaling (#57)
Browse files Browse the repository at this point in the history
Co-authored-by: Maik Menz <mycosd@hotmail.de>
  • Loading branch information
mycosd and mycosd authored Jul 26, 2024
1 parent 071f22b commit 66f4850
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions GY521.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,14 @@ void GY521::calibrate(uint16_t times)
_gze -= getGyroZ();
}

// adjust calibration errors so read() should get all zero's on average.
float factor = 1.0 / times;
// scale accelerometer calibration errors so read() should get all zero's on average.
float factor = _raw2g / times;
axe = _axe * factor;
aye = _aye * factor;
aze = _aze * factor;

// scale gyro calibration errors so read() should get all zero's on average.
factor = _raw2dps / times;
gxe = _gxe * factor;
gye = _gye * factor;
gze = _gze * factor;
Expand Down

0 comments on commit 66f4850

Please sign in to comment.