#ifndef RTCDS3231_H
#define RTCDS3231_H
//
#include <Arduino.h>
#include <Wire.h>
//
//-------------------------------------
// Constant
//-------------------------------------
#define I2CADDRESS_RTCDS3231 0x68
//
//-------------------------------------
// CRtcDS3231 
//-------------------------------------
class CRtcDS3231 
{
    private:
    byte FI2CAddress;
    TwoWire* FPWire;
    //
    protected:
    // Helper
    byte DecBcd(byte value);
    byte BcdDec(byte value);
    //
    public:
    CRtcDS3231(TwoWire* pwire, byte i2caddress);    
    bool Open(void) { return true; }
    bool Close(void) { return true; }   
    // [year, month, day, hours, minutes, seconds, dayofweek]
    void WriteDateTime(byte year, byte month, byte day, 
                       byte hours, byte minutes, byte seconds, 
                       byte dayofweek);
    // [year, month, day, hours, minutes, seconds, dayofweek]
    void ReadDateTime(byte &year, byte &month, byte &day, 
                      byte &hours, byte &minutes, byte &seconds, 
                      byte &dayofweek);
    float ReadTemperatureC(void);
};
//
#endif // RTCDS3231_H
