diff --git a/src/PCA9633.cpp b/src/PCA9633.cpp index 1af717a..61582de 100644 --- a/src/PCA9633.cpp +++ b/src/PCA9633.cpp @@ -147,6 +147,20 @@ void PCA9633::setDrvState(uint8_t state) { writeReg(REG_MODE2, newReg); } +void PCA9633::setInvertState(uint8_t invert) { + + uint8_t prevReg = readReg(REG_MODE2); + uint8_t newReg; + + // first clear the INVRT bit + newReg = prevReg & ~(1 << BIT_INVRT); + + // second set new state to specified invrt + newReg |= (state << BIT_INVRT); + + writeReg(REG_MODE2, newReg); +} + void PCA9633::setAutoIncrement(uint8_t option) { uint8_t newReg; diff --git a/src/PCA9633.h b/src/PCA9633.h index dd2fc92..3674b5d 100644 --- a/src/PCA9633.h +++ b/src/PCA9633.h @@ -207,6 +207,18 @@ */ #define OUTDRV_TOTEM_POLE 1 +// LED driver invert mode, INVRT (page 12, table 9, MODE2 register table, also see section 7.7) + +/** + * The 4 LED outputs are configured with non-inverting outputs + */ +#define INVERT_OFF 0 + +/** + * The 4 LED outputs are configured with inverting outputs + */ +#define INVERT_ON 1 + // LED driver output state, LEDOUT (page 14, below table 13) /** @@ -404,6 +416,15 @@ class PCA9633 { */ void setDrvState(uint8_t state); + /** + * Set the global output invert mode. There are two types: + * - INVERT_OFF + * - INVERT_ON + * + * @param state One of the two possible states + */ + void setInvertState(uint8_t state); + /** * Set the LED driver output state for a given channel. There are four states: * - LDR_STATE_OFF