From 4fc890aaf095f6a41a6f94d23d7be2fb6b30846c Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Mon, 11 Dec 2023 14:54:57 +0100 Subject: [PATCH] redo initialization order (#46) - redo initialization order. --- CHANGELOG.md | 4 ++++ GY521.cpp | 11 +++++++++-- GY521.h | 14 +++++--------- examples/GY521_angle/GY521_angle.ino | 5 +++-- examples/GY521_performance/GY521_performance.ino | 2 +- .../GY521_pitch_roll_yaw/GY521_pitch_roll_yaw.ino | 1 + .../GY521_readCalibration_1.ino | 3 ++- .../GY521_readCalibration_2.ino | 2 +- examples/GY521_test_1/GY521_test_1.ino | 2 +- examples/GY521_test_2/GY521_test_2.ino | 1 + examples/GY521_two_sensors/GY521_two_sensors.ino | 1 + library.json | 2 +- library.properties | 2 +- 13 files changed, 31 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94aec13..5f6c381 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.5.1] - 2023-12-11 +- redo initialization order. + + ## [0.5.0] - 2023-12-05 - refactor API, begin() - update readme.md diff --git a/GY521.cpp b/GY521.cpp index 28f6e9d..466dec2 100644 --- a/GY521.cpp +++ b/GY521.cpp @@ -1,7 +1,7 @@ // // FILE: GY521.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.5.0 +// VERSION: 0.5.1 // PURPOSE: Arduino library for I2C GY521 accelerometer-gyroscope sensor // URL: https://github.com/RobTillaart/GY521 @@ -25,7 +25,13 @@ GY521::GY521(uint8_t address, TwoWire *wire) { _address = address; _wire = wire; - reset(); + + _ax = _ay = _az = 0; + _aax = _aay = _aaz = 0; + _gx = _gy = _gz = 0; + _pitch = 0; + _roll = 0; + _yaw = 0; } @@ -35,6 +41,7 @@ bool GY521::begin() { return wakeup(); } + reset(); return false; } diff --git a/GY521.h b/GY521.h index b3a4c15..d20ccad 100644 --- a/GY521.h +++ b/GY521.h @@ -2,7 +2,7 @@ // // FILE: GY521.h // AUTHOR: Rob Tillaart -// VERSION: 0.5.0 +// VERSION: 0.5.1 // 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.0")) +#define GY521_LIB_VERSION (F("0.5.1")) // THROTTLE TIMING @@ -39,10 +39,6 @@ class GY521 public: GY521(uint8_t address = 0x69, TwoWire *wire = &Wire); // 0x68 or 0x69 - -#if defined (ESP8266) || defined(ESP32) - bool begin(uint8_t sda, uint8_t scl); -#endif bool begin(); bool isConnected(); void reset(); @@ -74,12 +70,12 @@ class GY521 int16_t read(); // optimized partial reading // read accelerometer only - int16_t readAccel(); + int16_t readAccel(); // read gyroscope only can be done too // however for pitch roll yaw you need all. - int16_t readGyro(); + int16_t readGyro(); // read temperature only, does not affect throttle. - int16_t readTemperature(); + int16_t readTemperature(); // CALL AFTER READ diff --git a/examples/GY521_angle/GY521_angle.ino b/examples/GY521_angle/GY521_angle.ino index e6121dc..d5c3101 100644 --- a/examples/GY521_angle/GY521_angle.ino +++ b/examples/GY521_angle/GY521_angle.ino @@ -2,6 +2,7 @@ // FILE: GY521_angle.ino // AUTHOR: Rob Tillaart // PURPOSE: read angleX, angleY, angleZ +// URL: https://github.com/RobTillaart/GY521 #include "GY521.h" @@ -56,8 +57,8 @@ void loop() // Serial.println("\nCNT\tX\tY\tZ"); } - // Serial.print(counter); - // Serial.print('\t'); + // Serial.print(counter); + // Serial.print('\t'); Serial.print(x, 1); Serial.print('\t'); Serial.print(y, 1); diff --git a/examples/GY521_performance/GY521_performance.ino b/examples/GY521_performance/GY521_performance.ino index 6988652..5c2f7d7 100644 --- a/examples/GY521_performance/GY521_performance.ino +++ b/examples/GY521_performance/GY521_performance.ino @@ -2,7 +2,7 @@ // FILE: GY521_performance.ino // AUTHOR: Rob Tillaart // PURPOSE: minimal demo - +// URL: https://github.com/RobTillaart/GY521 #include "GY521.h" diff --git a/examples/GY521_pitch_roll_yaw/GY521_pitch_roll_yaw.ino b/examples/GY521_pitch_roll_yaw/GY521_pitch_roll_yaw.ino index 255593b..6237693 100644 --- a/examples/GY521_pitch_roll_yaw/GY521_pitch_roll_yaw.ino +++ b/examples/GY521_pitch_roll_yaw/GY521_pitch_roll_yaw.ino @@ -2,6 +2,7 @@ // FILE: GY521_pitch_roll_yaw.ino // AUTHOR: Rob Tillaart // PURPOSE: demo pitch roll yaw +// URL: https://github.com/RobTillaart/GY521 #include "GY521.h" diff --git a/examples/GY521_readCalibration_1/GY521_readCalibration_1.ino b/examples/GY521_readCalibration_1/GY521_readCalibration_1.ino index e5ab4ec..3357e57 100644 --- a/examples/GY521_readCalibration_1/GY521_readCalibration_1.ino +++ b/examples/GY521_readCalibration_1/GY521_readCalibration_1.ino @@ -2,6 +2,7 @@ // FILE: GY521_readCalibration_1.ino // AUTHOR: Rob Tillaart // PURPOSE: read the calibration values / errors for a flat sensor. +// URL: https://github.com/RobTillaart/GY521 #include "GY521.h" @@ -29,7 +30,7 @@ void setup() { Serial.println("Could not connect to GY521"); } - // adjust when needed. + // adjust when needed. sensor.setAccelSensitivity(0); // 2g sensor.setGyroSensitivity(0); // 250 degrees/s sensor.setThrottle(false); diff --git a/examples/GY521_readCalibration_2/GY521_readCalibration_2.ino b/examples/GY521_readCalibration_2/GY521_readCalibration_2.ino index a4694de..10b069b 100644 --- a/examples/GY521_readCalibration_2/GY521_readCalibration_2.ino +++ b/examples/GY521_readCalibration_2/GY521_readCalibration_2.ino @@ -2,7 +2,7 @@ // FILE: readCalibration_2.ino // AUTHOR: Rob Tillaart // PURPOSE: read the calibration values / errors for a flat sensor. - +// URL: https://github.com/RobTillaart/GY521 #include "GY521.h" diff --git a/examples/GY521_test_1/GY521_test_1.ino b/examples/GY521_test_1/GY521_test_1.ino index 4d44ce7..2281cee 100644 --- a/examples/GY521_test_1/GY521_test_1.ino +++ b/examples/GY521_test_1/GY521_test_1.ino @@ -2,7 +2,7 @@ // FILE: GY521_test_1.ino // AUTHOR: Rob Tillaart // PURPOSE: minimal demo to test working of the sensor. - +// URL: https://github.com/RobTillaart/GY521 #include "GY521.h" diff --git a/examples/GY521_test_2/GY521_test_2.ino b/examples/GY521_test_2/GY521_test_2.ino index e575831..45499ba 100644 --- a/examples/GY521_test_2/GY521_test_2.ino +++ b/examples/GY521_test_2/GY521_test_2.ino @@ -2,6 +2,7 @@ // FILE: GY521_test_2.ino // AUTHOR: Rob Tillaart // PURPOSE: test set/get functions +// URL: https://github.com/RobTillaart/GY521 #include "GY521.h" diff --git a/examples/GY521_two_sensors/GY521_two_sensors.ino b/examples/GY521_two_sensors/GY521_two_sensors.ino index 7933752..effbcee 100644 --- a/examples/GY521_two_sensors/GY521_two_sensors.ino +++ b/examples/GY521_two_sensors/GY521_two_sensors.ino @@ -2,6 +2,7 @@ // FILE: GY521_two_sensors.ino // AUTHOR: Rob Tillaart // PURPOSE: read angleX, angleY, angleZ from two sensors +// URL: https://github.com/RobTillaart/GY521 #include "GY521.h" diff --git a/library.json b/library.json index 62811cd..9501e56 100644 --- a/library.json +++ b/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/GY521.git" }, - "version": "0.5.0", + "version": "0.5.1", "license": "MIT", "frameworks": "*", "platforms": "*", diff --git a/library.properties b/library.properties index b5801f4..7d8669e 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=GY521 -version=0.5.0 +version=0.5.1 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for GY521 angle measurement