Skip to content

Commit 5987b8b

Browse files
committed
0.2.1 HC4067
1 parent 58cdf36 commit 5987b8b

File tree

12 files changed

+42
-17
lines changed

12 files changed

+42
-17
lines changed

libraries/HC4067/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88

9+
## [0.2.1] - 2024-05-28
10+
- change return type of **bool setChannel()**
11+
- verify the channel parameter of **bool setChannel()**
12+
- add parameter to **bool setChannel(channel, disable = true)**
13+
- update readme.md
14+
915
## [0.2.0] - 2024-04-03
1016
- fix ghost channels when using for OUTPUT
1117
- add disable/enable in setChannel()

libraries/HC4067/HC4067.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
// FILE: HC4067.h
44
// AUTHOR: Rob Tillaart
55
// DATE: 2023-01-25
6-
// VERSION: 0.2.0
6+
// VERSION: 0.2.1
77
// PURPOSE: Arduino library for CD74HC4067 1 x 16 channel multiplexer and compatibles.
88
// URL: https://github.com/RobTillaart/HC4067
99

1010

1111

1212
#include "Arduino.h"
1313

14-
#define HC4067_LIB_VERSION (F("0.2.0"))
14+
#define HC4067_LIB_VERSION (F("0.2.1"))
1515

1616

1717
class HC4067
@@ -40,15 +40,19 @@ class HC4067
4040
}
4141

4242

