From f04d43c39597d139719f4aed15ffe5e20b7ac73b Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Mon, 18 Dec 2023 15:48:44 +0100 Subject: [PATCH] fix #18, rename analogRead() to read() (#19) - fix #18, support for Arduino ESP32 S3 - breaking change - update examples - Fix #17, readme.md --- CHANGELOG.md | 7 + MCP_ADC.cpp | 6 +- MCP_ADC.h | 28 ++-- README.md | 123 ++++++++---------- .../MCP3002_analogRead/MCP3002_analogRead.ino | 4 +- .../MCP3008_analogRead/MCP3008_analogRead.ino | 4 +- .../MCP3008_analogRead_ESP32_HWSPI.ino | 2 +- .../MCP3008_analogRead_ESP32_SWSPI.ino | 2 +- .../MCP3201_analogRead/MCP3201_analogRead.ino | 8 +- .../MCP3208_performance.ino | 24 ++-- .../MCP_ADC_performance.ino | 24 ++-- library.json | 2 +- library.properties | 2 +- test/unit_test_001.cpp | 2 +- 14 files changed, 121 insertions(+), 117 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e399772..2ba930b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.4.0] - 2023-12-18 +- fix #18, support for Arduino ESP32 S3 - breaking change +- update examples +- Fix #17, readme.md + +---- + ## [0.3.0] - 2023-11-29 - refactor constructor interface - breaking changes. - minimize conditional code. -- create SPI_CLASS macro to solve it. diff --git a/MCP_ADC.cpp b/MCP_ADC.cpp index 086bdbf..5801153 100644 --- a/MCP_ADC.cpp +++ b/MCP_ADC.cpp @@ -1,7 +1,7 @@ // // FILE: MCP_ADC.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.3.0 +// VERSION: 0.4.0 // DATE: 2019-10-24 // PURPOSE: Arduino library for MCP3001, MCP3002, MCP3004, MCP3008, MCP3201, MCP3202, MCP3204, MCP3208 // URL: https://github.com/RobTillaart/MCP_ADC @@ -80,14 +80,14 @@ uint32_t MCP_ADC::count() } -int16_t MCP_ADC::analogRead(uint8_t channel) +int16_t MCP_ADC::read(uint8_t channel) { if (channel >= _channels) return 0; return readADC(channel, true); } -void MCP_ADC::analogReadMultiple(uint8_t channels[], uint8_t numChannels, int16_t readings[]) +void MCP_ADC::readMultiple(uint8_t channels[], uint8_t numChannels, int16_t readings[]) { readADCMultiple(channels, numChannels, readings); } diff --git a/MCP_ADC.h b/MCP_ADC.h index 7bbd270..4ad6051 100644 --- a/MCP_ADC.h +++ b/MCP_ADC.h @@ -2,18 +2,24 @@ // // FILE: MCP_ADC.h // AUTHOR: Rob Tillaart -// VERSION: 0.3.0 +// VERSION: 0.4.0 // DATE: 2019-10-24 // PURPOSE: Arduino library for MCP3001, MCP3002, MCP3004, MCP3008, MCP3201, MCP3202, MCP3204, MCP3208 // URL: https://github.com/RobTillaart/MCP_ADC // +// #if defined(BOARD_HAS_PIN_REMAP) && !defined(BOARD_USES_HW_GPIO_NUMBERS) +// #error please read readme.md for Arduino NANO ESP32 bug +// #endif + + #include "Arduino.h" #include "SPI.h" -#define MCP_ADC_LIB_VERSION (F("0.3.0")) +#define MCP_ADC_LIB_VERSION (F("0.4.0")) + #ifndef __SPI_CLASS__ #if defined(ARDUINO_ARCH_RP2040) @@ -37,8 +43,8 @@ class MCP_ADC uint8_t channels(); int16_t maxValue(); - int16_t analogRead(uint8_t channel); - void analogReadMultiple(uint8_t channels[], uint8_t numChannels, int16_t readings[]); + int16_t read(uint8_t channel); + void readMultiple(uint8_t channels[], uint8_t numChannels, int16_t readings[]); int16_t differentialRead(uint8_t channel); int16_t deltaRead(uint8_t channel); @@ -94,7 +100,7 @@ class MCP3002 : public MCP_ADC { public: MCP3002(__SPI_CLASS__ * mySPI = &SPI); - MCP3002(uint8_t dataIn, uint8_t dataOut, uint8_t clock); + MCP3002(uint8_t dataIn, uint8_t dataOut, uint8_t clock); uint8_t buildRequest(uint8_t channel, bool single, uint8_t * data); }; @@ -103,7 +109,7 @@ class MCP3004 : public MCP_ADC { public: MCP3004(__SPI_CLASS__ * mySPI = &SPI); - MCP3004(uint8_t dataIn, uint8_t dataOut, uint8_t clock); + MCP3004(uint8_t dataIn, uint8_t dataOut, uint8_t clock); uint8_t buildRequest(uint8_t channel, bool single, uint8_t * data); }; @@ -112,7 +118,7 @@ class MCP3008 : public MCP_ADC { public: MCP3008(__SPI_CLASS__ * mySPI = &SPI); - MCP3008(uint8_t dataIn, uint8_t dataOut, uint8_t clock); + MCP3008(uint8_t dataIn, uint8_t dataOut, uint8_t clock); uint8_t buildRequest(uint8_t channel, bool single, uint8_t * data); }; @@ -121,7 +127,7 @@ class MCP3201 : public MCP_ADC { public: MCP3201(__SPI_CLASS__ * mySPI = &SPI); - MCP3201(uint8_t dataIn, uint8_t dataOut, uint8_t clock); + MCP3201(uint8_t dataIn, uint8_t dataOut, uint8_t clock); uint8_t buildRequest(uint8_t channel, bool single, uint8_t * data); }; @@ -130,7 +136,7 @@ class MCP3202 : public MCP_ADC { public: MCP3202(__SPI_CLASS__ * mySPI = &SPI); - MCP3202(uint8_t dataIn, uint8_t dataOut, uint8_t clock); + MCP3202(uint8_t dataIn, uint8_t dataOut, uint8_t clock); uint8_t buildRequest(uint8_t channel, bool single, uint8_t * data); }; @@ -139,7 +145,7 @@ class MCP3204 : public MCP_ADC { public: MCP3204(__SPI_CLASS__ * mySPI = &SPI); - MCP3204(uint8_t dataIn, uint8_t dataOut, uint8_t clock); + MCP3204(uint8_t dataIn, uint8_t dataOut, uint8_t clock); uint8_t buildRequest(uint8_t channel, bool single, uint8_t * data); }; @@ -148,7 +154,7 @@ class MCP3208 : public MCP_ADC { public: MCP3208(__SPI_CLASS__ * mySPI = &SPI); - MCP3208(uint8_t dataIn, uint8_t dataOut, uint8_t clock); + MCP3208(uint8_t dataIn, uint8_t dataOut, uint8_t clock); uint8_t buildRequest(uint8_t channel, bool single, uint8_t * data); }; diff --git a/README.md b/README.md index ea73021..31ac244 100644 --- a/README.md +++ b/README.md @@ -17,32 +17,53 @@ Arduino library for MCP3001 MCP3002 MCP3004 MCP3008 MCP3201 MCP3202 MCP3204 MCP3 ## Description This library reads the ADC ports of the MCP ADC convertors. -The chips are communicates with SPI and support both hardware SPI or optional software SPI. +The chips are 1 to 8 channels, 10 or 12 bit and communicates with SPI. +The library supports both hardware SPI and software SPI. -| type | bits | chan | notes | -|:----------|:------:|:------:|:--------| -| MCP3001 | 10 | 1 | not tested yet. -| MCP3002 | 10 | 2 | -| MCP3004 | 10 | 4 | -| MCP3008 | 10 | 8 | -| MCP3201 | 12 | 1 | test, see #13 -| MCP3202 | 12 | 2 | -| MCP3204 | 12 | 4 | -| MCP3208 | 12 | 8 | +| type | bits | channels | notes | +|:----------|:------:|:----------:|:--------| +| MCP3001 | 10 | 1 | not tested yet. +| MCP3002 | 10 | 2 | +| MCP3004 | 10 | 4 | +| MCP3008 | 10 | 8 | +| MCP3201 | 12 | 1 | test, see #13 +| MCP3202 | 12 | 2 | +| MCP3204 | 12 | 4 | +| MCP3208 | 12 | 8 | Current version allows manual override of the hardware SPI clock as the speed is not optimized per ADC type. -The MCP ADC allow single mode which compares voltage of a single channel against GND. +The MCP ADC's allow a single mode read which compares voltage of a single channel against GND. Furthermore they allow a differential mode which compares two channels **IN+** and **IN-** -to each other. if the **IN+** is equal or below **IN-** the ADC will return 0. +to each other. +If the **IN+** is equal or below **IN-** the ADC will return 0. Build into the library is a delta mode which is a software enhanced differential mode. This delta mode can return negative values too. +#### 0.4.0 Breaking change + +The version 0.4.0 has breaking changes in the interface. +The rationale is that the programming environment of the **Arduino ESP32 S3** +board uses a remapping by means of the include file **io_pin_remap.h**. +This file remaps the pins of several core Arduino functions. +The remapping is implemented by #define macros and these implement "hard" text +replacements without considering context. +The effect is that methods from this class (and several others) which have the same +name as those Arduino core functions will be remapped into something not working. + +The following library functions have been renamed: + +| old name | new name | notes | +|:----------------------|:-----------------|:--------| +| analogRead() | read() | bugfix. +| analogReadMultiple() | readMultiple() | for consistency. + + #### 0.3.0 Breaking change The version 0.3.0 has breaking changes in the interface. @@ -88,8 +109,8 @@ This makes it easy to calculate relative measurements. #### Base -- **int16_t analogRead(uint8_t channel)** reads the value of a single channel. -- **void analogReadMultiple(uint8_t channels[], uint8_t numChannels, int16_t readings[])** +- **int16_t read(uint8_t channel)** reads the value of a single channel. +- **void readMultiple(uint8_t channels[], uint8_t numChannels, int16_t readings[])** reads multiple channels in one call. See section below. - **int16_t differentialRead(uint8_t channel)** reads differential between two channels. Check datasheet for details. @@ -103,55 +124,25 @@ of the ADC first to get optimal speed. ### Differential channel table: -| Channel | diff IN+ | diff IN- | MCP | -|:-------:|:--------:|:--------:|---------------:| -| 0 | 0 | 1 | 3x02/3x04/3x08 | -| 1 | 1 | 0 | 3x02/3x04/3x08 | -| 2 | 2 | 3 | 3x04/3x08 | -| 3 | 3 | 2 | 3x04/3x08 | -| 4 | 4 | 5 | 3x08 | -| 5 | 5 | 4 | 3x08 | -| 6 | 6 | 7 | 3x08 | -| 7 | 7 | 6 | 3x08 | - -Note: the MCP3x01 are not included in this table, not investigated yet. - - -### Debug +| Channel | diff IN+ | diff IN- | 3x02 | 3x04 | 3x08 | +|:-------:|:--------:|:--------:|:----:|:----:|:----:| +| 0 | 0 | 1 | V | V | V | +| 1 | 1 | 0 | V | V | V | +| 2 | 2 | 3 | | V | V | +| 3 | 3 | 2 | | V | V | +| 4 | 4 | 5 | | | V | +| 5 | 5 | 4 | | | V | +| 6 | 6 | 7 | | | V | +| 7 | 7 | 6 | | | V | -- **bool usesHWSPI()** returns true if HW SPI is used. -- **uint32_t count()** returns number of channels read since start. +Note: the MCP3x01 ADC's are not included in this table, not investigated yet. -### ESP32 specific -- **void selectHSPI()** in case hardware SPI, the ESP32 has two options HSPI and VSPI. -- **void selectVSPI()** see above. -- **bool usesHSPI()** returns true if HSPI is used. -- **bool usesVSPI()** returns true if VSPI is used. - -The **selectVSPI()** or the **selectHSPI()** needs to be called -BEFORE the **begin()** function. - - -#### setGPIOpins() experimental - -- **void setGPIOpins(uint8_t clk, uint8_t miso, uint8_t mosi, uint8_t select)** -overrule GPIO pins of ESP32 for hardware SPI. -This function needs to be called AFTER the **begin()** function. - -in code: -```cpp -void setup() -{ - MCP.selectVSPI(); - MCP.begin(15); - MCP.setGPIOpins(CLK, MISO, MOSI, SELECT); // SELECT should match the parameter of begin() -} -``` +### Debug -This implementation might change in the future, e.g. leave out the select pin as it is -already known in the code. +- **bool usesHWSPI()** returns true if hardware SPI is used. +- **uint32_t count()** returns number of channels reads since start. ## About SPI Speed @@ -159,12 +150,12 @@ already known in the code. See https://github.com/RobTillaart/MCP_ADC/issues/3 The default SPI speed is reduced to 1 MHz. -This is the value recommended in the datasheet for 2.7V. +This is the value recommended in the datasheet for 2.7 Volt. In a test with an ESP32 (3.3V) the library showed stable results at 4 MHz and at 6 MHz it was almost good. -The maximum value read at 6 MHz was 1020 instead of 1023 (MCP3008) +The maximum value read at 6 MHz was 1020 instead of 1023 (MCP3008) which indicates that the last 2 bits got lost probably due to signal deformation. @@ -177,9 +168,9 @@ deformation. For hardware SPI the ESP32 uses the VSPI pins. (see ESP examples). -## analogReadMultiple() +## ReadMultiple() -Since version 0.2.0 the **analogReadMultiple(channels[], numChannels, readings[])** +Since version 0.2.0 the **readMultiple(channels[], numChannels, readings[])** is added to the interface. (See https://github.com/RobTillaart/MCP_ADC/pull/11 - Thanks to Alex Uta). @@ -192,7 +183,7 @@ the data from a specific channel multiple times, e.g. to be averaged. Other patterns are possible. These scenarios need still to be tested in practice. -Finally **analogReadMultiple()** can be used to read only one channel too +Finally **readMultiple()** can be used to read only one channel too by using numChannels = 1. @@ -204,7 +195,7 @@ was not correct. This has been fixed in the 0.2.1 version. Note that not all function calls make sense for the MCP3201 and MCP3001 as these -devices only have one channel. So use the library carefully. +devices only have one channel. So use the library carefully with these ADC's. Feedback is as always welcome. @@ -214,7 +205,7 @@ Feedback is as always welcome. #### Must - improve documentation -- test analogReadMultiple() scenario's +- test readMultiple() scenario's - MCP3201 buy hardware and test #### Should diff --git a/examples/MCP3002_analogRead/MCP3002_analogRead.ino b/examples/MCP3002_analogRead/MCP3002_analogRead.ino index a8af545..f49efa4 100644 --- a/examples/MCP3002_analogRead/MCP3002_analogRead.ino +++ b/examples/MCP3002_analogRead/MCP3002_analogRead.ino @@ -40,7 +40,7 @@ void loop() Serial.print("mcp1:\t"); for (int channel = 0 ; channel < mcp1.channels(); channel++) { - uint16_t val = mcp1.analogRead(channel); + uint16_t val = mcp1.read(channel); Serial.print(val); Serial.print("\t"); } @@ -48,7 +48,7 @@ void loop() Serial.print("mcp2:\t"); for (int channel = 0 ; channel < mcp2.channels(); channel++) { - uint16_t val = mcp2.analogRead(channel); + uint16_t val = mcp2.read(channel); Serial.print(val); Serial.print("\t"); } diff --git a/examples/MCP3008_analogRead/MCP3008_analogRead.ino b/examples/MCP3008_analogRead/MCP3008_analogRead.ino index 6151c96..4a7d66b 100644 --- a/examples/MCP3008_analogRead/MCP3008_analogRead.ino +++ b/examples/MCP3008_analogRead/MCP3008_analogRead.ino @@ -39,7 +39,7 @@ void loop() Serial.print("mcp1:\t"); for (int channel = 0 ; channel < mcp1.channels(); channel++) { - uint16_t val = mcp1.analogRead(channel); + uint16_t val = mcp1.read(channel); Serial.print(val); Serial.print("\t"); } @@ -47,7 +47,7 @@ void loop() Serial.print("mcp2:\t"); for (int channel = 0 ; channel < mcp2.channels(); channel++) { - uint16_t val = mcp2.analogRead(channel); + uint16_t val = mcp2.read(channel); Serial.print(val); Serial.print("\t"); } diff --git a/examples/MCP3008_analogRead_ESP32_HWSPI/MCP3008_analogRead_ESP32_HWSPI.ino b/examples/MCP3008_analogRead_ESP32_HWSPI/MCP3008_analogRead_ESP32_HWSPI.ino index 51dc55f..b04b320 100644 --- a/examples/MCP3008_analogRead_ESP32_HWSPI/MCP3008_analogRead_ESP32_HWSPI.ino +++ b/examples/MCP3008_analogRead_ESP32_HWSPI/MCP3008_analogRead_ESP32_HWSPI.ino @@ -52,7 +52,7 @@ void loop() Serial.print("\tmcp1:\t"); for (int channel = 0 ; channel < mcp1.channels(); channel++) { - uint16_t val = mcp1.analogRead(channel); + uint16_t val = mcp1.read(channel); Serial.print(val); Serial.print("\t"); delay(1); // added so single reads are better visible on a scope diff --git a/examples/MCP3008_analogRead_ESP32_SWSPI/MCP3008_analogRead_ESP32_SWSPI.ino b/examples/MCP3008_analogRead_ESP32_SWSPI/MCP3008_analogRead_ESP32_SWSPI.ino index e675b5c..ad6aec1 100644 --- a/examples/MCP3008_analogRead_ESP32_SWSPI/MCP3008_analogRead_ESP32_SWSPI.ino +++ b/examples/MCP3008_analogRead_ESP32_SWSPI/MCP3008_analogRead_ESP32_SWSPI.ino @@ -49,7 +49,7 @@ void loop() Serial.print("\tmcp1:\t"); for (int channel = 0 ; channel < mcp1.channels(); channel++) { - uint16_t val = mcp1.analogRead(channel); + uint16_t val = mcp1.read(channel); Serial.print(val); Serial.print("\t"); delay(1); // added so single reads are better visible on a scope diff --git a/examples/MCP3201_analogRead/MCP3201_analogRead.ino b/examples/MCP3201_analogRead/MCP3201_analogRead.ino index ed04a26..64e5b55 100644 --- a/examples/MCP3201_analogRead/MCP3201_analogRead.ino +++ b/examples/MCP3201_analogRead/MCP3201_analogRead.ino @@ -30,7 +30,7 @@ void setup() Serial.println(mcp1.maxValue()); delay(10); start = micros(); - uint16_t val = mcp1.analogRead(0); + uint16_t val = mcp1.read(0); stop = micros(); Serial.print("hwspi:\t"); Serial.print(stop - start); @@ -43,7 +43,7 @@ void setup() Serial.println(mcp2.maxValue()); delay(10); start = micros(); - val = mcp2.analogRead(0); + val = mcp2.read(0); stop = micros(); Serial.print("swspi:\t"); Serial.print(stop - start); @@ -59,7 +59,7 @@ void loop() Serial.print("mcp1:\t"); for (int channel = 0 ; channel < mcp1.channels(); channel++) { - uint16_t val = mcp1.analogRead(channel); + uint16_t val = mcp1.read(channel); Serial.print(val); Serial.print("\t"); } @@ -67,7 +67,7 @@ void loop() Serial.print("mcp2:\t"); for (int channel = 0 ; channel < mcp2.channels(); channel++) { - uint16_t val = mcp2.analogRead(channel); + uint16_t val = mcp2.read(channel); Serial.print(val); Serial.print("\t"); } diff --git a/examples/MCP3208_performance/MCP3208_performance.ino b/examples/MCP3208_performance/MCP3208_performance.ino index 3133963..9760e24 100644 --- a/examples/MCP3208_performance/MCP3208_performance.ino +++ b/examples/MCP3208_performance/MCP3208_performance.ino @@ -64,12 +64,12 @@ void test() start = micros(); for (int channel = 0; channel < mcp28.channels(); channel++) { - val += mcp28.analogRead(channel); + val += mcp28.read(channel); } stop = micros(); analog_read_time = stop - start; - Serial.print("mcp28.analogRead()\t8x: \t"); + Serial.print("mcp28.read()\t8x: \t"); Serial.println(analog_read_time); delay(10); @@ -77,14 +77,14 @@ void test() start = micros(); int16_t readings[num_channels]; - mcp28.analogReadMultiple(channels_list, num_channels, readings); + mcp28.readMultiple(channels_list, num_channels, readings); stop = micros(); analog_read_multiple_time = stop - start; - Serial.print("mcp28.analogReadMultiple()\t8x: \t"); + Serial.print("mcp28.readMultiple()\t8x: \t"); Serial.println(stop - start); - Serial.print("analogRead() time / analogReadMultiple() time \t"); + Serial.print("read() time / readMultiple() time \t"); Serial.println((1.0 * analog_read_time) / analog_read_multiple_time); delay(10); @@ -124,21 +124,21 @@ void testChannelsRead() { delay(10); - // analogRead() + // read() start = micros(); for (uint8_t i = 0; i < numChannelsToRead; i++) { - mcp28.analogRead(i); + mcp28.read(i); } stop = micros(); analog_read_time = stop - start; - Serial.print("mcp28.analogRead()\t"); + Serial.print("mcp28.read()\t"); Serial.print(numChannelsToRead); Serial.print(": \t"); Serial.print(analog_read_time); Serial.println(""); - // analogReadMultiple() + // readMultiple() uint8_t channels_list[numChannelsToRead]; for (uint8_t i = 0; i < numChannelsToRead; i++) { channels_list[i] = i; @@ -148,16 +148,16 @@ void testChannelsRead() { int16_t readings[numChannelsToRead]; start = micros(); - mcp28.analogReadMultiple(channels_list, numChannelsToRead, readings); + mcp28.readMultiple(channels_list, numChannelsToRead, readings); stop = micros(); analog_read_multiple_time = stop - start; - Serial.print("mcp28.analogReadMultiple()\t"); + Serial.print("mcp28.readMultiple()\t"); Serial.print(numChannelsToRead); Serial.print(": \t"); Serial.println(analog_read_multiple_time); - Serial.print("analogRead() time / analogReadMultiple() time \t"); + Serial.print("read() time / readMultiple() time \t"); Serial.println((1.0 * analog_read_time) / analog_read_multiple_time, 2); // print as float Serial.println("\n"); diff --git a/examples/MCP_ADC_performance/MCP_ADC_performance.ino b/examples/MCP_ADC_performance/MCP_ADC_performance.ino index 6626a06..d8726aa 100644 --- a/examples/MCP_ADC_performance/MCP_ADC_performance.ino +++ b/examples/MCP_ADC_performance/MCP_ADC_performance.ino @@ -126,10 +126,10 @@ void test_1() start = micros(); for (int channel = 0 ; channel < mcp2.channels(); channel++) { - val += mcp2.analogRead(channel); + val += mcp2.read(channel); } stop = micros(); - Serial.print("mcp2.analogRead()\t2x: \t"); + Serial.print("mcp2.read()\t2x: \t"); Serial.println(stop - start); delay(10); @@ -163,10 +163,10 @@ void test_2() start = micros(); for (int channel = 0 ; channel < mcp4.channels(); channel++) { - val += mcp4.analogRead(channel); + val += mcp4.read(channel); } stop = micros(); - Serial.print("mcp4.analogRead()\t4x: \t"); + Serial.print("mcp4.read()\t4x: \t"); Serial.println(stop - start); delay(10); @@ -200,10 +200,10 @@ void test_3() start = micros(); for (int channel = 0; channel < mcp8.channels(); channel++) { - val += mcp8.analogRead(channel); + val += mcp8.read(channel); } stop = micros(); - Serial.print("mcp8.analogRead()\t8x: \t"); + Serial.print("mcp8.read()\t8x: \t"); Serial.println(stop - start); delay(10); @@ -237,10 +237,10 @@ void test_4() start = micros(); for (int channel = 0; channel < mcp22.channels(); channel++) { - val += mcp22.analogRead(channel); + val += mcp22.read(channel); } stop = micros(); - Serial.print("mcp22.analogRead()\t2x: \t"); + Serial.print("mcp22.read()\t2x: \t"); Serial.println(stop - start); delay(10); @@ -274,10 +274,10 @@ void test_5() start = micros(); for (int channel = 0; channel < mcp24.channels(); channel++) { - val += mcp24.analogRead(channel); + val += mcp24.read(channel); } stop = micros(); - Serial.print("mcp24.analogRead()\t4x: \t"); + Serial.print("mcp24.read()\t4x: \t"); Serial.println(stop - start); delay(10); @@ -311,10 +311,10 @@ void test_6() start = micros(); for (int channel = 0; channel < mcp28.channels(); channel++) { - val += mcp28.analogRead(channel); + val += mcp28.read(channel); } stop = micros(); - Serial.print("mcp28.analogRead()\t8x: \t"); + Serial.print("mcp28.read()\t8x: \t"); Serial.println(stop - start); delay(10); diff --git a/library.json b/library.json index b34e724..71d54ab 100644 --- a/library.json +++ b/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/MCP_ADC.git" }, - "version": "0.3.0", + "version": "0.4.0", "license": "MIT", "frameworks": "*", "platforms": "*", diff --git a/library.properties b/library.properties index 8090d9e..2c6200c 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=MCP_ADC -version=0.3.0 +version=0.4.0 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for MCP_ADC, e.g. MCP3008 SPI 10 bit, 8 channel ADC diff --git a/test/unit_test_001.cpp b/test/unit_test_001.cpp index 55b8582..bc1b755 100644 --- a/test/unit_test_001.cpp +++ b/test/unit_test_001.cpp @@ -87,7 +87,7 @@ unittest(test_MCP3002) for (int ch = 0; ch < mcp_adc.channels(); ch++) { - assertEqual(0, mcp_adc.analogRead(ch)); + assertEqual(0, mcp_adc.read(ch)); } for (int ch = 0; ch < mcp_adc.channels(); ch++)