Skip to content

Commit 0686a77

Browse files
author
Jim Lindblom
committed
Adding sink flag to ledDriverInit
1 parent 963a825 commit 0686a77

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/sx1509_library.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ byte sx1509Class::readPin(byte pin)
151151
return 0;
152152
}
153153

154-
void sx1509Class::ledDriverInit(byte pin, byte freq, bool log)
154+
void sx1509Class::ledDriverInit(byte pin, byte freq, bool log, bool sink)
155155
{
156156
unsigned int tempWord;
157157
byte tempByte;
@@ -167,11 +167,14 @@ void sx1509Class::ledDriverInit(byte pin, byte freq, bool log)
167167
tempWord &= ~(1<<pin);
168168
writeWord(REG_PULL_UP_B, tempWord);
169169

170-
// Enable open-drain
171-
// Writing a 1 to the pin bit will enable open drain on that pin
172-
tempWord = readWord(REG_OPEN_DRAIN_B);
173-
tempWord |= (1<<pin);
174-
writeWord(REG_OPEN_DRAIN_B, tempWord);
170+
if (sink)
171+
{
172+
// Enable open-drain
173+
// Writing a 1 to the pin bit will enable open drain on that pin
174+
tempWord = readWord(REG_OPEN_DRAIN_B);
175+
tempWord |= (1<<pin);
176+
writeWord(REG_OPEN_DRAIN_B, tempWord);
177+
}
175178

176179
// Set direction to output (REG_DIR_B)
177180
pinDir(pin, OUTPUT);

src/sx1509_library.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class sx1509Class
148148
// - currently log sets both bank A and B to the same mode
149149
// Note: this function automatically decides to use the internal 2MHz osc.
150150
// -----------------------------------------------------------------------------
151-
void ledDriverInit(byte pin, byte freq = 1, bool log = 0);
151+
void ledDriverInit(byte pin, byte freq = 1, bool log = false, bool sink = false);
152152

153153
// -----------------------------------------------------------------------------
154154
// pwm(byte pin, byte iOn): This function can be used to control the intensity

0 commit comments

Comments
 (0)