-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathGravityRtc.h
68 lines (54 loc) · 1.43 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
/*********************************************************************
* GravityRtc.h
*
* Copyright (C) 2017 [DFRobot](http://www.dfrobot.com),
* GitHub Link :https://github.com/DFRobot/watermonitor
* 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:
*
* Sensor driver pin:I2C
*
* author : Jason(jason.ling@dfrobot.com)
* 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 Seconds
unsigned int year;
unsigned char month;
unsigned char day;
unsigned char week;
unsigned char hour;
unsigned char minute;
unsigned char second;
// initialize the RTC time to set the corresponding year, month, day, day, minute, minute
void initRtc();
// initialization
void setup ();
// update the sensor data
void update ();
// read the clock data
void readRtc();
// parse RTC data
void processRtc();
private:
unsigned char date[7];
// decimal to BCD
char decTobcd(char num);
void WriteTimeOn(void);
void WriteTimeOff(void);
unsigned long timeUpdate;
};