Skip to content

Commit 58cdf36

Browse files
committed
0.2.1 HC4052
1 parent 1f58227 commit 58cdf36

File tree

8 files changed

+27
-10
lines changed

8 files changed

+27
-10
lines changed

libraries/HC4052/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ 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+
- verify the channel parameter of **bool setChannel()**
11+
- add parameter to **bool setChannel(channel, disable = true)**
12+
- update readme.md
13+
914
## [0.2.0] - 2024-04-03
1015
- fix ghost channels when using for OUTPUT
1116
- add disable/enable in setChannel()

libraries/HC4052/HC4052.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
// FILE: HC4052.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 HC4052 2 x 4 channel multiplexer and compatibles.
88
// URL: https://github.com/RobTillaart/HC4052
99

1010

1111
#include "Arduino.h"
1212

13-
#define HC4052_LIB_VERSION (F("0.2.0"))
13+
#define HC4052_LIB_VERSION (F("0.2.1"))
1414

1515

1616
class HC4052
@@ -37,12 +37,15 @@ class HC4052
3737
}
3838

3939

40-
bool setChannel(uint8_t channel)
40+
bool setChannel(uint8_t channel, bool disable = true)
4141
{
42-
if (channel > 0x03) return false;
42+
if (channel > 3) return false;
4343
if (channel != _channel)
4444
{
45-
disable(); // prevent ghost channels.
45+
if (disable)
46+
{
47+
this->disable(); // prevent ghost channels.
48+
}
4649
digitalWrite(_pins[0], channel & 0x01);
4750
digitalWrite(_pins[1], channel & 0x02);
4851
enable();

libraries/HC4052/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,15 @@ Example multiplexing analog in.
9292
Set the two select pins and optional the enable pin.
9393
If the enablePin == 255 it is considered not used.
9494
- **bool setChannel(uint8_t channel)** set the current channel.
95-
Valid values 0..3, returns false if channel out of range.
95+
Valid values 0..3, this value is checked (since 0.2.1).
96+
Returns false if channel out of range.
9697
If the channel is already selected it does not change it.
97-
Calling setChannel will enable it.
98+
Note the three channels will not change at the very same moment,
99+
possibly resulting in an invalid selection for a (very short) time.
100+
The disable flag can be set to false so the device is not disabled during channel switching.
101+
Default the device is disabled during channel switching to prevent (very short) ghost channels.
102+
Note that a call to **setChannel()** will always enable the device again.
103+
Note the device cannot be disabled if there is no enable pin configured.
98104
- **uint8_t getChannel()** returns the current channel 0..3.
99105
The selected channel is also returned when the multiplexer is disabled.
100106

libraries/HC4052/examples/HC4052_demo/HC4052_demo.ino

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

67

78
#include "HC4052.h"

libraries/HC4052/examples/HC4052_performance/HC4052_performance.ino

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

67

78
#include "HC4052.h"

libraries/HC4052/keywords.txt

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

libraries/HC4052/library.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "HC4052",
33
"keywords": "",
4-
"description": "Arduino library for a HC4052 2x4 channel multiplexer.",
4+
"description": "Arduino library for a HC4052 2 x 4 channel multiplexer.",
55
"authors":
66
[
77
{
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/HC4052.git"
1717
},
18-
"version": "0.2.0",
18+
"version": "0.2.1",
1919
"license": "MIT",
2020
"frameworks": "*",
2121
"platforms": "*",

libraries/HC4052/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=HC4052
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 HC4052 2 x 4 channel multiplexer

0 commit comments

Comments
 (0)