Skip to content

Commit 95300d4

Browse files
committed
NOT_A_PIN is now allowed for the enable pin of a AnalogMultiplexer that has been tied to GND
1 parent c9c6900 commit 95300d4

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

avr/libraries/AnalogMultiplexer/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A library to interface with analog multiplexers. Supports 4051, 4052, 4053, and
77
#include <AnalogMultiplexer.h>
88
99
enum {
10-
PIN_EN = 2, // The enable pin of the multiplexer.
10+
PIN_EN = 2, // The enable pin of the multiplexer or NOT_A_PIN.
1111
PIN_S0 = 3, // Channel selector pin 0.
1212
PIN_S1 = 4, // Channel selector pin 1.
1313
PIN_S2 = 5, // Channel selector pin 2.

avr/libraries/AnalogMultiplexer/examples/AnalogMultiplexerExample/AnalogMultiplexerExample.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Selected Arduino pins.
44
enum {
5-
PIN_EN = 2, // The enable pin of the multiplexer.
5+
PIN_EN = 2, // The enable pin of the multiplexer or NOT_A_PIN.
66
PIN_S0 = 3, // Channel selector pin 0.
77
PIN_S1 = 4, // Channel selector pin 1.
88
PIN_S2 = 5, // Channel selector pin 2.

avr/libraries/AnalogMultiplexer/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=AnalogMultiplexer
2-
version=1.0.0
2+
version=1.0.1
33
author=Julian Sanin <sanin89julian@gmail.com>
44
maintainer=Julian Sanin <sanin89julian@gmail.com>
55
sentence=A library to interface with analog multiplexers.

avr/libraries/AnalogMultiplexer/src/AnalogMultiplexer.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,21 @@
2929
AnalogMultiplexer::AnalogMultiplexer(uint8_t pinEnable) {
3030
_pinEnable = pinEnable;
3131
_pinCommon = NOT_A_PIN;
32-
/*Arduino*/::pinMode(_pinEnable, OUTPUT);
32+
if (NOT_A_PIN != _pinEnable) {
33+
/*Arduino*/::pinMode(_pinEnable, OUTPUT);
34+
}
3335
}
3436

3537
void AnalogMultiplexer::enable() {
36-
/*Arduino*/::digitalWrite(_pinEnable, LOW);
38+
if (NOT_A_PIN != _pinEnable) {
39+
/*Arduino*/::digitalWrite(_pinEnable, LOW);
40+
}
3741
}
3842

3943
void AnalogMultiplexer::disable() {
40-
/*Arduino*/::digitalWrite(_pinEnable, HIGH);
44+
if (NOT_A_PIN != _pinEnable) {
45+
/*Arduino*/::digitalWrite(_pinEnable, HIGH);
46+
}
4147
}
4248

4349
void AnalogMultiplexer::pinMode(uint8_t pinCommon, uint8_t mode) {

0 commit comments

Comments
 (0)