From 8f530b6d8f75532c5e1e70e77308d098eb39c6fc Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Sat, 3 Dec 2022 12:37:49 +0100 Subject: [PATCH] fix #48 constructor (#49) * fix #48 --- CHANGELOG.md | 4 ++++ I2C_eeprom.cpp | 10 ++++++---- I2C_eeprom.h | 12 ++++++------ examples/I2C_eeprom_test/I2C_eeprom_test.ino | 3 ++- library.json | 2 +- library.properties | 2 +- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87a9bc4..7e79464 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [1.7.0] - 2022-12-02 +- fix #48 rewrote constructor. + + ## [1.6.2] - 2022-10-30 - Add RP2040 support to build-CI. - Add CHANGELOG.md diff --git a/I2C_eeprom.cpp b/I2C_eeprom.cpp index 391a4e6..67662b4 100644 --- a/I2C_eeprom.cpp +++ b/I2C_eeprom.cpp @@ -1,7 +1,7 @@ // // FILE: I2C_eeprom.cpp // AUTHOR: Rob Tillaart -// VERSION: 1.6.2 +// VERSION: 1.7.0 // PURPOSE: Arduino Library for external I2C EEPROM 24LC256 et al. // URL: https://github.com/RobTillaart/I2C_EEPROM.git // @@ -37,9 +37,9 @@ // // PUBLIC FUNCTIONS // -I2C_eeprom::I2C_eeprom(const uint8_t deviceAddress, TwoWire * wire) +I2C_eeprom::I2C_eeprom(const uint8_t deviceAddress, TwoWire * wire) : + I2C_eeprom(deviceAddress, I2C_PAGESIZE_24LC256, wire) { - I2C_eeprom(deviceAddress, I2C_PAGESIZE_24LC256, wire); } @@ -58,6 +58,7 @@ I2C_eeprom::I2C_eeprom(const uint8_t deviceAddress, const uint32_t deviceSize, T #if defined (ESP8266) || defined(ESP32) bool I2C_eeprom::begin(uint8_t sda, uint8_t scl) { + // if (_wire == 0) Serial.println("zero"); // test #48 if ((sda < 255) && (scl < 255)) { _wire->begin(sda, scl); @@ -74,6 +75,7 @@ bool I2C_eeprom::begin(uint8_t sda, uint8_t scl) bool I2C_eeprom::begin() { + // if (_wire == 0) Serial.println("zero"); // test #48 _wire->begin(); _lastWrite = 0; return isConnected(); @@ -313,7 +315,7 @@ uint32_t I2C_eeprom::determineSize(const bool debug) uint8_t I2C_eeprom::getPageSize(uint32_t deviceSize) { - // determine page size from device size + // determine page size from device size // based on Microchip 24LCXX data sheets. if (deviceSize <= I2C_DEVICESIZE_24LC02) return 8; if (deviceSize <= I2C_DEVICESIZE_24LC16) return 16; diff --git a/I2C_eeprom.h b/I2C_eeprom.h index 3823939..562977c 100644 --- a/I2C_eeprom.h +++ b/I2C_eeprom.h @@ -2,7 +2,7 @@ // // FILE: I2C_eeprom.h // AUTHOR: Rob Tillaart -// VERSION: 1.6.2 +// VERSION: 1.7.0 // PURPOSE: Arduino Library for external I2C EEPROM 24LC256 et al. // URL: https://github.com/RobTillaart/I2C_EEPROM.git // @@ -13,7 +13,7 @@ #include "Wire.h" -#define I2C_EEPROM_VERSION (F("1.6.2")) +#define I2C_EEPROM_VERSION (F("1.7.0")) #define I2C_DEVICESIZE_24LC512 65536 @@ -113,10 +113,10 @@ public: private: uint8_t _deviceAddress; - uint32_t _lastWrite = 0; // for waitEEReady - uint32_t _deviceSize; - uint8_t _pageSize; - uint8_t _extraTWR = 0; // milliseconds + uint32_t _lastWrite = 0; // for waitEEReady + uint32_t _deviceSize = 0; + uint8_t _pageSize = 0; + uint8_t _extraTWR = 0; // milliseconds // 24LC32..24LC512 use two bytes for memory address // 24LC01..24LC16 use one-byte addresses + part of device address diff --git a/examples/I2C_eeprom_test/I2C_eeprom_test.ino b/examples/I2C_eeprom_test/I2C_eeprom_test.ino index c08f061..1bae78b 100644 --- a/examples/I2C_eeprom_test/I2C_eeprom_test.ino +++ b/examples/I2C_eeprom_test/I2C_eeprom_test.ino @@ -17,7 +17,8 @@ // #define SERIAL_OUT SerialUSB -I2C_eeprom ee(0x50, I2C_DEVICESIZE_24LC256); +I2C_eeprom ee(0x50); +// I2C_eeprom ee(0x50, I2C_DEVICESIZE_24LC256); uint32_t start, diff, totals = 0; diff --git a/library.json b/library.json index c1297fd..d259baf 100644 --- a/library.json +++ b/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/I2C_EEPROM.git" }, - "version": "1.6.2", + "version": "1.7.0", "license": "MIT", "frameworks": "arduino", "platforms": "*", diff --git a/library.properties b/library.properties index 68ec417..471f007 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=I2C_EEPROM -version=1.6.2 +version=1.7.0 author=Rob Tillaart maintainer=Rob Tillaart sentence=Library for I2C EEPROMS