From 659140e0599d6dc76351f109cc94b083c529d571 Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Wed, 20 Oct 2021 15:49:30 +0200 Subject: [PATCH] update build-CI, badges, issue 28 (#29) --- .arduino-ci.yml | 10 +++++++--- .github/workflows/arduino_test_runner.yml | 10 +++++++--- GY521.cpp | 13 +++++++++++-- GY521.h | 2 +- README.md | 2 ++ .../GY521_pitch_roll_yaw/GY521_pitch_roll_yaw.ino | 7 ++++++- examples/readCalibration/readCalibration.ino | 7 ++++++- examples/test1/test1.ino | 6 +++++- examples/test_2/test_2.ino | 5 +++++ library.json | 2 +- library.properties | 2 +- test/unit_test_001.cpp | 6 ++++-- 12 files changed, 56 insertions(+), 16 deletions(-) diff --git a/.arduino-ci.yml b/.arduino-ci.yml index ff5659b..e7cb463 100644 --- a/.arduino-ci.yml +++ b/.arduino-ci.yml @@ -2,6 +2,10 @@ compile: # Choosing to run compilation tests on 2 different Arduino platforms platforms: - uno - - leonardo - - due - - zero + # - due + # - zero + # - leonardo + - m4 + - esp32 + # - esp8266 + # - mega2560 \ No newline at end of file diff --git a/.github/workflows/arduino_test_runner.yml b/.github/workflows/arduino_test_runner.yml index 476456b..096b975 100644 --- a/.github/workflows/arduino_test_runner.yml +++ b/.github/workflows/arduino_test_runner.yml @@ -4,10 +4,14 @@ name: Arduino CI on: [push, pull_request] jobs: - arduino_ci: + runTest: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: Arduino-CI/action@master - # Arduino-CI/action@v0.1.1 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + - run: | + gem install arduino_ci + arduino_ci.rb diff --git a/GY521.cpp b/GY521.cpp index b38913f..7fc9c0c 100644 --- a/GY521.cpp +++ b/GY521.cpp @@ -22,6 +22,7 @@ // 0.3.2 2021-07-05 fix #20 support multiWire // 0.3.3 2021-07-05 fix #22 improve maths // 0.3.4 2021-07-12 fix #24 improve precision +// 0.3.5 2021-10-20 update build-CI, badges + #28 add wakeup to begin(). #include "GY521.h" @@ -52,7 +53,11 @@ GY521::GY521(uint8_t address, TwoWire *wire) bool GY521::begin(uint8_t sda, uint8_t scl) { _wire->begin(sda, scl); - return isConnected(); + if (isConnected()) + { + return wakeup(); + } + return false; } #endif @@ -60,7 +65,11 @@ bool GY521::begin(uint8_t sda, uint8_t scl) bool GY521::begin() { _wire->begin(); - return isConnected(); + if (isConnected()) + { + return wakeup(); + } + return false; } diff --git a/GY521.h b/GY521.h index eff4b3c..0785b2f 100644 --- a/GY521.h +++ b/GY521.h @@ -15,7 +15,7 @@ #include "Wire.h" -#define GY521_LIB_VERSION (F("0.3.4")) +#define GY521_LIB_VERSION (F("0.3.5")) #ifndef GY521_THROTTLE_TIME diff --git a/README.md b/README.md index 7c767c5..b23a3dc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ [![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) [![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) 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 0f2a6e9..a99e714 100644 --- a/examples/GY521_pitch_roll_yaw/GY521_pitch_roll_yaw.ino +++ b/examples/GY521_pitch_roll_yaw/GY521_pitch_roll_yaw.ino @@ -5,12 +5,14 @@ // PURPOSE: demo PRY // DATE: 2020-08-06 + #include "GY521.h" GY521 sensor(0x69); uint32_t counter = 0; + void setup() { Serial.begin(115200); @@ -31,7 +33,7 @@ void setup() sensor.setThrottle(); Serial.println("start..."); - // set callibration values from calibration sketch. + // set calibration values from calibration sketch. sensor.axe = 0; sensor.aye = 0; sensor.aze = 0; @@ -40,6 +42,7 @@ void setup() sensor.gze = 0; } + void loop() { sensor.read(); @@ -64,4 +67,6 @@ void loop() counter++; } + // -- END OF FILE -- + diff --git a/examples/readCalibration/readCalibration.ino b/examples/readCalibration/readCalibration.ino index 807d215..2107c40 100644 --- a/examples/readCalibration/readCalibration.ino +++ b/examples/readCalibration/readCalibration.ino @@ -5,6 +5,7 @@ // PURPOSE: read the calibration values / errors for a flat sensor. // DATE: 2020-07-14 + #include "GY521.h" GY521 sensor(0x69); @@ -15,6 +16,7 @@ float ax, ay, az; float gx, gy, gz; float t; + void setup() { Serial.begin(115200); @@ -31,7 +33,7 @@ void setup() sensor.setGyroSensitivity(0); // 250 degrees/s sensor.setThrottle(false); - // set all callibration errors to zero + // set all calibration errors to zero sensor.axe = 0; sensor.aye = 0; sensor.aze = 0; @@ -42,6 +44,7 @@ void setup() Serial.println("\n\nReading calibration numbers..."); } + void loop() { ax = ay = az = 0; @@ -107,4 +110,6 @@ void loop() delay(100); } + // -- END OF FILE -- + diff --git a/examples/test1/test1.ino b/examples/test1/test1.ino index bca8426..a42a8dc 100644 --- a/examples/test1/test1.ino +++ b/examples/test1/test1.ino @@ -5,12 +5,14 @@ // PURPOSE: minimal demo // DATE: 2020-07-01 + #include "GY521.h" GY521 sensor(0x69); uint32_t counter = 0; + void setup() { Serial.begin(115200); @@ -31,7 +33,7 @@ void setup() sensor.setThrottle(); Serial.println("start..."); - // set callibration values from calibration sketch. + // set calibration values from calibration sketch. sensor.axe = 0; sensor.aye = 0; sensor.aze = 0; @@ -78,4 +80,6 @@ void loop() delay(1000); } + // -- END OF FILE -- + diff --git a/examples/test_2/test_2.ino b/examples/test_2/test_2.ino index 2b6160d..6d6d81e 100644 --- a/examples/test_2/test_2.ino +++ b/examples/test_2/test_2.ino @@ -5,10 +5,12 @@ // PURPOSE: test set/get // DATE: 2020-08-06 + #include "GY521.h" GY521 sensor(0x69); + void setup() { Serial.begin(115200); @@ -75,8 +77,11 @@ void setup() Serial.println("\nDone..."); } + void loop() { } + // -- END OF FILE -- + diff --git a/library.json b/library.json index cc08395..dedac82 100644 --- a/library.json +++ b/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/GY521.git" }, - "version": "0.3.4", + "version": "0.3.5", "license": "MIT", "frameworks": "arduino", "platforms": "*" diff --git a/library.properties b/library.properties index 69fa950..8249d8d 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=GY521 -version=0.3.4 +version=0.3.5 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for GY521 angle measurement diff --git a/test/unit_test_001.cpp b/test/unit_test_001.cpp index 4587c71..f586142 100644 --- a/test/unit_test_001.cpp +++ b/test/unit_test_001.cpp @@ -21,6 +21,7 @@ // assertNull(actual) // assertNotNull(actual) + #include @@ -32,6 +33,7 @@ unittest_setup() { } + unittest_teardown() { } @@ -40,7 +42,7 @@ unittest_teardown() unittest(test_constructor) { GY521 sensor(0x69); - fprintf(stderr, "VERSION: %s\n", GY521_LIB_VERSION); + fprintf(stderr, "VERSION: %s\n", (char *) GY521_LIB_VERSION); sensor.begin(); assertEqual(GY521_OK, sensor.getError()); @@ -95,7 +97,7 @@ unittest(test_get_set_sensitivity) unittest(test_constants) { - fprintf(stderr, "VERSION: %s\n", GY521_LIB_VERSION); + fprintf(stderr, "VERSION: %s\n", (char *) GY521_LIB_VERSION); assertEqual(GY521_OK, 0); assertEqual(GY521_THROTTLED, 1);