43-
void setChannel(uint8_t channel)
43+
bool setChannel(uint8_t channel, bool disable = true)
4444
{
45-
uint8_t _new = channel & 0x0F;
45+
if (channel > 15) return false;
46+
uint8_t _new = channel;
4647
if (_new != _channel)
4748
{
4849
uint8_t _changed = _new ^ _channel;
4950
uint8_t mask = 0x08;
5051
uint8_t i = 3;
51-
disable(); // prevent ghost channels.
52+
if (disable)
53+
{
54+
this->disable(); // prevent ghost channels.
55+
}
5256
while (mask)
5357
{
5458
// only write changed pins. // AVR only?
@@ -61,6 +65,7 @@ class HC4067
6165
enable();
6266
_channel = _new;
6367
}
68+
return true;
6469
}
6570

6671

libraries/HC4067/README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,16 @@ This will result in another subset of the Y pins to select from.
112112
- **HC4067(uint8_t s0, uint8_t s1, uint8_t s2, uint8_t s3, uint8_t enablePin = 255)** constructor.
113113
Set the 4 select pins and optional the enable pin.
114114
If the enablePin == 255 it is considered not used.
115-
- **void setChannel(uint8_t channel)** set the current channel.
116-
Valid values 0..15, this value is not checked, only the lower 4 bits will be used.
115+
- **bool setChannel(uint8_t channel, bool disable = true)** set the current channel.
116+
Valid values 0..15, this value is checked (since 0.2.1).
117+
Returns false if channel out of range.
118+
If the channel is already selected it does not change it.
119+
Note the four channels will not change at the very same moment,
120+
possibly resulting in an invalid selection for a (very short) time.
121+
The disable flag can be set to false so the device is not disabled during channel switching.
122+
Default the device is disabled during channel switching to prevent (very short) ghost channels.
123+
Note that a call to **setChannel()** will always enable the device again.
124+
Note the device cannot be disabled if there is no enable pin configured.
117125
- **uint8_t getChannel()** returns the current channel 0..15.
118126
The selected channel is also returned when the multiplexer is disabled.
119127

@@ -122,9 +130,9 @@ The selected channel is also returned when the multiplexer is disabled.
122130

123131
These functions work only if enablePin is set in the constructor.
124132

125-
- **void enable()** enables the HC4067 to multiplex.
126-
- **void disable()** disables the HC4067, no channel is selected.
127-
- **bool isEnabled()** returns the current status of the HC4067.
133+
- **void enable()** enables the device to multiplex.
134+
- **void disable()** disables the device, no channel is selected.
135+
- **bool isEnabled()** returns the current status of the device.
128136
Also returns true if the enablePin is not set in the constructor.
129137

130138

@@ -146,10 +154,10 @@ Also returns true if the enablePin is not set in the constructor.
146154

147155
#### Won't (unless requested)
148156

149-
- check channel in setChannel() ?
150-
- return true if in range, false otherwise.
151157
- move code to .cpp file
152-
158+
- uint8_t channelCount() { return 16; };
159+
- cache enable status
160+
- inline the enable/disable
153161

154162
## Support
155163

libraries/HC4067/examples/HC4067_16_buttons/HC4067_16_buttons.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// AUTHOR: Rob Tillaart
44
// PURPOSE: Demo for HC4067 16 channel (simple) multiplexer
55
// read 16 buttons / switches.
6+
// URL: https://github.com/RobTillaart/HC4067
67

78

89
#include "HC4067.h"

libraries/HC4067/examples/HC4067_4_channel_plotter/HC4067_4_channel_plotter.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// FILE: HC4067_4_channel_plotter.ino
33
// AUTHOR: Rob Tillaart
44
// PURPOSE: Demo for HC4067 16 channel (simple) multiplexer
5-
//
5+
// URL: https://github.com/RobTillaart/HC4067
66

77
// connect analog channel A0 to the multiplexer
88
// connect 4 analog signals to input 0..3 of the multiplexer

libraries/HC4067/examples/HC4067_demo/HC4067_demo.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// FILE: HC4067_demo.ino
33
// AUTHOR: Rob Tillaart
44
// PURPOSE: Demo for HC4067 16 channel (simple) multiplexer
5+
// URL: https://github.com/RobTillaart/HC4067
56

67

78
#include "HC4067.h"

libraries/HC4067/examples/HC4067_performance/HC4067_performance.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
// FILE: HC4067_performance.ino
33
// AUTHOR: Rob Tillaart
44
// PURPOSE: Demo for HC4067 16 channel (simple) multiplexer
5+
// URL: https://github.com/RobTillaart/HC4067
56

67

78
#include "HC4067.h"
89

9-
HC4067 mp(4, 5, 6, 7, 8);
10+
HC4067 mp(4, 5, 6, 7, 8); // enable pin(8)
1011

1112
uint32_t start, stop;
1213

libraries/HC4067/examples/HC4067_test/HC4067_test.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// FILE: HC4067_test.ino
33
// AUTHOR: Rob Tillaart
44
// PURPOSE: Demo for HC4067 16 channel (simple) multiplexer
5+
// URL: https://github.com/RobTillaart/HC4067
56

67

78
#include "HC4067.h"

libraries/HC4067/examples/HC4067_write/HC4067_write.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// FILE: HC4067_write.ino
33
// AUTHOR: Rob Tillaart
44
// PURPOSE: Demo for HC4067 16 channel (simple) multiplexer
5+
// URL: https://github.com/RobTillaart/HC4067
56

67

78
#include "HC4067.h"

libraries/HC4067/keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ HC4067 KEYWORD1
66
# Methods and Functions (KEYWORD2)
77
setChannel KEYWORD2
88
getChannel KEYWORD2
9+
910
enable KEYWORD2
1011
disable KEYWORD2
1112
isEnabled KEYWORD2

libraries/HC4067/library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/HC4067.git"
1717
},
18-
"version": "0.2.0",
18+
"version": "0.2.1",
1919
"license": "MIT",
2020
"frameworks": "*",
2121
"platforms": "*",

libraries/HC4067/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=HC4067
2-
version=0.2.0
2+
version=0.2.1
33
author=Rob Tillaart <[email protected]>
44
maintainer=Rob Tillaart <[email protected]>
55
sentence=Arduino library for a HC4067 1 x 16 channel multiplexer

0 commit comments

Comments
 (0)