File tree Expand file tree Collapse file tree 8 files changed +27
-10
lines changed
Expand file tree Collapse file tree 8 files changed +27
-10
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66and 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()
Original file line number Diff line number Diff line change 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
1616class 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 ();
Original file line number Diff line number Diff line change @@ -92,9 +92,15 @@ Example multiplexing analog in.
9292Set the two select pins and optional the enable pin.
9393If 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.
9697If 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.
99105The selected channel is also returned when the multiplexer is disabled.
100106
Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ HC4052 KEYWORD1
66# Methods and Functions (KEYWORD2)
77setChannel KEYWORD2
88getChannel KEYWORD2
9+
910enable KEYWORD2
1011disable KEYWORD2
1112isEnabled KEYWORD2
Original file line number Diff line number Diff line change 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 {
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" : " *" ,
Original file line number Diff line number Diff line change 11name =HC4052
2- version =0.2.0
2+ version =0.2.1
33author =Rob Tillaart <
[email protected] >
44maintainer =Rob Tillaart <
[email protected] >
55sentence =Arduino library for a HC4052 2 x 4 channel multiplexer
You can’t perform that action at this time.
0 commit comments