Skip to content

Commit

Permalink
redo initialization order (#46)
Browse files Browse the repository at this point in the history
- redo initialization order.
  • Loading branch information
RobTillaart authored Dec 11, 2023
1 parent f764535 commit 4fc890a
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions GY521.cpp
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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;
}


Expand All @@ -35,6 +41,7 @@ bool GY521::begin()
{
return wakeup();
}
reset();
return false;
}

Expand Down
14 changes: 5 additions & 9 deletions GY521.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions examples/GY521_angle/GY521_angle.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion examples/GY521_performance/GY521_performance.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// FILE: GY521_performance.ino
// AUTHOR: Rob Tillaart
// PURPOSE: minimal demo

// URL: https://github.com/RobTillaart/GY521

#include "GY521.h"

Expand Down
1 change: 1 addition & 0 deletions examples/GY521_pitch_roll_yaw/GY521_pitch_roll_yaw.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion examples/GY521_readCalibration_1/GY521_readCalibration_1.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion examples/GY521_test_1/GY521_test_1.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 1 addition & 0 deletions examples/GY521_test_2/GY521_test_2.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions examples/GY521_two_sensors/GY521_two_sensors.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=GY521
version=0.5.0
version=0.5.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for GY521 angle measurement
Expand Down

0 comments on commit 4fc890a

Please sign in to comment.