0.4.1 GY521

This commit is contained in:
Rob Tillaart 2023-11-02 15:58:05 +01:00
parent fa20816d6b
commit f853901f03
6 changed files with 39 additions and 18 deletions

View File

@ -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/).
## [0.4.1] - 2023-11-02
- update readme.md
- minor edits
## [0.4.0] - 2023-06-11
- fix #42 roll + pitch "jumps" after full rotation.
- fixed normalization code.

View File

@ -1,7 +1,7 @@
//
// FILE: GY521.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.4.0
// VERSION: 0.4.1
// PURPOSE: Arduino library for I2C GY521 accelerometer-gyroscope sensor
// URL: https://github.com/RobTillaart/GY521
@ -124,7 +124,7 @@ int16_t GY521::read()
// duration interval
now = micros();
float duration = (now - _lastMicros) * 1e-6; // duration in seconds.
float duration = (now - _lastMicros) * 1e-6; // duration in seconds.
_lastMicros = now;
@ -180,7 +180,7 @@ int16_t GY521::read()
// correction at 375 due to the factor 0.96 in pitch
if (_gay >= 375) _gay -= 375;
else if (_gay < 0) _gay += 375;
// correction at 360
// correction at 360
if (_gaz >= 360) _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
if (_gay >= 375) _gay -= 375;
else if (_gay < 0) _gay += 375;
// correction at 360
// correction at 360
if (_gaz >= 360) _gaz -= 360;
else if (_gaz < 0) _gaz += 360;
}
@ -376,7 +376,7 @@ bool GY521::setAccelSensitivity(uint8_t as)
{
return false;
}
// no need to write same value
// no need to write same value
if (((val >> 3) & 3) != _afs)
{
val &= 0xE7;
@ -386,7 +386,7 @@ bool GY521::setAccelSensitivity(uint8_t as)
return false;
}
}
// calculate conversion factor. // 4 possible values => lookup table?
// calculate conversion factor. // 4 possible values => lookup table?
_raw2g = (1 << _afs) * GY521_RAW2G;
return true;
}
@ -397,7 +397,7 @@ uint8_t GY521::getAccelSensitivity()
uint8_t val = getRegister(GY521_ACCEL_CONFIG);
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;
return _afs;
@ -423,7 +423,7 @@ bool GY521::setGyroSensitivity(uint8_t gs)
return false;
}
}
// calculate conversion factor..
// calculate conversion factor..
// 4 possible values => lookup table?
_raw2dps = (1 << _gfs) * GY521_RAW2DPS;
return true;
@ -487,5 +487,5 @@ int16_t GY521::_WireRead2()
}
// -- END OF FILE --
// -- END OF FILE --

View File

@ -2,17 +2,16 @@
//
// FILE: GY521.h
// AUTHOR: Rob Tillaart
// VERSION: 0.4.0
// VERSION: 0.4.1
// PURPOSE: Arduino library for I2C GY521 accelerometer-gyroscope sensor
// URL: https://github.com/RobTillaart/GY521
//
#include "Arduino.h"
#include "Wire.h"
#define GY521_LIB_VERSION (F("0.4.0"))
#define GY521_LIB_VERSION (F("0.4.1"))
// THROTTLE TIMING

View File

@ -2,8 +2,11 @@
[![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)
[![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)
[![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
@ -164,19 +167,33 @@ See examples, use with care
#### Must
- improve documentation
- add tables where appropriate
- sensitivity, error codes etc
- test test and test ...(ESP too)
#### Should
- add performance sketch
#### Could
- calibrate sketch could print code snippet to include...
- add examples
- improve unit tests?
#### Wont
- look for maths optimizations (atan, hypot, performance)
- ==> hypot optimized.
- ==> hypot optimized (fastTrig?)
- other ideas affect accuracy, so unless new ideas arise.
- calibrate function in the lib
- 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,

View File

@ -15,9 +15,9 @@
"type": "git",
"url": "https://github.com/RobTillaart/GY521.git"
},
"version": "0.4.0",
"version": "0.4.1",
"license": "MIT",
"frameworks": "arduino",
"frameworks": "*",
"platforms": "*",
"headers": "GY521.h"
}

View File

@ -1,5 +1,5 @@
name=GY521
version=0.4.0
version=0.4.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for GY521 angle measurement
@ -7,5 +7,5 @@ paragraph=
category=Sensors
url=https://github.com/RobTillaart/GY521
architectures=*
includes=GY521.h
includes=GY521.h
depends=