Skip to content

Commit

Permalink
Move defines not needed in .h file to .cpp file.
Browse files Browse the repository at this point in the history
Cosmetic and style changes.
  • Loading branch information
JChristensen committed Apr 1, 2018
1 parent c26505b commit 187a982
Show file tree
Hide file tree
Showing 12 changed files with 238 additions and 257 deletions.
8 changes: 4 additions & 4 deletions examples/SetSerial/SetSerial.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
// in the input will result in an incorrect RTC setting.
//
// Jack Christensen 08Aug2013

#include <DS3232RTC.h> // https://github.com/JChristensen/DS3232RTC
#include <Streaming.h> // http://arduiniana.org/libraries/streaming/

void setup()
{
Serial.begin(115200);

// setSyncProvider() causes the Time library to synchronize with the
// external RTC by calling RTC.get() every five minutes by default.
setSyncProvider(RTC.get);
Expand Down Expand Up @@ -68,15 +68,15 @@ void loop()
tm.Second = Serial.parseInt();
t = makeTime(tm);
RTC.set(t); // use the time_t value to ensure correct weekday is set
setTime(t);
setTime(t);
Serial << F("RTC set to: ");
printDateTime(t);
Serial << endl;
// dump any extraneous input
while (Serial.available() > 0) Serial.read();
}
}

