Skip to content

Commit

Permalink
updated setPolarity function and completed full usage exaple
Browse files Browse the repository at this point in the history
  • Loading branch information
nadavmatalon committed Oct 26, 2016
1 parent f66af41 commit 99c1ce8
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 201 deletions.
6 changes: 5 additions & 1 deletion PCA9536.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ void PCA9536::setPolarity(pin_t pin, polarity_t newPolarity) { // PARAM
*==============================================================================================================*/

void PCA9536::setPolarity(polarity_t newPolarity) { // PARAMS: IO_NON_INVERTED / IO_INVERTED
setReg(REG_POLARITY, (newPolarity ? ALL_INVERTED : ALL_NON_INVERTED));
byte polarityVals, polarityMask, polarityNew;
polarityVals = getReg(REG_POLARITY);
polarityMask = getReg(REG_CONFIG);
polarityNew = newPolarity ? ALL_INVERTED : ALL_NON_INVERTED;
setReg(REG_POLARITY, (polarityVals & ~polarityMask) | (polarityNew & polarityMask));
}

/*==============================================================================================================*
Expand Down
2 changes: 1 addition & 1 deletion PCA9536.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ namespace Pca9536 {
const byte NUM_BYTES = 0x01;
const byte ALL_INPUT = 0xFF;
const byte ALL_OUTPUT = 0x00;
const byte ALL_LOW = 0xFF;
const byte ALL_LOW = 0x00;
const byte ALL_HIGH = 0xFF;
const byte ALL_NON_INVERTED = 0x00;
const byte ALL_INVERTED = 0xFF;
Expand Down
Loading

0 comments on commit 99c1ce8

Please sign in to comment.