a copy of PCF8583_rtc lib with some modification

Fork of PCF8583_rtc by Dennis Smith

Revision:
3:c267167e379e
Parent:
2:3291c1f0b986
--- a/PCF8583_rtc.h	Tue Feb 25 23:41:08 2014 +0000
+++ b/PCF8583_rtc.h	Wed Oct 19 10:26:18 2016 +0000
@@ -32,134 +32,139 @@
 
 /// Structures
 struct Time_t {
-  bool fmt_hours;
-  bool am_pm_flag;
-  char hours;
-  char minutes;
-  char seconds;
-  char hundreds;
+    bool fmt_hours;
+    bool am_pm_flag;
+    char hours;
+    char minutes;
+    char seconds;
+    char hundreds;
 };
 
 struct Date_t {
-  char day;
-  char month;
-  char year;
-  char century;
-  char weekday;
+    char day;
+    char month;
+    char year;
+    char century;
+    char weekday;
 };
 
 struct DateTime_t {
-  struct Date_t date;
-  struct Time_t time;
+    struct Date_t date;
+    struct Time_t time;
 };
 
-class PCF8583rtc {
-  I2C *_i2c;
-  
+class PCF8583rtc
+{
+    I2C *_i2c;
+
 public:
 
-/**
- * Set these public variables according to your locale, default (in brackets) is Australian English.
- *  char *ShortDateFormat;  ("d,m,yy")
- *  char *LongDateFormat;   ("dddd dd mmmm yyyy")
- *  char *ShortTimeFormat;  ("d:m:yy")
- *  char *LongTimeFormat;   ("dd:nn:yyyy")
- *
- *  char DateSeparator;     ("\")
- *  char TimeSeparator;     (":")
- *
- *  char *ShortDayNames[7];    ({"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"})
- *  char *LongDayNames[7];     ({"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"})
- *  char *ShortMonthNames[12]; ({"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"})
- *  char *LongMonthNames[12];  ({"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"})
- *
-* Example:
-* @code
-* #include <mbed.h>
-* #include "PCF8583_rtc.h"
-*
-* I2C i2c(P0_10, P0_11);       // sda, scl
-* PCF8583rtc rtc(&i2c, PCF8583_addr_2);
-* 
-*    struct DateTime_t dtl;
-*
-*    //Set the time
-*    dtl = rtc.read(TIME);
-*    dtl.time.hours = rtc.bin2bcd(11);
-*    dtl.time.minutes = rtc.bin2bcd(43);
-*    rtc.write(TIME, dtl);
-*
-*    //Read and display the time on the nixie display
-*    dtl = rtc.read(TIME);
-*    i2c.write(ADDR_8574_1, &dtl.time.hours, 1);
-*    i2c.write(ADDR_8574_2, &dtl.time.minutes, 1);
-*
-* @endcode
+    /**
+     * Set these public variables according to your locale, default (in brackets) is Australian English.
+     *  char *ShortDateFormat;  ("d,m,yy")
+     *  char *LongDateFormat;   ("dddd dd mmmm yyyy")
+     *  char *ShortTimeFormat;  ("d:m:yy")
+     *  char *LongTimeFormat;   ("dd:nn:yyyy")
+     *
+     *  char DateSeparator;     ("\")
+     *  char TimeSeparator;     (":")
+     *
+     *  char *ShortDayNames[7];    ({"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"})
+     *  char *LongDayNames[7];     ({"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"})
+     *  char *ShortMonthNames[12]; ({"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"})
+     *  char *LongMonthNames[12];  ({"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"})
+     *
+    * Example:
+    * @code
+    * #include <mbed.h>
+    * #include "PCF8583_rtc.h"
+    *
+    * I2C i2c(P0_10, P0_11);       // sda, scl
+    * PCF8583rtc rtc(&i2c, PCF8583_addr_2);
+    *
+    *    struct DateTime_t dtl;
+    *
+    *    //Set the time
+    *    dtl = rtc.read(TIME);
+    *    dtl.time.hours = rtc.bin2bcd(11);
+    *    dtl.time.minutes = rtc.bin2bcd(43);
+    *    rtc.write(TIME, dtl);
+    *
+    *    //Read and display the time on the nixie display
+    *    dtl = rtc.read(TIME);
+    *    i2c.write(ADDR_8574_1, &dtl.time.hours, 1);
+    *    i2c.write(ADDR_8574_2, &dtl.time.minutes, 1);
+    *
+    * @endcode
 
-  PCF8583rtc(I2C *i2c, char I2cAddress);
+      PCF8583rtc(I2C *i2c, char I2cAddress);
+
+      DateTime_t read(const char address);
+      void   write(const char address, DateTime_t dti);
+      void   FormatDateTime(char *dest, char *format);
+      bool   WriteNVram(char address, char * value, char num);
+      bool   ReadNVram(char address, char * dest, char num);
+      void   SetDateTime(DateTime_t dti);
+      struct DateTime_t GetDateTimeBCD(void);
 
-  DateTime_t read(const char address);
-  void   write(const char address, DateTime_t dti);
-  void   FormatDateTime(char *dest, char *format);
-  bool   WriteNVram(char address, char * value, char num);
-  bool   ReadNVram(char address, char * dest, char num);
-  void   SetDateTime(DateTime_t dti);
-  struct DateTime_t GetDateTimeBCD(void);
+    */
 
-*/
+    char *ShortDateFormat;
+    char *LongDateFormat;
+    char *ShortTimeFormat;
+    char *LongTimeFormat;
 
-  char *ShortDateFormat;
-  char *LongDateFormat;
-  char *ShortTimeFormat;
-  char *LongTimeFormat;
+    char DateSeparator;
+    char TimeSeparator;
 
-  char DateSeparator;
-  char TimeSeparator;
+    char *ShortDayNames[7];
+    char *LongDayNames[7];
+    char *ShortMonthNames[12];
+    char *LongMonthNames[12];
 
-  char *ShortDayNames[7];
-  char *LongDayNames[7];
-  char *ShortMonthNames[12];
-  char *LongMonthNames[12];
-    
-  PCF8583rtc(I2C *i2c, char I2cAddress);
+    PCF8583rtc(I2C *i2c, char I2cAddress);
 
-/** read the current Time or Alarm
-*
-* @param address "TIME" = read the time, "ALARM" = read the alarm
-* @returns
-*   a DateTime_t structure
-*/
-  DateTime_t read(const char address);
+    /** read the current Time or Alarm
+    *
+    * @param address "TIME" = read the time, "ALARM" = read the alarm
+    * @returns
+    *   a DateTime_t structure
+    */
+    DateTime_t read(const char address);
+
+    /** write the current Time or Alarm
+    *
+    * @param address "TIME" = read the time, "ALARM" = read the alarm
+    * @param dti a DateTime_t structure containing the time or alarm data
+    */
+    void write(const char address, DateTime_t dti);
 
-/** write the current Time or Alarm
-*
-* @param address "TIME" = read the time, "ALARM" = read the alarm 
-* @param dti a DateTime_t structure containing the time or alarm data 
-*/
-  void write(const char address, DateTime_t dti);
+    void FormatDateTime(char *dest, char *format);
+
+    bool WriteNVram(char address, char * value, char num);
 
-  void FormatDateTime(char *dest, char *format);
+    bool ReadNVram(char address, char * dest, char num);
+
+    void SetDateTime(DateTime_t dti);
 
-  bool WriteNVram(char address, char * value, char num);
-
-  bool ReadNVram(char address, char * dest, char num);
+    char bin2bcd(char value);
 
-  void SetDateTime(DateTime_t dti);
-
-  char bin2bcd(char value);
-  
-  void configureAlarmReg(char alarm);
-  void configureControlReg(char control);
+    void configureAlarmReg(char alarm);
+    void configureControlReg(char control);
+    /*   void enableCounting(void);
+      void pauseCounting(void);*/
+    void enableCounting(void);
+    void pauseCounting(void);
 
 private:
-  struct DateTime_t dt;
-  char   _I2cAddress;
+    struct DateTime_t dt;
+    char   _I2cAddress;
 
-  char Bcd2Char(char *d, char val, char WantLeadZero);
-  void enableCounting(void);
-  void pauseCounting(void);
-  char readByte(char address);
-  void writeByte(char address, char d);
+    char Bcd2Char(char *d, char val, char WantLeadZero);
+    //void enableCounting(void);
+    //void pauseCounting(void);
+    char readByte(char address);
+    void writeByte(char address, char d);
 };
 
 /** PCF8583_rtc class.
@@ -172,15 +177,15 @@
  * I2C i2c(P0_10, P0_11);       // sda, scl
  * PCF8583rtc rtc(&i2c);
  *
- * int main() { 
- *  
+ * int main() {
+ *
  * rtc.read(TIME);
  * i2c.write(ADDR_8574_1, &rtc.HoursBCD, 1);   //write hours to display
  * i2c.write(ADDR_8574_2, &rtc.MinsBCD, 1);    //write minutes to display
  * }
  * @endcode
  */
- 
+
 /** Create a PCF8583rtc object using a pointer to the given I2C object.
  *
  * @param i2c pointer to an I2C object to which the PCF8583 device is connected.
@@ -200,11 +205,11 @@
  *                 Values are first set into the internal datetime structure prior to calling
  */
 //void write(const char address);
- 
+
 /** the FormatDateTime function.
  *
  * @param dest   a pointer to a char array where formatted values are to be placed
- * @param format a pointer to a string describing how to format the values 
+ * @param format a pointer to a string describing how to format the values
  */
 //void FormatDateTime(char *dest, char *format);