Skip to content

Commit

Permalink
simplify begin()
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart committed Oct 30, 2023
1 parent 39c7941 commit bb1c7e5
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 39 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.7.0] - 2023-10-30
- refactor / simplify begin()
- update examples

----

## [0.6.1] - 2023-09-16
- add Wire1 support for ESP32
- fix changelog.md


## [0.6.0] - 2023-09-16
- fix #42 ReadObject, WriteObject for FRAM32
- add examples
Expand Down
28 changes: 1 addition & 27 deletions FRAM.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: FRAM.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.6.1
// VERSION: 0.7.0
// DATE: 2018-01-24
// PURPOSE: Arduino library for I2C FRAM
// URL: https://github.com/RobTillaart/FRAM_I2C
Expand Down Expand Up @@ -36,32 +36,6 @@ FRAM::FRAM(TwoWire *wire)
}


#if defined (ESP8266) || defined(ESP32)
int FRAM::begin(int sda, int scl, const uint8_t address,
const int8_t writeProtectPin)
{
if ((address < 0x50) || (address > 0x57)) return FRAM_ERROR_ADDR;

_address = address;
if ((sda < 255) && (scl < 255))
{
_wire->begin(sda, scl);
} else {
_wire->begin();
}

if (writeProtectPin > -1)
{
_writeProtectPin = writeProtectPin;
pinMode(_writeProtectPin, OUTPUT);
}
if (! isConnected()) return FRAM_ERROR_CONNECT;
getSize();
return FRAM_OK;
}
#endif


int FRAM::begin(const uint8_t address,
const int8_t writeProtectPin)
{
Expand Down
9 changes: 2 additions & 7 deletions FRAM.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// FILE: FRAM.h
// AUTHOR: Rob Tillaart
// VERSION: 0.6.1
// VERSION: 0.7.0
// DATE: 2018-01-24
// PURPOSE: Arduino library for I2C FRAM
// URL: https://github.com/RobTillaart/FRAM_I2C
Expand All @@ -12,7 +12,7 @@
#include "Wire.h"


#define FRAM_LIB_VERSION (F("0.6.1"))
#define FRAM_LIB_VERSION (F("0.7.0"))


#define FRAM_OK 0
Expand All @@ -36,11 +36,6 @@ class FRAM
public:
FRAM(TwoWire *wire = &Wire);

#if defined (ESP8266) || defined(ESP32)
// address and writeProtectPin is optional
int begin(int sda, int scl, const uint8_t address = 0x50,
const int8_t writeProtectPin = -1);
#endif
// address and writeProtectPin is optional
int begin(const uint8_t address = 0x50,
const int8_t writeProtectPin = -1);
Expand Down
3 changes: 3 additions & 0 deletions FRAM_MULTILANGUAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
[![Arduino CI](https://github.com/RobTillaart/FRAM_I2C/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/FRAM_I2C/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/FRAM_I2C/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/FRAM_I2C/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/FRAM_I2C/actions/workflows/jsoncheck.yml)
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/FRAM_I2C.svg)](https://github.com/RobTillaart/FRAM_I2C/issues)

[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/FRAM_I2C/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/FRAM_I2C.svg?maxAge=3600)](https://github.com/RobTillaart/FRAM_I2C/releases)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/FRAM_I2C.svg)](https://registry.platformio.org/libraries/robtillaart/FRAM_I2C)


# FRAM_MULTILANGUAGE
Expand Down
3 changes: 3 additions & 0 deletions FRAM_RINGBUFFER.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
[![Arduino CI](https://github.com/RobTillaart/FRAM_I2C/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/FRAM_I2C/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/FRAM_I2C/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/FRAM_I2C/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/FRAM_I2C/actions/workflows/jsoncheck.yml)
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/FRAM_I2C.svg)](https://github.com/RobTillaart/FRAM_I2C/issues)

[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/FRAM_I2C/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/FRAM_I2C.svg?maxAge=3600)](https://github.com/RobTillaart/FRAM_I2C/releases)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/FRAM_I2C.svg)](https://registry.platformio.org/libraries/robtillaart/FRAM_I2C)


# FRAM_RINGBUFFER
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ specific for devices with 9 bit address e.g. **MB85RC04**.

- **int begin(uint8_t address = 0x50, int8_t writeProtectPin = -1)** address and writeProtectPin is optional.
Note the **MB85RC1MT** only uses even addresses.
- **int begin(int sda, int scl, uint8_t address = 0x50, int8_t writeProtectPin = -1)** idem for ESP32 a.o.
- **bool isConnected()** checks if the address set by begin() is visible on the I2C bus.


### Write & read
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/FRAM_I2C.git"
},
"version": "0.6.1",
"version": "0.7.0",
"license": "MIT",
"frameworks": "*",
"platforms": "*",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=FRAM_I2C
version=0.6.1
version=0.7.0
author=Rob Tillaart <[email protected]>
maintainer=Rob Tillaart <[email protected]>
sentence=Arduino library for I2C FRAM for persistent storage.
Expand Down

0 comments on commit bb1c7e5

Please sign in to comment.