diff --git a/doc/alarm-clock.dox b/doc/alarm-clock.dox index 73a82195..909adf85 100644 --- a/doc/alarm-clock.dox +++ b/doc/alarm-clock.dox @@ -28,8 +28,8 @@ The alarm clock described on this page is a large example application that uses many of the classes in the provided libraries: LCD, Form, -Field, SoftI2C, DS1307RTC, Melody and \ref power_save "PowerSave". -The clock has the following features: +Field, SoftI2C, DS1307RTC (or DS3232RTC), Melody and +\ref power_save "PowerSave". The clock has the following features: \li Displays both the time and date. \li 12 hour and 24 hour time display modes. @@ -53,6 +53,8 @@ Realtime Clock Module. I used the ready-made realtime clock module, but made my own equivalent to the LCD shield from parts to aid in spacing out the LCD and pushbuttons on the exterior of the box. The value of the 33R resistor may need to be adjusted for different types of back light LED's. +See \ref clock_ds3232 "below" for information on using a DS3232-based +clock module instead of a DS1307-based module. The whole circuit is built on a prototyping shield, with ribbon cables connecting to the LCD. The Stop Alarm button and piezo buzzer are not @@ -85,6 +87,25 @@ Arduino designs should also work. \image html kitten_minimal.jpg +\section clock_ds3232 Using DS3232 instead of DS1307 + +For clock modules based on the DS3232 chip, such as the +Freetronics Real Time Clock Module, change the \c Clock typedef +in Clock.h to the following: + +\code +typedef DS3232RTC Clock; +\endcode + +The pads on the Freetronics module should be connected to the Arduino +as follows: + +\li VCC and GND connected to 5V and GND on the Arduino. +\li SQI connected to A3. +\li SDA connected to A4. +\li SCL connected to A5. +\li BAT, 32K, and RST left unconnected. + */ /* diff --git a/doc/mainpage.dox b/doc/mainpage.dox index 2944b6c2..e639b6a6 100644 --- a/doc/mainpage.dox +++ b/doc/mainpage.dox @@ -67,7 +67,7 @@ The default implementation simulates the time and date based on the value of millis(). \li DS1307RTC class that talks to the DS1307 realtime clock chip via I2C. \li DS3232RTC class that talks to the DS3232 realtime clock chip via I2C. -\li \ref alarm_clock "Alarm Clock" example that uses the DS1307 +\li \ref alarm_clock "Alarm Clock" example that uses the DS1307 or DS3232 realtime clock and the LCD library to implement an alarm clock. \section main_other Other diff --git a/libraries/RTC/examples/AlarmClock/AlarmClock.pde b/libraries/RTC/examples/AlarmClock/AlarmClock.pde index 35a4e2c0..5677e343 100644 --- a/libraries/RTC/examples/AlarmClock/AlarmClock.pde +++ b/libraries/RTC/examples/AlarmClock/AlarmClock.pde @@ -27,10 +27,11 @@ #include #include #include -#include +#include #include #include #include +#include "Clock.h" #include "FrontScreen.h" #include "SetAlarm.h" #include "SetTime.h" @@ -59,7 +60,7 @@ LCD lcd; // Activate the realtime clock chip. SoftI2C bus(RTC_DATA, RTC_CLOCK); -DS1307RTC rtc(bus, RTC_ONE_HZ); +Clock rtc(bus, RTC_ONE_HZ); // Melody to play when the alarm sounds. int defaultMelodyNotes[5] = {NOTE_C6, NOTE_C6, NOTE_C6, NOTE_C6, NOTE_REST}; diff --git a/libraries/RTC/examples/AlarmClock/Clock.h b/libraries/RTC/examples/AlarmClock/Clock.h new file mode 100644 index 00000000..814493da --- /dev/null +++ b/libraries/RTC/examples/AlarmClock/Clock.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2012 Southern Storm Software, Pty Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef Clock_h +#define Clock_h + +#include +#include + +// Select the specific type of realtime clock chip to use. +typedef DS1307RTC Clock; +//typedef DS3232RTC Clock; + +extern Clock rtc; + +#endif diff --git a/libraries/RTC/examples/AlarmClock/SetAlarm.cpp b/libraries/RTC/examples/AlarmClock/SetAlarm.cpp index f003e673..69e45d4b 100644 --- a/libraries/RTC/examples/AlarmClock/SetAlarm.cpp +++ b/libraries/RTC/examples/AlarmClock/SetAlarm.cpp @@ -21,9 +21,7 @@ */ #include "SetAlarm.h" -#include - -extern DS1307RTC rtc; +#include "Clock.h" SetAlarm::SetAlarm(Form &form, const String &label, uint8_t alarmNum) : EditTime(form, label) diff --git a/libraries/RTC/examples/AlarmClock/SetDate.cpp b/libraries/RTC/examples/AlarmClock/SetDate.cpp index befe3c74..dfe19034 100644 --- a/libraries/RTC/examples/AlarmClock/SetDate.cpp +++ b/libraries/RTC/examples/AlarmClock/SetDate.cpp @@ -21,14 +21,12 @@ */ #include "SetDate.h" -#include +#include "Clock.h" #define EDIT_DAY 0 #define EDIT_MONTH 1 #define EDIT_YEAR 2 -extern DS1307RTC rtc; - SetDate::SetDate(Form &form, const String &label) : Field(form, label) , editField(EDIT_DAY) diff --git a/libraries/RTC/examples/AlarmClock/SetTime.cpp b/libraries/RTC/examples/AlarmClock/SetTime.cpp index 4643a3f5..61ad6a3d 100644 --- a/libraries/RTC/examples/AlarmClock/SetTime.cpp +++ b/libraries/RTC/examples/AlarmClock/SetTime.cpp @@ -21,9 +21,7 @@ */ #include "SetTime.h" -#include - -extern DS1307RTC rtc; +#include "Clock.h" SetTime::SetTime(Form &form, const String &label) : EditTime(form, label)