mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.5.0 GY521
This commit is contained in:
parent
edf1202f83
commit
9658f64ee5
@ -6,11 +6,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [0.5.0] - 2023-12-05
|
||||
- refactor API, begin()
|
||||
- update readme.md
|
||||
|
||||
----
|
||||
|
||||
## [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.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FILE: GY521.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.4.1
|
||||
// VERSION: 0.5.0
|
||||
// PURPOSE: Arduino library for I2C GY521 accelerometer-gyroscope sensor
|
||||
// URL: https://github.com/RobTillaart/GY521
|
||||
|
||||
@ -29,22 +29,8 @@ GY521::GY521(uint8_t address, TwoWire *wire)
|
||||
}
|
||||
|
||||
|
||||
#if defined (ESP8266) || defined(ESP32)
|
||||
bool GY521::begin(uint8_t sda, uint8_t scl)
|
||||
{
|
||||
_wire->begin(sda, scl);
|
||||
if (isConnected())
|
||||
{
|
||||
return wakeup();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool GY521::begin()
|
||||
{
|
||||
_wire->begin();
|
||||
if (isConnected())
|
||||
{
|
||||
return wakeup();
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: GY521.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.4.1
|
||||
// VERSION: 0.5.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.4.1"))
|
||||
#define GY521_LIB_VERSION (F("0.5.0"))
|
||||
|
||||
|
||||
// THROTTLE TIMING
|
||||
|
@ -23,6 +23,14 @@ It needs to be tested a lot more.
|
||||
|
||||
See changelog.md for latest updates.
|
||||
|
||||
#### 0.5.0 Breaking change
|
||||
|
||||
Version 0.5.0 introduced a breaking change.
|
||||
You cannot set the pins in **begin()** any more.
|
||||
This reduces the dependency of processor dependent Wire implementations.
|
||||
The user has to call **Wire.begin()** and can optionally set the Wire pins
|
||||
before calling **begin()**.
|
||||
|
||||
|
||||
#### Examples
|
||||
|
||||
@ -75,8 +83,8 @@ AD0 connected to VCC => 0x69
|
||||
|
||||
- **GY521(uint8_t address = 0x69, , TwoWire \*wire = &Wire)** Constructor with default address.
|
||||
0x68 is also a valid address. The wire argument is optional to select Wire1 Wire2 etc. on some boards.
|
||||
- **bool begin(uint8_t sda, uint8_t scl)** begin for ESP32 et al. Returns true if address can be found on I2C bus.
|
||||
- **bool begin()** Returns true if address can be found on I2C bus.
|
||||
Note call **Wire.begin()** before **begin()**.
|
||||
- **bool isConnected()** returns true if device can be found on I2C bus.
|
||||
- **void reset()** set all internal values to 0 and throttle time to 10 ms.
|
||||
- **bool wakeUp()** idem.
|
||||
|
@ -2,7 +2,6 @@
|
||||
// FILE: GY521_angle.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: read angleX, angleY, angleZ
|
||||
// DATE: 2022-06-06
|
||||
|
||||
|
||||
#include "GY521.h"
|
||||
|
@ -2,7 +2,6 @@
|
||||
// FILE: GY521_performance.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: minimal demo
|
||||
// DATE: 2021-06-13
|
||||
|
||||
|
||||
#include "GY521.h"
|
||||
@ -47,5 +46,5 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
// FILE: GY521_pitch_roll_yaw.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo pitch roll yaw
|
||||
// DATE: 2020-08-06
|
||||
|
||||
|
||||
#include "GY521.h"
|
||||
@ -29,13 +28,13 @@ void setup()
|
||||
Serial.println("\tCould not connect to GY521");
|
||||
delay(1000);
|
||||
}
|
||||
sensor.setAccelSensitivity(2); // 8g
|
||||
sensor.setGyroSensitivity(1); // 500 degrees/s
|
||||
sensor.setAccelSensitivity(2); // 8g
|
||||
sensor.setGyroSensitivity(1); // 500 degrees/s
|
||||
|
||||
sensor.setThrottle();
|
||||
Serial.println("start...");
|
||||
|
||||
// set calibration values from calibration sketch.
|
||||
// set calibration values from calibration sketch.
|
||||
sensor.axe = 0.574;
|
||||
sensor.aye = -0.002;
|
||||
sensor.aze = -1.043;
|
||||
@ -70,5 +69,5 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
// FILE: GY521_readCalibration_1.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: read the calibration values / errors for a flat sensor.
|
||||
// DATE: 2020-07-14
|
||||
|
||||
|
||||
#include "GY521.h"
|
||||
@ -31,11 +30,11 @@ void setup()
|
||||
Serial.println("Could not connect to GY521");
|
||||
}
|
||||
// adjust when needed.
|
||||
sensor.setAccelSensitivity(0); // 2g
|
||||
sensor.setGyroSensitivity(0); // 250 degrees/s
|
||||
sensor.setAccelSensitivity(0); // 2g
|
||||
sensor.setGyroSensitivity(0); // 250 degrees/s
|
||||
sensor.setThrottle(false);
|
||||
|
||||
// set all calibration errors to zero
|
||||
// set all calibration errors to zero
|
||||
sensor.axe = 0;
|
||||
sensor.aye = 0;
|
||||
sensor.aze = 0;
|
||||
@ -100,7 +99,7 @@ void loop()
|
||||
Serial.print(t * 0.05, 2);
|
||||
Serial.println();
|
||||
|
||||
// adjust calibration errors so table should get all zero's.
|
||||
// adjust calibration errors so table should get all zero's.
|
||||
sensor.axe += ax * 0.05;
|
||||
sensor.aye += ay * 0.05;
|
||||
sensor.aze += az * 0.05;
|
||||
@ -113,5 +112,5 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
// FILE: readCalibration_2.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: read the calibration values / errors for a flat sensor.
|
||||
// DATE: 2022-06-07
|
||||
|
||||
|
||||
#include "GY521.h"
|
||||
|
@ -2,7 +2,6 @@
|
||||
// FILE: GY521_test_1.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: minimal demo to test working of the sensor.
|
||||
// DATE: 2020-07-01
|
||||
|
||||
|
||||
#include "GY521.h"
|
||||
|
@ -2,7 +2,6 @@
|
||||
// FILE: GY521_test_2.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: test set/get functions
|
||||
// DATE: 2020-08-06
|
||||
|
||||
|
||||
#include "GY521.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/GY521.git"
|
||||
},
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"license": "MIT",
|
||||
"frameworks": "*",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=GY521
|
||||
version=0.4.1
|
||||
version=0.5.0
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for GY521 angle measurement
|
||||
|
@ -44,6 +44,7 @@ unittest(test_constructor)
|
||||
{
|
||||
GY521 sensor(0x69);
|
||||
|
||||
Wire.begin();
|
||||
sensor.begin();
|
||||
assertEqual(GY521_OK, sensor.getError());
|
||||
|
||||
@ -54,6 +55,8 @@ unittest(test_constructor)
|
||||
unittest(test_get_set_throttle)
|
||||
{
|
||||
GY521 sensor(0x69);
|
||||
|
||||
Wire.begin();
|
||||
sensor.begin();
|
||||
assertEqual(GY521_OK, sensor.getError());
|
||||
|
||||
@ -76,6 +79,8 @@ unittest(test_get_set_throttle)
|
||||
unittest(test_get_set_sensitivity)
|
||||
{
|
||||
GY521 sensor(0x69);
|
||||
|
||||
Wire.begin();
|
||||
sensor.begin();
|
||||
|
||||
fprintf(stderr, "setAccelSensitivity() - fails \n");
|
||||
@ -116,6 +121,8 @@ unittest(test_initial_values)
|
||||
{
|
||||
GY521 sensor(0x69);
|
||||
|
||||
Wire.begin();
|
||||
|
||||
assertEqualFloat(0, sensor.getAccelX(), 0.0001);
|
||||
assertEqualFloat(0, sensor.getAccelY(), 0.0001);
|
||||
assertEqualFloat(0, sensor.getAccelZ(), 0.0001);
|
||||
@ -143,6 +150,8 @@ unittest(test_initial_calibration_errors)
|
||||
{
|
||||
GY521 sensor(0x69);
|
||||
|
||||
Wire.begin();
|
||||
|
||||
assertEqualFloat(0, sensor.axe, 0.0001);
|
||||
assertEqualFloat(0, sensor.aye, 0.0001);
|
||||
assertEqualFloat(0, sensor.aze, 0.0001);
|
||||
@ -155,5 +164,6 @@ unittest(test_initial_calibration_errors)
|
||||
|
||||
unittest_main()
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user