Skip to content

Commit 5ec2731

Browse files
authored
Added Arduino CI integration (#6)
* Finnishing up High Level Tests * Minor Formatting issues from Code Review * Use recent `arduino_ci` for testing; move scripts to new directory * Use `Adafruit BusIO` as name for library. * Compiles with up-to-date Bus-IO * Add libraries
1 parent a551f49 commit 5ec2731

17 files changed

+438
-80
lines changed

.arduino-ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
unittest:
3+
platforms:
4+
- mega2560
5+
testfiles:
6+
reject:
7+
- "Common.cpp"
8+
libraries:
9+
- "Adafruit BusIO"
10+
11+
compile:
12+
platforms:
13+
- mega2560
14+
libraries:
15+
- "Adafruit BusIO"

.github/workflows/format.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: test-clang-format
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: DoozyX/clang-format-lint-action@v0.5
12+
with:
13+
source: './'
14+
extensions: 'c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx,ino'
15+
clangFormatVersion: 9

.github/workflows/githubci.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/max.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This is the name of the workflow, visible on GitHub UI
2+
name: Arduino CI Tests
3+
4+
# Run on a Push or a Pull Request
5+
on: [push, pull_request]
6+
7+
jobs:
8+
runTest:
9+
runs-on: ubuntu-latest
10+
steps:
11+
# Clone the repo using the `checkout` action
12+
- uses: actions/checkout@v2
13+
14+
# Get Ruby and run Arduino CI
15+
- uses: ruby/setup-ruby@v1
16+
with:
17+
ruby-version: 2.6
18+
19+
# Install Arduino IDE and Arduino CI
20+
- run: |
21+
bundle install
22+
23+
# Installing libraries needed for this project
24+
- name: Install libraries
25+
run: |
26+
./scripts/install_libraries.sh
27+
28+
# Run the tests
29+
- run: |
30+
bundle exec arduino_ci_remote.rb --skip-compilation
31+
32+
# Finally, verify that everything compiles
33+
- run: |
34+
bundle exec arduino_ci_remote.rb --skip-unittests

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/.bundle/
2+
/.yardoc
3+
Gemfile.lock
4+
/_yardoc/
5+
/coverage/
6+
/doc/
7+
/pkg/
8+
/spec/reports/
9+
vendor
10+
*.gem
11+
12+
# rspec failure tracking
13+
.rspec_status
14+
15+
# C++ stuff
16+
*.bin
17+
*.bin.dSYM

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
source 'https://rubygems.org'
2+
gem 'arduino_ci'

examples/max31865/max31865.ino

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
/***************************************************
1+
/***************************************************
22
This is a library for the Adafruit PT100/P1000 RTD Sensor w/MAX31865
33
44
Designed specifically to work with the Adafruit RTD Sensor
55
----> https://www.adafruit.com/products/3328
66
7-
This sensor uses SPI to communicate, 4 pins are required to
7+
This sensor uses SPI to communicate, 4 pins are required to
88
interface
9-
Adafruit invests time and resources providing this open source code,
10-
please support Adafruit and open-source hardware by purchasing
9+
Adafruit invests time and resources providing this open source code,
10+
please support Adafruit and open-source hardware by purchasing
1111
products from Adafruit!
1212
13-
Written by Limor Fried/Ladyada for Adafruit Industries.
13+
Written by Limor Fried/Ladyada for Adafruit Industries.
1414
BSD license, all text above must be included in any redistribution
1515
****************************************************/
1616

@@ -19,53 +19,57 @@
1919
// Use software SPI: CS, DI, DO, CLK
2020
Adafruit_MAX31865 thermo = Adafruit_MAX31865(10, 11, 12, 13);
2121
// use hardware SPI, just pass in the CS pin
22-
//Adafruit_MAX31865 thermo = Adafruit_MAX31865(10);
22+
// Adafruit_MAX31865 thermo = Adafruit_MAX31865(10);
2323

2424
// The value of the Rref resistor. Use 430.0 for PT100 and 4300.0 for PT1000
25-
#define RREF 430.0
25+
#define RREF 430.0
2626
// The 'nominal' 0-degrees-C resistance of the sensor
2727
// 100.0 for PT100, 1000.0 for PT1000
28-
#define RNOMINAL 100.0
28+
#define RNOMINAL 100.0
2929

3030
void setup() {
3131
Serial.begin(115200);
3232
Serial.println("Adafruit MAX31865 PT100 Sensor Test!");
3333

34-
thermo.begin(MAX31865_3WIRE); // set to 2WIRE or 4WIRE as necessary
34+
thermo.begin(MAX31865_3WIRE); // set to 2WIRE or 4WIRE as necessary
3535
}
3636

37-
3837
void loop() {
3938
uint16_t rtd = thermo.readRTD();
4039

41-
Serial.print("RTD value: "); Serial.println(rtd);
40+
Serial.print("RTD value: ");
41+
Serial.println(rtd);
4242
float ratio = rtd;
4343
ratio /= 32768;
44-
Serial.print("Ratio = "); Serial.println(ratio,8);
45-
Serial.print("Resistance = "); Serial.println(RREF*ratio,8);
46-
Serial.print("Temperature = "); Serial.println(thermo.temperature(RNOMINAL, RREF));
44+
Serial.print("Ratio = ");
45+
Serial.println(ratio, 8);
46+
Serial.print("Resistance = ");
47+
Serial.println(RREF * ratio, 8);
48+
Serial.print("Temperature = ");
49+
Serial.println(thermo.temperature(RNOMINAL, RREF));
4750

4851
// Check and print any faults
4952
uint8_t fault = thermo.readFault();
5053
if (fault) {
51-
Serial.print("Fault 0x"); Serial.println(fault, HEX);
54+
Serial.print("Fault 0x");
55+
Serial.println(fault, HEX);
5256
if (fault & MAX31865_FAULT_HIGHTHRESH) {
53-
Serial.println("RTD High Threshold");
57+
Serial.println("RTD High Threshold");
5458
}
5559
if (fault & MAX31865_FAULT_LOWTHRESH) {
56-
Serial.println("RTD Low Threshold");
60+
Serial.println("RTD Low Threshold");
5761
}
5862
if (fault & MAX31865_FAULT_REFINLOW) {
59-
Serial.println("REFIN- > 0.85 x Bias");
63+
Serial.println("REFIN- > 0.85 x Bias");
6064
}
6165
if (fault & MAX31865_FAULT_REFINHIGH) {
62-
Serial.println("REFIN- < 0.85 x Bias - FORCE- open");
66+
Serial.println("REFIN- < 0.85 x Bias - FORCE- open");
6367
}
6468
if (fault & MAX31865_FAULT_RTDINLOW) {
65-
Serial.println("RTDIN- < 0.85 x Bias - FORCE- open");
69+
Serial.println("RTDIN- < 0.85 x Bias - FORCE- open");
6670
}
6771
if (fault & MAX31865_FAULT_OVUV) {
68-
Serial.println("Under/Over voltage");
72+
Serial.println("Under/Over voltage");
6973
}
7074
thermo.clearFault();
7175
}

scripts/install_libraries.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
# this script has two use cases
4+
# 1 - CI testing and local development of this library only (SHALLOW)
5+
# 2 - Development of this library AND the supporting libraries
6+
# comment this out if you want full depth for the supporting libraries (case 2)
7+
export SHALLOW='--depth 1 --branch master --single-branch '
8+
# use this if you started with SHALLOW and now want the full repository with history
9+
# git fetch --unshallow
10+
11+
# ensure we have `arduino_ci`
12+
bundle config --local path vendor/bundle
13+
bundle install
14+
15+
# set up directories
16+
bundle exec ensure_arduino_installation.rb
17+
cd $(bundle exec arduino_library_location.rb)
18+
19+
# add missing libraries
20+
export GITHUB="https://github.com/Arduino-CI"
21+
if [ ! -d "./Adafruit_BusIO" ] ; then
22+
git clone $SHALLOW $GITHUB/Adafruit_BusIO.git
23+
fi

scripts/test.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#! /bin/sh
2+
bundle config --local path vendor/bundle
3+
bundle install
4+
bundle exec arduino_ci.rb --skip-examples-compilation

scripts/testAndBuild.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#! /bin/sh
2+
bundle config --local path vendor/bundle
3+
bundle install
4+
bundle exec arduino_ci.rb

Adafruit_MAX31865.cpp renamed to src/Adafruit_MAX31865.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
*/
3434
/**************************************************************************/
3535
//
36-
Adafruit_MAX31865::Adafruit_MAX31865(int8_t spi_cs, int8_t spi_mosi,
37-
int8_t spi_miso, int8_t spi_clk)
36+
Adafruit_MAX31865_Base::Adafruit_MAX31865_Base(int8_t spi_cs, int8_t spi_mosi,
37+
int8_t spi_miso, int8_t spi_clk)
3838
: spi_dev(spi_cs, spi_clk, spi_miso, spi_mosi, 1000000,
3939
SPI_BITORDER_MSBFIRST, SPI_MODE1) {}
4040

@@ -44,7 +44,7 @@ Adafruit_MAX31865::Adafruit_MAX31865(int8_t spi_cs, int8_t spi_mosi,
4444
@param spi_cs the SPI CS pin to use along with the default SPI device
4545
*/
4646
/**************************************************************************/
47-
Adafruit_MAX31865::Adafruit_MAX31865(int8_t spi_cs)
47+
Adafruit_MAX31865_Base::Adafruit_MAX31865_Base(int8_t spi_cs)
4848
: spi_dev(spi_cs, 1000000, SPI_BITORDER_MSBFIRST, SPI_MODE1) {}
4949

5050
/**************************************************************************/
@@ -55,7 +55,7 @@ Adafruit_MAX31865::Adafruit_MAX31865(int8_t spi_cs)
5555
@return True
5656
*/
5757
/**************************************************************************/
58-
bool Adafruit_MAX31865::begin(max31865_numwires_t wires) {
58+
bool Adafruit_MAX31865_Base::begin(max31865_numwires_t wires) {
5959
spi_dev.begin();
6060

6161
setWires(wires);
@@ -74,7 +74,7 @@ bool Adafruit_MAX31865::begin(max31865_numwires_t wires) {
7474
@return The raw unsigned 8-bit FAULT status register
7575
*/
7676
/**************************************************************************/
77-
uint8_t Adafruit_MAX31865::readFault(void) {
77+
uint8_t Adafruit_MAX31865_Base::readFault(void) {
7878
return readRegister8(MAX31865_FAULTSTAT_REG);
7979
}
8080

@@ -83,7 +83,7 @@ uint8_t Adafruit_MAX31865::readFault(void) {
8383
@brief Clear all faults in FAULTSTAT
8484
*/
8585
/**************************************************************************/
86-
void Adafruit_MAX31865::clearFault(void) {
86+
void Adafruit_MAX31865_Base::clearFault(void) {
8787
uint8_t t = readRegister8(MAX31865_CONFIG_REG);
8888
t &= ~0x2C;
8989
t |= MAX31865_CONFIG_FAULTSTAT;
@@ -96,7 +96,7 @@ void Adafruit_MAX31865::clearFault(void) {
9696
@param b If true bias is enabled, else disabled
9797
*/
9898
/**************************************************************************/
99-
void Adafruit_MAX31865::enableBias(bool b) {
99+
void Adafruit_MAX31865_Base::enableBias(bool b) {
100100
uint8_t t = readRegister8(MAX31865_CONFIG_REG);
101101
if (b) {
102102
t |= MAX31865_CONFIG_BIAS; // enable bias
@@ -112,7 +112,7 @@ void Adafruit_MAX31865::enableBias(bool b) {
112112
@param b If true, auto conversion is enabled
113113
*/
114114
/**************************************************************************/
115-
void Adafruit_MAX31865::autoConvert(bool b) {
115+
void Adafruit_MAX31865_Base::autoConvert(bool b) {
116116
uint8_t t = readRegister8(MAX31865_CONFIG_REG);
117117
if (b) {
118118
t |= MAX31865_CONFIG_MODEAUTO; // enable autoconvert
@@ -129,7 +129,7 @@ void Adafruit_MAX31865::autoConvert(bool b) {
129129
*/
130130
/**************************************************************************/
131131

132-
void Adafruit_MAX31865::enable50Hz(bool b) {
132+
void Adafruit_MAX31865_Base::enable50Hz(bool b) {
133133
uint8_t t = readRegister8(MAX31865_CONFIG_REG);
134134
if (b) {
135135
t |= MAX31865_CONFIG_FILT50HZ;
@@ -146,7 +146,7 @@ void Adafruit_MAX31865::enable50Hz(bool b) {
146146
@param wires The number of wires in enum format
147147
*/
148148
/**************************************************************************/
149-
void Adafruit_MAX31865::setWires(max31865_numwires_t wires) {
149+
void Adafruit_MAX31865_Base::setWires(max31865_numwires_t wires) {
150150
uint8_t t = readRegister8(MAX31865_CONFIG_REG);
151151
if (wires == MAX31865_3WIRE) {
152152
t |= MAX31865_CONFIG_3WIRE;
@@ -170,7 +170,7 @@ void Adafruit_MAX31865::setWires(max31865_numwires_t wires) {
170170
@returns Temperature in C
171171
*/
172172
/**************************************************************************/
173-
float Adafruit_MAX31865::temperature(float RTDnominal, float refResistor) {
173+
float Adafruit_MAX31865_Base::temperature(float RTDnominal, float refResistor) {
174174
float Z1, Z2, Z3, Z4, Rt, temp;
175175

176176
Rt = readRTD();
@@ -216,7 +216,7 @@ float Adafruit_MAX31865::temperature(float RTDnominal, float refResistor) {
216216
@return The raw unsigned 16-bit value, NOT temperature!
217217
*/
218218
/**************************************************************************/
219-
uint16_t Adafruit_MAX31865::readRTD(void) {
219+
uint16_t Adafruit_MAX31865_Base::readRTD(void) {
220220
clearFault();
221221
enableBias(true);
222222
delay(10);
@@ -237,14 +237,14 @@ uint16_t Adafruit_MAX31865::readRTD(void) {
237237

238238
/**********************************************/
239239

240-
uint8_t Adafruit_MAX31865::readRegister8(uint8_t addr) {
240+
uint8_t Adafruit_MAX31865_Base::readRegister8(uint8_t addr) {
241241
uint8_t ret = 0;
242242
readRegisterN(addr, &ret, 1);
243243

244244
return ret;
245245
}
246246

247-
uint16_t Adafruit_MAX31865::readRegister16(uint8_t addr) {
247+
uint16_t Adafruit_MAX31865_Base::readRegister16(uint8_t addr) {
248248
uint8_t buffer[2] = {0, 0};
249249
readRegisterN(addr, buffer, 2);
250250

@@ -255,14 +255,14 @@ uint16_t Adafruit_MAX31865::readRegister16(uint8_t addr) {
255255
return ret;
256256
}
257257

258-
void Adafruit_MAX31865::readRegisterN(uint8_t addr, uint8_t buffer[],
259-
uint8_t n) {
258+
void Adafruit_MAX31865_Base::readRegisterN(uint8_t addr, uint8_t buffer[],
259+
uint8_t n) {
260260
addr &= 0x7F; // make sure top bit is not set
261261

262262
spi_dev.write_then_read(&addr, 1, buffer, n);
263263
}
264264

265-
void Adafruit_MAX31865::writeRegister8(uint8_t addr, uint8_t data) {
265+
void Adafruit_MAX31865_Base::writeRegister8(uint8_t addr, uint8_t data) {
266266
addr |= 0x80; // make sure top bit is set
267267

268268
uint8_t buffer[2] = {addr, data};

0 commit comments

Comments
 (0)