0.2.0 PCA9552

This commit is contained in:
Rob Tillaart 2023-12-11 10:41:06 +01:00
parent 365bee7491
commit c391e24cb5
13 changed files with 42 additions and 27 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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();

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)
@ -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

View File

@ -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.");

View File

@ -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.");

View File

@ -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.");

View File

@ -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.");

View File

@ -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.");

View File

@ -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.");

View File

@ -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": "*",

View File

@ -1,5 +1,5 @@
name=PCA9552
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 PCA9552 I2C LED driver 16 channel

View File

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