ArduinoLibs
Main Page
Related Pages
Modules
Classes
Files
File List
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Groups
Pages
libraries
RTC
RTC.h
1
/*
2
* Copyright (C) 2012 Southern Storm Software, Pty Ltd.
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included
12
* in all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20
* DEALINGS IN THE SOFTWARE.
21
*/
22
23
#ifndef RTC_h
24
#define RTC_h
25
26
#include <inttypes.h>
27
28
struct
RTCTime
29
{
30
uint8_t
hour
;
31
uint8_t
minute
;
32
uint8_t
second
;
33
};
34
35
struct
RTCDate
36
{
37
unsigned
int
year
;
38
uint8_t
month
;
39
uint8_t
day
;
40
};
41
42
struct
RTCAlarm
43
{
44
uint8_t
hour
;
45
uint8_t
minute
;
46
uint8_t
flags
;
47
};
48
49
class
RTC
50
{
51
public
:
52
RTC
();
53
~
RTC
();
54
55
enum
DayOfWeek
56
{
57
Monday = 1,
58
Tuesday,
59
Wednesday,
60
Thursday,
61
Friday,
62
Saturday,
63
Sunday,
64
};
65
66
virtual
bool
hasUpdates
();
67
68
virtual
void
readTime
(
RTCTime
*value);
69
virtual
void
readDate
(
RTCDate
*value);
70
71
virtual
void
writeTime
(
const
RTCTime
*value);
72
virtual
void
writeDate
(
const
RTCDate
*value);
73
74
static
const
uint8_t
ALARM_COUNT
= 4;
75
76
virtual
void
readAlarm
(uint8_t alarmNum,
RTCAlarm
*value);
77
virtual
void
writeAlarm
(uint8_t alarmNum,
const
RTCAlarm
*value);
78
79
virtual
int
byteCount
()
const
;
80
virtual
uint8_t
readByte
(uint8_t offset);
81
virtual
void
writeByte
(uint8_t offset, uint8_t value);
82
83
static
const
int
NO_TEMPERATURE
= 32767;
84
85
virtual
int
readTemperature
();
86
87
// Flags for adjustDays(), adjustMonths(), and adjustYears().
88
static
const
uint8_t
INCREMENT
= 0x0000;
89
static
const
uint8_t
DECREMENT
= 0x0001;
90
static
const
uint8_t
WRAP
= 0x0002;
91
92
static
void
adjustDays
(
RTCDate
*date, uint8_t flags);
93
static
void
adjustMonths
(
RTCDate
*date, uint8_t flags);
94
static
void
adjustYears
(
RTCDate
*date, uint8_t flags);
95
96
static
DayOfWeek
dayOfWeek
(
const
RTCDate
*date);
97
98
private
:
99
unsigned
long
midnight;
100
RTCDate
date;
101
RTCAlarm
alarms[
ALARM_COUNT
];
102
uint8_t *nvram;
103
};
104
105
#endif
Generated on Sun Sep 29 2013 09:30:46 for ArduinoLibs by
1.8.1.2