From c95bb77987758d884197626a87ae85a41c7d3627 Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Fri, 19 Jan 2024 18:34:04 +0100 Subject: [PATCH] Improve SPI dependency (#32) - Fix #31, improve SPI dependency --- CHANGELOG.md | 5 +++++ LICENSE | 2 +- MAX31855.cpp | 8 ++++---- MAX31855.h | 4 ++-- README.md | 7 +++++++ examples/Demo_getRawData/Demo_getRawData.ino | 3 ++- examples/max31855_ESP32_HSPI/max31855_ESP32_HSPI.ino | 2 ++ examples/max31855_ESP32_VSPI/max31855_ESP32_VSPI.ino | 2 ++ examples/max31855_array/max31855_array.ino | 3 ++- examples/max31855_demo0/max31855_demo0.ino | 2 ++ examples/max31855_demo1/max31855_demo1.ino | 2 ++ examples/max31855_demo2/max31855_demo2.ino | 2 ++ examples/max31855_demo3/max31855_demo3.ino | 2 ++ examples/max31855_demo4/max31855_demo4.ino | 2 ++ examples/max31855_demo5/max31855_demo5.ino | 2 ++ examples/max31855_demo6/max31855_demo6.ino | 2 ++ examples/max31855_hwSPI/max31855_hwSPI.ino | 2 ++ examples/max31855_swSPI/max31855_swSPI.ino | 2 ++ examples/max31855_test_error/max31855_test_error.ino | 4 +++- library.json | 2 +- library.properties | 2 +- 21 files changed, 50 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3c9736..7fd4ffd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.6.0] - 2024-01-19 +- Fix #31, improve SPI dependency + +---- + ## [0.5.0] - 2023-11-29 - refactor constructor/begin interface - breaking changes. - minimize conditional code. -- create SPI_CLASS macro to solve it. diff --git a/LICENSE b/LICENSE index 2c8ea30..82b1f19 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2014-2023 Rob Tillaart +Copyright (c) 2014-2024 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 580ff44..f683056 100644 --- a/MAX31855.cpp +++ b/MAX31855.cpp @@ -1,7 +1,7 @@ // // FILE: MAX31855.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.5.0 +// VERSION: 0.6.0 // PURPOSE: Arduino library for MAX31855 chip for K type thermocouple // DATE: 2014-01-01 // URL: https://github.com/RobTillaart/MAX31855_RT @@ -48,9 +48,9 @@ void MAX31855::begin() if (_hwSPI) { - _mySPI->end(); - _mySPI->begin(); - delay(1); + // _mySPI->end(); + // _mySPI->begin(); + // delay(1); } else { diff --git a/MAX31855.h b/MAX31855.h index 8ccb4b0..8fce4da 100644 --- a/MAX31855.h +++ b/MAX31855.h @@ -2,7 +2,7 @@ // // FILE: MAX31855.h // AUTHOR: Rob Tillaart -// VERSION: 0.5.0 +// VERSION: 0.6.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.5.0")) +#define MAX31855_VERSION (F("0.6.0")) #ifndef __SPI_CLASS__ #if defined(ARDUINO_ARCH_RP2040) diff --git a/README.md b/README.md index 8dcc141..2eba709 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,13 @@ Library tested with breakout board. ``` +#### 0.6.0 Breaking change + +Version 0.6.0 introduced a breaking change to improve handling the SPI dependency. +The user has to call **SPI.begin()** or equivalent before calling **MX.begin()**. +Optionally the user can provide parameters to the **SPI.begin(...)** + + #### 0.5.0 Breaking change The version 0.5.0 has breaking changes in the interface. diff --git a/examples/Demo_getRawData/Demo_getRawData.ino b/examples/Demo_getRawData/Demo_getRawData.ino index cd80ad1..647c006 100644 --- a/examples/Demo_getRawData/Demo_getRawData.ino +++ b/examples/Demo_getRawData/Demo_getRawData.ino @@ -4,7 +4,6 @@ // PURPOSE: thermocouple lib demo application // DATE: 2020-08-24 // URL: https://github.com/RobTillaart/MAX31855_RT -// #include "MAX31855.h" @@ -26,6 +25,8 @@ void setup () Serial.println(); delay(250); + SPI.begin(); + thermoCouple.begin(); } diff --git a/examples/max31855_ESP32_HSPI/max31855_ESP32_HSPI.ino b/examples/max31855_ESP32_HSPI/max31855_ESP32_HSPI.ino index 7465ba8..282e7d0 100644 --- a/examples/max31855_ESP32_HSPI/max31855_ESP32_HSPI.ino +++ b/examples/max31855_ESP32_HSPI/max31855_ESP32_HSPI.ino @@ -52,6 +52,8 @@ void setup() Serial.println(); delay(250); + SPI.begin(); + thermoCouple.begin(); thermoCouple.setSPIspeed(1000000); } diff --git a/examples/max31855_ESP32_VSPI/max31855_ESP32_VSPI.ino b/examples/max31855_ESP32_VSPI/max31855_ESP32_VSPI.ino index caa4979..a81ca83 100644 --- a/examples/max31855_ESP32_VSPI/max31855_ESP32_VSPI.ino +++ b/examples/max31855_ESP32_VSPI/max31855_ESP32_VSPI.ino @@ -49,6 +49,8 @@ void setup() Serial.println(); delay(250); + myspi->begin(); + thermoCouple.begin(); thermoCouple.setSPIspeed(16000000); } diff --git a/examples/max31855_array/max31855_array.ino b/examples/max31855_array/max31855_array.ino index fa737b5..bbe54a6 100644 --- a/examples/max31855_array/max31855_array.ino +++ b/examples/max31855_array/max31855_array.ino @@ -6,7 +6,6 @@ // URL: https://github.com/RobTillaart/MAX31855_RT // // kudos to FabioBrondo for the idea. -// #include "MAX31855.h" @@ -35,6 +34,8 @@ void setup() Serial.println(); delay(250); + SPI.begin(); + Serial.println(sensorCount); for (int i = 0; i < sensorCount; i++) diff --git a/examples/max31855_demo0/max31855_demo0.ino b/examples/max31855_demo0/max31855_demo0.ino index 59c9b5b..2148335 100644 --- a/examples/max31855_demo0/max31855_demo0.ino +++ b/examples/max31855_demo0/max31855_demo0.ino @@ -26,6 +26,8 @@ void setup() Serial.println(); delay(250); + SPI.begin(); + thermoCouple.begin(); } diff --git a/examples/max31855_demo1/max31855_demo1.ino b/examples/max31855_demo1/max31855_demo1.ino index 3d9b00e..4bb5295 100644 --- a/examples/max31855_demo1/max31855_demo1.ino +++ b/examples/max31855_demo1/max31855_demo1.ino @@ -26,6 +26,8 @@ void setup() Serial.println(); delay(250); + SPI.begin(); + thermoCouple.begin(); } diff --git a/examples/max31855_demo2/max31855_demo2.ino b/examples/max31855_demo2/max31855_demo2.ino index f1758f8..02094fa 100644 --- a/examples/max31855_demo2/max31855_demo2.ino +++ b/examples/max31855_demo2/max31855_demo2.ino @@ -27,6 +27,8 @@ void setup() Serial.println(); delay(250); + SPI.begin(); + thermoCouple.begin(); thermoCouple.read(); diff --git a/examples/max31855_demo3/max31855_demo3.ino b/examples/max31855_demo3/max31855_demo3.ino index 90bef5f..aa9487d 100644 --- a/examples/max31855_demo3/max31855_demo3.ino +++ b/examples/max31855_demo3/max31855_demo3.ino @@ -25,6 +25,8 @@ void setup() Serial.println(); delay(250); + SPI.begin(); + thermoCouple.begin(); uint32_t start = micros(); diff --git a/examples/max31855_demo4/max31855_demo4.ino b/examples/max31855_demo4/max31855_demo4.ino index af6a55a..b8bffee 100644 --- a/examples/max31855_demo4/max31855_demo4.ino +++ b/examples/max31855_demo4/max31855_demo4.ino @@ -26,6 +26,8 @@ void setup() Serial.println(); delay(250); + SPI.begin(); + thermoCouple.begin(); uint32_t start = micros(); diff --git a/examples/max31855_demo5/max31855_demo5.ino b/examples/max31855_demo5/max31855_demo5.ino index 626f80d..e86a3ff 100644 --- a/examples/max31855_demo5/max31855_demo5.ino +++ b/examples/max31855_demo5/max31855_demo5.ino @@ -26,6 +26,8 @@ void setup() Serial.println(); delay(250); + SPI.begin(); + thermoCouple.begin(); thermoCouple.read(); diff --git a/examples/max31855_demo6/max31855_demo6.ino b/examples/max31855_demo6/max31855_demo6.ino index a865ada..8f625d6 100644 --- a/examples/max31855_demo6/max31855_demo6.ino +++ b/examples/max31855_demo6/max31855_demo6.ino @@ -26,6 +26,8 @@ void setup() Serial.println(); delay(250); + SPI.begin(); + thermoCouple.begin(); thermoCouple.read(); diff --git a/examples/max31855_hwSPI/max31855_hwSPI.ino b/examples/max31855_hwSPI/max31855_hwSPI.ino index 187c2c1..7ec4f26 100644 --- a/examples/max31855_hwSPI/max31855_hwSPI.ino +++ b/examples/max31855_hwSPI/max31855_hwSPI.ino @@ -48,6 +48,8 @@ void setup() Serial.println(); delay(250); + SPI.begin(); + thermoCouple.begin(); } diff --git a/examples/max31855_swSPI/max31855_swSPI.ino b/examples/max31855_swSPI/max31855_swSPI.ino index cf8e9af..515da62 100644 --- a/examples/max31855_swSPI/max31855_swSPI.ino +++ b/examples/max31855_swSPI/max31855_swSPI.ino @@ -49,6 +49,8 @@ void setup() Serial.println(); delay(250); + SPI.begin(); + thermoCouple.begin(); thermoCouple.setSWSPIdelay(4); // add 4 us per bit to improve signal. } diff --git a/examples/max31855_test_error/max31855_test_error.ino b/examples/max31855_test_error/max31855_test_error.ino index c522fc6..39e2bdc 100644 --- a/examples/max31855_test_error/max31855_test_error.ino +++ b/examples/max31855_test_error/max31855_test_error.ino @@ -26,6 +26,8 @@ void setup() Serial.println(); delay(250); + SPI.begin(); + thermoCouple.begin(); } @@ -35,7 +37,7 @@ void loop() int status = thermoCouple.read(); Serial.print("stat:\t\t"); Serial.println(status); - + if (thermoCouple.getStatus()) { Serial.print("error:\t\t"); diff --git a/library.json b/library.json index 441af4a..79ee47e 100644 --- a/library.json +++ b/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/MAX31855_RT" }, - "version": "0.5.0", + "version": "0.6.0", "license": "MIT", "frameworks": "*", "platforms": "*", diff --git a/library.properties b/library.properties index 17a2f91..d63fb27 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=MAX31855_RT -version=0.5.0 +version=0.6.0 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for MAX31855 chip for K type thermocouple.