Skip to content

Commit

Permalink
Bugfixes and Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
cvmanjoo committed Sep 2, 2022
1 parent e2fc67c commit ffb03a6
Show file tree
Hide file tree
Showing 15 changed files with 489 additions and 481 deletions.
109 changes: 109 additions & 0 deletions examples/Auto_setTime/Auto_setTime.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@

#include <Wire.h>
#include <I2C_RTC.h>

//static DS1307 RTC;
//static DS3231 RTC;
//static PCF8523 RTC;
//static PCF8563 RTC;

int hours,minutes,seconds,day,month,year;

void setup()
{
Serial.begin(9600);
while (!Serial); // wait for serial port to connect. Needed for native USB

RTC.begin();

Serial.print("Is Clock Running: ");
if (RTC.isRunning())
{
Serial.println("Yes");
switch (RTC.getWeek())
{
case 1: Serial.print("MON");
break;
case 2: Serial.print("TUE");
break;
case 3: Serial.print("WED");
break;
case 4: Serial.print("THU");
break;
case 5: Serial.print("FRI");
break;
case 6: Serial.print("SAT");
break;
case 7: Serial.print("SUN");
break;
}
Serial.print(" ");

day=RTC.getDay();
month=RTC.getMonth();
year=RTC.getYear();

if(day<10)
Serial.print("0");

Serial.print(RTC.getDay());
Serial.print("-");
if(month<10)
Serial.print("0");
Serial.print(RTC.getMonth());
Serial.print("-");
Serial.print(RTC.getYear());
Serial.print(" ");

hours = RTC.getHours();
minutes = RTC.getMinutes();
seconds = RTC.getSeconds();

if(hours<10)
Serial.print("0");
Serial.print(hours);
Serial.print(":");
if(minutes<10)
Serial.print("0");
Serial.print(minutes);
Serial.print(":");
if(seconds<10)
Serial.print("0");
Serial.print(RTC.getSeconds());
Serial.print("");
if (RTC.getHourMode() == CLOCK_H12)
{
switch (RTC.getMeridiem())
{
case HOUR_AM:
Serial.print(" AM");
break;
case HOUR_PM:
Serial.print(" PM");
break;
}
}
Serial.println();
delay(1000);
}
else
{
delay(250);

Serial.println("No");
Serial.println("Setting Time");
RTC.setHourMode(CLOCK_H12); //Comment if RTC PCF8563
//RTC.setHourMode(CLOCK_H24);
RTC.setDateTime(__DATE__, __TIME__);
RTC.updateWeek(); //Update Weekdaybased on new date.
Serial.println("New Time Set");
Serial.print(__DATE__);
Serial.print(" ");
Serial.println(__TIME__);
RTC.startClock(); //Start the Clock;
}
}

void loop()
{
}
62 changes: 0 additions & 62 deletions examples/DS1307/DS1307_Auto/DS1307_Auto.ino

This file was deleted.

4 changes: 3 additions & 1 deletion examples/DS1307/DS1307_Info/DS1307_Info.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ static DS1307 RTC;
void setup()
{
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB
}
RTC.begin();

Serial.println();
Expand All @@ -32,7 +35,6 @@ void setup()
else
Serial.println("No");


}

void loop()
Expand Down
64 changes: 0 additions & 64 deletions examples/DS3231/DS3231_Auto/DS3231_Auto.ino

This file was deleted.

64 changes: 0 additions & 64 deletions examples/PCF8523/PCF8523_Auto/PCF8523_Auto.ino

This file was deleted.

3 changes: 3 additions & 0 deletions examples/PCF8523/PCF8523_Info/PCF8523_Info.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ static PCF8523 RTC;
void setup()
{
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB
}
RTC.begin();

Serial.println();
Expand Down
52 changes: 0 additions & 52 deletions examples/PCF8563/PCF8563_Auto/PCF8563_Auto.ino

This file was deleted.

Loading

0 comments on commit ffb03a6

Please sign in to comment.