diff --git a/libraries/HC4053/CHANGELOG.md b/libraries/HC4053/CHANGELOG.md index 4568725f..fc59ffea 100644 --- a/libraries/HC4053/CHANGELOG.md +++ b/libraries/HC4053/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.2.1] - 2024-05-28 +- change return type of **bool setChannel()** +- verify the channel parameter of **bool setChannel()** +- add parameter to **bool setChannel(channel, disable = true)** +- update readme.md + ## [0.2.0] - 2024-04-03 - fix ghost channels when using for OUTPUT - add disable/enable in setChannel() diff --git a/libraries/HC4053/HC4053.h b/libraries/HC4053/HC4053.h index 327ce4ed..af626106 100644 --- a/libraries/HC4053/HC4053.h +++ b/libraries/HC4053/HC4053.h @@ -3,15 +3,14 @@ // FILE: HC4053.h // AUTHOR: Rob Tillaart // DATE: 2023-01-25 -// VERSION: 0.2.0 +// VERSION: 0.2.1 // PURPOSE: Arduino library for CD74HC4053 8 channel multiplexer and compatibles. // URL: https://github.com/RobTillaart/HC4053 - #include "Arduino.h" -#define HC4053_LIB_VERSION (F("0.2.0")) +#define HC4053_LIB_VERSION (F("0.2.1")) class HC4053 @@ -42,13 +41,18 @@ public: } - void setChannel(uint8_t channel) + bool setChannel(uint8_t channel, bool disable = true) { - disable(); + if (channel > 1) return false; + if (disable) + { + this->disable(); + } setChannelA(channel); setChannelB(channel); setChannelC(channel); enable(); + return true; } diff --git a/libraries/HC4053/README.md b/libraries/HC4053/README.md index 6232d063..40b03a1f 100644 --- a/libraries/HC4053/README.md +++ b/libraries/HC4053/README.md @@ -93,10 +93,16 @@ Example multiplexing three times analog in. - **HC4053(uint8_t A, uint8_t B, uint8_t C, uint8_t enablePin = 255)** constructor. Set the three select pins and optional the enable pin. If the enablePin == 255 it is considered not used. -- **void setChannel(uint8_t channel)** sets A, B and C to channel in one call. +- **bool setChannel(uint8_t channel, bool disable = true)** sets A, B and C to channel in one call. Think of it as a master switch. -Valid values 0, 1, this value is not checked, only last bit is used. -Note the three channels will not change at the very same moment. +Valid values 0, 1, this value is checked (since 0.2.1). +Returns false if channel out of range. +Note the three channels will not change at the very same moment, +possibly resulting in an invalid selection for a (very short) time. +The disable flag can be set to false so the device is not disabled during channel switching. +Default the device is disabled during channel switching to prevent (very short) ghost channels. +Note that a call to **setChannel()** will always enable the device again. +Note the device cannot be disabled if there is no enable pin configured. - **void setChannelA(uint8_t channel)** sets A to channel. Valid values 0, 1, this value is not checked, only last bit is used. - **void setChannelB(uint8_t channel)** sets B to channel. diff --git a/libraries/HC4053/examples/HC4053_demo/HC4053_demo.ino b/libraries/HC4053/examples/HC4053_demo/HC4053_demo.ino index 89592851..dfd60911 100644 --- a/libraries/HC4053/examples/HC4053_demo/HC4053_demo.ino +++ b/libraries/HC4053/examples/HC4053_demo/HC4053_demo.ino @@ -2,6 +2,7 @@ // FILE: HC4053_demo.ino // AUTHOR: Rob Tillaart // PURPOSE: Demo for HC4051 8 channel (simple) multiplexer +// URL: https://github.com/RobTillaart/HC4053 #include "HC4053.h" diff --git a/libraries/HC4053/examples/HC4053_performance/HC4053_performance.ino b/libraries/HC4053/examples/HC4053_performance/HC4053_performance.ino index 0f824df5..dfe629fe 100644 --- a/libraries/HC4053/examples/HC4053_performance/HC4053_performance.ino +++ b/libraries/HC4053/examples/HC4053_performance/HC4053_performance.ino @@ -2,6 +2,7 @@ // FILE: HC4053_performance.ino // AUTHOR: Rob Tillaart // PURPOSE: Demo for HC4053 3 x 2 channel (simple) multiplexer +// URL: https://github.com/RobTillaart/HC4053 #include "HC4053.h" diff --git a/libraries/HC4053/keywords.txt b/libraries/HC4053/keywords.txt index 0474716e..d27cc808 100644 --- a/libraries/HC4053/keywords.txt +++ b/libraries/HC4053/keywords.txt @@ -6,6 +6,7 @@ HC4053 KEYWORD1 # Methods and Functions (KEYWORD2) setChannel KEYWORD2 getChannel KEYWORD2 + enable KEYWORD2 disable KEYWORD2 isEnabled KEYWORD2 diff --git a/libraries/HC4053/library.json b/libraries/HC4053/library.json index ac52b257..46037d82 100644 --- a/libraries/HC4053/library.json +++ b/libraries/HC4053/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/HC4053.git" }, - "version": "0.2.0", + "version": "0.2.1", "license": "MIT", "frameworks": "*", "platforms": "*", diff --git a/libraries/HC4053/library.properties b/libraries/HC4053/library.properties index a0954d9c..2f13df07 100644 --- a/libraries/HC4053/library.properties +++ b/libraries/HC4053/library.properties @@ -1,5 +1,5 @@ name=HC4053 -version=0.2.0 +version=0.2.1 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for a HC4053 3 x 2 channel multiplexer