Skip to content

Commit

Permalink
update example / documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart committed Jan 16, 2024
1 parent 4fc890a commit f1fc9a2
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 29 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.5.2] - 2024-01-16
- fix #48, update example
- add some tables to readme.md
- minor edits


## [0.5.1] - 2023-12-11
- redo initialization order.


## [0.5.0] - 2023-12-05
- refactor API, begin()
- update readme.md
Expand Down
2 changes: 1 addition & 1 deletion 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.1
// VERSION: 0.5.2
// PURPOSE: Arduino library for I2C GY521 accelerometer-gyroscope sensor
// URL: https://github.com/RobTillaart/GY521

Expand Down
9 changes: 5 additions & 4 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.1
// VERSION: 0.5.2
// 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.1"))
#define GY521_LIB_VERSION (F("0.5.2"))


// THROTTLE TIMING
Expand All @@ -37,7 +37,8 @@
class GY521
{
public:
GY521(uint8_t address = 0x69, TwoWire *wire = &Wire); // 0x68 or 0x69
// address == 0x68 or 0x69
GY521(uint8_t address = 0x69, TwoWire *wire = &Wire);

bool begin();
bool isConnected();
Expand All @@ -48,7 +49,7 @@ class GY521
// throttle to force delay between reads.
void setThrottle(bool throttle = true) { _throttle = throttle; };
bool getThrottle() { return _throttle; };
// 0..65535 (max milliseconds == roughly 1 minute.
// 0..65535 max milliseconds == roughly 1 minute.
void setThrottleTime(uint16_t ti ) { _throttleTime = ti; };
uint16_t getThrottleTime() { return _throttleTime; };

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017-2023 Rob Tillaart
Copyright (c) 2017-2024 Rob Tillaart

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
53 changes: 47 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ Note call **Wire.begin()** before **begin()**.

#### Actual read

- **int16_t read()** returns status = GY521_OK on success.
- **int16_t read()** reads all core measurements.
returns status = GY521_OK on success.
- **int16_t readAccel()** read accelerometer only to speed up interaction. This call does update the throttle timer.
returns status = GY521_OK on success.
- **int16_t readGyro()** read gyroscope only to speed up interaction. This call does update the throttle timer.
Expand All @@ -132,7 +133,8 @@ In version 0.4.0 the normalization of pitch, roll and yaw is fixed and made cond

#### Calls after read

Note that multiple calls will return the same value. One must explicitly call **read()** to get new values.
Note that multiple calls will return the same value.
One must explicitly call **read()** to get new values.

- **float getAccelX()** idem.
- **float getAccelY()** idem.
Expand Down Expand Up @@ -162,7 +164,42 @@ Read the register PDF for the specific value and meaning of registers.

## documents

- check details - MPU-6000-Register-Map1.pdf
- check details registers - MPU-6000-Register-Map1.pdf


#### Error codes

| Error code | value | notes |
|:----------------------------|:-------:|:-------:|
| GY521_OK | 0 | not an error
| GY521_THROTTLED | 1 | not an error
| GY521_ERROR_READ | -1 |
| GY521_ERROR_WRITE | -2 |
| GY521_ERROR_NOT_CONNECTED | -3 |


#### Sensitivity Acceleration

unit g = gravity == 9.81 m/s^2

| Acceleration | value | notes |
|:--------------|:-------:|:-------:|
| 2 g | 0 | default
| 4 g | 1 |
| 8 g | 2 |
| 16 g | 3 |


#### Sensitivity Gyroscope

unit dps = degrees per second.

| Gyroscope | value | notes |
|:--------------|:-------:|:-------:|
| 250 dps | 0 | default
| 500 dps | 1 |
| 1000 dps | 2 |
| 2000 dps | 3 |


## Operation
Expand All @@ -175,19 +212,20 @@ 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?
- reorder code in read(), would that save some micros.?
- first all ax, then ay etc
- footprint / performance gain?


#### Wont

Expand All @@ -196,6 +234,9 @@ See examples, use with care
- other ideas affect accuracy, so unless new ideas arise.
- calibrate function in the lib
- not as lib will grow too large.
- defaults value for functions?
- user must set function parameters explicit


## Support

Expand Down
29 changes: 15 additions & 14 deletions examples/GY521_test_1/GY521_test_1.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// PURPOSE: minimal demo to test working of the sensor.
// URL: https://github.com/RobTillaart/GY521


#include "GY521.h"

GY521 sensor(0x69);
Expand Down Expand Up @@ -47,13 +48,13 @@ void setup()
void loop()
{
sensor.read();
int ax = sensor.getAccelX();
int ay = sensor.getAccelY();
int az = sensor.getAccelZ();
int gx = sensor.getGyroX();
int gy = sensor.getGyroY();
int gz = sensor.getGyroZ();
int t = sensor.getTemperature();
float ax = sensor.getAccelX();
float ay = sensor.getAccelY();
float az = sensor.getAccelZ();
float gx = sensor.getGyroX();
float gy = sensor.getGyroY();
float gz = sensor.getGyroZ();
float t = sensor.getTemperature();

if (counter % 10 == 0)
{
Expand All @@ -63,19 +64,19 @@ void loop()

Serial.print(counter);
Serial.print('\t');
Serial.print(ax);
Serial.print(ax, 3);
Serial.print('\t');
Serial.print(ay);
Serial.print(ay, 3);
Serial.print('\t');
Serial.print(az);
Serial.print(az, 3);
Serial.print('\t');
Serial.print(gx);
Serial.print(gx, 3);
Serial.print('\t');
Serial.print(gy);
Serial.print(gy, 3);
Serial.print('\t');
Serial.print(gz);
Serial.print(gz, 3);
Serial.print('\t');
Serial.print(t);
Serial.print(t, 3);
Serial.println();

counter++;
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.1",
"version": "0.5.2",
"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.1
version=0.5.2
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 f1fc9a2

Please sign in to comment.