0.6.0 GY521

This commit is contained in:
Rob Tillaart 2024-06-24 11:40:29 +02:00
parent 04e2b8c617
commit 881f755f4c
7 changed files with 42 additions and 24 deletions

View File

@ -6,13 +6,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.6.0] - 2024-06-22
- fix #54, calibrate() function, Kudos to jens-kuerten and MArimont3
- minor edits
----
## [0.5.3] - 2024-05-08
- fix #52, add **uint8_t getAddrress()**
- fix #51, add **bool setDLPFMode(uint8_t mode)** and **uint8_t getDLPFMode()**
- add const float GRAVITY=9.80655;
- minor edits
## [0.5.2] - 2024-01-16
- fix #48, use float variables in example GY521_test_1.ino
- add **void calibrate(uint16_t times)** to API
@ -72,7 +77,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- update library.json, license, minor edits
## [0.3.5] - 2021-10-20
- update build-CI, badges
- update build-CI, badges
- fix #28 add wakeup to begin().
## [0.3.4] - 2021-07-12
@ -85,7 +90,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- fix #20 support multiWire
## [0.3.1] - 2021-06-13
- added more unit test
- added more unit test
- some initialization
## [0.3.0] - 2021-04-07

View File

@ -1,7 +1,7 @@
//
// FILE: GY521.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.5.3
// VERSION: 0.6.0
// PURPOSE: Arduino library for I2C GY521 accelerometer-gyroscope sensor
// URL: https://github.com/RobTillaart/GY521
@ -78,31 +78,39 @@ void GY521::calibrate(uint16_t times)
bool oldThrottle = _throttle;
_throttle = false;
// set errors to zero
// set all errors to zero, to get the raw reads.
axe = aye = aze = 0;
gxe = gye = gze = 0;
// use local error sums, to calculate the average error.
float _axe = 0, _aye = 0, _aze = 0;
float _gxe = 0, _gye = 0, _gze = 0;
// adjust times if zero.
if (times == 0) times = 1;
// summarize (6x) the measurements.
for (uint16_t i = 0; i < times; i++)
{
read();
axe -= getAccelX();
aye -= getAccelY();
aze -= getAccelZ();
gxe -= getGyroX();
gye -= getGyroY();
gze -= getGyroZ();
_axe -= getAccelX();
_aye -= getAccelY();
_aze -= getAccelZ();
_gxe -= getGyroX();
_gye -= getGyroY();
_gze -= getGyroZ();
}
// adjust calibration errors so table should get all zero's.
// adjust calibration errors so read() should get all zero's on average.
float factor = 1.0 / times;
axe *= factor;
aye *= factor;
aze *= factor;
gxe *= factor;
gye *= factor;
gze *= factor;
axe = _axe * factor;
aye = _aye * factor;
aze = _aze * factor;
gxe = _gxe * factor;
gye = _gye * factor;
gze = _gze * factor;
// restore throttle state
// restore throttle state.
_throttle = oldThrottle;
}

View File

@ -2,7 +2,7 @@
//
// FILE: GY521.h
// AUTHOR: Rob Tillaart
// VERSION: 0.5.3
// VERSION: 0.6.0
// PURPOSE: Arduino library for I2C GY521 accelerometer-gyroscope sensor
// URL: https://github.com/RobTillaart/GY521
@ -11,7 +11,7 @@
#include "Wire.h"
#define GY521_LIB_VERSION (F("0.5.3"))
#define GY521_LIB_VERSION (F("0.6.0"))
const float GRAVITY = 9.80655;

View File

@ -24,6 +24,11 @@ It needs to be tested a lot more.
See changelog.md for latest updates.
#### 0.6.0
Fixed a bug in calibration function, making previous versions obsolete.
#### 0.5.0 Breaking change
Version 0.5.0 introduced a breaking change.

View File

@ -51,7 +51,7 @@ void test(uint16_t times)
// flush all output
delay(100);
uint32_t start = micros();
sensor.calibrate(100);
sensor.calibrate(times);
uint32_t duration = micros() - start;
// print results

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/GY521.git"
},
"version": "0.5.3",
"version": "0.6.0",
"license": "MIT",
"frameworks": "*",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=GY521
version=0.5.3
version=0.6.0
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for GY521 angle measurement