mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.2.1 HC4052
This commit is contained in:
parent
1f58227dec
commit
58cdf368a5
@ -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/).
|
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
|
## [0.2.0] - 2024-04-03
|
||||||
- fix ghost channels when using for OUTPUT
|
- fix ghost channels when using for OUTPUT
|
||||||
- add disable/enable in setChannel()
|
- add disable/enable in setChannel()
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
// FILE: HC4052.h
|
// FILE: HC4052.h
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// DATE: 2023-01-25
|
// DATE: 2023-01-25
|
||||||
// VERSION: 0.2.0
|
// VERSION: 0.2.1
|
||||||
// PURPOSE: Arduino library for HC4052 2 x 4 channel multiplexer and compatibles.
|
// PURPOSE: Arduino library for HC4052 2 x 4 channel multiplexer and compatibles.
|
||||||
// URL: https://github.com/RobTillaart/HC4052
|
// URL: https://github.com/RobTillaart/HC4052
|
||||||
|
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
|
||||||
#define HC4052_LIB_VERSION (F("0.2.0"))
|
#define HC4052_LIB_VERSION (F("0.2.1"))
|
||||||
|
|
||||||
|
|
||||||
class HC4052
|
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)
|
if (channel != _channel)
|
||||||
{
|
{
|
||||||
disable(); // prevent ghost channels.
|
if (disable)
|
||||||
|
{
|
||||||
|
this->disable(); // prevent ghost channels.
|
||||||
|
}
|
||||||
digitalWrite(_pins[0], channel & 0x01);
|
digitalWrite(_pins[0], channel & 0x01);
|
||||||
digitalWrite(_pins[1], channel & 0x02);
|
digitalWrite(_pins[1], channel & 0x02);
|
||||||
enable();
|
enable();
|
||||||
|
@ -92,9 +92,15 @@ Example multiplexing analog in.
|
|||||||
Set the two select pins and optional the enable pin.
|
Set the two select pins and optional the enable pin.
|
||||||
If the enablePin == 255 it is considered not used.
|
If the enablePin == 255 it is considered not used.
|
||||||
- **bool setChannel(uint8_t channel)** set the current channel.
|
- **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.
|
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.
|
- **uint8_t getChannel()** returns the current channel 0..3.
|
||||||
The selected channel is also returned when the multiplexer is disabled.
|
The selected channel is also returned when the multiplexer is disabled.
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// FILE: HC4052_demo.ino
|
// FILE: HC4052_demo.ino
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// PURPOSE: Demo for HC4052 2 x 4 channel (simple) multiplexer
|
// PURPOSE: Demo for HC4052 2 x 4 channel (simple) multiplexer
|
||||||
|
// URL: https://github.com/RobTillaart/HC4052
|
||||||
|
|
||||||
|
|
||||||
#include "HC4052.h"
|
#include "HC4052.h"
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// FILE: HC4052_performance.ino
|
// FILE: HC4052_performance.ino
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// PURPOSE: Demo for HC4052 2 x 4 channel (simple) multiplexer
|
// PURPOSE: Demo for HC4052 2 x 4 channel (simple) multiplexer
|
||||||
|
// URL: https://github.com/RobTillaart/HC4052
|
||||||
|
|
||||||
|
|
||||||
#include "HC4052.h"
|
#include "HC4052.h"
|
||||||
|
@ -6,6 +6,7 @@ HC4052 KEYWORD1
|
|||||||
# Methods and Functions (KEYWORD2)
|
# Methods and Functions (KEYWORD2)
|
||||||
setChannel KEYWORD2
|
setChannel KEYWORD2
|
||||||
getChannel KEYWORD2
|
getChannel KEYWORD2
|
||||||
|
|
||||||
enable KEYWORD2
|
enable KEYWORD2
|
||||||
disable KEYWORD2
|
disable KEYWORD2
|
||||||
isEnabled KEYWORD2
|
isEnabled KEYWORD2
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "HC4052",
|
"name": "HC4052",
|
||||||
"keywords": "",
|
"keywords": "",
|
||||||
"description": "Arduino library for a HC4052 2x4 channel multiplexer.",
|
"description": "Arduino library for a HC4052 2 x 4 channel multiplexer.",
|
||||||
"authors":
|
"authors":
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@ -15,7 +15,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/RobTillaart/HC4052.git"
|
"url": "https://github.com/RobTillaart/HC4052.git"
|
||||||
},
|
},
|
||||||
"version": "0.2.0",
|
"version": "0.2.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"frameworks": "*",
|
"frameworks": "*",
|
||||||
"platforms": "*",
|
"platforms": "*",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name=HC4052
|
name=HC4052
|
||||||
version=0.2.0
|
version=0.2.1
|
||||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
sentence=Arduino library for a HC4052 2 x 4 channel multiplexer
|
sentence=Arduino library for a HC4052 2 x 4 channel multiplexer
|
||||||
|
Loading…
Reference in New Issue
Block a user