0.2.1 HC4052

This commit is contained in:
Rob Tillaart 2024-05-28 21:37:41 +02:00
parent 1f58227dec
commit 58cdf368a5
8 changed files with 27 additions and 10 deletions

View File

@ -6,6 +6,11 @@ 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
- 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()

View File

@ -3,14 +3,14 @@
// FILE: HC4052.h
// AUTHOR: Rob Tillaart
// DATE: 2023-01-25
// VERSION: 0.2.0
// VERSION: 0.2.1
// PURPOSE: Arduino library for HC4052 2 x 4 channel multiplexer and compatibles.
// URL: https://github.com/RobTillaart/HC4052
#include "Arduino.h"
#define HC4052_LIB_VERSION (F("0.2.0"))
#define HC4052_LIB_VERSION (F("0.2.1"))
class HC4052
@ -37,12 +37,15 @@ public:
}
bool setChannel(uint8_t channel)
bool setChannel(uint8_t channel, bool disable = true)
{
if (channel > 0x03) return false;
if (channel > 3) return false;
if (channel != _channel)
{
disable(); // prevent ghost channels.
if (disable)
{
this->disable(); // prevent ghost channels.
}
digitalWrite(_pins[0], channel & 0x01);
digitalWrite(_pins[1], channel & 0x02);
enable();

View File

@ -92,9 +92,15 @@ Example multiplexing analog in.
Set the two select pins and optional the enable pin.
If the enablePin == 255 it is considered not used.
- **bool setChannel(uint8_t channel)** set the current channel.
Valid values 0..3, returns false if channel out of range.
Valid values 0..3, this value is checked (since 0.2.1).
Returns false if channel out of range.
If the channel is already selected it does not change it.
Calling setChannel will enable it.
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.
- **uint8_t getChannel()** returns the current channel 0..3.
The selected channel is also returned when the multiplexer is disabled.

View File

@ -2,6 +2,7 @@
// FILE: HC4052_demo.ino
// AUTHOR: Rob Tillaart
// PURPOSE: Demo for HC4052 2 x 4 channel (simple) multiplexer
// URL: https://github.com/RobTillaart/HC4052
#include "HC4052.h"

View File

@ -2,6 +2,7 @@
// FILE: HC4052_performance.ino
// AUTHOR: Rob Tillaart
// PURPOSE: Demo for HC4052 2 x 4 channel (simple) multiplexer
// URL: https://github.com/RobTillaart/HC4052
#include "HC4052.h"

View File

@ -6,6 +6,7 @@ HC4052 KEYWORD1
# Methods and Functions (KEYWORD2)
setChannel KEYWORD2
getChannel KEYWORD2
enable KEYWORD2
disable KEYWORD2
isEnabled KEYWORD2

View File

@ -1,7 +1,7 @@
{
"name": "HC4052",
"keywords": "",
"description": "Arduino library for a HC4052 2x4 channel multiplexer.",
"description": "Arduino library for a HC4052 2 x 4 channel multiplexer.",
"authors":
[
{
@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/HC4052.git"
},
"version": "0.2.0",
"version": "0.2.1",
"license": "MIT",
"frameworks": "*",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=HC4052
version=0.2.0
version=0.2.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for a HC4052 2 x 4 channel multiplexer