Skip to content

Commit

Permalink
Merge pull request #23 from caternuson/actionsci
Browse files Browse the repository at this point in the history
Actionify and clang
  • Loading branch information
caternuson authored May 21, 2020
2 parents daec858 + 236f8eb commit d158d41
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 119 deletions.
46 changes: 46 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Thank you for opening an issue on an Adafruit Arduino library repository. To
improve the speed of resolution please review the following guidelines and
common troubleshooting steps below before creating the issue:

- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
the forums at http://forums.adafruit.com to ask questions and troubleshoot why
something isn't working as expected. In many cases the problem is a common issue
that you will more quickly receive help from the forum community. GitHub issues
are meant for known defects in the code. If you don't know if there is a defect
in the code then start with troubleshooting on the forum first.

- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
check all of the steps and commands to run have been followed. Consult the
forum if you're unsure or have questions about steps in a guide/tutorial.

- **For Arduino projects check these very common issues to ensure they don't apply**:

- For uploading sketches or communicating with the board make sure you're using
a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
very hard to tell the difference between a data and charge cable! Try using the
cable with other devices or swapping to another cable to confirm it is not
the problem.

- **Be sure you are supplying adequate power to the board.** Check the specs of
your board and plug in an external power supply. In many cases just
plugging a board into your computer is not enough to power it and other
peripherals.

- **Double check all soldering joints and connections.** Flakey connections
cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.

- **Ensure you are using an official Arduino or Adafruit board.** We can't
guarantee a clone board will have the same functionality and work as expected
with this code and don't support them.

If you're sure this issue is a defect in the code and checked the steps above
please fill in the following fields to provide enough troubleshooting information.
You may delete the guideline and text above to just leave the following details:

- Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**

- Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
VERSION HERE**

- List the steps to reproduce the problem below (if possible attach a sketch or
copy the sketch code in too): **LIST REPRO STEPS BELOW**
26 changes: 26 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Thank you for creating a pull request to contribute to Adafruit's GitHub code!
Before you open the request please review the following guidelines and tips to
help it be more easily integrated:

- **Describe the scope of your change--i.e. what the change does and what parts
of the code were modified.** This will help us understand any risks of integrating
the code.

- **Describe any known limitations with your change.** For example if the change
doesn't apply to a supported platform of the library please mention it.

- **Please run any tests or examples that can exercise your modified code.** We
strive to not break users of the code and running tests/examples helps with this
process.

Thank you again for contributing! We will try to test and integrate the change
as soon as we can, but be aware we have many GitHub repositories to manage and
can't immediately respond to every request. There is no need to bump or check in
on a pull request (it will clutter the discussion of the request).

Also don't be worried if the request is closed or not integrated--sometimes the
priorities of Adafruit's GitHub code (education, ease of use) might not match the
priorities of the pull request. Don't fret, the open source community thrives on
forks and GitHub makes it easy to keep your changes in a forked repo.

After reviewing the guidelines above you can delete this text from the pull request.
32 changes: 32 additions & 0 deletions .github/workflows/githubci.yml
Original file line number Diff line number Diff line change
@@ -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 : "Arduino Library for Adafruit MAX31856"
run: bash ci/doxy_gen_and_deploy.sh
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

77 changes: 44 additions & 33 deletions Adafruit_MAX31856.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
*
* @section dependencies Dependencies
*
* This library depends on <a href="https://github.com/adafruit/Adafruit_Sensor">
* Adafruit_Sensor</a> being present on your system. Please make sure you have
* installed the latest version before using this library.
* This library depends on <a
* href="https://github.com/adafruit/Adafruit_Sensor"> Adafruit_Sensor</a> being
* present on your system. Please make sure you have installed the latest
* version before using this library.
*
* @section author Author
*
Expand All @@ -34,14 +35,13 @@

#include "Adafruit_MAX31856.h"
#ifdef __AVR
#include <avr/pgmspace.h>
#include <avr/pgmspace.h>
#elif defined(ESP8266)
#include <pgmspace.h>
#include <pgmspace.h>
#endif

