mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.4.1 GY521
This commit is contained in:
parent
fa20816d6b
commit
f853901f03
@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|||||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
|
||||||
|
## [0.4.1] - 2023-11-02
|
||||||
|
- update readme.md
|
||||||
|
- minor edits
|
||||||
|
|
||||||
|
|
||||||
## [0.4.0] - 2023-06-11
|
## [0.4.0] - 2023-06-11
|
||||||
- fix #42 roll + pitch "jumps" after full rotation.
|
- fix #42 roll + pitch "jumps" after full rotation.
|
||||||
- fixed normalization code.
|
- fixed normalization code.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// FILE: GY521.cpp
|
// FILE: GY521.cpp
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// VERSION: 0.4.0
|
// VERSION: 0.4.1
|
||||||
// PURPOSE: Arduino library for I2C GY521 accelerometer-gyroscope sensor
|
// PURPOSE: Arduino library for I2C GY521 accelerometer-gyroscope sensor
|
||||||
// URL: https://github.com/RobTillaart/GY521
|
// URL: https://github.com/RobTillaart/GY521
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ int16_t GY521::read()
|
|||||||
|
|
||||||
// duration interval
|
// duration interval
|
||||||
now = micros();
|
now = micros();
|
||||||
float duration = (now - _lastMicros) * 1e-6; // duration in seconds.
|
float duration = (now - _lastMicros) * 1e-6; // duration in seconds.
|
||||||
_lastMicros = now;
|
_lastMicros = now;
|
||||||
|
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ int16_t GY521::read()
|
|||||||
// correction at 375 due to the factor 0.96 in pitch
|
// correction at 375 due to the factor 0.96 in pitch
|
||||||
if (_gay >= 375) _gay -= 375;
|
if (_gay >= 375) _gay -= 375;
|
||||||
else if (_gay < 0) _gay += 375;
|
else if (_gay < 0) _gay += 375;
|
||||||
// correction at 360
|
// correction at 360
|
||||||
if (_gaz >= 360) _gaz -= 360;
|
if (_gaz >= 360) _gaz -= 360;
|
||||||
else if (_gaz < 0) _gaz += 360;
|
else if (_gaz < 0) _gaz += 360;
|
||||||
}
|
}
|
||||||
@ -335,7 +335,7 @@ int16_t GY521::readGyro()
|
|||||||
// correction at 375 due to the factor 0.96 in pitch
|
// correction at 375 due to the factor 0.96 in pitch
|
||||||
if (_gay >= 375) _gay -= 375;
|
if (_gay >= 375) _gay -= 375;
|
||||||
else if (_gay < 0) _gay += 375;
|
else if (_gay < 0) _gay += 375;
|
||||||
// correction at 360
|
// correction at 360
|
||||||
if (_gaz >= 360) _gaz -= 360;
|
if (_gaz >= 360) _gaz -= 360;
|
||||||
else if (_gaz < 0) _gaz += 360;
|
else if (_gaz < 0) _gaz += 360;
|
||||||
}
|
}
|
||||||
@ -376,7 +376,7 @@ bool GY521::setAccelSensitivity(uint8_t as)
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// no need to write same value
|
// no need to write same value
|
||||||
if (((val >> 3) & 3) != _afs)
|
if (((val >> 3) & 3) != _afs)
|
||||||
{
|
{
|
||||||
val &= 0xE7;
|
val &= 0xE7;
|
||||||
@ -386,7 +386,7 @@ bool GY521::setAccelSensitivity(uint8_t as)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// calculate conversion factor. // 4 possible values => lookup table?
|
// calculate conversion factor. // 4 possible values => lookup table?
|
||||||
_raw2g = (1 << _afs) * GY521_RAW2G;
|
_raw2g = (1 << _afs) * GY521_RAW2G;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -397,7 +397,7 @@ uint8_t GY521::getAccelSensitivity()
|
|||||||
uint8_t val = getRegister(GY521_ACCEL_CONFIG);
|
uint8_t val = getRegister(GY521_ACCEL_CONFIG);
|
||||||
if (_error != GY521_OK)
|
if (_error != GY521_OK)
|
||||||
{
|
{
|
||||||
return _error; // return and propagate error (best thing to do)
|
return _error; // return and propagate error (best thing to do)
|
||||||
}
|
}
|
||||||
_afs = (val >> 3) & 3;
|
_afs = (val >> 3) & 3;
|
||||||
return _afs;
|
return _afs;
|
||||||
@ -423,7 +423,7 @@ bool GY521::setGyroSensitivity(uint8_t gs)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// calculate conversion factor..
|
// calculate conversion factor..
|
||||||
// 4 possible values => lookup table?
|
// 4 possible values => lookup table?
|
||||||
_raw2dps = (1 << _gfs) * GY521_RAW2DPS;
|
_raw2dps = (1 << _gfs) * GY521_RAW2DPS;
|
||||||
return true;
|
return true;
|
||||||
@ -487,5 +487,5 @@ int16_t GY521::_WireRead2()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -- END OF FILE --
|
// -- END OF FILE --
|
||||||
|
|
||||||
|
@ -2,17 +2,16 @@
|
|||||||
//
|
//
|
||||||
// FILE: GY521.h
|
// FILE: GY521.h
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// VERSION: 0.4.0
|
// VERSION: 0.4.1
|
||||||
// PURPOSE: Arduino library for I2C GY521 accelerometer-gyroscope sensor
|
// PURPOSE: Arduino library for I2C GY521 accelerometer-gyroscope sensor
|
||||||
// URL: https://github.com/RobTillaart/GY521
|
// URL: https://github.com/RobTillaart/GY521
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "Wire.h"
|
#include "Wire.h"
|
||||||
|
|
||||||
|
|
||||||
#define GY521_LIB_VERSION (F("0.4.0"))
|
#define GY521_LIB_VERSION (F("0.4.1"))
|
||||||
|
|
||||||
|
|
||||||
// THROTTLE TIMING
|
// THROTTLE TIMING
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
[![Arduino CI](https://github.com/RobTillaart/GY521/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
[![Arduino CI](https://github.com/RobTillaart/GY521/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
||||||
[![Arduino-lint](https://github.com/RobTillaart/GY521/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/GY521/actions/workflows/arduino-lint.yml)
|
[![Arduino-lint](https://github.com/RobTillaart/GY521/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/GY521/actions/workflows/arduino-lint.yml)
|
||||||
[![JSON check](https://github.com/RobTillaart/GY521/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/GY521/actions/workflows/jsoncheck.yml)
|
[![JSON check](https://github.com/RobTillaart/GY521/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/GY521/actions/workflows/jsoncheck.yml)
|
||||||
|
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/GY521.svg)](https://github.com/RobTillaart/GY521/issues)
|
||||||
|
|
||||||
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/GY521/blob/master/LICENSE)
|
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/GY521/blob/master/LICENSE)
|
||||||
[![GitHub release](https://img.shields.io/github/release/RobTillaart/GY521.svg?maxAge=3600)](https://github.com/RobTillaart/GY521/releases)
|
[![GitHub release](https://img.shields.io/github/release/RobTillaart/GY521.svg?maxAge=3600)](https://github.com/RobTillaart/GY521/releases)
|
||||||
|
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/GY521.svg)](https://registry.platformio.org/libraries/robtillaart/GY521)
|
||||||
|
|
||||||
|
|
||||||
# GY521
|
# GY521
|
||||||
@ -164,19 +167,33 @@ See examples, use with care
|
|||||||
#### Must
|
#### Must
|
||||||
|
|
||||||
- improve documentation
|
- improve documentation
|
||||||
|
- add tables where appropriate
|
||||||
|
- sensitivity, error codes etc
|
||||||
- test test and test ...(ESP too)
|
- test test and test ...(ESP too)
|
||||||
|
|
||||||
|
|
||||||
#### Should
|
#### Should
|
||||||
|
|
||||||
|
- add performance sketch
|
||||||
|
|
||||||
#### Could
|
#### Could
|
||||||
|
|
||||||
- calibrate sketch could print code snippet to include...
|
- calibrate sketch could print code snippet to include...
|
||||||
|
- add examples
|
||||||
|
- improve unit tests?
|
||||||
|
|
||||||
#### Wont
|
#### Wont
|
||||||
|
|
||||||
- look for maths optimizations (atan, hypot, performance)
|
- look for maths optimizations (atan, hypot, performance)
|
||||||
- ==> hypot optimized.
|
- ==> hypot optimized (fastTrig?)
|
||||||
- other ideas affect accuracy, so unless new ideas arise.
|
- other ideas affect accuracy, so unless new ideas arise.
|
||||||
- calibrate function in the lib
|
- calibrate function in the lib
|
||||||
- not as lib will grow too large.
|
- not as lib will grow too large.
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
If you appreciate my libraries, you can support the development and maintenance.
|
||||||
|
Improve the quality of the libraries by providing issues and Pull Requests, or
|
||||||
|
donate through PayPal or GitHub sponsors.
|
||||||
|
|
||||||
|
Thank you,
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/RobTillaart/GY521.git"
|
"url": "https://github.com/RobTillaart/GY521.git"
|
||||||
},
|
},
|
||||||
"version": "0.4.0",
|
"version": "0.4.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"frameworks": "arduino",
|
"frameworks": "*",
|
||||||
"platforms": "*",
|
"platforms": "*",
|
||||||
"headers": "GY521.h"
|
"headers": "GY521.h"
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name=GY521
|
name=GY521
|
||||||
version=0.4.0
|
version=0.4.1
|
||||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
sentence=Arduino library for GY521 angle measurement
|
sentence=Arduino library for GY521 angle measurement
|
||||||
@ -7,5 +7,5 @@ paragraph=
|
|||||||
category=Sensors
|
category=Sensors
|
||||||
url=https://github.com/RobTillaart/GY521
|
url=https://github.com/RobTillaart/GY521
|
||||||
architectures=*
|
architectures=*
|
||||||
includes=GY521.h
|
includes=GY521.h
|
||||||
depends=
|
depends=
|
||||||
|
Loading…
Reference in New Issue
Block a user