From c391e24cb5e178a13af0292bfe647621b54f1772 Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Mon, 11 Dec 2023 10:41:06 +0100 Subject: [PATCH] 0.2.0 PCA9552 --- libraries/PCA9552/CHANGELOG.md | 7 +++++++ libraries/PCA9552/PCA9552.cpp | 18 +----------------- libraries/PCA9552/PCA9552.h | 7 ++----- libraries/PCA9552/README.md | 13 ++++++++++--- .../examples/PCA9552_PWM/PCA9552_PWM.ino | 3 +++ .../examples/PCA9552_blink/PCA9552_blink.ino | 3 +++ .../PCA9552_digitalRead.ino | 3 +++ .../examples/PCA9552_test01/PCA9552_test01.ino | 3 +++ .../examples/PCA9552_test02/PCA9552_test02.ino | 3 +++ .../PCA9552_test_registers.ino | 3 +++ libraries/PCA9552/library.json | 2 +- libraries/PCA9552/library.properties | 2 +- libraries/PCA9552/test/unit_test_001.cpp | 2 ++ 13 files changed, 42 insertions(+), 27 deletions(-) diff --git a/libraries/PCA9552/CHANGELOG.md b/libraries/PCA9552/CHANGELOG.md index 752d4f85..38c37119 100644 --- a/libraries/PCA9552/CHANGELOG.md +++ b/libraries/PCA9552/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.2.0] - 2023-12-11 +- refactor API, begin() +- update readme.md +- update examples + +---- + ## [0.1.1] - 2023-09-25 - add Wire1 support for ESP32 - update readme.md diff --git a/libraries/PCA9552/PCA9552.cpp b/libraries/PCA9552/PCA9552.cpp index b95487e4..ecc5f97f 100644 --- a/libraries/PCA9552/PCA9552.cpp +++ b/libraries/PCA9552/PCA9552.cpp @@ -2,7 +2,7 @@ // FILE: PCA9552.cpp // AUTHOR: Rob Tillaart // DATE: 2023-07-17 -// VERSION: 0.1.1 +// VERSION: 0.2.0 // PURPOSE: Arduino library for for I2C PCA9552 16 channel PWM // URL: https://github.com/RobTillaart/PCA9552 @@ -23,24 +23,8 @@ PCA9552::PCA9552(const uint8_t deviceAddress, TwoWire *wire) } -#if defined (ESP8266) || defined(ESP32) -bool PCA9552::begin(int sda, int scl) -{ - if ((sda < 255) && (scl < 255)) - { - _wire->begin(sda, scl); - } else { - _wire->begin(); - } - if (! isConnected()) return false; - return true; -} -#endif - - bool PCA9552::begin() { - _wire->begin(); if (! isConnected()) return false; return true; } diff --git a/libraries/PCA9552/PCA9552.h b/libraries/PCA9552/PCA9552.h index d7a4405e..7592031a 100644 --- a/libraries/PCA9552/PCA9552.h +++ b/libraries/PCA9552/PCA9552.h @@ -3,7 +3,7 @@ // FILE: PCA9552.h // AUTHOR: Rob Tillaart // DATE: 2023-07-17 -// VERSION: 0.1.1 +// VERSION: 0.2.0 // PUPROSE: Arduino library for for I2C PCA9552 16 channel PWM // URL: https://github.com/RobTillaart/PCA9552 @@ -12,7 +12,7 @@ #include "Wire.h" -#define PCA9552_LIB_VERSION (F("0.1.1")) +#define PCA9552_LIB_VERSION (F("0.2.0")) // REGISTERS @@ -54,9 +54,6 @@ class PCA9552 public: explicit PCA9552(const uint8_t deviceAddress, TwoWire *wire = &Wire); -#if defined (ESP8266) || defined(ESP32) - bool begin(int sda, int scl); -#endif bool begin(); bool isConnected(); uint8_t reset(); diff --git a/libraries/PCA9552/README.md b/libraries/PCA9552/README.md index b447a5b3..bf11eafb 100644 --- a/libraries/PCA9552/README.md +++ b/libraries/PCA9552/README.md @@ -43,6 +43,15 @@ Power-On Reset (POR) initializes the registers to their default state, all zeroes, causing the bits to be set HIGH (LED off). +#### 0.2.0 Breaking change + +Version 0.2.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/PCA9551 (8 channel) @@ -68,12 +77,10 @@ Follow up series and optional the Wire interface as parameter. - **bool begin()** initializes the library after startup. Returns true if device address is available on I2C bus. -- **bool begin(int sda, int scl)** -idem, ESP32 ESP8266 only. - **bool isConnected()** checks if address is available on I2C bus. - **uint8_t getAddress()** returns I2C address. - **uint8_t outputCount()** returns the number of channels = 16. -- **uint8_t reset()** +- **uint8_t reset()** idem. #### GPIO diff --git a/libraries/PCA9552/examples/PCA9552_PWM/PCA9552_PWM.ino b/libraries/PCA9552/examples/PCA9552_PWM/PCA9552_PWM.ino index 75f04e43..9ab4a42a 100644 --- a/libraries/PCA9552/examples/PCA9552_PWM/PCA9552_PWM.ino +++ b/libraries/PCA9552/examples/PCA9552_PWM/PCA9552_PWM.ino @@ -20,10 +20,13 @@ PCA9552 leds(0x62); void setup() { Serial.begin(115200); + Serial.println(__FILE__); Serial.print("PCA9552_LIB_VERSION: "); Serial.println(PCA9552_LIB_VERSION); Serial.println(); + Wire.begin(); + if (leds.begin() == false) { Serial.println("Could not connect."); diff --git a/libraries/PCA9552/examples/PCA9552_blink/PCA9552_blink.ino b/libraries/PCA9552/examples/PCA9552_blink/PCA9552_blink.ino index 468ed0b4..8f461adf 100644 --- a/libraries/PCA9552/examples/PCA9552_blink/PCA9552_blink.ino +++ b/libraries/PCA9552/examples/PCA9552_blink/PCA9552_blink.ino @@ -20,10 +20,13 @@ PCA9552 leds(0x62); void setup() { Serial.begin(115200); + Serial.println(__FILE__); Serial.print("PCA9552_LIB_VERSION: "); Serial.println(PCA9552_LIB_VERSION); Serial.println(); + Wire.begin(); + if (leds.begin() == false) { Serial.println("Could not connect."); diff --git a/libraries/PCA9552/examples/PCA9552_digitalRead/PCA9552_digitalRead.ino b/libraries/PCA9552/examples/PCA9552_digitalRead/PCA9552_digitalRead.ino index 5a378f9b..6c908939 100644 --- a/libraries/PCA9552/examples/PCA9552_digitalRead/PCA9552_digitalRead.ino +++ b/libraries/PCA9552/examples/PCA9552_digitalRead/PCA9552_digitalRead.ino @@ -20,10 +20,13 @@ PCA9552 leds(0x62); void setup() { Serial.begin(115200); + Serial.println(__FILE__); Serial.print("PCA9552_LIB_VERSION: "); Serial.println(PCA9552_LIB_VERSION); Serial.println(); + Wire.begin(); + if (leds.begin() == false) { Serial.println("Could not connect."); diff --git a/libraries/PCA9552/examples/PCA9552_test01/PCA9552_test01.ino b/libraries/PCA9552/examples/PCA9552_test01/PCA9552_test01.ino index 30f15389..09536f87 100644 --- a/libraries/PCA9552/examples/PCA9552_test01/PCA9552_test01.ino +++ b/libraries/PCA9552/examples/PCA9552_test01/PCA9552_test01.ino @@ -17,10 +17,13 @@ PCA9552 leds(0x62); void setup() { Serial.begin(115200); + Serial.println(__FILE__); Serial.print("PCA9552_LIB_VERSION: "); Serial.println(PCA9552_LIB_VERSION); Serial.println(); + Wire.begin(); + if (leds.begin() == false) { Serial.println("Could not connect."); diff --git a/libraries/PCA9552/examples/PCA9552_test02/PCA9552_test02.ino b/libraries/PCA9552/examples/PCA9552_test02/PCA9552_test02.ino index 77852a7a..87ca6653 100644 --- a/libraries/PCA9552/examples/PCA9552_test02/PCA9552_test02.ino +++ b/libraries/PCA9552/examples/PCA9552_test02/PCA9552_test02.ino @@ -17,10 +17,13 @@ PCA9552 leds(0x62); void setup() { Serial.begin(115200); + Serial.println(__FILE__); Serial.print("PCA9552_LIB_VERSION: "); Serial.println(PCA9552_LIB_VERSION); Serial.println(); + Wire.begin(); + if (leds.begin() == false) { Serial.println("Could not connect."); diff --git a/libraries/PCA9552/examples/PCA9552_test_registers/PCA9552_test_registers.ino b/libraries/PCA9552/examples/PCA9552_test_registers/PCA9552_test_registers.ino index b1f9ef03..60454909 100644 --- a/libraries/PCA9552/examples/PCA9552_test_registers/PCA9552_test_registers.ino +++ b/libraries/PCA9552/examples/PCA9552_test_registers/PCA9552_test_registers.ino @@ -88,10 +88,13 @@ void test_source() void setup() { Serial.begin(115200); + Serial.println(__FILE__); Serial.print("PCA9552_LIB_VERSION: "); Serial.println(PCA9552_LIB_VERSION); Serial.println(); + Wire.begin(); + if (leds.begin() == false) { Serial.println("Could not connect."); diff --git a/libraries/PCA9552/library.json b/libraries/PCA9552/library.json index 07a8d634..4690f080 100644 --- a/libraries/PCA9552/library.json +++ b/libraries/PCA9552/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/PCA9552.git" }, - "version": "0.1.1", + "version": "0.2.0", "license": "MIT", "frameworks": "*", "platforms": "*", diff --git a/libraries/PCA9552/library.properties b/libraries/PCA9552/library.properties index da11b6a6..e1a5c52e 100644 --- a/libraries/PCA9552/library.properties +++ b/libraries/PCA9552/library.properties @@ -1,5 +1,5 @@ name=PCA9552 -version=0.1.1 +version=0.2.0 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for PCA9552 I2C LED driver 16 channel diff --git a/libraries/PCA9552/test/unit_test_001.cpp b/libraries/PCA9552/test/unit_test_001.cpp index ad30a3d0..5245532c 100644 --- a/libraries/PCA9552/test/unit_test_001.cpp +++ b/libraries/PCA9552/test/unit_test_001.cpp @@ -81,6 +81,8 @@ unittest(test_constructor) { PCA9552 pca(0x62); + Wire.begin(); + assertEqual(16, pca.outputCount()); assertEqual(0x62, pca.getAddress()); }