-
Notifications
You must be signed in to change notification settings - Fork 0
/
RichUNODS1307.h
67 lines (58 loc) · 1.79 KB
/
RichUNODS1307.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/****************************************************************************/
// Function: Header file for DS1307
// Hardware: RTC by Catalex
// Arduino IDE: Arduino-1.0
// Author: Fred.Chu
// Date: April 19,2013
// Version: v1.0
// by catalex.taobao.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
/****************************************************************************/
#ifndef _RichUNO_DS1307_H__
#define _RichUNO_DS1307_H__
#include <Arduino.h>
#define DS1307_I2C_ADDRESS 0x68
#define MON 1
#define TUE 2
#define WED 3
#define THU 4
#define FRI 5
#define SAT 6
#define SUN 7
class DS1307
{
private:
uint8_t decToBcd(uint8_t val);
uint8_t bcdToDec(uint8_t val);
public:
void begin();
void startClock(void);
void stopClock(void);
void setTime(void);
void getTime(void);
void fillByHMS(uint8_t _hour, uint8_t _minute, uint8_t _second);
void fillByYMD(uint16_t _year, uint8_t _month, uint8_t _day);
void fillDayOfWeek(uint8_t _dow);
uint8_t second;
uint8_t minute;
uint8_t hour;
uint8_t dayOfWeek;// day of week, 1 = Monday
uint8_t dayOfMonth;
uint8_t month;
uint16_t year;
};
#endif