File tree Expand file tree Collapse file tree 6 files changed +42
-24
lines changed
Expand file tree Collapse file tree 6 files changed +42
-24
lines changed Original file line number Diff line number Diff line change @@ -6,13 +6,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66and this project adheres to [ Semantic Versioning] ( http://semver.org/ ) .
77
88
9+ ## [ 0.6.0] - 2024-06-22
10+ - fix #54 , calibrate() function, Kudos to jens-kuerten and MArimont3
11+ - minor edits
12+
13+ ----
14+
915## [ 0.5.3] - 2024-05-08
1016- fix #52 , add ** uint8_t getAddrress()**
1117- fix #51 , add ** bool setDLPFMode(uint8_t mode)** and ** uint8_t getDLPFMode()**
1218- add const float GRAVITY=9.80655;
1319- minor edits
1420
15-
1621## [ 0.5.2] - 2024-01-16
1722- fix #48 , use float variables in example GY521_test_1.ino
1823- add ** void calibrate(uint16_t times)** to API
@@ -72,7 +77,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
7277- update library.json, license, minor edits
7378
7479## [ 0.3.5] - 2021-10-20
75- - update build-CI, badges
80+ - update build-CI, badges
7681- fix #28 add wakeup to begin().
7782
7883## [ 0.3.4] - 2021-07-12
@@ -85,7 +90,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
8590- fix #20 support multiWire
8691
8792## [ 0.3.1] - 2021-06-13
88- - added more unit test
93+ - added more unit test
8994- some initialization
9095
9196## [ 0.3.0] - 2021-04-07
Original file line number Diff line number Diff line change 11//
22// FILE: GY521.cpp
33// AUTHOR: Rob Tillaart
4- // VERSION: 0.5.3
4+ // VERSION: 0.6.0
55// PURPOSE: Arduino library for I2C GY521 accelerometer-gyroscope sensor
66// URL: https://github.com/RobTillaart/GY521
77
@@ -78,31 +78,39 @@ void GY521::calibrate(uint16_t times)
7878 bool oldThrottle = _throttle;
7979 _throttle = false ;
8080
81- // set errors to zero
81+ // set all errors to zero, to get the raw reads.
8282 axe = aye = aze = 0 ;
8383 gxe = gye = gze = 0 ;
8484
85+ // use local error sums, to calculate the average error.
86+ float _axe = 0 , _aye = 0 , _aze = 0 ;
87+ float _gxe = 0 , _gye = 0 , _gze = 0 ;
88+
89+ // adjust times if zero.
90+ if (times == 0 ) times = 1 ;
91+
92+ // summarize (6x) the measurements.
8593 for (uint16_t i = 0 ; i < times; i++)
8694 {
8795 read ();
88- axe -= getAccelX ();
89- aye -= getAccelY ();
90- aze -= getAccelZ ();
91- gxe -= getGyroX ();
92- gye -= getGyroY ();
93- gze -= getGyroZ ();
96+ _axe -= getAccelX ();
97+ _aye -= getAccelY ();
98+ _aze -= getAccelZ ();
99+ _gxe -= getGyroX ();
100+ _gye -= getGyroY ();
101+ _gze -= getGyroZ ();
94102 }
95103
96- // adjust calibration errors so table should get all zero's.
104+ // adjust calibration errors so read() should get all zero's on average .
97105 float factor = 1.0 / times;
98- axe *= factor;
99- aye *= factor;
100- aze *= factor;
101- gxe *= factor;
102- gye *= factor;
103- gze *= factor;
104-
105- // restore throttle state
106+ axe = _axe * factor;
107+ aye = _aye * factor;
108+ aze = _aze * factor;
109+ gxe = _gxe * factor;
110+ gye = _gye * factor;
111+ gze = _gze * factor;
112+
113+ // restore throttle state.
106114 _throttle = oldThrottle;
107115}
108116
Original file line number Diff line number Diff line change 22//
33// FILE: GY521.h
44// AUTHOR: Rob Tillaart
5- // VERSION: 0.5.3
5+ // VERSION: 0.6.0
66// PURPOSE: Arduino library for I2C GY521 accelerometer-gyroscope sensor
77// URL: https://github.com/RobTillaart/GY521
88
1111#include " Wire.h"
1212
1313
14- #define GY521_LIB_VERSION (F(" 0.5.3 " ))
14+ #define GY521_LIB_VERSION (F(" 0.6.0 " ))
1515
1616const float GRAVITY = 9.80655 ;
1717
Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ It needs to be tested a lot more.
2424See changelog.md for latest updates.
2525
2626
27+ #### 0.6.0
28+
29+ Fixed a bug in calibration function, making previous versions obsolete.
30+
31+
2732#### 0.5.0 Breaking change
2833
2934Version 0.5.0 introduced a breaking change.
Original file line number Diff line number Diff line change 1515 "type" : " git" ,
1616 "url" : " https://github.com/RobTillaart/GY521.git"
1717 },
18- "version" : " 0.5.3 " ,
18+ "version" : " 0.6.0 " ,
1919 "license" : " MIT" ,
2020 "frameworks" : " *" ,
2121 "platforms" : " *" ,
Original file line number Diff line number Diff line change 11name =GY521
2- version =0.5.3
2+ version =0.6.0
33author =Rob Tillaart <
[email protected] >
44maintainer =Rob Tillaart <
[email protected] >
55sentence =Arduino library for GY521 angle measurement
You can’t perform that action at this time.
0 commit comments