From f46f99898f0728a175c20d7978ca2791a5b48c21 Mon Sep 17 00:00:00 2001 From: rob tillaart Date: Wed, 16 Nov 2022 13:14:42 +0100 Subject: [PATCH] 0.1.2 MAX6675 --- libraries/MAX6675/.arduino-ci.yml | 16 ++++++++ libraries/MAX6675/CHANGELOG.md | 19 +++++++++ libraries/MAX6675/MAX6675.cpp | 51 +++++++++++------------- libraries/MAX6675/MAX6675.h | 32 +++++++-------- libraries/MAX6675/README.md | 3 +- libraries/MAX6675/library.json | 2 +- libraries/MAX6675/library.properties | 2 +- libraries/MAX6675/test/unit_test_001.cpp | 17 ++------ 8 files changed, 82 insertions(+), 60 deletions(-) create mode 100644 libraries/MAX6675/CHANGELOG.md diff --git a/libraries/MAX6675/.arduino-ci.yml b/libraries/MAX6675/.arduino-ci.yml index cecf5850..25980972 100644 --- a/libraries/MAX6675/.arduino-ci.yml +++ b/libraries/MAX6675/.arduino-ci.yml @@ -1,3 +1,18 @@ +platforms: + rpipico: + board: rp2040:rp2040:rpipico + package: rp2040:rp2040 + gcc: + features: + defines: + - ARDUINO_ARCH_RP2040 + warnings: + flags: + +packages: + rp2040:rp2040: + url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json + compile: # Choosing to run compilation tests on 2 different Arduino platforms platforms: @@ -9,3 +24,4 @@ compile: - esp32 # - esp8266 # - mega2560 + - rpipico diff --git a/libraries/MAX6675/CHANGELOG.md b/libraries/MAX6675/CHANGELOG.md new file mode 100644 index 00000000..1cf62f11 --- /dev/null +++ b/libraries/MAX6675/CHANGELOG.md @@ -0,0 +1,19 @@ +# Change Log MAX6675 + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + + +## [0.1.2] - 2022-11-16 +- add RP2040 in build-CI +- add changelog.md + + +## [0.1.1] - 2022-04-20 +- updated documentation after tests with UNO. +- added examples + +## [0.1.0] - 2022-01-11 +- initial version. diff --git a/libraries/MAX6675/MAX6675.cpp b/libraries/MAX6675/MAX6675.cpp index a6937d54..8e607de4 100644 --- a/libraries/MAX6675/MAX6675.cpp +++ b/libraries/MAX6675/MAX6675.cpp @@ -1,15 +1,12 @@ // // FILE: MAX6675.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.1.1 +// VERSION: 0.1.2 // PURPOSE: Arduino library for MAX6675 chip for K type thermocouple // DATE: 2022-01-11 // URL: https://github.com/RobTillaart/MAX6675 // -// HISTORY: -// 0.1.0 2022-01-11 initial version. -// 0.1.1 2022-04-20 updated documentation after tests with UNO. -// added examples. +// HISTORY: see changelog.md #include "MAX6675.h" @@ -46,19 +43,19 @@ void MAX6675::begin(const uint8_t clock, const uint8_t select, const uint8_t mis if (_hwSPI) { #if defined(ESP32) - if (_useHSPI) // HSPI + if (_useHSPI) // HSPI { mySPI = new SPIClass(HSPI); mySPI->end(); - mySPI->begin(14, 12, 13, _select); // CLK=14 MISO=12 MOSI=13 + mySPI->begin(14, 12, 13, _select); // CLK=14 MISO=12 MOSI=13 } - else // VSPI + else // VSPI { mySPI = new SPIClass(VSPI); mySPI->end(); - mySPI->begin(18, 19, 23, _select); // CLK=18 MISO=19 MOSI=23 + mySPI->begin(18, 19, 23, _select); // CLK=18 MISO=19 MOSI=23 } - #else // generic hardware SPI + #else // generic hardware SPI mySPI = &SPI; mySPI->end(); mySPI->begin(); @@ -99,14 +96,14 @@ void MAX6675::setGPIOpins(uint8_t clock, uint8_t miso, uint8_t mosi, uint8_t sel uint8_t MAX6675::read() { - // return value of _read() page 5 datasheet - // BITS DESCRIPTION - // ---------------------- - // 00 three state ? - // 01 device ID ? - // 02 INPUT OPEN - // 03 - 14 TEMPERATURE (RAW) - // 15 SIGN + // return value of _read() page 5 datasheet + // BITS DESCRIPTION + // ------------------------------ + // 00 three state ? + // 01 device ID ? + // 02 INPUT OPEN + // 03 - 14 TEMPERATURE (RAW) + // 15 SIGN uint16_t value = _read(); // needs a pull up on MISO pin to work properly! @@ -123,10 +120,10 @@ uint8_t MAX6675::read() value >>= 3; - // process temperature bits + // process temperature bits _temperature = (value & 0x1FFF) * 0.25; - // dummy negative flag set ? - // if (value & 0x2000) + // dummy negative flag set ? + // if (value & 0x2000) return _status; } @@ -134,7 +131,7 @@ uint8_t MAX6675::read() uint32_t MAX6675::_read(void) { _rawData = 0; - // DATA TRANSFER + // DATA TRANSFER if (_hwSPI) { mySPI->beginTransaction(_spi_settings); @@ -145,10 +142,10 @@ uint32_t MAX6675::_read(void) digitalWrite(_select, HIGH); mySPI->endTransaction(); } - else // Software SPI + else // Software SPI { - // split _swSPIdelay in equal dLow and dHigh - // dLow should be longer one when _swSPIdelay = odd. + // split _swSPIdelay in equal dLow and dHigh + // dLow should be longer one when _swSPIdelay = odd. uint16_t dHigh = _swSPIdelay/2; uint16_t dLow = _swSPIdelay - dHigh; digitalWrite(_select, LOW); @@ -156,10 +153,10 @@ uint32_t MAX6675::_read(void) { _rawData <<= 1; digitalWrite(_clock, LOW); - if (dLow > 0) delayMicroseconds(dLow); // DUE might need 1 us + if (dLow > 0) delayMicroseconds(dLow); // DUE might need 1 us if ( digitalRead(_miso) ) _rawData++; digitalWrite(_clock, HIGH); - if (dHigh > 0) delayMicroseconds(dHigh); // DUE + if (dHigh > 0) delayMicroseconds(dHigh); // DUE } digitalWrite(_select, HIGH); } diff --git a/libraries/MAX6675/MAX6675.h b/libraries/MAX6675/MAX6675.h index 1de0416c..b84bddee 100644 --- a/libraries/MAX6675/MAX6675.h +++ b/libraries/MAX6675/MAX6675.h @@ -2,33 +2,33 @@ // // FILE: MAX6675.h // AUTHOR: Rob Tillaart -// VERSION: 0.1.1 +// VERSION: 0.1.2 // PURPOSE: Arduino library for MAX6675 chip for K type thermocouple // DATE: 2022-01-12 // URL: https://github.com/RobTillaart/MAX6675 -// TODO Breakout board +// TODO Breakout board // -// +---------+ -// Vin | o | -// 3V3 | o | -// GND | o O | Thermocouple -// D0 | o O | Thermocouple -// CS | o | -// CLK | o | -// +---------+ +// +---------+ +// Vin | o | +// 3V3 | o | +// GND | o O | Thermocouple +// D0 | o O | Thermocouple +// CS | o | +// CLK | o | +// +---------+ #include "Arduino.h" #include "SPI.h" -#define MAX6675_LIB_VERSION (F("0.1.1")) +#define MAX6675_LIB_VERSION (F("0.1.2")) #define MAX6675_NO_TEMPERATURE -999 -// STATE constants returned by read() -// TODO check +// STATE constants returned by read() +// TODO check #define STATUS_OK 0x00 #define STATUS_ERROR 0x04 #define STATUS_NOREAD 0x80 @@ -53,13 +53,13 @@ public: // SW SPI void begin(uint8_t clock, uint8_t select, uint8_t miso); - // returns state - bit field: 0 = STATUS_OK + // returns state - bit field: 0 = STATUS_OK uint8_t read(); float getTemperature(void) { return _temperature + _offset; }; uint8_t getStatus(void) const { return _status; }; - // use offset to calibrate the TC. + // use offset to calibrate the TC. void setOffset(const float t) { _offset = t; }; float getOffset() const { return _offset; }; @@ -80,7 +80,7 @@ public: bool usesHSPI() { return _useHSPI; }; bool usesVSPI() { return !_useHSPI; }; - // to overrule ESP32 default hardware pins + // to overrule ESP32 default hardware pins void setGPIOpins(uint8_t clock, uint8_t miso, uint8_t mosi, uint8_t select); #endif diff --git a/libraries/MAX6675/README.md b/libraries/MAX6675/README.md index 6db7337a..61a69b05 100644 --- a/libraries/MAX6675/README.md +++ b/libraries/MAX6675/README.md @@ -14,7 +14,8 @@ The library is based upon (stripped and adapted version of) the https://github.c Currently the library is experimental, so use with care. -Hardware has finally arrived (April 2022) and I had time to do my first round of tests with an UNO @ 16 MHz. The library works and it reads temperatures well, both with HW SPI and SW SPI. +Hardware has finally arrived (April 2022) and I had time to do my first round of tests with an UNO @ 16 MHz. +The library works and it reads temperatures well, both with HW SPI and SW SPI. ## Description diff --git a/libraries/MAX6675/library.json b/libraries/MAX6675/library.json index a70f9b93..d2ed0cb2 100644 --- a/libraries/MAX6675/library.json +++ b/libraries/MAX6675/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/MAX6675" }, - "version": "0.1.1", + "version": "0.1.2", "license": "MIT", "frameworks": "arduino", "platforms": "*", diff --git a/libraries/MAX6675/library.properties b/libraries/MAX6675/library.properties index cc94fd55..2a95e4eb 100644 --- a/libraries/MAX6675/library.properties +++ b/libraries/MAX6675/library.properties @@ -1,5 +1,5 @@ name=MAX6675 -version=0.1.1 +version=0.1.2 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for MAX6675 chip for K type thermocouple. diff --git a/libraries/MAX6675/test/unit_test_001.cpp b/libraries/MAX6675/test/unit_test_001.cpp index 9e3d951b..0d860d75 100644 --- a/libraries/MAX6675/test/unit_test_001.cpp +++ b/libraries/MAX6675/test/unit_test_001.cpp @@ -46,18 +46,6 @@ unittest_teardown() { } -/* -unittest(test_new_operator) -{ - assertEqualINF(exp(800)); - assertEqualINF(0.0/0.0); - assertEqualINF(42); - - assertEqualNAN(INFINITY - INFINITY); - assertEqualNAN(0.0/0.0); - assertEqualNAN(42); -} -*/ unittest(test_constants) { @@ -65,7 +53,7 @@ unittest(test_constants) assertEqual(0x04, STATUS_ERROR); assertEqual(0x80, STATUS_NOREAD); assertEqual(0x81, STATUS_NO_COMMUNICATION); - + assertEqual(-999, MAX6675_NO_TEMPERATURE); } @@ -137,4 +125,5 @@ unittest(test_SPIspeed_SWSPIdelay) unittest_main() -// -------- + +// -- END OF FILE --