-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6255900
commit ee26ea0
Showing
15 changed files
with
753 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
platforms: | ||
rpipico: | ||
board: rp2040:rp2040:rpipico | ||
package: rp2040:rp2040 | ||
gcc: | ||
features: | ||
defines: | ||
- ARDUINO_ARCH_RP2040 | ||
warnings: | ||
flags: | ||
|
||
packages: | ||
rp2040:rp2040: | ||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json | ||
|
||
compile: | ||
# Choosing to run compilation tests on 2 different Arduino platforms | ||
platforms: | ||
- uno | ||
# - due | ||
# - zero | ||
# - leonardo | ||
- m4 | ||
- esp32 | ||
- esp8266 | ||
# - mega2560 | ||
- rpipico | ||
|
||
libraries: | ||
- "printHelpers" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# These are supported funding model platforms | ||
|
||
github: RobTillaart | ||
custom: "https://www.paypal.me/robtillaart" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Arduino-lint | ||
|
||
on: [push, pull_request] | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: arduino/arduino-lint-action@v1 | ||
with: | ||
library-manager: update | ||
compliance: strict |
17 changes: 17 additions & 0 deletions
17
libraries/ADG2188/.github/workflows/arduino_test_runner.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Arduino CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
runTest: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.6 | ||
- run: | | ||
gem install arduino_ci | ||
arduino_ci.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: JSON check | ||
|
||
on: | ||
push: | ||
paths: | ||
- '**.json' | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: json-syntax-check | ||
uses: limitusus/json-syntax-check@v2 | ||
with: | ||
pattern: "\\.json$" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
// | ||
// FILE: ADG2188.cpp | ||
// AUTHOR: Rob Tillaart | ||
// DATE: 2025-02-28 | ||
// VERSION: 0.1.0 | ||
// PURPOSE: Arduino library for ADG2188 8x8 (cross-point) matrix switch with I2C. | ||
// URL: https://github.com/RobTillaart/ADG2188 | ||
|
||
|
||
|
||
#include "ADG2188.h" | ||
|
||
#define ADG2188_LATCHED_MODE 0x00 | ||
#define ADG2188_DIRECT_MODE 0x01 | ||
|
||
|
||
ADG2188::ADG2188(uint8_t address, TwoWire *wire) | ||
{ | ||
_address = address; | ||
_wire = wire; | ||
_error = 0; | ||
_mode = ADG2188_DIRECT_MODE; | ||
_reset = 255; | ||
} | ||
|
||
bool ADG2188::begin() | ||
{ | ||
// reset variables | ||
_error = 0; | ||
|
||
if ((_address < 0x70) || (_address > 0x77)) | ||
{ | ||
_error = -1; | ||
return false; | ||
} | ||
if (! isConnected()) | ||
{ | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
bool ADG2188::isConnected() | ||
{ | ||
_wire->beginTransmission(_address); | ||
return (_wire->endTransmission() == 0); | ||
} | ||
|
||
uint8_t ADG2188::getAddress() | ||
{ | ||
return _address; | ||
} | ||
|
||
|
||
///////////////////////////////////////////// | ||
// | ||
// SWITCHES | ||
// | ||
void ADG2188::on(uint8_t row, uint8_t col) | ||
{ | ||
if ((row > 7 ) || (col > 7)) return; | ||
uint8_t pins = 0x80; // 0x80 == ON | ||
if (col < 6) pins |= (col << 3) + row; | ||
else pins |= ((col + 2) << 3) + row; | ||
_send(pins, _mode); | ||
} | ||
|
||
void ADG2188::off(uint8_t row, uint8_t col) | ||
{ | ||
if ((row > 7 ) || (col > 7)) return; | ||
uint8_t pins = 0x00; // 0x00 == OFF | ||
if (col < 6) pins |= (col << 3) + row; | ||
else pins |= ((col + 2) << 3) + row; | ||
|
||
_send(pins, _mode); | ||
} | ||
|
||
bool ADG2188::isOn(uint8_t row, uint8_t col) | ||
{ | ||
if ((row > 7 ) || (col > 7)) return false; | ||
uint8_t value = isOn(col); | ||
return (value & (1 << row)) > 0; | ||
} | ||
|
||
uint8_t ADG2188::isOnMask(uint8_t col) | ||
{ | ||
if (col > 7) return false; | ||
// Table 8 datasheet | ||
uint8_t mask = 0x34; // == 0b00110100; | ||
if (col & 0x04) mask |= 0x01; | ||
if (col & 0x02) mask |= 0x40; | ||
if (col & 0x01) mask |= 0x08; | ||
|
||
return _readback(mask); | ||
} | ||
|
||
|
||
///////////////////////////////////////////// | ||
// | ||
// MODE | ||
// | ||
// default direct (transparent) mode | ||
void ADG2188::setMode(bool latched) | ||
{ | ||
_mode = latched ? ADG2188_LATCHED_MODE : ADG2188_DIRECT_MODE; | ||
} | ||
|
||
bool ADG2188::isLatchedMode() | ||
{ | ||
return _mode == ADG2188_LATCHED_MODE; | ||
} | ||
|
||
bool ADG2188::isDirectMode() | ||
{ | ||
return _mode == ADG2188_DIRECT_MODE; | ||
} | ||
|
||
|
||
///////////////////////////////////////////// | ||
// | ||
// RESET | ||
// | ||
void ADG2188::setResetPin(uint8_t resetPin) | ||
{ | ||
_reset = resetPin; | ||
pinMode(_reset, OUTPUT); | ||
digitalWrite(_reset, HIGH); | ||
} | ||
|
||
|
||
void ADG2188::pulseResetPin() | ||
{ | ||
digitalWrite(_reset, LOW); | ||
// need delay(1); | ||
digitalWrite(_reset, HIGH); | ||
} | ||
|
||
|
||
///////////////////////////////////////////// | ||
// | ||
// DEBUG | ||
// | ||
int ADG2188::getLastError() | ||
{ | ||
int e = _error; | ||
_error = 0; | ||
return e; | ||
} | ||
|
||
|
||
/////////////////////////////////////////////// | ||
// | ||
// PRIVATE | ||
// | ||
|
||
int ADG2188::_send(uint8_t pins, uint8_t value) | ||
{ | ||
_wire->beginTransmission(_address); | ||
_wire->write(pins); | ||
_wire->write(value); | ||
_error = _wire->endTransmission(); | ||
return _error; | ||
} | ||
|
||
|
||
int ADG2188::_readback(uint8_t value) | ||
{ | ||
_wire->beginTransmission(_address); | ||
_wire->write(value); | ||
_error = _wire->endTransmission(); | ||
uint8_t bytes = _wire->requestFrom(_address, (uint8_t)2); | ||
if (bytes != 2) | ||
{ | ||
_error = -1; | ||
return 0; | ||
} | ||
_wire->read(); // skip dummy data | ||
return _wire->read(); | ||
} | ||
|
||
|
||
// -- END OF FILE -- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#pragma once | ||
// | ||
// FILE: ADG2188.h | ||
// AUTHOR: Rob Tillaart | ||
// DATE: 2025-02-28 | ||
// VERSION: 0.1.0 | ||
// PURPOSE: Arduino library for ADG2188 8x8 (cross-point) matrix switch with I2C. | ||
// URL: https://github.com/RobTillaart/ADG2188 | ||
// | ||
|
||
|
||
#include "Arduino.h" | ||
#include "Wire.h" | ||
|
||
|
||
#define ADG2188_LIB_VERSION (F("0.1.0")) | ||
|
||
#define ADG2188_DEFAULT_ADDRESS 0x70 | ||
|
||
// ERROR CODES | ||
// values <> 0 are errors. | ||
#define ADG2188_OK 0x00 | ||
#define ADG2188_CRC_ERROR 0x01 | ||
#define ADG2188_NOT_READY 0x10 | ||
#define ADG2188_REQUEST_ERROR 0x11 | ||
|
||
|
||
class ADG2188 | ||
{ | ||
public: | ||
ADG2188(uint8_t address = ADG2188_DEFAULT_ADDRESS, TwoWire *wire = &Wire); | ||
|
||
bool begin(); | ||
bool isConnected(); | ||
uint8_t getAddress(); | ||
|
||
|
||
// SWITCH | ||
void on(uint8_t row, uint8_t col); | ||
void off(uint8_t row, uint8_t col); | ||
bool isOn(uint8_t row, uint8_t col); | ||
uint8_t isOnMask(uint8_t col); // get a whole column at once as bit mask. | ||
|
||
// WRAPPERS. | ||
void on(uint8_t sw) { on(sw / 8, sw % 8); }; | ||
void off(uint8_t sw) { off(sw / 8, sw % 8); }; | ||
uint8_t isOn(uint8_t sw) { return isOn(sw / 8, sw % 8); }; | ||
|
||
|
||
// MODE | ||
// default direct (transparent) mode | ||
void setMode(bool latched = false); | ||
bool isLatchedMode(); | ||
bool isDirectMode(); | ||
|
||
|
||
// RESET | ||
void setResetPin(uint8_t resetPin); | ||
// reset ==> all switches off, registers ==> 0. | ||
void pulseResetPin(); | ||
|
||
|
||
// DEBUG | ||
int getLastError(); | ||
|
||
|
||
private: | ||
uint8_t _address = 0x2A; | ||
TwoWire* _wire; | ||
|
||
int _send(uint8_t pins, uint8_t value); | ||
int _readback(uint8_t value); | ||
|
||
int _error; | ||
uint8_t _mode; | ||
uint8_t _reset; | ||
}; | ||
|
||
|
||
// -- END OF FILE -- | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Change Log ADG2188 | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
|
||
## [0.1.0] - 2025-02-28 | ||
- initial version | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2025-2025 Rob Tillaart | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Oops, something went wrong.