Skip to content

Commit d6697e4

Browse files
committed
0.1.0 I2C_HC4067
1 parent 0975b9b commit d6697e4

16 files changed

Lines changed: 730 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
platforms:
2+
rpipico:
3+
board: rp2040:rp2040:rpipico
4+
package: rp2040:rp2040
5+
gcc:
6+
features:
7+
defines:
8+
- ARDUINO_ARCH_RP2040
9+
warnings:
10+
flags:
11+
12+
packages:
13+
rp2040:rp2040:
14+
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
15+
16+
compile:
17+
# Choosing to run compilation tests on 2 different Arduino platforms
18+
platforms:
19+
- uno
20+
# - due
21+
# - zero
22+
# - leonardo
23+
- m4
24+
- esp32
25+
- esp8266
26+
# - mega2560
27+
- rpipico
28+
29+
libraries:
30+
- "printHelpers"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# These are supported funding model platforms
2+
3+
github: RobTillaart
4+
custom: "https://www.paypal.me/robtillaart"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Arduino-lint
2+
3+
on: [push, pull_request]
4+
jobs:
5+
lint:
6+
runs-on: ubuntu-latest
7+
timeout-minutes: 5
8+
steps:
9+
- uses: actions/checkout@v6
10+
- uses: arduino/arduino-lint-action@v2
11+
with:
12+
library-manager: update
13+
compliance: strict
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Arduino CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
runTest:
7+
runs-on: ubuntu-latest
8+
timeout-minutes: 20
9+
steps:
10+
- uses: actions/checkout@v6
11+
- uses: ruby/setup-ruby@v1
12+
with:
13+
ruby-version: 2.6
14+
- run: |
15+
gem install arduino_ci
16+
arduino_ci.rb
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: JSON check
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.json'
7+
pull_request:
8+
paths:
9+
- '**.json'
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 5
15+
steps:
16+
- uses: actions/checkout@v6
17+
- name: json-syntax-check
18+
uses: limitusus/json-syntax-check@v2
19+
with:
20+
pattern: "\\.json$"

libraries/I2C_HC4067/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Change Log I2C_HC4067
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/).
7+
8+
9+
## [0.1.0] - 2026-03-30
10+
- initial version (based upon 0.3.1 HC4067)
11+
12+

libraries/I2C_HC4067/I2C_HC4067.h

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#pragma once
2+
//
3+
// FILE: I2C_I2C_HC4067.h
4+
// AUTHOR: Rob Tillaart
5+
// DATE: 2026-03-30
6+
// VERSION: 0.1.0
7+
// PURPOSE: Arduino library for CD74HC4067 1 x 16 channel multiplexer and compatibles.
8+
// URL: https://github.com/RobTillaart/I2C_HC4067
9+
10+
11+
#include "Arduino.h"
12+
#include "Wire.h"
13+
14+
#define I2C_HC4067_LIB_VERSION (F("0.1.0"))
15+
16+
17+
class I2C_HC4067
18+
{
19+
public:
20+
////////////////////////////////////////////////////////////
21+
//
22+
// Constructor
23+
//
24+
I2C_HC4067(uint8_t address, TwoWire *wire = &Wire)
25+
{
26+
_address = address;
27+
_wire = wire;
28+
29+
_channel = 0;
30+
// to force write.
31+
_lastValue = 0x10;
32+
}
33+
34+
bool begin()
35+
{
36+
if (! isConnected())
37+
{
38+
return false;
39+
}
40+
this->disable();
41+
return true;
42+
}
43+
44+
bool isConnected()
45+
{
46+
_wire->beginTransmission(_address);
47+
return (_wire->endTransmission() == 0);
48+
}
49+
50+
uint8_t getAddress()
51+
{
52+
return _address;
53+
}
54+
55+
56+
////////////////////////////////////////////////////////////
57+
//
58+
// HC4067 API
59+
//
60+
bool setChannel(uint8_t channel, bool disable = true)
61+
{
62+
if (channel > 15) return false;
63+
if (channel != _channel)
64+
{
65+
_channel = channel;
66+
if (disable) this->disable(); // prevent ghost channels.
67+
this->_write();
68+
this->enable();
69+
}
70+
return true;
71+
}
72+
73+
uint8_t getChannel()
74+
{
75+
return _channel;
76+
}
77+
78+
void enable()
79+
{
80+
_enable = true;
81+
this->_write();
82+
}
83+
84+
void disable()
85+
{
86+
_enable = false;
87+
this->_write();
88+
}
89+
90+
bool isEnabled()
91+
{
92+
return _enable;
93+
}
94+
95+
96+
private:
97+
int _write()
98+
{
99+
uint8_t value = _channel;
100+
if (_enable) value |= 0x10;
101+
102+
// no change.
103+
if (_lastValue == value) return 0;
104+
_lastValue = value;
105+
_wire->beginTransmission(_address);
106+
_wire->write(value);
107+
_error = _wire->endTransmission();
108+
return _error;
109+
}
110+
111+
uint8_t _address;
112+
TwoWire* _wire;
113+
114+
bool _enable;
115+
uint8_t _channel;
116+
uint8_t _lastValue;
117+
int _error;
118+
};
119+
120+
121+
// -- END OF FILE --
122+

libraries/I2C_HC4067/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026-2026 Rob Tillaart
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)