From 312d2103e20587befc635d98df3987852c0cc7c6 Mon Sep 17 00:00:00 2001 From: siddacious Date: Wed, 25 Mar 2020 14:46:27 -0700 Subject: [PATCH] actionified, formatted and doxy'd --- .github/workflows/githubci.yml | 32 ++++++++ .travis.yml | 29 ------- Adafruit_HTU21DF.cpp | 138 ++++++++++++++++----------------- Adafruit_HTU21DF.h | 34 ++++---- README.md | 2 +- library.properties | 2 +- 6 files changed, 118 insertions(+), 119 deletions(-) create mode 100644 .github/workflows/githubci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/githubci.yml b/.github/workflows/githubci.yml new file mode 100644 index 0000000..d8ed0b2 --- /dev/null +++ b/.github/workflows/githubci.yml @@ -0,0 +1,32 @@ +name: Arduino Library CI + +on: [pull_request, push, repository_dispatch] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/setup-python@v1 + with: + python-version: '3.x' + - uses: actions/checkout@v2 + - uses: actions/checkout@v2 + with: + repository: adafruit/ci-arduino + path: ci + + - name: pre-install + run: bash ci/actions_install.sh + + - name: test platforms + run: python3 ci/build_platform.py main_platforms + + - name: clang + run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r . + + - name: doxygen + env: + GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }} + PRETTYNAME : "Adafruit HTU21D-F Arduino Library" + run: bash ci/doxy_gen_and_deploy.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 75abc60..0000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: c -sudo: false -cache: - directories: - - ~/arduino_ide - - ~/.arduino15/packages/ -git: - depth: false - quiet: true -env: - global: - - ARDUINO_IDE_VERSION="1.8.5" - - PRETTYNAME="Adafruit HTU21D-F Arduino Library" -# Optional, will default to "$TRAVIS_BUILD_DIR/Doxyfile" -# - DOXYFILE: $TRAVIS_BUILD_DIR/Doxyfile - -before_install: - - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh) - -install: - - true - -script: - - build_main_platforms - -# Generate and deploy documentation -after_success: - - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/library_check.sh) - - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/doxy_gen_and_deploy.sh) diff --git a/Adafruit_HTU21DF.cpp b/Adafruit_HTU21DF.cpp index 7299081..1bdab4e 100644 --- a/Adafruit_HTU21DF.cpp +++ b/Adafruit_HTU21DF.cpp @@ -21,13 +21,12 @@ #endif /** -* Constructor for the HTU21DF driver. + * Constructor for the HTU21DF driver. */ -Adafruit_HTU21DF::Adafruit_HTU21DF() -{ - /* Assign default values to internal tracking variables. */ - _last_humidity = 0.0f; - _last_temp = 0.0f; +Adafruit_HTU21DF::Adafruit_HTU21DF() { + /* Assign default values to internal tracking variables. */ + _last_humidity = 0.0f; + _last_temp = 0.0f; } /** @@ -36,28 +35,26 @@ Adafruit_HTU21DF::Adafruit_HTU21DF() * @return true (1) if the device was successfully initialised, otherwise * false (0). */ -boolean Adafruit_HTU21DF::begin(void) -{ - Wire.begin(); +boolean Adafruit_HTU21DF::begin(void) { + Wire.begin(); - reset(); + reset(); - Wire.beginTransmission(HTU21DF_I2CADDR); - Wire.write(HTU21DF_READREG); - Wire.endTransmission(); - Wire.requestFrom(HTU21DF_I2CADDR, 1); - return (Wire.read() == 0x2); // after reset should be 0x2 + Wire.beginTransmission(HTU21DF_I2CADDR); + Wire.write(HTU21DF_READREG); + Wire.endTransmission(); + Wire.requestFrom(HTU21DF_I2CADDR, 1); + return (Wire.read() == 0x2); // after reset should be 0x2 } /** * Sends a 'reset' request to the HTU21DF, followed by a 15ms delay. */ -void Adafruit_HTU21DF::reset(void) -{ - Wire.beginTransmission(HTU21DF_I2CADDR); - Wire.write(HTU21DF_RESET); - Wire.endTransmission(); - delay(15); +void Adafruit_HTU21DF::reset(void) { + Wire.beginTransmission(HTU21DF_I2CADDR); + Wire.write(HTU21DF_RESET); + Wire.endTransmission(); + delay(15); } /** @@ -66,39 +63,38 @@ void Adafruit_HTU21DF::reset(void) * @return a single-precision (32-bit) float value indicating the measured * temperature in degrees Celsius. */ -float Adafruit_HTU21DF::readTemperature(void) -{ - // OK lets ready! - Wire.beginTransmission(HTU21DF_I2CADDR); - Wire.write(HTU21DF_READTEMP); - Wire.endTransmission(); +float Adafruit_HTU21DF::readTemperature(void) { + // OK lets ready! + Wire.beginTransmission(HTU21DF_I2CADDR); + Wire.write(HTU21DF_READTEMP); + Wire.endTransmission(); - delay(50); // add delay between request and actual read! + delay(50); // add delay between request and actual read! - uint8_t count = Wire.requestFrom(HTU21DF_I2CADDR, 3); + uint8_t count = Wire.requestFrom(HTU21DF_I2CADDR, 3); - /* Make sure we got 3 bytes back. */ - if (count != 3) { - return 0.0f; - } + /* Make sure we got 3 bytes back. */ + if (count != 3) { + return 0.0f; + } - /* Read 16 bits of data, dropping the last two status bits. */ - uint16_t t = Wire.read(); - t <<= 8; - t |= Wire.read() & 0b11111100; + /* Read 16 bits of data, dropping the last two status bits. */ + uint16_t t = Wire.read(); + t <<= 8; + t |= Wire.read() & 0b11111100; - uint8_t crc = Wire.read(); - (void)crc; + uint8_t crc = Wire.read(); + (void)crc; - float temp = t; - temp *= 175.72f; - temp /= 65536.0f; - temp -= 46.85f; + float temp = t; + temp *= 175.72f; + temp /= 65536.0f; + temp -= 46.85f; - /* Track the value internally in case we need to access it later. */ - _last_temp = temp; + /* Track the value internally in case we need to access it later. */ + _last_temp = temp; - return temp; + return temp; } /** @@ -108,37 +104,37 @@ float Adafruit_HTU21DF::readTemperature(void) * humidity in percent (0..100.0%). */ float Adafruit_HTU21DF::readHumidity(void) { - /* Prepare the I2C request. */ - Wire.beginTransmission(HTU21DF_I2CADDR); - Wire.write(HTU21DF_READHUM); - Wire.endTransmission(); + /* Prepare the I2C request. */ + Wire.beginTransmission(HTU21DF_I2CADDR); + Wire.write(HTU21DF_READHUM); + Wire.endTransmission(); - /* Wait a bit for the conversion to complete. */ - delay(50); + /* Wait a bit for the conversion to complete. */ + delay(50); - /* Read the conversion results. */ - uint8_t count = Wire.requestFrom(HTU21DF_I2CADDR, 3); + /* Read the conversion results. */ + uint8_t count = Wire.requestFrom(HTU21DF_I2CADDR, 3); - /* Make sure we got 3 bytes back. */ - if (count != 3) { - return 0.0f; - } + /* Make sure we got 3 bytes back. */ + if (count != 3) { + return 0.0f; + } - /* Read 16 bits of data, dropping the last two status bits. */ - uint16_t h = Wire.read(); - h <<= 8; - h |= Wire.read() & 0b11111100; + /* Read 16 bits of data, dropping the last two status bits. */ + uint16_t h = Wire.read(); + h <<= 8; + h |= Wire.read() & 0b11111100; - uint8_t crc = Wire.read(); - (void)crc; + uint8_t crc = Wire.read(); + (void)crc; - float hum = h; - hum *= 125.0f; - hum /= 65536.0f; - hum -= 6.0f; + float hum = h; + hum *= 125.0f; + hum /= 65536.0f; + hum -= 6.0f; - /* Track the value internally in case we need to access it later. */ - _last_humidity = hum; + /* Track the value internally in case we need to access it later. */ + _last_humidity = hum; - return hum; + return hum; } diff --git a/Adafruit_HTU21DF.h b/Adafruit_HTU21DF.h index 5a41cea..0d9e963 100644 --- a/Adafruit_HTU21DF.h +++ b/Adafruit_HTU21DF.h @@ -18,45 +18,45 @@ #define _ADAFRUIT_HTU21DF_H #if (ARDUINO >= 100) - #include "Arduino.h" +#include "Arduino.h" #else - #include "WProgram.h" +#include "WProgram.h" #endif #include "Wire.h" /** Default I2C address for the HTU21D. */ -#define HTU21DF_I2CADDR (0x40) +#define HTU21DF_I2CADDR (0x40) /** Read temperature register. */ -#define HTU21DF_READTEMP (0xE3) +#define HTU21DF_READTEMP (0xE3) /** Read humidity register. */ -#define HTU21DF_READHUM (0xE5) +#define HTU21DF_READHUM (0xE5) /** Write register command. */ -#define HTU21DF_WRITEREG (0xE6) +#define HTU21DF_WRITEREG (0xE6) /** Read register command. */ -#define HTU21DF_READREG (0xE7) +#define HTU21DF_READREG (0xE7) /** Reset command. */ -#define HTU21DF_RESET (0xFE) +#define HTU21DF_RESET (0xFE) /** * Driver for the Adafruit HTU21DF breakout board. */ class Adafruit_HTU21DF { - public: - Adafruit_HTU21DF(); +public: + Adafruit_HTU21DF(); - boolean begin(void); - float readTemperature(void); - float readHumidity(void); - void reset(void); + boolean begin(void); + float readTemperature(void); + float readHumidity(void); + void reset(void); - private: - boolean readData(void); - float _last_humidity, _last_temp; +private: + boolean readData(void); + float _last_humidity, _last_temp; }; #endif /* _ADAFRUIT_HTU21DF_H */ diff --git a/README.md b/README.md index d78570f..9541e66 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Adafruit HTU21D-F Humidity/Temp Sensor for Arduino [![Build Status](https://travis-ci.org/adafruit/Adafruit_HTU21DF_Library.svg?branch=master)](https://travis-ci.org/adafruit/Adafruit_HTU21DF_Library) +# Adafruit HTU21D-F Humidity/Temp Sensor for Arduino [![Build Status](https://github.com/adafruit/Adafruit_HTU21DF_Library/workflows/Arduino%20Library%20CI/badge.svg)](https://github.com/adafruit/Adafruit_HTU21DF_Library/actions) ![sensors_1899-00](https://user-images.githubusercontent.com/181073/46350691-b53d1880-c655-11e8-8415-452aec129b44.jpg) diff --git a/library.properties b/library.properties index cd3f782..b638eba 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Adafruit HTU21DF Library -version=1.0.2 +version=1.0.3 author=Adafruit maintainer=Adafruit sentence=Arduino library for the HTU21D-F sensors in the Adafruit shop