Skip to content

Commit

Permalink
Move #defines to the .h file.
Browse files Browse the repository at this point in the history
  • Loading branch information
JChristensen committed Feb 12, 2022
1 parent f2563ce commit 20d8dee
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 29 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ sentence=Arduino Library for Maxim Integrated DS3232 and DS3231 Real-Time Clocks
paragraph=Copyright (C) 2017-2022 by Jack Christensen and licensed under GNU GPL v3.0. See README file for important information regarding compatibility with earlier versions.
category=Timing
url=https://github.com/JChristensen/DS3232RTC
architectures=avr
architectures=*
depends=Time
28 changes: 0 additions & 28 deletions src/DS3232RTC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,7 @@
// Arduino library for the Maxim Integrated DS3232
// and DS3231 Real-Time Clocks.

// define release-independent I2C functions
#if defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
#include <TinyWireM.h>
#define i2cBegin TinyWireM.begin
#define i2cBeginTransmission TinyWireM.beginTransmission
#define i2cEndTransmission TinyWireM.endTransmission
#define i2cRequestFrom TinyWireM.requestFrom
#define i2cRead TinyWireM.receive
#define i2cWrite TinyWireM.send
#elif ARDUINO >= 100
#include <Wire.h>
#define i2cBegin Wire.begin
#define i2cBeginTransmission Wire.beginTransmission
#define i2cEndTransmission Wire.endTransmission
#define i2cRequestFrom Wire.requestFrom
#define i2cRead Wire.read
#define i2cWrite Wire.write
#else
#include <Wire.h>
#define i2cBegin Wire.begin
#define i2cBeginTransmission Wire.beginTransmission
#define i2cEndTransmission Wire.endTransmission
#define i2cRequestFrom Wire.requestFrom
#define i2cRead Wire.receive
#define i2cWrite Wire.send
#endif

#include <DS3232RTC.h>
#include <TimeLib.h> // https://github.com/PaulStoffregen/Time

uint8_t DS3232RTC::errCode;

Expand Down
27 changes: 27 additions & 0 deletions src/DS3232RTC.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,33 @@
#include <Arduino.h>
#include <TimeLib.h> // https://github.com/PaulStoffregen/Time

// define release-independent I2C functions
#if defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
#include <TinyWireM.h>
#define i2cBegin TinyWireM.begin
#define i2cBeginTransmission TinyWireM.beginTransmission
#define i2cEndTransmission TinyWireM.endTransmission
#define i2cRequestFrom TinyWireM.requestFrom
#define i2cRead TinyWireM.receive
#define i2cWrite TinyWireM.send
#elif ARDUINO >= 100
#include <Wire.h>
#define i2cBegin Wire.begin
#define i2cBeginTransmission Wire.beginTransmission
#define i2cEndTransmission Wire.endTransmission
#define i2cRequestFrom Wire.requestFrom
#define i2cRead Wire.read
#define i2cWrite Wire.write
#else
#include <Wire.h>
#define i2cBegin Wire.begin
#define i2cBeginTransmission Wire.beginTransmission
#define i2cEndTransmission Wire.endTransmission
#define i2cRequestFrom Wire.requestFrom
#define i2cRead Wire.receive
#define i2cWrite Wire.send
#endif

#ifndef _BV
#define _BV(bit) (1 << (bit))
#endif
Expand Down

0 comments on commit 20d8dee

Please sign in to comment.