#include <stdlib.h>
#include <SPI.h>

#include <stdlib.h>

/**************************************************************************/
/*!
Expand All @@ -52,7 +52,8 @@
@param spi_clk Bitbang SPI Clock
*/
/**************************************************************************/
Adafruit_MAX31856::Adafruit_MAX31856(int8_t spi_cs, int8_t spi_mosi, int8_t spi_miso, int8_t spi_clk) {
Adafruit_MAX31856::Adafruit_MAX31856(int8_t spi_cs, int8_t spi_mosi,
int8_t spi_miso, int8_t spi_clk) {
spi_dev = Adafruit_SPIDevice(spi_cs, spi_clk, spi_miso, spi_mosi, 1000000);

initialized = false;
Expand All @@ -65,21 +66,25 @@ Adafruit_MAX31856::Adafruit_MAX31856(int8_t spi_cs, int8_t spi_mosi, int8_t spi_
*/
/**************************************************************************/
Adafruit_MAX31856::Adafruit_MAX31856(int8_t spi_cs) {
spi_dev = Adafruit_SPIDevice(spi_cs, 1000000, SPI_BITORDER_MSBFIRST, SPI_MODE1);
spi_dev =
Adafruit_SPIDevice(spi_cs, 1000000, SPI_BITORDER_MSBFIRST, SPI_MODE1);

initialized = false;
}

/**************************************************************************/
/*!
@brief Initialize MAX31856 attach/set pins or SPI device, default to K thermocouple
@returns Always returns true at this time (no known way of detecting chip ID)
@brief Initialize MAX31856 attach/set pins or SPI device, default to K
thermocouple
@returns Always returns true at this time (no known way of detecting chip
ID)
*/
/**************************************************************************/
boolean Adafruit_MAX31856::begin(void) {
initialized = spi_dev.begin();

if (!initialized) return false;
if (!initialized)
return false;

// assert on any fault
writeRegister8(MAX31856_MASK_REG, 0x0);
Expand Down Expand Up @@ -107,15 +112,15 @@ boolean Adafruit_MAX31856::begin(void) {
/**************************************************************************/
void Adafruit_MAX31856::setConversionMode(max31856_conversion_mode_t mode) {
conversionMode = mode;
uint8_t t = readRegister8(MAX31856_CR0_REG); // get current register value
uint8_t t = readRegister8(MAX31856_CR0_REG); // get current register value
if (conversionMode == MAX31856_CONTINUOUS) {
t |= MAX31856_CR0_AUTOCONVERT; // turn on automatic
t &= ~MAX31856_CR0_1SHOT; // turn off one-shot
t |= MAX31856_CR0_AUTOCONVERT; // turn on automatic
t &= ~MAX31856_CR0_1SHOT; // turn off one-shot
} else {
t &= ~MAX31856_CR0_AUTOCONVERT; // turn off automatic
t |= MAX31856_CR0_1SHOT; // turn on one-shot
t &= ~MAX31856_CR0_AUTOCONVERT; // turn off automatic
t |= MAX31856_CR0_1SHOT; // turn on one-shot
}
writeRegister8(MAX31856_CR0_REG, t); // write value back to register
writeRegister8(MAX31856_CR0_REG, t); // write value back to register
}

/**************************************************************************/
Expand Down Expand Up @@ -172,7 +177,8 @@ uint8_t Adafruit_MAX31856::readFault(void) {
@param high High (max) temperature, signed 8 bit so -128 to 127 degrees C
*/
/**************************************************************************/
void Adafruit_MAX31856::setColdJunctionFaultThreshholds(int8_t low, int8_t high) {
void Adafruit_MAX31856::setColdJunctionFaultThreshholds(int8_t low,
int8_t high) {
writeRegister8(MAX31856_CJLF_REG, low);
writeRegister8(MAX31856_CJHF_REG, high);
}
Expand All @@ -181,15 +187,16 @@ void Adafruit_MAX31856::setColdJunctionFaultThreshholds(int8_t low, int8_t high)
/*!
@brief Sets the mains noise filter. Can be set to 50 or 60hz.
Defaults to 60hz. You need to call this if you live in a 50hz country.
@param noiseFilter One of MAX31856_NOISE_FILTER_50HZ or MAX31856_NOISE_FILTER_60HZ
@param noiseFilter One of MAX31856_NOISE_FILTER_50HZ or
MAX31856_NOISE_FILTER_60HZ
*/
/**************************************************************************/
void Adafruit_MAX31856::setNoiseFilter(max31856_noise_filter_t noiseFilter) {
uint8_t t = readRegister8(MAX31856_CR0_REG);
if(noiseFilter == MAX31856_NOISE_FILTER_50HZ) {
t|=0x01;
if (noiseFilter == MAX31856_NOISE_FILTER_50HZ) {
t |= 0x01;
} else {
t&=0xfe;
t &= 0xfe;
}
writeRegister8(MAX31856_CR0_REG, t);
}
Expand Down Expand Up @@ -226,13 +233,14 @@ void Adafruit_MAX31856::setTempFaultThreshholds(float flow, float fhigh) {
/**************************************************************************/
void Adafruit_MAX31856::triggerOneShot(void) {

if (conversionMode == MAX31856_CONTINUOUS) return;
if (conversionMode == MAX31856_CONTINUOUS)
return;

uint8_t t = readRegister8(MAX31856_CR0_REG); // get current register value
t &= ~MAX31856_CR0_AUTOCONVERT; // turn off autoconvert
t |= MAX31856_CR0_1SHOT; // turn on one-shot
writeRegister8(MAX31856_CR0_REG, t); // write value back to register
// conversion starts when CS goes high
// conversion starts when CS goes high
}

/**************************************************************************/
Expand All @@ -243,7 +251,8 @@ void Adafruit_MAX31856::triggerOneShot(void) {
/**************************************************************************/
bool Adafruit_MAX31856::conversionComplete(void) {

if (conversionMode == MAX31856_CONTINUOUS) return true;
if (conversionMode == MAX31856_CONTINUOUS)
return true;
return !(readRegister8(MAX31856_CR0_REG) & MAX31856_CR0_1SHOT);
}

Expand Down Expand Up @@ -271,7 +280,8 @@ float Adafruit_MAX31856::readThermocoupleTemperature(void) {
triggerOneShot();
uint32_t start = millis();
while (!conversionComplete()) {
if (millis() - start > 250) return NAN;
if (millis() - start > 250)
return NAN;
delay(10);
}
}
Expand All @@ -280,10 +290,10 @@ float Adafruit_MAX31856::readThermocoupleTemperature(void) {
int32_t temp24 = readRegister24(MAX31856_LTCBH_REG);
// and compute temperature
if (temp24 & 0x800000) {
temp24 |= 0xFF000000; // fix sign
temp24 |= 0xFF000000; // fix sign
}

temp24 >>= 5; // bottom 5 bits are unused
temp24 >>= 5; // bottom 5 bits are unused

return temp24 * 0.0078125;
}
Expand All @@ -303,7 +313,7 @@ uint16_t Adafruit_MAX31856::readRegister16(uint8_t addr) {

uint16_t ret = buffer[0];
ret <<= 8;
ret |= buffer[1];
ret |= buffer[1];

return ret;
}
Expand All @@ -314,14 +324,15 @@ uint32_t Adafruit_MAX31856::readRegister24(uint8_t addr) {

uint32_t ret = buffer[0];
ret <<= 8;
ret |= buffer[1];
ret |= buffer[1];
ret <<= 8;
ret |= buffer[2];
ret |= buffer[2];

return ret;
}

void Adafruit_MAX31856::readRegisterN(uint8_t addr, uint8_t buffer[], uint8_t n) {
void Adafruit_MAX31856::readRegisterN(uint8_t addr, uint8_t buffer[],
uint8_t n) {
addr &= 0x7F; // MSB=0 for read, make sure top bit is not set

spi_dev.write_then_read(&addr, 1, buffer, n);
Expand Down
Loading

0 comments on commit d158d41

Please sign in to comment.