t = now();
if (t != tLast) {
tLast = t;
Expand Down
10 changes: 5 additions & 5 deletions examples/TimeRTC/TimeRTC.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ void setup()
{
Serial.begin(9600);
setSyncProvider(RTC.get); // the function to get the time from the RTC
if(timeStatus() != timeSet)
if(timeStatus() != timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
Serial.println("RTC has set the system time");
}

void loop()
{
digitalClockDisplay();
digitalClockDisplay();
delay(1000);
}

Expand All @@ -34,8 +34,8 @@ void digitalClockDisplay()
Serial.print(' ');
Serial.print(month());
Serial.print(' ');
Serial.print(year());
Serial.println();
Serial.print(year());
Serial.println();
}

void printDigits(int digits)
Expand Down
4 changes: 2 additions & 2 deletions examples/alarm_ex1/alarm_ex1.ino
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
void setup()
{
Serial.begin(115200);

// initialize the alarms to known values, clear the alarm flags, clear the alarm interrupt flags
RTC.setAlarm(ALM1_MATCH_DATE, 0, 0, 0, 1);
RTC.setAlarm(ALM2_MATCH_DATE, 0, 0, 0, 1);
Expand All @@ -33,7 +33,7 @@ void setup()

// set the RTC time and date to the compile time
RTC.set(compileTime());

// set Alarm 1 to occur at 5 seconds after every minute
RTC.setAlarm(ALM1_MATCH_SECONDS, 5, 0, 0, 1);
// clear the alarm flag
Expand Down
6 changes: 3 additions & 3 deletions examples/alarm_ex2/alarm_ex2.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Connect RTC INT/SQW to Arduino pin 2.
//
// Jack Christensen 16Sep2017

#include <DS3232RTC.h> // https://github.com/JChristensen/DS3232RTC
#include <Streaming.h> // http://arduiniana.org/libraries/streaming/

Expand All @@ -36,7 +36,7 @@ void setup()
RTC.alarmInterrupt(ALARM_1, false);
RTC.alarmInterrupt(ALARM_2, false);
RTC.squareWave(SQWAVE_NONE);

tmElements_t tm;
tm.Hour = 00; // set the RTC to an arbitrary time
tm.Minute = 00;
Expand All @@ -45,7 +45,7 @@ void setup()
tm.Month = 9;
tm.Year = 2017 - 1970; // tmElements_t.Year is the offset from 1970
RTC.write(tm); // set the RTC from the tm structure

// set Alarm 1 to occur at 5 seconds after every minute
RTC.setAlarm(ALM1_MATCH_SECONDS, 5, 0, 0, 0);
// clear the alarm flag
Expand Down
8 changes: 4 additions & 4 deletions examples/alarm_ex3/alarm_ex3.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// Connect RTC SCL to Arduino pin A5.
//
// Jack Christensen 16Sep2017

#include <DS3232RTC.h> // https://github.com/JChristensen/DS3232RTC
#include <Streaming.h> // http://arduiniana.org/libraries/streaming/

Expand Down Expand Up @@ -45,11 +45,11 @@ void setup()
tm.Year = 2017 - 1970; // tmElements_t.Year is the offset from 1970
time_t t = makeTime(tm); // change the tm structure into time_t (seconds since epoch)
time_t alarmTime = t + ALARM_INTERVAL; // calculate the alarm time

// set the current time
RTC.set(t);
// set the alarm
RTC.setAlarm(ALM1_MATCH_HOURS, second(alarmTime), minute(alarmTime), hour(alarmTime), 0);
RTC.setAlarm(ALM1_MATCH_HOURS, second(alarmTime), minute(alarmTime), hour(alarmTime), 0);
// clear the alarm flag
RTC.alarm(ALARM_1);

Expand All @@ -68,7 +68,7 @@ void loop()
// calculate the next alarm time
time_t alarmTime = t + ALARM_INTERVAL;
// set the alarm
RTC.setAlarm(ALM1_MATCH_HOURS, second(alarmTime), minute(alarmTime), hour(alarmTime), 0);
RTC.setAlarm(ALM1_MATCH_HOURS, second(alarmTime), minute(alarmTime), hour(alarmTime), 0);

Serial << millis() << " ALARM_1 ";
printDateTime(t);
Expand Down
6 changes: 3 additions & 3 deletions examples/alarm_ex4/alarm_ex4.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// Connect RTC SCL to Arduino pin A5.
//
// Jack Christensen 16Sep2017

#include <DS3232RTC.h> // https://github.com/JChristensen/DS3232RTC
#include <Streaming.h> // http://arduiniana.org/libraries/streaming/

Expand All @@ -30,7 +30,7 @@ void setup()
RTC.alarmInterrupt(ALARM_1, false);
RTC.alarmInterrupt(ALARM_2, false);
RTC.squareWave(SQWAVE_NONE);

tmElements_t tm;
tm.Hour = 00; // set the RTC to an arbitrary time
tm.Minute = 00;
Expand All @@ -39,7 +39,7 @@ void setup()
tm.Month = 9;
tm.Year = 2017 - 1970; // tmElements_t.Year is the offset from 1970
RTC.write(tm); // set the RTC from the tm structure

// set Alarm 1 to occur once per second
RTC.setAlarm(ALM1_EVERY_SECOND, 0, 0, 0, 0);
// clear the alarm flag
Expand Down
4 changes: 2 additions & 2 deletions examples/alarm_ex5/alarm_ex5.ino
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void setup()
RTC.alarmInterrupt(ALARM_1, false);
RTC.alarmInterrupt(ALARM_2, false);
RTC.squareWave(SQWAVE_NONE);

tmElements_t tm;
tm.Hour = 00; // set the RTC to an arbitrary time
tm.Minute = 00;
Expand All @@ -39,7 +39,7 @@ void setup()
tm.Month = 9;
tm.Year = 2017 - 1970; // tmElements_t.Year is the offset from 1970
RTC.write(tm); // set the RTC from the tm structure

// set Alarm 2 to occur once per minute
RTC.setAlarm(ALM2_EVERY_MINUTE, 0, 0, 0, 0);
// clear the alarm flag
Expand Down
6 changes: 3 additions & 3 deletions examples/alarm_ex7/alarm_ex7.ino
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void setup()
{
Serial.begin(115200);
pinMode(2, INPUT_PULLUP);

// initialize the alarms to known values, clear the alarm flags, clear the alarm interrupt flags
RTC.setAlarm(ALM1_MATCH_DATE, 0, 0, 0, 1);
RTC.setAlarm(ALM2_MATCH_DATE, 0, 0, 0, 1);
Expand All @@ -36,7 +36,7 @@ void setup()
RTC.alarmInterrupt(ALARM_1, false);
RTC.alarmInterrupt(ALARM_2, false);
RTC.squareWave(SQWAVE_NONE);

tmElements_t tm;
tm.Hour = 06; // set the RTC time to 06:29:50
tm.Minute = 29;
Expand All @@ -45,7 +45,7 @@ void setup()
tm.Month = 9;
tm.Year = 2017 - 1970; // tmElements_t.Year is the offset from 1970
RTC.write(tm); // set the RTC from the tm structure

// set Alarm 2 for 06:30:00
RTC.setAlarm(ALM2_MATCH_HOURS, 0, 30, 6, 0);
// clear the alarm flags
Expand Down
2 changes: 1 addition & 1 deletion examples/tiny3232_KnockBang/tiny3232_KnockBang.ino
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
void setup()
{
Debug.begin(250000);

// setSyncProvider() causes the Time library to synchronize with the
// external RTC by calling RTC.get() every five minutes by default.
setSyncProvider(RTC.get);
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=DS3232RTC
version=1.2.1
version=1.2.2
author=Jack Christensen <[email protected]>
maintainer=Jack Christensen <[email protected]>
sentence=Arduino Library for Maxim Integrated DS3232 and DS3231 Real-Time Clocks.
Expand Down
Loading

0 comments on commit 187a982

Please sign in to comment.