-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGravityRtc.h
70 lines (55 loc) · 1.65 KB
/
GravityRtc.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
68
69
/*********************************************************************
* GravityRtc.h
*
* Copyright (C) 2017 [DFRobot](http://www.dfrobot.com),
* GitHub Link :https://github.com/DFRobot/Gravity-I2C-SD2405-RTC-Module/
* This Library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Description:Get real-time clock data
*
* Product Links:https://www.dfrobot.com/wiki/index.php/Gravity:_I2C_SD2405_RTC_Module_SKU:_DFR0469
*
* Sensor driver pin:I2C
*
* author : Jason([email protected])
* version : V1.0
* date : 2017-04-18
**********************************************************************/
#pragma once
#define RTC_Address 0x32 //RTC_Address
class GravityRtc
{
public:
GravityRtc();
~GravityRtc();
public:
//Year Month Day Weekday Minute Second
unsigned int year;
unsigned char month;
unsigned char day;
unsigned char week;
unsigned char hour;
unsigned char minute;
unsigned char second;
//Initialize RTC time to set the corresponding year, month, day, Weekday Minute Second
void initRtc(unsigned int year, unsigned char month,unsigned char day,unsigned char week,
unsigned char hour,unsigned char minute,unsigned char second);
//initialization
void setup();
//Update sensor data
void update();
private:
unsigned char date[7];
//Read RTC Time
void readRtc();
//Analysis RTC Time
void processRtc();
//Decimal turn to BCD
char decTobcd(char num);
void WriteTimeOn(void);
void WriteTimeOff(void);
unsigned long timeUpdate;
};