0.2.5 PCA9634

This commit is contained in:
rob tillaart 2023-01-19 19:09:52 +01:00
parent 2c03a831e7
commit 353b00ec0e
11 changed files with 128 additions and 68 deletions

View File

@ -6,7 +6,7 @@ jobs:
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: arduino/arduino-lint-action@v1 - uses: arduino/arduino-lint-action@v1
with: with:
library-manager: update library-manager: update

View File

@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@v1
with: with:
ruby-version: 2.6 ruby-version: 2.6

View File

@ -10,7 +10,7 @@ jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: json-syntax-check - name: json-syntax-check
uses: limitusus/json-syntax-check@v1 uses: limitusus/json-syntax-check@v1
with: with:

View File

@ -6,12 +6,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.2.5] - 2023-01-19
- fix #22 update readme.md
- update GitHub actions
- update license
- minor edits (comments)
## [0.2.4] - 2022-11-19 ## [0.2.4] - 2022-11-19
- add RP2040 in build-CI - add RP2040 in build-CI
- add changelog.md - add changelog.md
## [0.2.3] - 2022-09-11 ## [0.2.3] - 2022-09-11
- update documentation - update documentation
- fix begin() for ESP32 ambiguity - See PCA9635 #17 - fix begin() for ESP32 ambiguity - See PCA9635 #17
@ -32,11 +37,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
---- ----
## [0.1.2] - 2022-04-13 ## [0.1.2] - 2022-04-13
- issue #7 add constants and functions for mode registers. - issue #7 add constants and functions for mode registers.
## [0.1.1] - 2022-01-04 ## [0.1.1] - 2022-01-04
- minor fixes - minor fixes
## [0.1.0] - 2022-01-03 ## [0.1.0] - 2022-01-03
- initial version -- based upon 0.3.2 PCA9635 - initial version -- based upon 0.3.2 PCA9635

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2022-2022 Rob Tillaart Copyright (c) 2022-2023 Rob Tillaart
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,8 +1,8 @@
// //
// FILE: PCA9634.cpp // FILE: PCA9634.cpp
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// DATE: 03-01-2022 // DATE: 2022-01-03
// VERSION: 0.2.4 // VERSION: 0.2.5
// PURPOSE: Arduino library for PCA9634 I2C LED driver // PURPOSE: Arduino library for PCA9634 I2C LED driver
// URL: https://github.com/RobTillaart/PCA9634 // URL: https://github.com/RobTillaart/PCA9634
@ -66,15 +66,15 @@ void PCA9634::configure(uint8_t mode1_mask, uint8_t mode2_mask)
} }
// write value to single PWM registers // write value to single PWM registers
uint8_t PCA9634::write1(uint8_t channel, uint8_t value) uint8_t PCA9634::write1(uint8_t channel, uint8_t value)
{ {
return writeN(channel, &value, 1); return writeN(channel, &value, 1);
} }
// write three values in consecutive PWM registers // write three values in consecutive PWM registers
// typically for RGB values // typically for RGB values
uint8_t PCA9634::write3(uint8_t channel, uint8_t R, uint8_t G, uint8_t B) uint8_t PCA9634::write3(uint8_t channel, uint8_t R, uint8_t G, uint8_t B)
{ {
uint8_t arr[3] = { R, G, B }; uint8_t arr[3] = { R, G, B };
@ -82,8 +82,8 @@ uint8_t PCA9634::write3(uint8_t channel, uint8_t R, uint8_t G, uint8_t B)
} }
// write count values in consecutive PWM registers // write count values in consecutive PWM registers
// checks if [channel + count - 1 > 8] // checks if [channel + count - 1 > 8]
uint8_t PCA9634::writeN(uint8_t channel, uint8_t* arr, uint8_t count) uint8_t PCA9634::writeN(uint8_t channel, uint8_t* arr, uint8_t count)
{ {
if (channel + count > _channelCount) if (channel + count > _channelCount)
@ -108,6 +108,37 @@ uint8_t PCA9634::writeN(uint8_t channel, uint8_t* arr, uint8_t count)
} }
uint8_t PCA9634::writeN_noStop(uint8_t channel, uint8_t* arr, uint8_t count)
{
if (channel + count > _channelCount)
{
_error = PCA9634_ERR_WRITE;
return PCA9634_ERROR;
}
uint8_t base = PCA9634_PWM(channel);
_wire->beginTransmission(_address);
_wire->write(base);
for(uint8_t i = 0; i < count; i++)
{
_wire->write(arr[i]);
}
// OK so far
return PCA9634_OK;
}
uint8_t PCA9634::writeStop()
{
_error = _wire->endTransmission();
if (_error != 0)
{
_error = PCA9634_ERR_I2C;
return PCA9634_ERROR;
}
return PCA9634_OK;
}
uint8_t PCA9634::writeMode(uint8_t reg, uint8_t value) uint8_t PCA9634::writeMode(uint8_t reg, uint8_t value)
{ {
if ((reg == PCA9634_MODE1) || (reg == PCA9634_MODE2)) if ((reg == PCA9634_MODE1) || (reg == PCA9634_MODE2))
@ -120,7 +151,7 @@ uint8_t PCA9634::writeMode(uint8_t reg, uint8_t value)
} }
// Note 0xFF can also mean an error.... check error flag.. // Note 0xFF can also mean an error.... ==> check error flag.
uint8_t PCA9634::readMode(uint8_t reg) uint8_t PCA9634::readMode(uint8_t reg)
{ {
if ((reg == PCA9634_MODE1) || (reg == PCA9634_MODE2)) if ((reg == PCA9634_MODE1) || (reg == PCA9634_MODE2))
@ -148,8 +179,8 @@ uint8_t PCA9634::setLedDriverMode(uint8_t channel, uint8_t mode)
} }
uint8_t reg = PCA9634_LEDOUT_BASE + (channel >> 2); uint8_t reg = PCA9634_LEDOUT_BASE + (channel >> 2);
// some bit magic // some bit magic
uint8_t shift = (channel & 0x03) * 2; // 0,2,4,6 places uint8_t shift = (channel & 0x03) * 2; // 0, 2, 4, 6 places
uint8_t setmask = mode << shift; uint8_t setmask = mode << shift;
uint8_t clrmask = ~(0x03 << shift); uint8_t clrmask = ~(0x03 << shift);
uint8_t value = (readReg(reg) & clrmask) | setmask; uint8_t value = (readReg(reg) & clrmask) | setmask;
@ -158,7 +189,7 @@ uint8_t PCA9634::setLedDriverMode(uint8_t channel, uint8_t mode)
} }
// returns 0..3 if OK, other values indicate an error // returns 0..3 if OK, other values indicate an error
uint8_t PCA9634::getLedDriverMode(uint8_t channel) uint8_t PCA9634::getLedDriverMode(uint8_t channel)
{ {
if (channel >= _channelCount) if (channel >= _channelCount)
@ -168,13 +199,13 @@ uint8_t PCA9634::getLedDriverMode(uint8_t channel)
} }
uint8_t reg = PCA9634_LEDOUT_BASE + (channel >> 2); uint8_t reg = PCA9634_LEDOUT_BASE + (channel >> 2);
uint8_t shift = (channel & 0x03) * 2; // 0,2,4,6 places uint8_t shift = (channel & 0x03) * 2; // 0, 2, 4, 6 places
uint8_t value = (readReg(reg) >> shift ) & 0x03; uint8_t value = (readReg(reg) >> shift ) & 0x03;
return value; return value;
} }
// note error flag is set to PCA9634_OK after read! // note error flag is set to PCA9634_OK after read!
int PCA9634::lastError() int PCA9634::lastError()
{ {
int e = _error; int e = _error;
@ -186,7 +217,7 @@ int PCA9634::lastError()
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
// //
// SUB CALL - ALL CALL // SUB CALL - ALL CALL
// //
bool PCA9634::enableSubCall(uint8_t nr) bool PCA9634::enableSubCall(uint8_t nr)
{ {
@ -310,7 +341,7 @@ int PCA9634::I2C_SoftwareReset(uint8_t method)
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
// //
// PRIVATE // PRIVATE
// //
uint8_t PCA9634::writeReg(uint8_t reg, uint8_t value) uint8_t PCA9634::writeReg(uint8_t reg, uint8_t value)
{ {
@ -340,5 +371,5 @@ uint8_t PCA9634::readReg(uint8_t reg)
} }
// -- END OF FILE -- // -- END OF FILE --

View File

@ -2,8 +2,8 @@
// //
// FILE: PCA9634.h // FILE: PCA9634.h
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// DATE: 03-01-2022 // DATE: 2022-01-03
// VERSION: 0.2.4 // VERSION: 0.2.5
// PURPOSE: Arduino library for PCA9634 I2C LED driver, 8 channel // PURPOSE: Arduino library for PCA9634 I2C LED driver, 8 channel
// URL: https://github.com/RobTillaart/PCA9634 // URL: https://github.com/RobTillaart/PCA9634
@ -12,7 +12,7 @@
#include "Wire.h" #include "Wire.h"
#define PCA9634_LIB_VERSION (F("0.2.4")) #define PCA9634_LIB_VERSION (F("0.2.5"))
#define PCA9634_MODE1 0x00 #define PCA9634_MODE1 0x00
#define PCA9634_MODE2 0x01 #define PCA9634_MODE2 0x01
@ -24,7 +24,7 @@
#define PCA9634_GRPPWM 0x0A #define PCA9634_GRPPWM 0x0A
#define PCA9634_GRPFREQ 0x0B #define PCA9634_GRPFREQ 0x0B
// check datasheet for details // check datasheet for details
#define PCA9634_LEDOUT_BASE 0x0C // 0x0C..0x0D #define PCA9634_LEDOUT_BASE 0x0C // 0x0C..0x0D
#define PCA9634_LEDOFF 0x00 // default @ startup #define PCA9634_LEDOFF 0x00 // default @ startup
#define PCA9634_LEDON 0x01 #define PCA9634_LEDON 0x01
@ -59,10 +59,18 @@
#define PCA9634_MODE2_TOTEMPOLE 0x04 // 0 = open drain 1 = totem-pole #define PCA9634_MODE2_TOTEMPOLE 0x04 // 0 = open drain 1 = totem-pole
#define PCA9634_MODE2_NONE 0x00 #define PCA9634_MODE2_NONE 0x00
// (since 0.2.0) // Registers in which the ALLCALL and sub-addresses are stored
#define PCA9634_SUBADR(x) (0x0D +(x)) // x = 1..3 #define PCA9634_SUBADR(x) (0x0D +(x)) // x = 1..3
#define PCA9634_ALLCALLADR 0x11 #define PCA9634_ALLCALLADR 0x11
// Standard ALLCALL and sub-addresses --> only work for write commands and NOT for read commands
#define PCA9634_ALLCALL 0x70 // TDS of chip says 0xE0, however,
// in this library the LSB is added during the write command
// (0xE0 --> 0b11100000, 0x70 --> 0b1110000)
#define PCA9634_SUB1 0x71 // see line above (0xE2 --> 0x71)
#define PCA9634_SUB2 0x72 // see line above (0xE4 --> 0x72)
#define PCA9634_SUB3 0x74 // see line above (0xE8 --> 0x74)
class PCA9634 class PCA9634
{ {
@ -70,11 +78,11 @@ public:
explicit PCA9634(const uint8_t deviceAddress, TwoWire *wire = &Wire); explicit PCA9634(const uint8_t deviceAddress, TwoWire *wire = &Wire);
#if defined (ESP8266) || defined(ESP32) #if defined (ESP8266) || defined(ESP32)
bool begin(int sda, int scl, bool begin(int sda, int scl,
uint8_t mode1_mask = PCA9634_MODE1_ALLCALL, uint8_t mode1_mask = PCA9634_MODE1_ALLCALL,
uint8_t mode2_mask = PCA9634_MODE2_NONE); uint8_t mode2_mask = PCA9634_MODE2_NONE);
#endif #endif
bool begin(uint8_t mode1_mask = PCA9634_MODE1_ALLCALL, bool begin(uint8_t mode1_mask = PCA9634_MODE1_ALLCALL,
uint8_t mode2_mask = PCA9634_MODE2_NONE); uint8_t mode2_mask = PCA9634_MODE2_NONE);
void configure(uint8_t mode1_mask, uint8_t mode2_mask); void configure(uint8_t mode1_mask, uint8_t mode2_mask);
bool isConnected(); bool isConnected();
@ -93,10 +101,16 @@ public:
// generic worker, write N consecutive PWM registers // generic worker, write N consecutive PWM registers
uint8_t writeN(uint8_t channel, uint8_t* arr, uint8_t count); uint8_t writeN(uint8_t channel, uint8_t* arr, uint8_t count);
// generic worker, write N consecutive PWM registers without Stop command
uint8_t writeN_noStop(uint8_t channel, uint8_t* arr, uint8_t count);
// write stop command to end transmission
uint8_t writeStop();
// reg = 1, 2 check datasheet for values // reg = 1, 2 check datasheet for values
uint8_t writeMode(uint8_t reg, uint8_t value); uint8_t writeMode(uint8_t reg, uint8_t value);
uint8_t readMode(uint8_t reg); uint8_t readMode(uint8_t reg);
// convenience wrappers // convenience wrappers
uint8_t setMode1(uint8_t value) { return writeMode(PCA9634_MODE1, value); }; uint8_t setMode1(uint8_t value) { return writeMode(PCA9634_MODE1, value); };
uint8_t setMode2(uint8_t value) { return writeMode(PCA9634_MODE2, value); }; uint8_t setMode2(uint8_t value) { return writeMode(PCA9634_MODE2, value); };
uint8_t getMode1() { return readMode(PCA9634_MODE1); }; uint8_t getMode1() { return readMode(PCA9634_MODE1); };
@ -113,6 +127,7 @@ public:
int lastError(); int lastError();
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
// //
// SUB CALL - ALL CALL (since 0.2.0) // SUB CALL - ALL CALL (since 0.2.0)

View File

@ -16,7 +16,7 @@ Arduino library for PCA9634 I2C 8 bit PWM LED driver, 8 channel.
This library is to control the I2C PCA9634 PWM extender. This library is to control the I2C PCA9634 PWM extender.
The 8 channels are independently configurable in steps of 1/256. The 8 channels are independently configurable in steps of 1/256.
this allows for better than 1% fine tuning of the duty-cycle this allows for better than 1% fine tuning of the duty-cycle
of the PWM signal. of the PWM signal.
library is a 8 channel derived variation of the PCA9635 class. library is a 8 channel derived variation of the PCA9635 class.
(these might merge in the future) (these might merge in the future)
@ -27,15 +27,15 @@ library is a 8 channel derived variation of the PCA9635 class.
### Constructor ### Constructor
- **PCA9634(uint8_t deviceAddress, TwoWire \*wire = &Wire)** Constructor with I2C device address, - **PCA9634(uint8_t deviceAddress, TwoWire \*wire = &Wire)** Constructor with I2C device address,
and optional the Wire interface as parameter. and optional the Wire interface as parameter.
- **bool begin(uint8_t mode1_mask = PCA9634_MODE1_ALLCALL, uint8_t mode2_mask = PCA9634_MODE2_NONE)** - **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. initializes the library after startup. Optionally setting the MODE1 and MODE2 configuration registers.
See PCA9634.h and datasheet for settings possible. See PCA9634.h and datasheet for settings possible.
- **bool begin(int sda, int scl, uint8_t mode1_mask = PCA9634_MODE1_ALLCALL, uint8_t mode2_mask = PCA9634_MODE2_NONE)** - **bool begin(int sda, int scl, uint8_t mode1_mask = PCA9634_MODE1_ALLCALL, uint8_t mode2_mask = PCA9634_MODE2_NONE)**
idem, ESP32 ESP8266 only. idem, ESP32 ESP8266 only.
- **void configure(uint8_t mode1_mask, uint8_t mode2_mask)** - **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. To configure the library after startup one can set the MODE1 and MODE2 configuration registers.
See PCA9634.h and datasheet for settings possible. See PCA9634.h and datasheet for settings possible.
- **bool isConnected()** checks if address is visible on I2C bus. - **bool isConnected()** checks if address is visible on I2C bus.
- **uint8_t channelCount()** returns the number of channels = 8. - **uint8_t channelCount()** returns the number of channels = 8.
@ -55,22 +55,23 @@ Configure LED behaviour.
| PCA9634_LEDPWM | 0x02 | set LED in PWM mode, 0..255 | | PCA9634_LEDPWM | 0x02 | set LED in PWM mode, 0..255 |
| PCA9634_LEDGRPPWM | 0x03 | add LED to the GRPPWM* | | PCA9634_LEDGRPPWM | 0x03 | add LED to the GRPPWM* |
\* all LEDs in the group GRPPWM can be set to the same PWM value in one set. \* all LEDs in the group GRPPWM can be set to the same PWM value in one set.
This is ideal to trigger e.g. multiple LEDs (servo's) at same time. This is ideal to trigger e.g. multiple LEDs (servo's) at same time.
### Read and write ### Read and write
Read and write individual values to LED channels. Read and write individual values to LED channels.
Requires LEDs' DriverMode of the specific channels to be in PWM mode. Requires LEDs' DriverMode of the specific channels to be in PWM mode.
- **uint8_t write1(uint8_t channel, uint8_t value)** writes a single 8 bit PWM value. - **uint8_t write1(uint8_t channel, uint8_t value)** writes a single 8 bit PWM value.
- **uint8_t write3(uint8_t channel, uint8_t R, uint8_t G, uint8_t B)** - **uint8_t write3(uint8_t channel, uint8_t R, uint8_t G, uint8_t B)**
writes three consecutive PWM registers. writes three consecutive PWM registers.
typical use is to write R, G, B values for a full colour LED. typical use is to write R, G, B values for a full colour LED.
- **uint8_t writeN(uint8_t channel, uint8_t \* array, uint8_t count)** - **uint8_t writeN(uint8_t channel, uint8_t \* array, uint8_t count)**
write count consecutive PWM registers. write count consecutive PWM registers.
May return **PCA9634_ERR_WRITE** if array has too many elements May return **PCA9634_ERR_WRITE** if array has too many elements
(including channel as offset). (including channel as offset).
@ -80,7 +81,7 @@ Used to configure the PCA963x general behaviour.
- **uint8_t writeMode(uint8_t reg, uint8_t value)** configuration of one of the two configuration registers. - **uint8_t writeMode(uint8_t reg, uint8_t value)** configuration of one of the two configuration registers.
Check datasheet for details. Check datasheet for details.
- **uint8_t readMode(uint8_t reg)** reads back the configured mode, - **uint8_t readMode(uint8_t reg)** reads back the configured mode,
useful to add or remove a single flag (bit masking). useful to add or remove a single flag (bit masking).
- **uint8_t setMode1(uint8_t value)** convenience wrapper. - **uint8_t setMode1(uint8_t value)** convenience wrapper.
- **uint8_t setMode2(uint8_t value)** convenience wrapper. - **uint8_t setMode2(uint8_t value)** convenience wrapper.
@ -103,13 +104,14 @@ useful to add or remove a single flag (bit masking).
| PCA9634_MODE1_SUB3 | 0x02 | 0 = disable 1 = enable | | PCA9634_MODE1_SUB3 | 0x02 | 0 = disable 1 = enable |
| PCA9634_MODE1_ALLCALL | 0x01 | 0 = disable 1 = enable | | PCA9634_MODE1_ALLCALL | 0x01 | 0 = disable 1 = enable |
| PCA9634_MODE1_NONE | 0x00 | | | PCA9634_MODE1_NONE | 0x00 | |
| | | | | ---- | | |
| PCA9634_MODE2_BLINK | 0x20 | 0 = dim 1 = blink | | PCA9634_MODE2_BLINK | 0x20 | 0 = dim 1 = blink |
| PCA9634_MODE2_INVERT | 0x10 | 0 = normal 1 = inverted | | PCA9634_MODE2_INVERT | 0x10 | 0 = normal 1 = inverted |
| PCA9634_MODE2_STOP | 0x08 | 0 = on STOP 1 = on ACK | | PCA9634_MODE2_STOP | 0x08 | 0 = on STOP 1 = on ACK |
| PCA9634_MODE2_TOTEMPOLE | 0x04 | 0 = open drain 1 = totem-pole | | PCA9634_MODE2_TOTEMPOLE | 0x04 | 0 = open drain 1 = totem-pole |
| PCA9634_MODE2_NONE | 0x00 | | | PCA9634_MODE2_NONE | 0x00 | |
These constants makes it easier to set modes without using a non descriptive These constants makes it easier to set modes without using a non descriptive
bit mask. The constants can be merged by OR-ing them together, see snippet: bit mask. The constants can be merged by OR-ing them together, see snippet:
@ -134,8 +136,8 @@ Check datasheet for the details.
- **void setGroupPWM(uint8_t value)** sets all channels that are part of the PWM group to value. - **void setGroupPWM(uint8_t value)** sets all channels that are part of the PWM group to value.
- **uint8_t getGroupPWM()** get the current PWM setting of the group. - **uint8_t getGroupPWM()** get the current PWM setting of the group.
- **void setGroupFREQ(uint8_t value)** is used for blinking the group of configured LED. - **void setGroupFREQ(uint8_t value)** is used for blinking the group of configured LED.
Value goes from 0 to 255 with each step representing an increase of approx. 41 ms. Value goes from 0 to 255 with each step representing an increase of approx. 41 ms.
So 0x00 results in 41 ms blinking period (on AND off) and 0xFF in approx. 10.5 s. So 0x00 results in 41 ms blinking period (on AND off) and 0xFF in approx. 10.5 s.
- **uint8_t getGroupFREQ()** returns the set frequency of the PWM group. - **uint8_t getGroupFREQ()** returns the set frequency of the PWM group.
@ -164,13 +166,14 @@ It needs more testing and if there are issues, please report.
AllCall is automatically activated for each device on startup. AllCall is automatically activated for each device on startup.
#### Description #### Description
**SUB CALL** allows one to make groups of PCA9634 devices and control them on group level. **SUB CALL** allows one to make groups of PCA9634 devices and control them on group level.
The number of groups one can make depends on free I2C addresses on one I2C bus. The number of groups one can make depends on free I2C addresses on one I2C bus.
Using multiple I2C buses or multiplexers will even increase the possible number. Using multiple I2C buses or multiplexers will even increase the possible number.
Every PCA9634 device can be member of up to three of these groups. Every PCA9634 device can be member of up to three of these groups.
To become member one needs to set the **setSubCallAddress(nr, address)** and enable To become member one needs to set the **setSubCallAddress(nr, address)** and enable
it with **enableSubCall(nr)**. it with **enableSubCall(nr)**.
In the same way one can become member of an **ALL CALL** group. In the same way one can become member of an **ALL CALL** group.
@ -196,26 +199,26 @@ The functions to enable all/sub-addresses are straightforward:
### I2C Software reset ### I2C Software reset
The goal of this function is to reset ALL PCA9634 devices on the bus. The goal of this function is to reset ALL PCA9634 devices on the bus.
When using the software reset, ALL devices attached to the bus are set to their hardware startup conditions. 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 I²C inventor NXP. Generally, there are multiple definitions of software resets by the I²C inventor NXP.
To accommodate this, two different modes for this function have been defined and tested (library version 0.2.2). To accommodate this, two different modes for this function have been defined and tested (library version 0.2.2).
- Method 1 is a tested method which is specific to the PCA9634. - Method 1 is a tested method which is specific to the PCA9634.
Since the number of different types of I²C chips is very large, side-effects on other chips might be possible. Since the number of different types of I²C 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. 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 I²C-bus. - Method 0 is a somewhat “general” method which resets many chips on the I²C-bus.
However, this method DOES NOT reset the PCA9634 chip. However, this method DOES NOT reset the PCA9634 chip.
Therefore, consult the data sheet of all different chips on the bus to mitigate potential undefined states. Therefore, consult the data sheet of all different chips on the bus to mitigate potential undefined states.
When only working with PCA9634 chips on a bus, only method 1 is required. When only working with PCA9634 chips on a bus, only method 1 is required.
```cpp ```cpp
ledArray.I2C_SoftwareReset(1); // for method 1 ledArray.I2C_SoftwareReset(1); // for method 1
ledArray.I2C_SoftwareReset(0); // for method 0 ledArray.I2C_SoftwareReset(0); // for method 0
``` ```
In case you experience issues with this function on your chips (non-PCA9634), In case you experience issues with this function on your chips (non-PCA9634),
please give feedback, so the documentation can be improved. please give feedback, so the documentation can be improved.
For further details of the development, see - #10 (comment) For further details of the development, see - #10 (comment)
@ -228,16 +231,21 @@ See examples
## Future ## Future
#### must #### Must
- improve documentation - improve documentation
#### should #### Should
- unit tests - unit tests
- SUB CALL if possible? - SUB CALL if possible?
- ALL CALL if possible? - ALL CALL if possible?
- add examples - add examples
#### could
#### Could
- move code from .h to .cpp
- sync with PCA9635 developments - sync with PCA9635 developments
- merge with PCA9635 and a PCA963X base class if possible - merge with PCA9635 and a PCA963X base class if possible

View File

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

View File

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

View File

@ -94,4 +94,5 @@ unittest(test_LedDriverMode)
unittest_main() unittest_main()
// -------- // -- END OF FILE --