mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
Update alarm clock to support DS3232
This commit is contained in:
parent
be14f5c2e7
commit
c2fdaee863
@ -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</a>. 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
|
||||
<a href="http://www.freetronics.com/products/real-time-clock-rtc-module">Freetronics Real Time Clock Module</a>, change the \c Clock typedef
|
||||
in <tt>Clock.h</tt> 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.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -67,7 +67,7 @@ The default implementation simulates the time and date based on the value of
|
||||
<tt>millis()</tt>.
|
||||
\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
|
||||
|
@ -27,10 +27,11 @@
|
||||
#include <BoolField.h>
|
||||
#include <IntField.h>
|
||||
#include <SoftI2C.h>
|
||||
#include <DS1307RTC.h>
|
||||
#include <RTC.h>
|
||||
#include <Melody.h>
|
||||
#include <PowerSave.h>
|
||||
#include <avr/power.h>
|
||||
#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};
|
||||
|
35
libraries/RTC/examples/AlarmClock/Clock.h
Normal file
35
libraries/RTC/examples/AlarmClock/Clock.h
Normal file
@ -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 <DS1307RTC.h>
|
||||
#include <DS3232RTC.h>
|
||||
|
||||
// Select the specific type of realtime clock chip to use.
|
||||
typedef DS1307RTC Clock;
|
||||
//typedef DS3232RTC Clock;
|
||||
|
||||
extern Clock rtc;
|
||||
|
||||
#endif
|
@ -21,9 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "SetAlarm.h"
|
||||
#include <DS1307RTC.h>
|
||||
|
||||
extern DS1307RTC rtc;
|
||||
#include "Clock.h"
|
||||
|
||||
SetAlarm::SetAlarm(Form &form, const String &label, uint8_t alarmNum)
|
||||
: EditTime(form, label)
|
||||
|
@ -21,14 +21,12 @@
|
||||
*/
|
||||
|
||||
#include "SetDate.h"
|
||||
#include <DS1307RTC.h>
|
||||
#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)
|
||||
|
@ -21,9 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "SetTime.h"
|
||||
#include <DS1307RTC.h>
|
||||
|
||||
extern DS1307RTC rtc;
|
||||
#include "Clock.h"
|
||||
|
||||
SetTime::SetTime(Form &form, const String &label)
|
||||
: EditTime(form, label)
|
||||
|
Loading…
x
Reference in New Issue
Block a user