forked from opensprinklershop/OpenSprinkler-Firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathI2CRTC.h
39 lines (30 loc) · 749 Bytes
/
I2CRTC.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
/*
* I2CRTC.h - library for common I2C RTCs
* This library is intended to be uses with Arduino Time.h library functions
*/
#ifndef I2CRTC_h
#define I2CRTC_h
#define DS1307_ADDR 0x68
#define MCP7940_ADDR 0x6F
#define PCF8563_ADDR 0x51
#include "types.h"
#include "TimeLib.h"
// library interface description
class I2CRTC
{
// user-accessible "public" interface
public:
I2CRTC();
static time_os_t get();
static void set(time_os_t t);
static void read(tmElements_t &tm);
static void write(tmElements_t &tm);
static bool detect();
static bool exists();
private:
static uint8_t dec2bcd(uint8_t num);
static uint8_t bcd2dec(uint8_t num);
static uint8_t addr;
};
extern I2CRTC RTC;
#endif