From 9227291ee374d42f23a68c27fd8c512482fb7eaf Mon Sep 17 00:00:00 2001 From: Renzo Mischianti Date: Thu, 1 Feb 2024 18:29:23 +0100 Subject: [PATCH] Add the possibility to insert address at begin() function --- PCF8591.cpp | 5 +++++ PCF8591.h | 4 ++-- README.md | 1 + library.json | 2 +- library.properties | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/PCF8591.cpp b/PCF8591.cpp index 65ef3b5..ea00f20 100644 --- a/PCF8591.cpp +++ b/PCF8591.cpp @@ -140,6 +140,11 @@ PCF8591::PCF8591(uint8_t address, int sda, int scl){ // //#endif +void PCF8591::begin(uint8_t address){ + _address = address; + return PCF8591::begin(); +} + /** * wake up i2c controller */ diff --git a/PCF8591.h b/PCF8591.h index 55657e2..ec5dfab 100644 --- a/PCF8591.h +++ b/PCF8591.h @@ -112,14 +112,14 @@ class PCF8591 { // //#endif - void begin(void); + void begin(); + void begin(uint8_t address); struct AnalogInput analogReadAll(byte readType = SINGLE_ENDED_INPUT); uint8_t analogRead(uint8_t channel, byte readType = SINGLE_ENDED_INPUT); void analogWrite(uint8_t value); void voltageWrite(float value, bool microcontrollerReferenceVoltage = true, float referenceVoltage = 5.0); float voltageRead(uint8_t analogPin, bool microcontrollerReferenceVoltage = true, float referenceVoltage = 5.0); - private: TwoWire *_wire; diff --git a/README.md b/README.md index 57484af..d4f0826 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ You can find updated version of documentation on my site​ [PCF8591](https://ww Library to use i2c analog IC with arduino and esp8266. Can read analog value and write analog value with only 2 wire (perfect for ESP-01). + - 01/02/2024: v1.1.2 Add the possibility to insert address at begin() function - 10/07/2023: v1.1.1 Add support for Arduino UNO R4 - 16/02/2023: v1.1.0 - Fix STM32 support and add support for Raspberry Pi Pico and other rp2040 boards diff --git a/library.json b/library.json index 3077ced..bb27719 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "PCF8591 library", - "version": "1.1.1", + "version": "1.1.2", "keywords": "analog, digital, i2c, encoder, expander, pcf8591, pcf8591a, esp32, esp8266, stm32, SAMD, Arduino, wire, Raspberry, rp2040", "description": "PCF8591 library. i2c digital expander for i2c digital expander for Arduino, Raspberry Pi Pico and rp2040 boards, esp32, SMT32 and ESP8266. Can read write digital values with only 2 wire. Very simple to use and encoder support.", "homepage": "https://www.mischianti.org/2019/01/03/pcf8591-i2c-analog-i-o-expander/", diff --git a/library.properties b/library.properties index 4c95ef0..a91fbd7 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=PCF8591 library -version=1.1.1 +version=1.1.2 author=Renzo Mischianti maintainer=Renzo Mischianti sentence=PCF8591, library for Arduino, Raspberry Pi Pico and rp2040 boards, esp32, SMT32 and ESP8266.