mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.6.0 GY521
This commit is contained in:
parent
04e2b8c617
commit
881f755f4c
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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": "*",
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user