0.2.1 PCA9634

This commit is contained in:
rob tillaart 2022-06-12 17:20:31 +02:00
parent 314a071f28
commit b4984c0be8
6 changed files with 34 additions and 30 deletions

View File

@ -2,7 +2,7 @@
// FILE: PCA9634.cpp
// AUTHOR: Rob Tillaart
// DATE: 03-01-2022
// VERSION: 0.2.0
// VERSION: 0.2.1
// PURPOSE: Arduino library for PCA9634 I2C LED driver
// URL: https://github.com/RobTillaart/PCA9634
//
@ -17,7 +17,7 @@
// add SUB CALL and ALL CALL functions.
// update documentation.
// renamed PCA9634_MODE2_STOP to PCA9634_MODE2_ACK
// 0.2.1 2022-05-30 add mode parameters to begin()
#include "PCA9634.h"
@ -36,7 +36,7 @@ PCA9634::PCA9634(const uint8_t deviceAddress, TwoWire *wire)
#if defined (ESP8266) || defined(ESP32)
bool PCA9634::begin(uint8_t sda, uint8_t scl)
bool PCA9634::begin(uint8_t sda, uint8_t scl, uint8_t mode1_mask, uint8_t mode2_mask)
{
_wire = &Wire;
if ((sda < 255) && (scl < 255))
@ -46,17 +46,17 @@ bool PCA9634::begin(uint8_t sda, uint8_t scl)
_wire->begin();
}
if (! isConnected()) return false;
configure();
configure(mode1_mask, mode2_mask);
return true;
}
#endif
bool PCA9634::begin()
bool PCA9634::begin(uint8_t mode1_mask, uint8_t mode2_mask)
{
_wire->begin();
if (! isConnected()) return false;
configure();
configure(mode1_mask, mode2_mask);
return true;
}

View File

@ -3,7 +3,7 @@
// FILE: PCA9634.h
// AUTHOR: Rob Tillaart
// DATE: 03-01-2022
// VERSION: 0.2.0
// VERSION: 0.2.1
// 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.0"))
#define PCA9634_LIB_VERSION (F("0.2.1"))
#define PCA9634_MODE1 0x00
#define PCA9634_MODE2 0x01
@ -70,11 +70,13 @@ public:
explicit PCA9634(const uint8_t deviceAddress, TwoWire *wire = &Wire);
#if defined (ESP8266) || defined(ESP32)
bool begin(uint8_t sda, uint8_t scl);
#endif
bool begin();
void configure(uint8_t mode1_mask = PCA9634_MODE1_ALLCALL,
bool begin(uint8_t sda, uint8_t scl,
uint8_t mode1_mask = PCA9634_MODE1_ALLCALL,
uint8_t mode2_mask = PCA9634_MODE2_NONE);
#endif
bool begin(uint8_t mode1_mask = PCA9634_MODE1_ALLCALL,
uint8_t mode2_mask = PCA9634_MODE2_NONE);
void configure(uint8_t mode1_mask, uint8_t mode2_mask);
bool isConnected();
uint8_t channelCount() { return _channelCount; };
@ -116,17 +118,17 @@ public:
// SUB CALL - ALL CALL (since 0.2.0)
//
// nr = { 1, 2, 3 }
bool enableSubCall(uint8_t nr);
bool disableSubCall(uint8_t nr);
bool isEnabledSubCall(uint8_t nr);
bool setSubCallAddress(uint8_t nr, uint8_t address);
uint8_t getSubCallAddress(uint8_t nr);
bool enableSubCall(uint8_t nr);
bool disableSubCall(uint8_t nr);
bool isEnabledSubCall(uint8_t nr);
bool setSubCallAddress(uint8_t nr, uint8_t address);
uint8_t getSubCallAddress(uint8_t nr);
bool enableAllCall();
bool disableAllCall();
bool isEnabledAllCall();
bool setAllCallAddress(uint8_t address);
uint8_t getAllCallAddress();
bool enableAllCall();
bool disableAllCall();
bool isEnabledAllCall();
bool setAllCallAddress(uint8_t address);
uint8_t getAllCallAddress();
private:

View File

@ -29,12 +29,14 @@ library is a 8 channel derived variation of the PCA9635 class.
- **PCA9634(uint8_t deviceAddress, TwoWire \*wire = &Wire)** Constructor with I2C device address,
and optional the Wire interface as parameter.
- **bool begin()** initializes the library after startup. Mandatory.
- **bool begin(uint8_t sda, uint8_t scl)** idem, ESP32 ESP8266 only.
- **void configure(uint8_t mode1_mask = PCA9634_MODE1_ALLCALL, uint8_t mode2_mask = PCA9634_MODE2_NONE)**
configures the library, optionally setting the MODE1 and MODE2 configuration registers.
- **bool begin(uint8_t mode1_mask = PCA9634_MODE1_ALLCALL, uint8_t mode2_mask = PCA9634_MODE2_NONE)**
initializes the library after startup. Optionally setting the MODE1 and MODE2 configuration registers.
See PCA9634.h and datasheet for settings possible.
**configure()** is typically used at startup.
- **bool begin(uint8_t sda, uint8_t scl, uint8_t mode1_mask = PCA9634_MODE1_ALLCALL, uint8_t mode2_mask = PCA9634_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.
- **bool isConnected()** checks if address is available on I2C bus.
- **uint8_t channelCount()** returns the number of channels = 8.

View File

@ -61,7 +61,7 @@ PCA9634_MODE1_NONE LITERAL1
PCA9634_MODE2_BLINK LITERAL1
PCA9634_MODE2_INVERT LITERAL1
PCA9634_MODE2_STOP LITERAL1
PCA9634_MODE2_ACK LITERAL1
PCA9634_MODE2_TOTEMPOLE LITERAL1
PCA9634_MODE2_NONE LITERAL1

View File

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

View File

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