Skip to content

Commit e898e2f

Browse files
authored
Merge pull request #59 from ladyada-piclaw/fix-clang-format-ci
Fix clang-format CI
2 parents f0c5494 + 0bc41cc commit e898e2f

File tree

7 files changed

+1962
-2050
lines changed

7 files changed

+1962
-2050
lines changed

.clang-format

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Language: Cpp
2+
BasedOnStyle: Google
3+
IndentWidth: 2
4+
ColumnLimit: 80
5+
AllowShortBlocksOnASingleLine: Always
6+
AllowShortFunctionsOnASingleLine: Empty
7+
AllowShortIfStatementsOnASingleLine: false
8+
AllowShortLoopsOnASingleLine: false
9+
BinPackArguments: true
10+
BinPackParameters: true
11+
BreakBeforeBraces: Attach
12+
DerivePointerAlignment: false
13+
PointerAlignment: Left
14+
SpacesBeforeTrailingComments: 1

.github/workflows/githubci.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,19 @@ name: Arduino Library CI
33
on: [pull_request, push, repository_dispatch]
44

55
jobs:
6+
clang-format:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- uses: actions/checkout@v4
11+
with:
12+
repository: adafruit/ci-arduino
13+
path: ci
14+
- name: Check code formatting with clang-format
15+
run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
16+
617
build:
18+
needs: clang-format
719
runs-on: ubuntu-latest
820

921
steps:
@@ -22,11 +34,8 @@ jobs:
2234
- name: test platforms
2335
run: python3 ci/build_platform.py main_platforms
2436

25-
- name: clang
26-
run: python3 ci/run-clang-format.py -e "ci" -e "bin/*" -r Adafruit_*
27-
2837
- name: doxygen
2938
env:
3039
GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
3140
PRETTYNAME : "Adafruit BME680 Library"
32-
run: bash ci/doxy_gen_and_deploy.sh
41+
run: bash ci/doxy_gen_and_deploy.sh

Adafruit_BME680.cpp

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,21 @@
2828
*/
2929

3030
#include "Adafruit_BME680.h"
31+
3132
#include "Arduino.h"
3233

33-
//#define BME680_DEBUG
34+
// #define BME680_DEBUG
3435

3536
/** Our hardware interface functions **/
36-
static int8_t i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len,
37-
void *interface);
38-
static int8_t i2c_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len,
39-
void *interface);
40-
static int8_t spi_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len,
41-
void *interface);
42-
static int8_t spi_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len,
43-
void *interface);
44-
static void delay_usec(uint32_t us, void *intf_ptr);
37+
static int8_t i2c_read(uint8_t reg_addr, uint8_t* reg_data, uint32_t len,
38+
void* interface);
39+
static int8_t i2c_write(uint8_t reg_addr, const uint8_t* reg_data, uint32_t len,
40+
void* interface);
41+
static int8_t spi_read(uint8_t reg_addr, uint8_t* reg_data, uint32_t len,
42+
void* interface);
43+
static int8_t spi_write(uint8_t reg_addr, const uint8_t* reg_data, uint32_t len,
44+
void* interface);
45+
static void delay_usec(uint32_t us, void* intf_ptr);
4546

4647
// PUBLIC FUNCTIONS
4748

