0.2.0 PCA9551

This commit is contained in:
Rob Tillaart 2023-12-11 10:38:24 +01:00
parent 6e9c45eb52
commit 365bee7491
13 changed files with 43 additions and 28 deletions

View File

@ -6,7 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.1.0] - 2023-09-25
## [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

View File

@ -2,7 +2,7 @@
// FILE: PCA9551.cpp
// AUTHOR: Rob Tillaart
// DATE: 2023-07-17
// VERSION: 0.1.1
// VERSION: 0.2.0
// PURPOSE: Arduino library for for I2C PCA9551 8 channel PWM
// URL: https://github.com/RobTillaart/PCA9551
@ -23,24 +23,8 @@ PCA9551::PCA9551(const uint8_t deviceAddress, TwoWire *wire)
}
#if defined (ESP8266) || defined(ESP32)
bool PCA9551::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 PCA9551::begin()
{
_wire->begin();
if (! isConnected()) return false;
return true;
}

View File

@ -3,7 +3,7 @@
// FILE: PCA9551.h
// AUTHOR: Rob Tillaart
// DATE: 2023-07-17
// VERSION: 0.1.1
// VERSION: 0.2.0
// PUPROSE: Arduino library for for I2C PCA9551 8 channel PWM
// URL: https://github.com/RobTillaart/PCA9551
@ -12,7 +12,7 @@
#include "Wire.h"
#define PCA9551_LIB_VERSION (F("0.1.1"))
#define PCA9551_LIB_VERSION (F("0.2.0"))
// REGISTERS
@ -51,9 +51,6 @@ class PCA9551
public:
explicit PCA9551(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();

View File

@ -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)
@ -69,12 +78,10 @@ Follow up series
Address = 0x60 .. 0x67 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 = 8.
- **uint8_t reset()**
- **uint8_t reset()** idem.
#### GPIO

View File

@ -20,10 +20,13 @@ PCA9551 leds(0x62);
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("PCA9551_LIB_VERSION: ");
Serial.println(PCA9551_LIB_VERSION);
Serial.println();
Wire.begin();
if (leds.begin() == false)
{
Serial.println("Could not connect.");

View File

@ -20,10 +20,13 @@ PCA9551 leds(0x62);
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("PCA9551_LIB_VERSION: ");
Serial.println(PCA9551_LIB_VERSION);
Serial.println();
Wire.begin();
if (leds.begin() == false)
{
Serial.println("Could not connect.");

View File

@ -20,10 +20,13 @@ PCA9551 leds(0x62);
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("PCA9551_LIB_VERSION: ");
Serial.println(PCA9551_LIB_VERSION);
Serial.println();
Wire.begin();
if (leds.begin() == false)
{
Serial.println("Could not connect.");

View File

@ -17,10 +17,13 @@ PCA9551 leds(0x62);
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("PCA9551_LIB_VERSION: ");
Serial.println(PCA9551_LIB_VERSION);
Serial.println();
Wire.begin();
if (leds.begin() == false)
{
Serial.println("Could not connect.");

View File

@ -17,10 +17,13 @@ PCA9551 leds(0x62);
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("PCA9551_LIB_VERSION: ");
Serial.println(PCA9551_LIB_VERSION);
Serial.println();
Wire.begin();
if (leds.begin() == false)
{
Serial.println("Could not connect.");

View File

@ -88,10 +88,13 @@ void test_source()
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("PCA9551_LIB_VERSION: ");
Serial.println(PCA9551_LIB_VERSION);
Serial.println();
Wire.begin();
if (leds.begin() == false)
{
Serial.println("Could not connect.");

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/PCA9551.git"
},
"version": "0.1.1",
"version": "0.2.0",
"license": "MIT",
"frameworks": "*",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=PCA9551
version=0.1.1
version=0.2.0
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for PCA9551 I2C LED driver 8 channel

View File

@ -77,6 +77,8 @@ unittest(test_constructor)
{
PCA9551 pca(0x62);
Wire.begin();
assertEqual(8, pca.outputCount());
assertEqual(0x62, pca.getAddress());
}