From 686576cf8cba9b0dd85eae8577647e4e4bda2244 Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Sat, 16 Mar 2024 19:58:26 +0100 Subject: [PATCH] 0.1.1 AD5248 --- libraries/AD5248/.github/FUNDING.yml | 2 +- .../AD5248/.github/workflows/arduino-lint.yml | 2 +- .../.github/workflows/arduino_test_runner.yml | 2 +- .../AD5248/.github/workflows/jsoncheck.yml | 4 +-- libraries/AD5248/AD5248.cpp | 12 +++++++-- libraries/AD5248/AD5248.h | 9 ++++--- libraries/AD5248/CHANGELOG.md | 7 ++++++ libraries/AD5248/LICENSE | 2 +- libraries/AD5248/README.md | 25 ++++++++----------- .../examples/AD5243_read/AD5243_read.ino | 1 - .../examples/AD5243_write/AD5243_write.ino | 1 - .../AD5243_write_ESP32/AD5243_write_ESP32.ino | 3 +-- .../AD5243_write_RP2040.ino | 3 +-- libraries/AD5248/keywords.txt | 5 ++++ libraries/AD5248/library.json | 4 +-- libraries/AD5248/library.properties | 4 +-- libraries/AD5248/test/unit_test_001.cpp | 4 ++- 17 files changed, 52 insertions(+), 38 deletions(-) diff --git a/libraries/AD5248/.github/FUNDING.yml b/libraries/AD5248/.github/FUNDING.yml index 90d9ab4c..554358c3 100644 --- a/libraries/AD5248/.github/FUNDING.yml +++ b/libraries/AD5248/.github/FUNDING.yml @@ -1,4 +1,4 @@ # These are supported funding model platforms github: RobTillaart - +custom: "https://www.paypal.me/robtillaart" diff --git a/libraries/AD5248/.github/workflows/arduino-lint.yml b/libraries/AD5248/.github/workflows/arduino-lint.yml index 8a26f14a..870a1769 100644 --- a/libraries/AD5248/.github/workflows/arduino-lint.yml +++ b/libraries/AD5248/.github/workflows/arduino-lint.yml @@ -6,7 +6,7 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: arduino/arduino-lint-action@v1 with: library-manager: update diff --git a/libraries/AD5248/.github/workflows/arduino_test_runner.yml b/libraries/AD5248/.github/workflows/arduino_test_runner.yml index fadfa904..5506eb6a 100644 --- a/libraries/AD5248/.github/workflows/arduino_test_runner.yml +++ b/libraries/AD5248/.github/workflows/arduino_test_runner.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: 2.6 diff --git a/libraries/AD5248/.github/workflows/jsoncheck.yml b/libraries/AD5248/.github/workflows/jsoncheck.yml index 37a11298..d4f78d58 100644 --- a/libraries/AD5248/.github/workflows/jsoncheck.yml +++ b/libraries/AD5248/.github/workflows/jsoncheck.yml @@ -10,9 +10,9 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: json-syntax-check - uses: limitusus/json-syntax-check@v1 + uses: limitusus/json-syntax-check@v2 with: pattern: "\\.json$" diff --git a/libraries/AD5248/AD5248.cpp b/libraries/AD5248/AD5248.cpp index dd213344..a4851528 100644 --- a/libraries/AD5248/AD5248.cpp +++ b/libraries/AD5248/AD5248.cpp @@ -1,7 +1,7 @@ // // FILE: AD5248.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.1.0 +// VERSION: 0.1.1 // PURPOSE: Library for I2C digital potentiometer AD5243 + rheostat AD5248 // DATE: 2023-12-12 // URL: https://github.com/RobTillaart/AD5248 @@ -15,6 +15,8 @@ #define AD5248_RESET 0x40 #define AD5248_SHUTDOWN 0x20 +#define AD5243_ADDRESS 0x2F + AD5248::AD5248(uint8_t address, TwoWire *wire) { @@ -42,6 +44,12 @@ bool AD5248::isConnected() } +uint8_t AD5248::getAddress() +{ + return _address; +} + + uint8_t AD5248::reset() { write(0, AD5248_MIDPOINT); @@ -123,7 +131,7 @@ uint8_t AD5248::send(const uint8_t cmd, const uint8_t value) // // DERIVED CLASS AD5243 potentiometer // -AD5243::AD5243(TwoWire * wire) : AD5248(0x2C, wire) +AD5243::AD5243(TwoWire * wire) : AD5248(AD5243_ADDRESS, wire) // fixed address { _pmCount = 2; } diff --git a/libraries/AD5248/AD5248.h b/libraries/AD5248/AD5248.h index 6ee534b5..5a23b028 100644 --- a/libraries/AD5248/AD5248.h +++ b/libraries/AD5248/AD5248.h @@ -2,7 +2,7 @@ // // FILE: AD5248.h // AUTHOR: Rob Tillaart -// VERSION: 0.1.0 +// VERSION: 0.1.1 // PURPOSE: Library for I2C digital potentiometer AD5243 + rheostat AD5248 // DATE: 2023-12-12 // URL: https://github.com/RobTillaart/AD5248 @@ -12,7 +12,7 @@ #include "Wire.h" -#define AD5248_LIB_VERSION (F("0.1.0")) +#define AD5248_LIB_VERSION (F("0.1.1")) #define AD5248_OK 0 @@ -20,7 +20,7 @@ #define AD5248_MIDPOINT 127 - + class AD5248 { @@ -29,6 +29,7 @@ public: bool begin(); bool isConnected(); + uint8_t getAddress(); // RESET uint8_t reset(); // reset both channels to AD524X_MIDPOINT @@ -62,7 +63,7 @@ protected: ////////////////////////////////////////////////////////////// // -// DERIVED CLASSES AD5248 rheostat +// DERIVED CLASS AD5243 potentiometer // class AD5243 : public AD5248 { diff --git a/libraries/AD5248/CHANGELOG.md b/libraries/AD5248/CHANGELOG.md index 00b11ce4..47ae19a4 100644 --- a/libraries/AD5248/CHANGELOG.md +++ b/libraries/AD5248/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.1.1] - 2024-03-16 +- add **getAddress()** (e.g. debugging) +- update GitHub actions +- update keywords.txt +- minor edits + + ## [0.1.0] - 2023-12-12 - initial versions diff --git a/libraries/AD5248/LICENSE b/libraries/AD5248/LICENSE index 16ef1551..03053375 100644 --- a/libraries/AD5248/LICENSE +++ b/libraries/AD5248/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023-2023 Rob Tillaart +Copyright (c) 2023-2024 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 diff --git a/libraries/AD5248/README.md b/libraries/AD5248/README.md index 72654295..af914af8 100644 --- a/libraries/AD5248/README.md +++ b/libraries/AD5248/README.md @@ -11,7 +11,7 @@ # AD5248 -Arduino library for I2C digital potentioMeter AD5243 + rheostat AD5248 +Arduino library for I2C digital potentioMeter AD5243 and rheostat AD5248 ## Description @@ -28,22 +28,22 @@ The AD5243 is a digital potentiometer, the AD5248 is a digital rheostat. Both IC's have two "channels" and they do not have the output lines some other IC's in these series have e.g. like the AD5242. -The AD5243 has a fixed address (0x2F = 47) while the AD5248 has 2 address pins -giving 4 possible addresses. See table. +The AD5243 has a fixed address (0x2F = 47 decimal) while the AD5248 has +two address pins giving 4 possible addresses. See table below. -| Addr(dec)| Addr(Hex) | AD1 | AD0 | -|:--------:|:---------:|:-----:|:-----:| +| Addr(dec)| Addr(Hex) | AD1 | AD0 | Notes | +|:--------:|:---------:|:-----:|:-----:|:-------:| | 44 | 0x2C | GND | GND | | 45 | 0x2D | GND | +5V | | 46 | 0x2E | +5V | GND | -| 47 | 0x2F | +5V | +5V | +| 47 | 0x2F | +5V | +5V | fixed address of AD5243 | An important property of the devices is that they defaults to their mid position at startup. -The library defines AD5243_MIDPOINT == 127. +The library defines **AD5248_MIDPOINT == 127**. To be used to set to defined mid-point. @@ -52,6 +52,7 @@ To be used to set to defined mid-point. - https://github.com/RobTillaart/AD520x - https://github.com/RobTillaart/AD524X - https://github.com/RobTillaart/AD5245 +- https://github.com/RobTillaart/AD5248 - https://github.com/RobTillaart/AD5144A - https://github.com/RobTillaart/AD5263 - https://github.com/RobTillaart/X9C10X @@ -59,7 +60,6 @@ To be used to set to defined mid-point. #### Compatibles - If you know compatible devices please let me know. @@ -81,9 +81,9 @@ creates an instance with 2 potentiometers. - **bool begin()** initialization of the object. Note the user must call **wire.begin()** or equivalent before calling **begin()**. - **bool isConnected()** See if the address set in constructor is on the I2C bus. +- **uint8_t getAddress()** Returns address set in the constructor, or fixed 0x2F for the AD5243. - -#### REad write +#### Read write - **uint8_t read(uint8_t channel)** read back the set value. - **uint8_t write(uint8_t channel, uint8_t value)** set channel 0/1 to value 0..255. @@ -98,11 +98,6 @@ Note the user must call **wire.begin()** or equivalent before calling **begin()* - **uint8_t shutDown()** check datasheet, not tested yet, use at own risk. -## Operation - -The examples show the basic working of the functions. - - ## Error codes | define | value | diff --git a/libraries/AD5248/examples/AD5243_read/AD5243_read.ino b/libraries/AD5248/examples/AD5243_read/AD5243_read.ino index a411438c..a80ef6e6 100644 --- a/libraries/AD5248/examples/AD5243_read/AD5243_read.ino +++ b/libraries/AD5248/examples/AD5243_read/AD5243_read.ino @@ -3,7 +3,6 @@ // AUTHOR: Rob Tillaart // PURPOSE: demo // URL: https://github.com/RobTillaart/AD5248 -// #include "AD5248.h" diff --git a/libraries/AD5248/examples/AD5243_write/AD5243_write.ino b/libraries/AD5248/examples/AD5243_write/AD5243_write.ino index a665cc68..91e888f5 100644 --- a/libraries/AD5248/examples/AD5243_write/AD5243_write.ino +++ b/libraries/AD5248/examples/AD5243_write/AD5243_write.ino @@ -3,7 +3,6 @@ // AUTHOR: Rob Tillaart // PURPOSE: demo // URL: https://github.com/RobTillaart/AD5248 -// #include "AD5248.h" diff --git a/libraries/AD5248/examples/AD5243_write_ESP32/AD5243_write_ESP32.ino b/libraries/AD5248/examples/AD5243_write_ESP32/AD5243_write_ESP32.ino index 2d238486..f4c22ae9 100644 --- a/libraries/AD5248/examples/AD5243_write_ESP32/AD5243_write_ESP32.ino +++ b/libraries/AD5248/examples/AD5243_write_ESP32/AD5243_write_ESP32.ino @@ -3,7 +3,6 @@ // AUTHOR: Rob Tillaart // PURPOSE: demo // URL: https://github.com/RobTillaart/AD5248 -// #include "AD5248.h" @@ -21,7 +20,7 @@ void setup() Wire1.begin(21, 22); // adjust if needed Wire1.setClock(400000); - + bool b = AD01.begin(); Serial.println(b ? "true" : "false"); Serial.println(AD01.isConnected()); diff --git a/libraries/AD5248/examples/AD5243_write_RP2040/AD5243_write_RP2040.ino b/libraries/AD5248/examples/AD5243_write_RP2040/AD5243_write_RP2040.ino index 017ff0f6..7115e8e8 100644 --- a/libraries/AD5248/examples/AD5243_write_RP2040/AD5243_write_RP2040.ino +++ b/libraries/AD5248/examples/AD5243_write_RP2040/AD5243_write_RP2040.ino @@ -3,7 +3,6 @@ // AUTHOR: Rob Tillaart // PURPOSE: demo // URL: https://github.com/RobTillaart/AD5248 -// #include "AD5248.h" @@ -23,7 +22,7 @@ void setup() Wire1.setSCL(13); // adjust if needed Wire1.begin(); Wire1.setClock(400000); - + bool b = AD01.begin(); Serial.println(b ? "true" : "false"); Serial.println(AD01.isConnected()); diff --git a/libraries/AD5248/keywords.txt b/libraries/AD5248/keywords.txt index 9202bc2a..e9f9a551 100644 --- a/libraries/AD5248/keywords.txt +++ b/libraries/AD5248/keywords.txt @@ -7,6 +7,9 @@ AD5248 KEYWORD1 # Methods and Functions (KEYWORD2) begin KEYWORD2 +isConnected KEYWORD2 +getAddress KEYWORD2 + reset KEYWORD2 zeroAll KEYWORD2 @@ -15,6 +18,8 @@ write KEYWORD2 midScaleReset KEYWORD2 pmCount KEYWORD2 + +readBackRegister KEYWORD2 shutDown KEYWORD2 diff --git a/libraries/AD5248/library.json b/libraries/AD5248/library.json index 6053156e..3897b766 100644 --- a/libraries/AD5248/library.json +++ b/libraries/AD5248/library.json @@ -1,7 +1,7 @@ { "name": "AD5248", "keywords": "I2C,digital,potentiometer, rheostat, AD5243, AD5248", - "description": "Library for I2C digital potentiometer AD5243 + rheostat AD5248.", + "description": "Library for I2C digital potentiometer AD5243 and rheostat AD5248.", "authors": [ { @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/AD5248" }, - "version": "0.1.0", + "version": "0.1.1", "license": "MIT", "frameworks": "*", "platforms": "*", diff --git a/libraries/AD5248/library.properties b/libraries/AD5248/library.properties index 4096b33c..bc98c7ff 100644 --- a/libraries/AD5248/library.properties +++ b/libraries/AD5248/library.properties @@ -1,8 +1,8 @@ name=AD5248 -version=0.1.0 +version=0.1.1 author=Rob Tillaart maintainer=Rob Tillaart -sentence=Library for I2C digital potentiometer AD5243 + rheostat AD5248 +sentence=Library for I2C digital potentiometer AD5243 and rheostat AD5248 paragraph= category=Signal Input/Output url=https://github.com/RobTillaart/AD5248 diff --git a/libraries/AD5248/test/unit_test_001.cpp b/libraries/AD5248/test/unit_test_001.cpp index 3e431ac0..0ec5e5d5 100644 --- a/libraries/AD5248/test/unit_test_001.cpp +++ b/libraries/AD5248/test/unit_test_001.cpp @@ -41,10 +41,12 @@ unittest(test_constructors) Wire.begin(); AD5243 ADx; + assertEqual(0x2F, ADx.getAddress()); assertEqual(127, ADx.read(0)); assertEqual(127, ADx.read(1)); AD5248 AD1(0x2C); + assertEqual(0x2C, AD1.getAddress()); assertEqual(127, AD1.read(0)); assertEqual(127, AD1.read(1)); } @@ -56,7 +58,7 @@ unittest(test_pmCount) AD5243 ADx; assertEqual(2, ADx.pmCount()); - + AD5248 AD1(0x2C); assertEqual(2, ADx.pmCount()); }