From 195afcdebe7f07f3005ed678b8be652155f7724d Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Thu, 9 Dec 2021 20:33:57 +0100 Subject: [PATCH] fix #21 move constructor code to begin() - breaking change (#22) * fix #21 breaking change * move constructor code to begin() * fix examples * removed "premature" return from read() so internal and temperature are always converted from raw data. --- LICENSE | 2 +- MAX31855.cpp | 47 ++++++++++--------- MAX31855.h | 17 +++---- README.md | 27 +++++++---- examples/Demo_getRawData/Demo_getRawData.ino | 11 +++-- examples/max31855_ESP32_HSPI/.arduino-ci.yml | 1 + .../max31855_ESP32_HSPI.ino | 12 +++-- examples/max31855_ESP32_VSPI/.arduino-ci.yml | 1 + .../max31855_ESP32_VSPI.ino | 10 ++-- examples/max31855_array/max31855_array.ino | 16 +++++-- examples/max31855_demo0/max31855_demo0.ino | 13 ++++- examples/max31855_demo1/max31855_demo1.ino | 13 +++-- examples/max31855_demo2/max31855_demo2.ino | 13 +++-- examples/max31855_demo3/max31855_demo3.ino | 15 ++++-- examples/max31855_demo4/max31855_demo4.ino | 8 +++- examples/max31855_demo5/max31855_demo5.ino | 8 +++- examples/max31855_demo6/max31855_demo6.ino | 14 ++++-- examples/max31855_hwSPI/max31855_hwSPI.ino | 15 ++++-- examples/max31855_swSPI/max31855_swSPI.ino | 7 +-- .../max31855_test_error.ino | 11 +++-- library.json | 2 +- library.properties | 2 +- test/unit_test_001.cpp | 6 +-- 23 files changed, 183 insertions(+), 88 deletions(-) diff --git a/LICENSE b/LICENSE index 0637a28..4feba6f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2014-2021 Rob Tillaart +Copyright (c) 2014-2022 Rob Tillaart Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/MAX31855.cpp b/MAX31855.cpp index a0b25d2..ff2eeb5 100644 --- a/MAX31855.cpp +++ b/MAX31855.cpp @@ -1,12 +1,15 @@ // // FILE: MAX31855.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.3.0 +// VERSION: 0.4.0 // PURPOSE: Arduino library for MAX31855 chip for K type thermocouple // DATE: 2014-01-01 // URL: https://github.com/RobTillaart/MAX31855_RT // // HISTORY: +// 0.4.0 2021-12-09 fix #21 breaking change for HW SPI +// move constructor code to begin() +// read() removed "premature" return on status. // 0.3.0 2021-08-11 VSPI / HSPI support for ESP32 // add setGIOpins - ESP32 specific // add get/setSPIspeed() - all @@ -33,18 +36,23 @@ #include "MAX31855.h" -MAX31855::MAX31855(const uint8_t select) +MAX31855::MAX31855() { - MAX31855(255, select, 255); } -MAX31855::MAX31855(const uint8_t clock, const uint8_t select, const uint8_t miso) +void MAX31855::begin(const uint8_t select) { - _clock = clock; - _select = select; - _miso = miso; - _hwSPI = (clock == 255); + begin(255, select, 255); +} + + +void MAX31855::begin(const uint8_t clock, const uint8_t select, const uint8_t miso) +{ + _clock = clock; + _miso = miso; + _select = select; + _hwSPI = (_clock == 255); _lastTimeRead = 0; _offset = 0; @@ -53,16 +61,11 @@ MAX31855::MAX31855(const uint8_t clock, const uint8_t select, const uint8_t miso _temperature = MAX31855_NO_TEMPERATURE; _internal = MAX31855_NO_TEMPERATURE; _rawData = 0; -} - + setSPIspeed(1000000); -void MAX31855::begin() -{ pinMode(_select, OUTPUT); digitalWrite(_select, HIGH); - _spi_settings = SPISettings(_SPIspeed, MSBFIRST, SPI_MODE0); - if (_hwSPI) { #if defined(ESP32) @@ -110,7 +113,8 @@ void MAX31855::setGPIOpins(uint8_t clock, uint8_t miso, uint8_t mosi, uint8_t se pinMode(_select, OUTPUT); digitalWrite(_select, HIGH); - mySPI->end(); // disable SPI + // disable SPI and enable again + mySPI->end(); mySPI->begin(clock, miso, mosi, select); } #endif @@ -130,7 +134,7 @@ uint8_t MAX31855::read() // 31 SIGN uint32_t value = _read(); - if (value == 0xFFFFFFFF) // needs a pull up on miso pin to work properly! + if (value == 0xFFFFFFFF) // needs a pull up on MISO pin to work properly! { // bit 3 and bit 17 should always be 0 - P10 datasheet _status = STATUS_NO_COMMUNICATION; @@ -139,12 +143,12 @@ uint8_t MAX31855::read() _lastTimeRead = millis(); - // process status bit 0-2 + // process status bit 0-2 _status = value & 0x0007; - if (_status != STATUS_OK) - { - return _status; - } + // if (_status != STATUS_OK) // removed in 0.4.0 as internal can be valid. + // { + // return _status; + // } value >>= 3; @@ -233,3 +237,4 @@ float MAX31855::getTemperature() // -- END OF FILE -- + diff --git a/MAX31855.h b/MAX31855.h index b578f52..bd68ff8 100644 --- a/MAX31855.h +++ b/MAX31855.h @@ -2,7 +2,7 @@ // // FILE: MAX31855.h // AUTHOR: Rob Tillaart -// VERSION: 0.3.0 +// VERSION: 0.4.0 // PURPOSE: Arduino library for MAX31855 chip for K type thermocouple // DATE: 2014-01-01 // URL: https://github.com/RobTillaart/MAX31855_RT @@ -25,7 +25,7 @@ #include "SPI.h" -#define MAX31855_VERSION (F("0.3.0")) +#define MAX31855_VERSION (F("0.4.0")) #define MAX31855_NO_TEMPERATURE -999 @@ -63,12 +63,13 @@ class MAX31855 { public: - // HW SPI - MAX31855(uint8_t select); - // SW SPI - MAX31855(uint8_t clock, uint8_t select, uint8_t miso); - void begin(); + MAX31855(); + + // HW SPI + void begin(uint8_t select); + // SW SPI + void begin(uint8_t clock, uint8_t select, uint8_t miso); // returns state - bit field: 0 = STATUS_OK uint8_t read(); @@ -128,7 +129,7 @@ class MAX31855 uint8_t _miso; uint8_t _select; - uint32_t _SPIspeed = 1000000; + uint32_t _SPIspeed; SPIClass * mySPI; SPISettings _spi_settings; #if defined(ESP32) diff --git a/README.md b/README.md index 38466c8..dbe67f3 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,12 @@ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/MAX31855_RT/blob/master/LICENSE) [![GitHub release](https://img.shields.io/github/release/RobTillaart/MAX31855_RT.svg?maxAge=3600)](https://github.com/RobTillaart/MAX31855_RT/releases) + # MAX31855_RT Arduino library for MAX31855 chip for K type thermocouple. -The library has experimental support for other types of thermocouples E, J, N, R, S, T +The library has experimental support for other types of thermocouples E, J, N, R, S, T. ## Description @@ -42,11 +43,11 @@ Library tested with breakout board Default pin connections. ESP32 can overrule with **setGPIOpins()**. | HW SPI | UNO | ESP32 VSPI | ESP32 HSPI | Notes - |:---------|:-----:|:-------:|:-------:|:----------| - | CLOCKPIN | 13 | 18 | 14 | - | MISO | 12 | 19 | 12 | - | MOSI | 11 | 23 | 13 | *not used...* - | SELECT | eg. 4 | 5 | 15 | *can be others too.* + |:---------|:-----:|:-----------:|:-----------:|:----------| + | CLOCKPIN | 13 | 18 | 14 | + | MISO | 12 | 19 | 12 | + | MOSI | 11 | 23 | 13 | *not used...* + | SELECT | eg. 4 | 5 | 15 | *can be others too.* Performance read() function, timing in us. (ESP32 @240MHz) @@ -67,16 +68,17 @@ Performance read() function, timing in us. (ESP32 @240MHz) ### Constructor -- **MAX31855(const uint8_t select)** create object and set select pin => hardware SPI -- **MAX31855(const uint8_t sclk, const uint8_t select, const uint8_t miso)** create object, set clock, select and miso pin => software SPI +- **MAX31855()** create object. +- **void begin(const uint8_t select)** set select pin => hardware SPI +- **void begin(const uint8_t sclk, const uint8_t select, const uint8_t miso)** set clock, select and miso pin => software SPI ### Hardware SPI To be used only if one needs a specific speed. -- **void setSPIspeed(uint32_t speed)** set SPI transfer rate -- **uint32_t getSPIspeed()** returns SPI transfer rate +- **void setSPIspeed(uint32_t speed)** set SPI transfer rate. +- **uint32_t getSPIspeed()** returns SPI transfer rate. ### ESP32 specific @@ -228,6 +230,11 @@ or See examples +#### breaking change 0.4.0 + +In issue #21 it became clear that the code in the constructor is not always executed correctly. +Therefore this code + parameters is moved to the **Begin()** function. + ## Experimental part (to be tested) diff --git a/examples/Demo_getRawData/Demo_getRawData.ino b/examples/Demo_getRawData/Demo_getRawData.ino index 0f5b699..ff6e1c5 100644 --- a/examples/Demo_getRawData/Demo_getRawData.ino +++ b/examples/Demo_getRawData/Demo_getRawData.ino @@ -1,27 +1,30 @@ // // FILE: Demo_getRawData.ino // AUTHOR: FabioBrondo -// VERSION: 0.1.1 +// VERSION: 0.4.0 // PURPOSE: thermocouple lib demo application // DATE: 2020-08-24 // URL: https://github.com/RobTillaart/MAX31855_RT // + #include #include + #define MAXDO 7 // Defining the MISO pin #define MAXCS 6 // Defining the CS pin #define MAXCLK 5 // Defining the SCK pin -MAX31855 thermocouple(MAXCLK, MAXCS, MAXDO); +MAX31855 thermocouple; + void setup () { Serial.begin(115200); delay(250); - thermocouple.begin(); + thermocouple.begin(MAXCLK, MAXCS, MAXDO); } @@ -52,4 +55,6 @@ void loop () delay(100); } + // -- END OF FILE -- + diff --git a/examples/max31855_ESP32_HSPI/.arduino-ci.yml b/examples/max31855_ESP32_HSPI/.arduino-ci.yml index 1877a86..604ef17 100644 --- a/examples/max31855_ESP32_HSPI/.arduino-ci.yml +++ b/examples/max31855_ESP32_HSPI/.arduino-ci.yml @@ -5,3 +5,4 @@ compile: # - leonardo # - due # - zero + - esp32 \ No newline at end of file diff --git a/examples/max31855_ESP32_HSPI/max31855_ESP32_HSPI.ino b/examples/max31855_ESP32_HSPI/max31855_ESP32_HSPI.ino index 1845df7..96dadfd 100644 --- a/examples/max31855_ESP32_HSPI/max31855_ESP32_HSPI.ino +++ b/examples/max31855_ESP32_HSPI/max31855_ESP32_HSPI.ino @@ -11,6 +11,7 @@ // one might to need to disconnect pin 12 during upload of the code // when HSPI is used. + #include "MAX31855.h" @@ -35,8 +36,7 @@ const int csPin = 15; uint32_t start, stop; - -MAX31855 tc(csPin); +MAX31855 tc; void setup() @@ -49,8 +49,11 @@ void setup() Serial.println(); tc.selectHSPI(); // needs to be called before begin() - tc.begin(); - tc.setSPIspeed(16000000); + + tc.begin(csPin); + // tc.begin(14, csPin, 12); // SW SPI for testing + + tc.setSPIspeed(1000000); } @@ -90,3 +93,4 @@ void loop() // -- END OF FILE -- + diff --git a/examples/max31855_ESP32_VSPI/.arduino-ci.yml b/examples/max31855_ESP32_VSPI/.arduino-ci.yml index 1877a86..c890108 100644 --- a/examples/max31855_ESP32_VSPI/.arduino-ci.yml +++ b/examples/max31855_ESP32_VSPI/.arduino-ci.yml @@ -5,3 +5,4 @@ compile: # - leonardo # - due # - zero + - esp32 diff --git a/examples/max31855_ESP32_VSPI/max31855_ESP32_VSPI.ino b/examples/max31855_ESP32_VSPI/max31855_ESP32_VSPI.ino index 4caa0a1..2b9263d 100644 --- a/examples/max31855_ESP32_VSPI/max31855_ESP32_VSPI.ino +++ b/examples/max31855_ESP32_VSPI/max31855_ESP32_VSPI.ino @@ -29,12 +29,12 @@ // | MOSI | 11 | 23 | 13 | * not used... // | SELECT | eg. 4 | 5 | 15 | * can be others too. -const int csPin = 15; +const int csPin = 25; uint32_t start, stop; -MAX31855 tc(csPin); +MAX31855 tc; void setup() @@ -47,7 +47,10 @@ void setup() Serial.println(); tc.selectVSPI(); // needs to be called before begin() - tc.begin(); + + tc.begin(csPin); + // tc.begin(14, csPin, 12); // SW SPI for testing + tc.setSPIspeed(16000000); } @@ -88,3 +91,4 @@ void loop() // -- END OF FILE -- + diff --git a/examples/max31855_array/max31855_array.ino b/examples/max31855_array/max31855_array.ino index 902e812..8c708e5 100644 --- a/examples/max31855_array/max31855_array.ino +++ b/examples/max31855_array/max31855_array.ino @@ -15,15 +15,18 @@ const int dataPin = 7; const int clockPin = 6; -MAX31855 sensors[] = + +MAX31855 A, B, C; + +MAX31855 sensors[] = { - MAX31855(clockPin, 5, dataPin), - MAX31855(clockPin, 4, dataPin), - MAX31855(clockPin, 3, dataPin) + A, B, C }; + const uint8_t sensorCount = sizeof(sensors) / sizeof(MAX31855); + void setup() { Serial.begin(115200); @@ -35,10 +38,11 @@ void setup() for (int i = 0; i < sensorCount; i++) { - sensors[i].begin(); + sensors[i].begin(clockPin, 3 + i, dataPin); // three different select pins. } } + void loop() { Serial.print("\tTime:\t"); @@ -66,4 +70,6 @@ void loop() delay(1000); } + // -- END OF FILE -- + diff --git a/examples/max31855_demo0/max31855_demo0.ino b/examples/max31855_demo0/max31855_demo0.ino index e862a6c..64e8a4d 100644 --- a/examples/max31855_demo0/max31855_demo0.ino +++ b/examples/max31855_demo0/max31855_demo0.ino @@ -7,13 +7,17 @@ // URL: https://github.com/RobTillaart/MAX31855_RT // + #include "MAX31855.h" + const int doPin = 7; const int csPin = 6; const int clPin = 5; -MAX31855 tc(clPin, csPin, doPin); + +MAX31855 tc; + void setup() { @@ -22,9 +26,10 @@ void setup() Serial.println(MAX31855_VERSION); Serial.println(); - tc.begin(); + tc.begin(clPin, csPin, doPin); } + void loop() { int status = tc.read(); @@ -40,3 +45,7 @@ void loop() Serial.println(temp, 3); delay(1000); } + + +// -- END OF FILE + diff --git a/examples/max31855_demo1/max31855_demo1.ino b/examples/max31855_demo1/max31855_demo1.ino index b93a405..97e7802 100644 --- a/examples/max31855_demo1/max31855_demo1.ino +++ b/examples/max31855_demo1/max31855_demo1.ino @@ -1,19 +1,23 @@ // // FILE: max31855_demo1.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.4 +// VERSION: 0.4.0 // PURPOSE: thermocouple lib demo application // DATE: 2014-01-02 // URL: https://github.com/RobTillaart/MAX31855_RT // + #include "MAX31855.h" + const int doPin = 7; const int csPin = 6; const int clPin = 5; -MAX31855 tc(clPin, csPin, doPin); + +MAX31855 tc; + void setup() { @@ -22,9 +26,10 @@ void setup() Serial.println(MAX31855_VERSION); Serial.println(); - tc.begin(); + tc.begin(clPin, csPin, doPin); } + void loop() { int status = tc.read(); @@ -43,4 +48,6 @@ void loop() Serial.println(); } + // -- END OF FILE -- + diff --git a/examples/max31855_demo2/max31855_demo2.ino b/examples/max31855_demo2/max31855_demo2.ino index 7c82ff7..285b92d 100644 --- a/examples/max31855_demo2/max31855_demo2.ino +++ b/examples/max31855_demo2/max31855_demo2.ino @@ -1,19 +1,22 @@ // // FILE: max31855_demo2.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.4 +// VERSION: 0.4.0 // PURPOSE: thermocouple lib demo application // DATE: 2014-01-02 // URL: https://github.com/RobTillaart/MAX31855_RT // + #include "MAX31855.h" const int doPin = 7; const int csPin = 6; const int clPin = 5; -MAX31855 tc(clPin, csPin, doPin); + +MAX31855 tc; + float t1, t2; @@ -24,12 +27,14 @@ void setup() Serial.println(MAX31855_VERSION); Serial.println(); - tc.begin(); + tc.begin(clPin, csPin, doPin); + tc.read(); t1 = tc.getTemperature(); delay(1000); } + void loop() { tc.read(); @@ -40,4 +45,6 @@ void loop() delay(1000); } + // -- END OF FILE -- + diff --git a/examples/max31855_demo3/max31855_demo3.ino b/examples/max31855_demo3/max31855_demo3.ino index 29383cf..23b71e5 100644 --- a/examples/max31855_demo3/max31855_demo3.ino +++ b/examples/max31855_demo3/max31855_demo3.ino @@ -7,13 +7,16 @@ // URL: https://github.com/RobTillaart/MAX31855_RT // + #include "MAX31855.h" const int doPin = 7; const int csPin = 6; const int clPin = 5; -MAX31855 tc(clPin, csPin, doPin); + +MAX31855 tc; + void setup() { @@ -22,7 +25,7 @@ void setup() Serial.println(MAX31855_VERSION); Serial.println(); - tc.begin(); + tc.begin(clPin, csPin, doPin); uint32_t start = micros(); tc.read(); @@ -47,7 +50,8 @@ void setup() Serial.println(t2, 2); Serial.println(); } - + + void loop() { // this loop returns multiples of about 73mSec (counter multiples of ~143) @@ -73,4 +77,7 @@ void loop() Serial.println(t1, 2); Serial.println(); } - + + +// -- END OF FILE -- + diff --git a/examples/max31855_demo4/max31855_demo4.ino b/examples/max31855_demo4/max31855_demo4.ino index 7af4c8d..7e9888f 100644 --- a/examples/max31855_demo4/max31855_demo4.ino +++ b/examples/max31855_demo4/max31855_demo4.ino @@ -7,13 +7,16 @@ // URL: https://github.com/RobTillaart/MAX31855_RT // + #include "MAX31855.h" const int doPin = 7; const int csPin = 6; const int clPin = 5; -MAX31855 tc(clPin, csPin, doPin); + +MAX31855 tc; + void setup() { @@ -22,7 +25,7 @@ void setup() Serial.println(MAX31855_VERSION); Serial.println(); - tc.begin(); + tc.begin(clPin, csPin, doPin); uint32_t start = micros(); for (int i = 0; i < 10; i++) tc.read(); @@ -75,3 +78,4 @@ void loop() } // -- END OF FILE -- + diff --git a/examples/max31855_demo5/max31855_demo5.ino b/examples/max31855_demo5/max31855_demo5.ino index db2f585..756f53e 100644 --- a/examples/max31855_demo5/max31855_demo5.ino +++ b/examples/max31855_demo5/max31855_demo5.ino @@ -13,7 +13,7 @@ const int doPin = 7; const int csPin = 6; const int clPin = 5; -MAX31855 tc(clPin, csPin, doPin); +MAX31855 tc; void setup() { @@ -22,7 +22,8 @@ void setup() Serial.println(MAX31855_VERSION); Serial.println(); - tc.begin(); + tc.begin(clPin, csPin, doPin); + tc.read(); float t1 = tc.getTemperature(); Serial.print(" temp before:\t"); @@ -48,8 +49,11 @@ void setup() Serial.println("\ndone..."); } + void loop() { } + // -- END OF FILE -- + diff --git a/examples/max31855_demo6/max31855_demo6.ino b/examples/max31855_demo6/max31855_demo6.ino index 7f828b1..d05e5f2 100644 --- a/examples/max31855_demo6/max31855_demo6.ino +++ b/examples/max31855_demo6/max31855_demo6.ino @@ -1,19 +1,22 @@ // // FILE: max31855_demo6.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.1 +// VERSION: 0.4.0 // PURPOSE: thermocouple lib demo setSeebeckCoefficient() // DATE: 2015-12-06 // URL: https://github.com/RobTillaart/MAX31855_RT // + #include "MAX31855.h" const int doPin = 7; const int csPin = 6; const int clPin = 5; -MAX31855 tc(clPin, csPin, doPin); + +MAX31855 tc; + void setup() { @@ -22,7 +25,8 @@ void setup() Serial.println(MAX31855_VERSION); Serial.println(); - tc.begin(); + tc.begin(clPin, csPin, doPin); + tc.read(); float t1 = tc.getTemperature(); Serial.print(" temp before:\t"); @@ -49,6 +53,10 @@ void setup() Serial.println("\ndone..."); } + void loop() { } + +// -- END OF FILE -- + diff --git a/examples/max31855_hwSPI/max31855_hwSPI.ino b/examples/max31855_hwSPI/max31855_hwSPI.ino index 5cd6713..6c21a0c 100644 --- a/examples/max31855_hwSPI/max31855_hwSPI.ino +++ b/examples/max31855_hwSPI/max31855_hwSPI.ino @@ -25,17 +25,24 @@ // | CLOCKPIN | 13 | 18 | // | MISO | 12 | 19 | // | MOSI | 11 | 23 | * not used... +// | SELECT | 10 | 25 | + const int csPin = 25; const int clkPin = 18; const int dataPin = 19; +// const int csPin = 10; +// const int clkPin = 13; +// const int dataPin = 12; +// const int csPin = 15; +// const int clkPin = 14; +// const int dataPin = 12; uint32_t start, stop; -MAX31855 tc(csPin); -// MAX31855 tc(clkPin, csPin, dataPin); // sw SPI +MAX31855 tc; void setup() @@ -46,7 +53,8 @@ void setup() Serial.println(MAX31855_VERSION); Serial.println(); - tc.begin(); + tc.begin(csPin); + // tc.begin(clkPin, csPin, dataPin); // sw SPI to test } @@ -86,3 +94,4 @@ void loop() // -- END OF FILE -- + diff --git a/examples/max31855_swSPI/max31855_swSPI.ino b/examples/max31855_swSPI/max31855_swSPI.ino index c52453b..2050a10 100644 --- a/examples/max31855_swSPI/max31855_swSPI.ino +++ b/examples/max31855_swSPI/max31855_swSPI.ino @@ -1,7 +1,7 @@ // // FILE: max31855_sw_SPI.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.0 +// VERSION: 0.4.0 // PURPOSE: thermocouple lib demo application // DATE: 2021-08-11 // URL: https://github.com/RobTillaart/MAX31855_RT @@ -36,7 +36,7 @@ const int dataPin = 12; uint32_t start, stop; -MAX31855 tc(clkPin, csPin, dataPin); // sw SPI +MAX31855 tc; void setup() @@ -47,7 +47,7 @@ void setup() Serial.println(MAX31855_VERSION); Serial.println(); - tc.begin(); + tc.begin(clkPin, csPin, dataPin); // sw SPI } @@ -87,3 +87,4 @@ void loop() // -- END OF FILE -- + diff --git a/examples/max31855_test_error/max31855_test_error.ino b/examples/max31855_test_error/max31855_test_error.ino index 5139495..f825fe4 100644 --- a/examples/max31855_test_error/max31855_test_error.ino +++ b/examples/max31855_test_error/max31855_test_error.ino @@ -1,19 +1,21 @@ // // FILE: max31855_test_error.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.1 +// VERSION: 0.4.0 // PURPOSE: thermocouple lib inline tests // DATE: 2019-07-31 // URL: https://github.com/RobTillaart/MAX31855_RT // + #include "MAX31855.h" const int doPin = 7; const int csPin = 6; const int clPin = 5; -MAX31855 tc(clPin, csPin, doPin); +MAX31855 tc; + void setup() { @@ -22,9 +24,10 @@ void setup() Serial.println(MAX31855_VERSION); Serial.println(); - tc.begin(); + tc.begin(clPin, csPin, doPin); } + void loop() { int status = tc.read(); @@ -52,4 +55,6 @@ void loop() delay(1000); } + // -- END OF FILE -- + diff --git a/library.json b/library.json index 1949b41..a0e2035 100644 --- a/library.json +++ b/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/MAX31855_RT" }, - "version": "0.3.0", + "version": "0.4.0", "license": "MIT", "frameworks": "arduino", "platforms": "*", diff --git a/library.properties b/library.properties index cae38b5..9fa3425 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=MAX31855_RT -version=0.3.0 +version=0.4.0 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for MAX31855 chip for K type thermocouple. diff --git a/test/unit_test_001.cpp b/test/unit_test_001.cpp index 8240ca4..cfea91c 100644 --- a/test/unit_test_001.cpp +++ b/test/unit_test_001.cpp @@ -60,14 +60,14 @@ unittest(test_new_operator) unittest(test_all) { - fprintf(stderr, "VERSION: %s\n", MAX31855_VERSION); + fprintf(stderr, "MAX31855_VERSION: %s\n", (char *) MAX31855_VERSION); const int doPin = 7; const int csPin = 6; const int clPin = 5; - MAX31855 tc(clPin, csPin, doPin); - tc.begin(); + MAX31855 tc; + tc.begin(clPin, csPin, doPin); fprintf(stderr, "Status...\n"); assertEqual(STATUS_NOREAD, (int)tc.getStatus());