mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-09-19 16:46:11 -04:00
0.4.4 PCA9635
This commit is contained in:
parent
c1260eb16c
commit
f357d9b81c
@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [0.4.4] - 2023-01-23
|
||||
- fix #22 update documentation
|
||||
- add **I2C_SoftwareReset()** experimental
|
||||
|
||||
|
||||
## [0.4.3] - 2023-01-23
|
||||
- update GitHub actions
|
||||
- update license 2023
|
||||
@ -16,7 +21,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- update readme.md
|
||||
- minor edits
|
||||
|
||||
|
||||
## [0.4.2] - 2022-11-19
|
||||
- add RP2040 in build-CI
|
||||
- add changelog.md
|
||||
|
@ -2,7 +2,7 @@
|
||||
// FILE: PCA9635.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// DATE: 23-apr-2016
|
||||
// VERSION: 0.4.3
|
||||
// VERSION: 0.4.4
|
||||
// PURPOSE: Arduino library for PCA9635 I2C LED driver
|
||||
// URL: https://github.com/RobTillaart/PCA9635
|
||||
|
||||
@ -155,12 +155,12 @@ uint8_t PCA9635::setLedDriverMode(uint8_t channel, uint8_t mode)
|
||||
if (channel >= _channelCount)
|
||||
{
|
||||
_error = PCA9635_ERR_CHAN;
|
||||
return PCA9635_ERROR;
|
||||
return _error;
|
||||
}
|
||||
if (mode > 3)
|
||||
{
|
||||
_error = PCA9635_ERR_MODE;
|
||||
return PCA9635_ERROR;
|
||||
return _error;
|
||||
}
|
||||
|
||||
uint8_t reg = PCA9635_LEDOUT_BASE + (channel >> 2);
|
||||
@ -181,7 +181,7 @@ uint8_t PCA9635::getLedDriverMode(uint8_t channel)
|
||||
if (channel >= _channelCount)
|
||||
{
|
||||
_error = PCA9635_ERR_CHAN;
|
||||
return PCA9635_ERROR;
|
||||
return _error;
|
||||
}
|
||||
|
||||
uint8_t reg = PCA9635_LEDOUT_BASE + (channel >> 2);
|
||||
@ -198,7 +198,7 @@ uint8_t PCA9635::getLedDriverMode(uint8_t channel)
|
||||
int PCA9635::lastError()
|
||||
{
|
||||
int e = _error;
|
||||
_error = 0;
|
||||
_error = PCA9635_OK;
|
||||
return e;
|
||||
}
|
||||
|
||||
@ -367,6 +367,31 @@ uint8_t PCA9635::getOutputEnable()
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// EXPERIMENTAL
|
||||
//
|
||||
int PCA9635::I2C_SoftwareReset(uint8_t method)
|
||||
{
|
||||
// only support 0 and 1
|
||||
if (method > 1) return -999;
|
||||
if (method == 1)
|
||||
{
|
||||
// from https://github.com/RobTillaart/PCA9634/issues/10#issuecomment-1206326417
|
||||
const uint8_t SW_RESET = 0x03;
|
||||
_wire->beginTransmission(SW_RESET);
|
||||
_wire->write(0xA5);
|
||||
_wire->write(0x5A);
|
||||
return _wire->endTransmission(true);
|
||||
}
|
||||
|
||||
// default - based upon NXP specification - UM10204.pdf - page 16
|
||||
_wire->beginTransmission(0x00);
|
||||
_wire->write(0x06);
|
||||
return _wire->endTransmission(true);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//
|
||||
// PRIVATE
|
||||
|
@ -3,7 +3,7 @@
|
||||
// FILE: PCA9635.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// DATE: 23-apr-2016
|
||||
// VERSION: 0.4.3
|
||||
// VERSION: 0.4.4
|
||||
// PURPOSE: Arduino library for PCA9635 I2C LED driver, 16 channel
|
||||
// URL: https://github.com/RobTillaart/PCA9635
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
#include "Wire.h"
|
||||
|
||||
|
||||
#define PCA9635_LIB_VERSION (F("0.4.3"))
|
||||
#define PCA9635_LIB_VERSION (F("0.4.4"))
|
||||
|
||||
#define PCA9635_MODE1 0x00
|
||||
#define PCA9635_MODE2 0x01
|
||||
@ -156,6 +156,10 @@ public:
|
||||
uint8_t getOutputEnable();
|
||||
|
||||
|
||||
// EXPERIMENTAL 0.4.4
|
||||
int I2C_SoftwareReset(uint8_t method);
|
||||
|
||||
|
||||
private:
|
||||
// DIRECT CONTROL
|
||||
uint8_t writeReg(uint8_t reg, uint8_t value); // returns error status.
|
||||
|
@ -198,24 +198,52 @@ The functions to enable all/sub-addresses are straightforward:
|
||||
#### OutputEnable
|
||||
|
||||
Since 0.4.3 (experimental) support to control the OE (Output Enable) pin of the PCA9635.
|
||||
This OE pin can control all LEDs simultaneously. It also allows to
|
||||
control multiple PCA9635.
|
||||
Think of simultaneous switching ON/OFF of get dimming with a high frequency PWM.
|
||||
This OE pin can control all LEDs simultaneously.
|
||||
It also allows to control multiple PCA9634 modules by connecting the OE pins.
|
||||
Think of simultaneous switching ON/OFF or get dimming with a high frequency PWM.
|
||||
Or use 2 modules alternatively by placing an inverter in between.
|
||||
|
||||
See datasheet for the details
|
||||
|
||||
- **bool setOutputEnablePin(uint8_t pin = 255)** sets the IO pin to connect to the OE pin of the PCA9635.
|
||||
A value of 255 indicates no pin set/selected.
|
||||
Sets the OE pin to LOW.
|
||||
Sets the OE pin to HIGH.
|
||||
Returns true on success.
|
||||
- **bool setOutputEnable(uint8_t value)** Sets the OE pin HIGH or LOW.
|
||||
All non zero values are HIGH.
|
||||
All non zero values are LOW.
|
||||
Returns true on success.
|
||||
- **uint8_t getOutputEnable()** get the current value of the OE pin.
|
||||
If pin is not set/selected it will return LOW.
|
||||
If pin is not set/selected it will return HIGH.
|
||||
|
||||
Note: the OE is LOW active. The user has to set the power on value
|
||||
by means of a PULL UP / DOWN resistor.
|
||||
Note: the OE is LOW active.
|
||||
The user has to set the power on value by means of a PULL UP / DOWN resistor.
|
||||
|
||||
|
||||
#### I2C Software reset
|
||||
|
||||
The goal of this function is to reset ALL PCA9635 devices on the bus.
|
||||
When using the software reset, ALL devices attached to the bus are set to their hardware startup conditions.
|
||||
Generally, there are multiple definitions of software resets by the I2C inventor NXP.
|
||||
To accommodate this, two different modes for this function have been defined and tested (see PCA9634).
|
||||
|
||||
- Method 1 is a tested method which is specific to the PCA9634.
|
||||
Since the number of different types of I2C chips is very large, side-effects on other chips might be possible.
|
||||
Before using this method, consult the data sheets of all chips on the bus to mitigate potential undefined states.
|
||||
- Method 0 is a somewhat “general” method which resets many chips on the I2C-bus.
|
||||
However, this method DOES NOT reset the PCA9635 chip.
|
||||
Therefore, consult the data sheet of all different chips on the bus to mitigate potential undefined states.
|
||||
|
||||
When only working with PCA9635 chips on a bus, only method 1 is required.
|
||||
|
||||
```cpp
|
||||
ledArray.I2C_SoftwareReset(1); // for method 1
|
||||
ledArray.I2C_SoftwareReset(0); // for method 0
|
||||
```
|
||||
|
||||
In case you experience issues with this function on your chips (non-PCA9635),
|
||||
please give feedback, so the documentation can be improved.
|
||||
|
||||
For further details of the development, see - #10 (PCA9634 repo)
|
||||
|
||||
|
||||
## Future
|
||||
|
@ -42,6 +42,8 @@ setOutputEnablePin KEYWORD2
|
||||
setOutputEnable KEYWORD2
|
||||
getOutputEnable KEYWORD2
|
||||
|
||||
I2C_SoftwareReset KEYWORD2
|
||||
|
||||
#
|
||||
# Constants ( LITERAL1)
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/PCA9635.git"
|
||||
},
|
||||
"version": "0.4.3",
|
||||
"version": "0.4.4",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=PCA9635
|
||||
version=0.4.3
|
||||
version=0.4.4
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for PCA9635 I2C LED driver 16 channel
|
||||
|
Loading…
Reference in New Issue
Block a user