From d770aeeeffd0625ff52068a7cfaf08de5734794a Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Mon, 11 Dec 2023 13:54:15 +0100 Subject: [PATCH] 0.3.0 PCA9634 --- libraries/PCA9634/CHANGELOG.md | 11 ++++++-- libraries/PCA9634/PCA9634.cpp | 25 ++++++------------- libraries/PCA9634/PCA9634.h | 10 +++----- libraries/PCA9634/README.md | 11 ++++++-- .../PCA9634_OE_control/PCA9634_OE_control.ino | 6 ++++- .../PCA9634_shift_rotate.ino | 3 +++ .../PCA9634_software_reset.ino | 4 +++ .../PCA9634_test01/PCA9634_test01.ino | 5 +++- .../PCA9634_test_multiple.ino | 5 +++- libraries/PCA9634/library.json | 2 +- libraries/PCA9634/library.properties | 2 +- libraries/PCA9634/test/unit_test_001.cpp | 10 +++++++- 12 files changed, 59 insertions(+), 35 deletions(-) diff --git a/libraries/PCA9634/CHANGELOG.md b/libraries/PCA9634/CHANGELOG.md index a77ae22f..42117403 100644 --- a/libraries/PCA9634/CHANGELOG.md +++ b/libraries/PCA9634/CHANGELOG.md @@ -6,11 +6,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [0.2.8] - 2023-09-24 +## [0.3.0] - 2023-12-11 +- refactor API, begin() +- update readme.md +- add **uint8_t getAddress()** +- minor edits + +---- + +## [0.2.9] - 2023-09-24 - add Wire1 support for ESP32 - update readme.md - ## [0.2.8] - 2023-05-24 - renaming #defines PCA963X... to prepare merge with PCA9634. - old defines will work until next major release diff --git a/libraries/PCA9634/PCA9634.cpp b/libraries/PCA9634/PCA9634.cpp index 29a7e6d2..c87f371e 100644 --- a/libraries/PCA9634/PCA9634.cpp +++ b/libraries/PCA9634/PCA9634.cpp @@ -2,7 +2,7 @@ // FILE: PCA9634.cpp // AUTHOR: Rob Tillaart // DATE: 2022-01-03 -// VERSION: 0.2.9 +// VERSION: 0.3.0 // PURPOSE: Arduino library for PCA9634 I2C LED driver // URL: https://github.com/RobTillaart/PCA9634 @@ -24,25 +24,8 @@ PCA9634::PCA9634(const uint8_t deviceAddress, TwoWire *wire) } -#if defined (ESP8266) || defined(ESP32) -bool PCA9634::begin(int sda, int scl, uint8_t mode1_mask, uint8_t mode2_mask) -{ - if ((sda < 255) && (scl < 255)) - { - _wire->begin(sda, scl); - } else { - _wire->begin(); - } - if (! isConnected()) return false; - configure(mode1_mask, mode2_mask); - return true; -} -#endif - - bool PCA9634::begin(uint8_t mode1_mask, uint8_t mode2_mask) { - _wire->begin(); if (! isConnected()) return false; configure(mode1_mask, mode2_mask); return true; @@ -57,6 +40,12 @@ bool PCA9634::isConnected() } +uint8_t PCA9634::getAddress() +{ + return _address; +} + + ///////////////////////////////////////////////////// // // CONFIGURATION diff --git a/libraries/PCA9634/PCA9634.h b/libraries/PCA9634/PCA9634.h index 8b7a75fc..93e3fb22 100644 --- a/libraries/PCA9634/PCA9634.h +++ b/libraries/PCA9634/PCA9634.h @@ -3,7 +3,7 @@ // FILE: PCA9634.h // AUTHOR: Rob Tillaart // DATE: 2022-01-03 -// VERSION: 0.2.9 +// VERSION: 0.3.0 // PURPOSE: Arduino library for PCA9634 I2C LED driver, 8 channel // URL: https://github.com/RobTillaart/PCA9634 @@ -12,7 +12,7 @@ #include "Wire.h" -#define PCA9634_LIB_VERSION (F("0.2.9")) +#define PCA9634_LIB_VERSION (F("0.3.0")) // mode codes @@ -143,14 +143,10 @@ class PCA9634 public: explicit PCA9634(const uint8_t deviceAddress, TwoWire *wire = &Wire); -#if defined (ESP8266) || defined(ESP32) - bool begin(int sda, int scl, - uint8_t mode1_mask = PCA963X_MODE1_ALLCALL, - uint8_t mode2_mask = PCA963X_MODE2_NONE); -#endif bool begin(uint8_t mode1_mask = PCA963X_MODE1_ALLCALL, uint8_t mode2_mask = PCA963X_MODE2_NONE); bool isConnected(); + uint8_t getAddress(); ///////////////////////////////////////////////////// diff --git a/libraries/PCA9634/README.md b/libraries/PCA9634/README.md index 42278187..26630d8f 100644 --- a/libraries/PCA9634/README.md +++ b/libraries/PCA9634/README.md @@ -22,6 +22,15 @@ This allows for better than 1% fine tuning of the duty-cycle of the PWM signal. +#### 0.3.0 Breaking change + +Version 0.3.0 introduced a breaking change. +You cannot set the pins in **begin()** any more. +This reduces the dependency of processor dependent Wire implementations. +The user has to call **Wire.begin()** and can optionally set the Wire pins +before calling **begin()**. + + #### Related - https://github.com/RobTillaart/PCA9634 (8 channel) @@ -43,8 +52,6 @@ and optional the Wire interface as parameter. - **bool begin(uint8_t mode1_mask = PCA963X_MODE1_ALLCALL, uint8_t mode2_mask = PCA963X_MODE2_NONE)** initializes the library after startup. Optionally setting the MODE1 and MODE2 configuration registers. See PCA9634.h and datasheet for settings possible. -- **bool begin(int sda, int scl, uint8_t mode1_mask = PCA963X_MODE1_ALLCALL, uint8_t mode2_mask = PCA963X_MODE2_NONE)** -idem, ESP32 ESP8266 only. - **void configure(uint8_t mode1_mask, uint8_t mode2_mask)** To configure the library after startup one can set the MODE1 and MODE2 configuration registers. See PCA9634.h and datasheet for settings possible. diff --git a/libraries/PCA9634/examples/PCA9634_OE_control/PCA9634_OE_control.ino b/libraries/PCA9634/examples/PCA9634_OE_control/PCA9634_OE_control.ino index a45262b3..68ec0bdb 100644 --- a/libraries/PCA9634/examples/PCA9634_OE_control/PCA9634_OE_control.ino +++ b/libraries/PCA9634/examples/PCA9634_OE_control/PCA9634_OE_control.ino @@ -1,7 +1,8 @@ // // FILE: PCA9634_OE_control.ino // AUTHOR: Rob Tillaart -// PURPOSE: test PCA9635 library +// PURPOSE: test PCA9634 library +// URL: https://github.com/RobTillaart/PCA9634 #include "Arduino.h" @@ -15,10 +16,13 @@ PCA9634 ledArray(0x20); void setup() { Serial.begin(115200); + Serial.println(__FILE__); Serial.print("PCA9634 LIB version: "); Serial.println(PCA9634_LIB_VERSION); Serial.println(); + Wire.begin(); + ledArray.begin(); // just one channel diff --git a/libraries/PCA9634/examples/PCA9634_shift_rotate/PCA9634_shift_rotate.ino b/libraries/PCA9634/examples/PCA9634_shift_rotate/PCA9634_shift_rotate.ino index 66abd97a..6abfa7f0 100644 --- a/libraries/PCA9634/examples/PCA9634_shift_rotate/PCA9634_shift_rotate.ino +++ b/libraries/PCA9634/examples/PCA9634_shift_rotate/PCA9634_shift_rotate.ino @@ -18,10 +18,13 @@ uint8_t channels = 8; void setup() { Serial.begin(115200); + Serial.println(__FILE__); Serial.print("PCA9634 LIB version: "); Serial.println(PCA9634_LIB_VERSION); Serial.println(); + Wire.begin(); + ledArray.begin(); channels = ledArray.channelCount(); diff --git a/libraries/PCA9634/examples/PCA9634_software_reset/PCA9634_software_reset.ino b/libraries/PCA9634/examples/PCA9634_software_reset/PCA9634_software_reset.ino index 8cc7878d..48d77d0d 100644 --- a/libraries/PCA9634/examples/PCA9634_software_reset/PCA9634_software_reset.ino +++ b/libraries/PCA9634/examples/PCA9634_software_reset/PCA9634_software_reset.ino @@ -2,6 +2,7 @@ // FILE: PCA9634_software_reset.ino // AUTHOR: Rob Tillaart // PURPOSE: test PCA9634 library +// URL: https://github.com/RobTillaart/PCA9634 #include "Arduino.h" @@ -15,10 +16,13 @@ PCA9634 ledArray(0x20); void setup() { Serial.begin(115200); + Serial.println(__FILE__); Serial.print("PCA9634 LIB version: "); Serial.println(PCA9634_LIB_VERSION); Serial.println(); + Wire.begin(); + ledArray.begin(); ledArray.setLedDriverMode(0, PCA963X_LEDON); diff --git a/libraries/PCA9634/examples/PCA9634_test01/PCA9634_test01.ino b/libraries/PCA9634/examples/PCA9634_test01/PCA9634_test01.ino index fc96b3c6..b4f4340c 100644 --- a/libraries/PCA9634/examples/PCA9634_test01/PCA9634_test01.ino +++ b/libraries/PCA9634/examples/PCA9634_test01/PCA9634_test01.ino @@ -1,8 +1,8 @@ // // FILE: PCA9634_test01.ino // AUTHOR: Rob Tillaart -// DATE: 2022-01-03 // PURPOSE: test PCA9634 library +// URL: https://github.com/RobTillaart/PCA9634 #include "Arduino.h" @@ -16,10 +16,13 @@ PCA9634 ledArray(0x20); void setup() { Serial.begin(115200); + Serial.println(__FILE__); Serial.print("PCA9634 LIB version: "); Serial.println(PCA9634_LIB_VERSION); Serial.println(); + Wire.begin(); + ledArray.begin(); testSetLedDriverModeLEDON(); diff --git a/libraries/PCA9634/examples/PCA9634_test_multiple/PCA9634_test_multiple.ino b/libraries/PCA9634/examples/PCA9634_test_multiple/PCA9634_test_multiple.ino index 250afd6c..622d098a 100644 --- a/libraries/PCA9634/examples/PCA9634_test_multiple/PCA9634_test_multiple.ino +++ b/libraries/PCA9634/examples/PCA9634_test_multiple/PCA9634_test_multiple.ino @@ -1,8 +1,8 @@ // // FILE: PCA9634_test_multiple.ino // AUTHOR: Rob Tillaart -// DATE: 2022-01-03 // PURPOSE: test PCA9634 library +// URL: https://github.com/RobTillaart/PCA9634 #include "Arduino.h" @@ -17,10 +17,13 @@ PCA9634 ledArray2(0x21); void setup() { Serial.begin(115200); + Serial.println(__FILE__); Serial.print("PCA9634 LIB version: "); Serial.println(PCA9634_LIB_VERSION); Serial.println(); + Wire.begin(); + ledArray.begin(); ledArray2.begin(); diff --git a/libraries/PCA9634/library.json b/libraries/PCA9634/library.json index bb404dd6..1d70e716 100644 --- a/libraries/PCA9634/library.json +++ b/libraries/PCA9634/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/PCA9634.git" }, - "version": "0.2.9", + "version": "0.3.0", "license": "MIT", "frameworks": "*", "platforms": "*", diff --git a/libraries/PCA9634/library.properties b/libraries/PCA9634/library.properties index 6c49a16b..5454c3e6 100644 --- a/libraries/PCA9634/library.properties +++ b/libraries/PCA9634/library.properties @@ -1,5 +1,5 @@ name=PCA9634 -version=0.2.9 +version=0.3.0 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for PCA9634 I2C LED driver 8 channel diff --git a/libraries/PCA9634/test/unit_test_001.cpp b/libraries/PCA9634/test/unit_test_001.cpp index e17c2bb1..ce179b48 100644 --- a/libraries/PCA9634/test/unit_test_001.cpp +++ b/libraries/PCA9634/test/unit_test_001.cpp @@ -77,6 +77,9 @@ unittest(test_constants) unittest(test_constructor) { PCA9634 ledArray(0x20); + + Wire.begin(); + assertTrue(ledArray.begin()); assertTrue(ledArray.isConnected()); assertEqual(8, ledArray.channelCount()); @@ -86,6 +89,9 @@ unittest(test_constructor) unittest(test_LedDriverMode) { PCA9634 ledArray(0x20); + + Wire.begin(); + assertTrue(ledArray.begin()); // TODO @@ -96,12 +102,14 @@ unittest(test_OutputEnable) { PCA9634 ledArray(0x20); + Wire.begin(); + assertTrue(ledArray.begin()); assertEqual(HIGH, ledArray.getOutputEnable()); assertTrue(ledArray.setOutputEnablePin(12)); - // assertEqual(HIGH, ledArray.getOutputEnable()); // need mock + // assertEqual(HIGH, ledArray.getOutputEnable()); // need mock assertTrue(ledArray.setOutputEnable(true)); // assertEqual(LOW, ledArray.getOutputEnable());