BayEOS-Arduino  1.8.0_0.0.4
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  DateTime now();
44  volatile long _seconds;
45 };
46 
47 // RTC using the internal millis() clock, has to be initialized before use
48 // NOTE: this clock won't be correct once the millis() timer rolls over (>49d?)
49 class RTC_Millis : public RTC {
50 public:
51  void begin() {}
52  void adjust(const DateTime& dt);
53  DateTime now();
54 
55 protected:
56  static long offset;
57 };
58 
59 // RTC based on the DS3231
60 //based on DS3231 Class is by Seeed Technology Inc(http://www.seeedstudio.com)
61 class DS3231 : public RTC {
62 public:
63  void begin();
64  void adjust(const DateTime& dt);
65  DateTime now();
66  uint8_t readRegister(uint8_t regaddress);
67  void writeRegister(uint8_t regaddress, uint8_t value);
68  //Decides the /INT pin's output setting
69  //periodicity can be any of following defines: EverySecond, EveryMinute, EveryHour
70  void enableInterrupts(uint8_t periodicity);
71  void enableInterrupts(uint8_t hh24, uint8_t mm,uint8_t ss);
72  void disableInterrupts();
73  void clearINTStatus();
74 
75  void convertTemperature();
76  float getTemperature();
77 protected:
78  uint8_t intType, intPeriodicity, intHH24, intMM;
79 };
80 
81 // RTC RX8025 chip connected via I2C and uses the Wire library.
82 // Only 24 Hour time format is supported in this implementation
83 class R8025 : public RTC {
84 public:
85  void begin(void);
86  void adjust(const DateTime& dt); //Changes the date-time
87  DateTime now(); //Gets the current date-time
88 
89  //Decides the /INTA pin's output setting
90  //periodicity cn be any of following defines: EverySecond, EveryMinute, EveryHour or EveryMonth
91  void enableINTA_Interrupts(uint8_t periodicity);
92  void enableINTA_Interrupts(uint8_t hh24, uint8_t mm);
93  void disableINTA_Interrupts();
94  void refreshINTA();
95  void changeOffset(uint8_t digitalOffset);
96 protected:
97  uint8_t intType, intPeriodicity, intHH24, intMM;
98 };
99 
100 // DS1337 RTC
101 class DS1337: public RTC {
102 public:
103  void begin(void);
104  void adjust(const DateTime& dt); //Changes the date-time
105  DateTime now(); //Gets the current date-time
106  unsigned char time_is_set();
107  unsigned char alarm_is_set();
108  //unsigned char time_is_valid();
109 
110  void enable_interrupt();
111  void disable_interrupt();
112  void clear_interrupt();
113 
114  void readTime();
115  void readAlarm();
116  void writeTime();
117  void writeAlarm();
118  void writeAlarm(unsigned long sse);
119  void setAlarmRepeat(byte repeat);
120  unsigned char getSeconds();
121  unsigned char getMinutes();
122  unsigned char getHours();
123  unsigned char getDays();
124  unsigned char getDayOfWeek();
125  unsigned char getMonths();
126  unsigned int getYears();
127 
128  void setSeconds(unsigned char);
129  void setMinutes(unsigned char);
130  void setHours(unsigned char);
131  void setDays(unsigned char);
132  void setDayOfWeek(unsigned char);
133  void setMonths(unsigned char);
134  void setYears(unsigned int);
135  void epoch_seconds_to_date(unsigned long seconds_left);
136  unsigned long date_to_epoch_seconds(unsigned int year, byte month, byte day, byte hour, byte minute, byte second);
137  unsigned long date_to_epoch_seconds();
138 
139  void start(void);
140  void stop(void);
141  unsigned char getRegister(unsigned char registerNumber);
142  void setRegister(unsigned char registerNumber, unsigned char registerValue);
143 
144 // library-accessible "private" interface
145 private:
146  byte time_set;
147  byte alarm_repeat;
148  byte rtc_bcd[7]; // used prior to read/set DS1337 registers;
149  void read(void);
150  void save(void);
151  byte bcd2bin(byte);
152  byte bin2bcd(byte);
153 
154 };
155 
156 
157 #endif
158 
Definition: RTClib.h:83
Definition: RTClib.h:61
Definition: RTClib.h:101