0.5.0 PCA9635

This commit is contained in:
Rob Tillaart 2023-12-11 13:55:36 +01:00
parent d4f8a62fe3
commit af30360e5f
12 changed files with 54 additions and 34 deletions

View File

@ -6,12 +6,19 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.5.0] - 2023-12-11
= refactor API, begin()
- add **uint8_t getAddress()**
- update readme.md
- update examples
----
## [0.4.7] - 2023-09-24
- add Wire1 support for ESP32
- update readme.md
- minor edits
## [0.4.6] - 2023-05-24
- renaming #defines PCA963X... to prepare merge with PCA9634.
- old defines will work until next major release

View File

@ -2,7 +2,7 @@
// FILE: PCA9635.cpp
// AUTHOR: Rob Tillaart
// DATE: 23-apr-2016
// VERSION: 0.4.7
// VERSION: 0.5.0
// PURPOSE: Arduino library for PCA9635 I2C LED driver, 16 channel PWM, 8 bit
// URL: https://github.com/RobTillaart/PCA9635
@ -24,25 +24,8 @@ PCA9635::PCA9635(const uint8_t deviceAddress, TwoWire *wire)
}
#if defined (ESP8266) || defined(ESP32)
bool PCA9635::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 PCA9635::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 PCA9635::isConnected()
}
uint8_t PCA9635::getAddress()
{
return _address;
}
/////////////////////////////////////////////////////
//
// CONFIGURATION

View File

@ -3,7 +3,7 @@
// FILE: PCA9635.h
// AUTHOR: Rob Tillaart
// DATE: 23-apr-2016
// VERSION: 0.4.7
// VERSION: 0.5.0
// PURPOSE: Arduino library for PCA9635 I2C LED driver, 16 channel PWM, 8 bit
// URL: https://github.com/RobTillaart/PCA9635
@ -12,7 +12,7 @@
#include "Wire.h"
#define PCA9635_LIB_VERSION (F("0.4.7"))
#define PCA9635_LIB_VERSION (F("0.5.0"))
// mode codes
@ -140,14 +140,10 @@ class PCA9635
public:
explicit PCA9635(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();
/////////////////////////////////////////////////////

View File

@ -22,6 +22,15 @@ This allows for better than 1% fine tuning of the duty-cycle
of the PWM signal.
#### 0.5.0 Breaking change
Version 0.5.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 PCA9635.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 PCA9635.h and datasheet for settings possible.

View File

@ -16,10 +16,13 @@ PCA9635 ledArray(0x20);
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("PCA9635 LIB version: ");
Serial.println(PCA9635_LIB_VERSION);
Serial.println();
Wire.begin();
ledArray.begin();
// just one channel

View File

@ -17,10 +17,13 @@ uint32_t start, stop;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("PCA9635 LIB version: ");
Serial.println(PCA9635_LIB_VERSION);
Serial.println();
Wire.begin();
ledArray.begin();
delay(100); // flush all Serial interrupts

View File

@ -20,10 +20,13 @@ uint8_t channels = 16;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("PCA9635 LIB version: ");
Serial.println(PCA9635_LIB_VERSION);
Serial.println();
Wire.begin();
ledArray.begin();
channels = ledArray.channelCount();

View File

@ -1,7 +1,6 @@
//
// FILE: PCA9635_test01.ino
// AUTHOR: Rob Tillaart
// DATE: 23-APR-2016
// PURPOSE: test PCA9635 library
// URL: https://github.com/RobTillaart/PCA9635
@ -17,10 +16,13 @@ PCA9635 ledArray(0x20);
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("PCA9635 LIB version: ");
Serial.println(PCA9635_LIB_VERSION);
Serial.println();
Wire.begin();
ledArray.begin();
testSetLedDriverModeLEDON();

View File

@ -1,7 +1,6 @@
//
// FILE: PCA9635_test_multiple.ino
// AUTHOR: Rob Tillaart
// DATE: 2018-02-18
// PURPOSE: test PCA9635 library
// URL: https://github.com/RobTillaart/PCA9635
@ -18,10 +17,13 @@ PCA9635 ledArray2(0x21);
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("PCA9635 LIB version: ");
Serial.println(PCA9635_LIB_VERSION);
Serial.println();
Wire.begin();
ledArray.begin();
ledArray2.begin();

View File

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

View File

@ -1,5 +1,5 @@
name=PCA9635
version=0.4.7
version=0.5.0
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for PCA9635 I2C LED driver, 16 channel PWM, 8 bit.

View File

@ -77,6 +77,9 @@ unittest(test_constants)
unittest(test_constructor)
{
PCA9635 ledArray(0x20);
Wire.begin();
assertTrue(ledArray.begin());
assertTrue(ledArray.isConnected());
assertEqual(16, ledArray.channelCount());
@ -86,9 +89,12 @@ unittest(test_constructor)
unittest(test_LedDriverMode)
{
PCA9635 ledArray(0x20);
Wire.begin();
assertTrue(ledArray.begin());
// TODO
// TODO
}
@ -96,12 +102,14 @@ unittest(test_OutputEnable)
{
PCA9635 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());