@@ -50,7 +51,7 @@ static void delay_usec(uint32_t us, void *intf_ptr);
5051
* @param *theWire
5152
* optional Wire object
5253
*/
53-
Adafruit_BME680::Adafruit_BME680(TwoWire *theWire)
54+
Adafruit_BME680::Adafruit_BME680(TwoWire* theWire)
5455
: _meas_start(0), _meas_period(0) {
5556
_wire = theWire;
5657
}
@@ -62,7 +63,7 @@ Adafruit_BME680::Adafruit_BME680(TwoWire *theWire)
6263
* @param theSPI
6364
* optional SPI object
6465
*/
65-
Adafruit_BME680::Adafruit_BME680(int8_t cspin, SPIClass *theSPI)
66+
Adafruit_BME680::Adafruit_BME680(int8_t cspin, SPIClass* theSPI)
6667
: _meas_start(0), _meas_period(0) {
6768
_spidev = new Adafruit_SPIDevice(cspin, 1000000, SPI_BITORDER_MSBFIRST,
6869
SPI_MODE0, theSPI);
@@ -111,7 +112,7 @@ bool Adafruit_BME680::begin(uint8_t addr, bool initSettings) {
111112

112113
gas_sensor.chip_id = addr;
113114
gas_sensor.intf = BME68X_I2C_INTF;
114-
gas_sensor.intf_ptr = (void *)_i2cdev;
115+
gas_sensor.intf_ptr = (void*)_i2cdev;
115116
gas_sensor.read = &i2c_read;
116117
gas_sensor.write = &i2c_write;
117118

@@ -122,7 +123,7 @@ bool Adafruit_BME680::begin(uint8_t addr, bool initSettings) {
122123

123124
gas_sensor.chip_id = 0;
124125
gas_sensor.intf = BME68X_SPI_INTF;
125-
gas_sensor.intf_ptr = (void *)_spidev;
126+
gas_sensor.intf_ptr = (void*)_spidev;
126127
gas_sensor.read = &spi_read;
127128
gas_sensor.write = &spi_write;
128129
}
@@ -288,7 +289,9 @@ float Adafruit_BME680::readAltitude(float seaLevel) {
288289
* Adafruit_BME680#gas_resistance member variables
289290
* @return True on success, False on failure
290291
*/
291-
bool Adafruit_BME680::performReading(void) { return endReading(); }
292+
bool Adafruit_BME680::performReading(void) {
293+
return endReading();
294+
}
292295

293296
/*! @brief Begin an asynchronous reading.
294297
* @return When the reading would be ready as absolute time in millis().
@@ -415,7 +418,6 @@ int Adafruit_BME680::remainingReadingMillis(void) {
415418
* @return True on success, False on failure
416419
*/
417420
bool Adafruit_BME680::setGasHeater(uint16_t heaterTemp, uint16_t heaterTime) {
418-
419421
if ((heaterTemp == 0) || (heaterTime == 0)) {
420422
gas_heatr_conf.enable = BME68X_DISABLE;
421423
} else {
@@ -548,9 +550,8 @@ bool Adafruit_BME680::setIIRFilterSize(uint8_t filtersize) {
548550
/*!
549551
* @brief Reads 8 bit values over I2C
550552
*/
551-
int8_t i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf) {
552-
553-
Adafruit_I2CDevice *_dev = (Adafruit_I2CDevice *)intf;
553+
int8_t i2c_read(uint8_t reg_addr, uint8_t* reg_data, uint32_t len, void* intf) {
554+
Adafruit_I2CDevice* _dev = (Adafruit_I2CDevice*)intf;
554555

555556
if (!_dev->write_then_read(&reg_addr, 1, reg_data, len, true)) {
556557
return -1;
@@ -562,11 +563,11 @@ int8_t i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf) {
562563
/*!
563564
* @brief Writes 8 bit values over I2C
564565
*/
565-
int8_t i2c_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len,
566-
void *intf) {
567-
Adafruit_I2CDevice *_dev = (Adafruit_I2CDevice *)intf;
566+
int8_t i2c_write(uint8_t reg_addr, const uint8_t* reg_data, uint32_t len,
567+
void* intf) {
568+
Adafruit_I2CDevice* _dev = (Adafruit_I2CDevice*)intf;
568569

569-
if (!_dev->write((uint8_t *)reg_data, len, true, &reg_addr, 1)) {
570+
if (!_dev->write((uint8_t*)reg_data, len, true, &reg_addr, 1)) {
570571
return -1;
571572
}
572573
return 0;
@@ -575,9 +576,9 @@ int8_t i2c_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len,
575576
/*!
576577
* @brief Reads 8 bit values over SPI
577578
*/
578-
static int8_t spi_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len,
579-
void *intf_ptr) {
580-
Adafruit_SPIDevice *_dev = (Adafruit_SPIDevice *)intf_ptr;
579+
static int8_t spi_read(uint8_t reg_addr, uint8_t* reg_data, uint32_t len,
580+
void* intf_ptr) {
581+
Adafruit_SPIDevice* _dev = (Adafruit_SPIDevice*)intf_ptr;
581582

582583
reg_addr |= 0x80;
583584

@@ -591,18 +592,18 @@ static int8_t spi_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len,
591592
/*!
592593
* @brief Writes 8 bit values over SPI
593594
*/
594-
static int8_t spi_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len,
595-
void *intf_ptr) {
596-
Adafruit_SPIDevice *_dev = (Adafruit_SPIDevice *)intf_ptr;
595+
static int8_t spi_write(uint8_t reg_addr, const uint8_t* reg_data, uint32_t len,
596+
void* intf_ptr) {
597+
Adafruit_SPIDevice* _dev = (Adafruit_SPIDevice*)intf_ptr;
597598

598-
if (!_dev->write((uint8_t *)reg_data, len, &reg_addr, 1)) {
599+
if (!_dev->write((uint8_t*)reg_data, len, &reg_addr, 1)) {
599600
return -1;
600601
}
601602

602603
return 0;
603604
}
604605

605-
static void delay_usec(uint32_t us, void *intf_ptr) {
606+
static void delay_usec(uint32_t us, void* intf_ptr) {
606607
(void)intf_ptr; // Unused parameter
607608
delayMicroseconds(us);
608609
yield();

Adafruit_BME680.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
#ifndef __BME680_H__
2525
#define __BME680_H__
2626

27-
#include "Arduino.h"
28-
29-
#include "bme68x.h"
3027
#include <Adafruit_I2CDevice.h>
3128
#include <Adafruit_SPIDevice.h>
3229
#include <Adafruit_Sensor.h>
3330
#include <Wire.h>
3431

32+
#include "Arduino.h"
33+
#include "bme68x.h"
34+
3535
#define BME68X_DEFAULT_ADDRESS (0x77) ///< The default I2C address
3636
#define BME68X_DEFAULT_SPIFREQ (1000000) ///< The default SPI Clock speed
3737

@@ -42,37 +42,37 @@
4242
#define BME680_OS_1X BME68X_OS_1X ///< Alias for BME680 existing examples
4343
#define BME680_OS_NONE BME68X_OS_NONE ///< Alias for BME680 existing examples
4444

45-
#define BME680_FILTER_SIZE_127 \
45+
#define BME680_FILTER_SIZE_127 \
4646
BME68X_FILTER_SIZE_127 ///< Alias for BME680 existing examples
47-
#define BME680_FILTER_SIZE_63 \
47+
#define BME680_FILTER_SIZE_63 \
4848
BME68X_FILTER_SIZE_63 ///< Alias for BME680 existing examples
49-
#define BME680_FILTER_SIZE_31 \
49+
#define BME680_FILTER_SIZE_31 \
5050
BME68X_FILTER_SIZE_31 ///< Alias for BME680 existing examples
51-
#define BME680_FILTER_SIZE_15 \
51+
#define BME680_FILTER_SIZE_15 \
5252
BME68X_FILTER_SIZE_15 ///< Alias for BME680 existing examples
53-
#define BME680_FILTER_SIZE_7 \
53+
#define BME680_FILTER_SIZE_7 \
5454
BME68X_FILTER_SIZE_7 ///< Alias for BME680 existing examples
55-
#define BME680_FILTER_SIZE_3 \
55+
#define BME680_FILTER_SIZE_3 \
5656
BME68X_FILTER_SIZE_3 ///< Alias for BME680 existing examples
57-
#define BME680_FILTER_SIZE_1 \
57+
#define BME680_FILTER_SIZE_1 \
5858
BME68X_FILTER_SIZE_1 ///< Alias for BME680 existing examples
59-
#define BME680_FILTER_SIZE_0 \
59+
#define BME680_FILTER_SIZE_0 \
6060
BME68X_FILTER_OFF ///< Alias for BME680 existing examples
6161

6262
/*! Adafruit_BME680 Class for both I2C and SPI usage.
6363
* Wraps the Bosch library for Arduino usage
6464
*/
6565
class Adafruit_BME680 {
66-
public:
66+
public:
6767
/** Value returned by remainingReadingMillis indicating no asynchronous
6868
* reading has been initiated by beginReading. **/
6969
static constexpr int reading_not_started = -1;
7070
/** Value returned by remainingReadingMillis indicating asynchronous reading
7171
* is complete and calling endReading will not block. **/
7272
static constexpr int reading_complete = 0;
7373

74-
Adafruit_BME680(TwoWire *theWire = &Wire);
75-
Adafruit_BME680(int8_t cspin, SPIClass *theSPI = &SPI);
74+
Adafruit_BME680(TwoWire* theWire = &Wire);
75+
Adafruit_BME680(int8_t cspin, SPIClass* theSPI = &SPI);
7676
Adafruit_BME680(int8_t cspin, int8_t mosipin, int8_t misopin, int8_t sckpin);
7777

7878
bool begin(uint8_t addr = BME68X_DEFAULT_ADDRESS, bool initSettings = true);
@@ -111,10 +111,10 @@ class Adafruit_BME680 {
111111
* endReading() **/
112112
uint32_t gas_resistance;
113113

114-
private:
115-
Adafruit_I2CDevice *_i2cdev = NULL;
116-
Adafruit_SPIDevice *_spidev = NULL;
117-
TwoWire *_wire = NULL;
114+
private:
115+
Adafruit_I2CDevice* _i2cdev = NULL;
116+
Adafruit_SPIDevice* _spidev = NULL;
117+
TwoWire* _wire = NULL;
118118

119119
int32_t _sensorID;
120120
uint32_t _meas_start = 0;

0 commit comments

Comments
 (0)