BayEOSArduino Library
RTClib.h
1 //Modified RTC-Library
2 // S.Holzheu (holzheu@bayceer.uni-bayreuth.de)
3 //
4 //
5 // A library for handling real-time clocks, dates, etc.
6 // 2010-02-04 <jcw@equi4.com> http://opensource.org/licenses/mit-license.php
7 // $Id: RTClib.h 7763 2011-12-11 01:28:16Z jcw $
8 
9 // Simple general-purpose date/time class (no TZ / DST / leap second handling!)
10 #ifndef RTClib_H
11 #define RTClib_H
12 
13 #include <Wire.h>
14 #include <BayEOSBuffer.h>
15 
16 
17 
18 // RTC based on the DS1307 chip connected via I2C and the Wire library
19 class RTC_DS1307 : public RTC {
20 public:
21  void begin() {}
22  void adjust(const DateTime& dt);
23  DateTime now();
24 
25 };
26 
27 // RTC based on the PCF8563 chip connected via I2C and the Wire library
28 // contributed by @mariusster, see http://forum.jeelabs.net/comment/1902
29 class RTC_PCF8563 : public RTC {
30 public:
31  void begin() {}
32  void adjust(const DateTime& dt);
33  DateTime now();
34 
35 };
36 
37 // RTC using the time2 clock, has to be initialized before use
38 // NOTE: You have to add a appropriate ISR to your code to update _seconds
39 class RTC_Timer2 : public RTC {
40 public:
41  void begin() {}
42  void adjust(const DateTime& dt);
43  void adjust(unsigned long sec);
44  DateTime now();
45  volatile long _seconds;
46  unsigned long get();
47 };
48 
49 // RTC using the internal millis() clock, has to be initialized before use
50 class RTC_Millis : public RTC {
51 public:
52  void begin() {}
53  void adjust(const DateTime& dt);
54  DateTime now();
55 
56 protected:
57  unsigned long last_set; //store the millis() value of last adjust()
58  static long offset;
59 };
60 
61 // RTC based on the DS3231
62 //based on DS3231 Class is by Seeed Technology Inc(http://www.seeedstudio.com)
63 class DS3231 : public RTC {
64 public:
65  void begin();
66  void adjust(const DateTime& dt);
67  DateTime now();
68  uint8_t readRegister(uint8_t regaddress);
69  void writeRegister(uint8_t regaddress, uint8_t value);
70  //Decides the /INT pin's output setting
71  //periodicity can be any of following defines: EverySecond, EveryMinute, EveryHour
72  void enableInterrupts(uint8_t periodicity);
73  void enableInterrupts(uint8_t hh24, uint8_t mm,uint8_t ss);
74  void disableInterrupts();
75  void clearINTStatus();
76 
77  void convertTemperature();
78  float getTemperature();
79 protected:
80  uint8_t intType, intPeriodicity, intHH24, intMM;
81 };
82 
83 // RTC RX8025 chip connected via I2C and uses the Wire library.
84 // Only 24 Hour time format is supported in this implementation
85 class R8025 : public RTC {
86 public:
87  void begin(void);
88  void adjust(const DateTime& dt); //Changes the date-time
89  DateTime now(); //Gets the current date-time
90 
91  //Decides the /INTA pin's output setting
92  //periodicity cn be any of following defines: EverySecond, EveryMinute, EveryHour or EveryMonth
93  void enableINTA_Interrupts(uint8_t periodicity);
94  void enableINTA_Interrupts(uint8_t hh24, uint8_t mm);
95  void disableINTA_Interrupts();
96  void refreshINTA();
97  void changeOffset(uint8_t digitalOffset);
98 protected:
99  uint8_t intType, intPeriodicity, intHH24, intMM;
100 };
101 
102 // DS1337 RTC
103 class DS1337: public RTC {
104 public:
105  void begin(void);
106  void adjust(const DateTime& dt); //Changes the date-time
107  DateTime now(); //Gets the current date-time
108  unsigned char time_is_set();
109  unsigned char alarm_is_set();
110  //unsigned char time_is_valid();
111 
112  void enable_interrupt();
113  void disable_interrupt();
114  void clear_interrupt();
115 
116  void readTime();
117  void readAlarm();
118  void writeTime();
119  void writeAlarm();
120  void writeAlarm(unsigned long sse);
121  void setAlarmRepeat(byte repeat);
122  unsigned char getSeconds();
123  unsigned char getMinutes();
124  unsigned char getHours();
125  unsigned char getDays();
126  unsigned char getDayOfWeek();
127  unsigned char getMonths();
128  unsigned int getYears();
129 
130  void setSeconds(unsigned char);
131  void setMinutes(unsigned char);
132  void setHours(unsigned char);
133  void setDays(unsigned char);
134  void setDayOfWeek(unsigned char);
135  void setMonths(unsigned char);
136  void setYears(unsigned int);
137  void epoch_seconds_to_date(unsigned long seconds_left);
138  unsigned long date_to_epoch_seconds(unsigned int year, byte month, byte day, byte hour, byte minute, byte second);
139  unsigned long date_to_epoch_seconds();
140 
141  void start(void);
142  void stop(void);
143  unsigned char getRegister(unsigned char registerNumber);
144  void setRegister(unsigned char registerNumber, unsigned char registerValue);
145 
146 // library-accessible "private" interface
147 private:
148  byte time_set;
149  byte alarm_repeat;
150  byte rtc_bcd[7]; // used prior to read/set DS1337 registers;
151  void read(void);
152  void save(void);
153  byte bcd2bin(byte);
154  byte bin2bcd(byte);
155 
156 };
157 
158 
159 #endif
160 
Definition: RTClib.h:103
Definition: RTClib.h:63
Definition: BayEOSBuffer.h:33
Definition: RTClib.h:85
Definition: RTClib.h:19
Definition: RTClib.h:50
Definition: RTClib.h:29
Definition: RTClib.h:39
Definition: BayEOSBuffer.h:56